...
You can use a few techniques to make your grammar more readable:
- Include Add comments including single-line
//
, and multi-line/* ... /
and Javadoc-style/* ... */
- Gather your simple token definitions (single characters, single words, etc.) into a
tokens
section at the top of the file. - Consider defining sub-parts of tokens with
fragment
rules. Afragment
will never generate a token by itself but can be used as part of the rule defining another token.
...