From ANTLR By Example: Part 3: Parsing:
We guide the AST construction using postfix annotations on the tokens in our parser rules. The following annotations are available:
- no annotation: a token without an annotation becomes a leaf node in the tree
- ^: a token annotated with a carat becomes a sub-expression root
- !: a token annotated with an exclamation point is not included in the tree
(Which also covers the !
s in your example that you hadn't yet asked about)