avalanche icon indicating copy to clipboard operation
avalanche copied to clipboard

[tool] Grammar Linter

Open tysmith opened this issue 9 years ago • 2 comments

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)

tysmith avatar Aug 04 '16 21:08 tysmith

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.

jschwartzentruber avatar Oct 03 '16 19:10 jschwartzentruber

Started in fad0c7e2398113f1fd3f654601e23cad29636789

jschwartzentruber avatar Oct 20 '16 20:10 jschwartzentruber