avalanche
avalanche copied to clipboard
[tool] Grammar Linter
Grammar files can get big and complicated and it is easy to over look issues. The best solution is to make avalanche check at run time for issues (ex. unused symbols) but this is not always appropriate.
Issues to potentially warn about:
- Choices with weight set to 0
- Potential reference (@
) usage before generation - Common mistakes. /[0-f]/ likely should be /[0-9a-f]/
- Document can exceed size limit
- Choice with 2 options and one is itself
- Choice does not have a weighted item set to 1
- Symbol has a weight but is not a choice. eg "Sym 1 'def'"
- Trailing white space
- Potential for randomness at execution time of created document eg Math.random() (language dependent)
Warn about patterns like this:
func func_head ')'
func_head 1 'func(' arg
1 func_head ',' arg
instead of:
func 'func(' arg (',' arg){0,5} ')'
The former pattern is commonly used in specification grammars, but is unbounded.
Started in fad0c7e2398113f1fd3f654601e23cad29636789