...
No Format |
---|
prog : ^(PROGRAM (d+=decl)+) -> file(decls={$d}) ; decl : ^(DECL type ID) ; // auto creates template from input tokens for decl |
The mechanism should also create templates for alternatives that do not have template specifications even when others do:
No Format |
---|
e : ^('+' e e) // auto create template
| ^('*' e e)
| INT -> intval(...)
| ID -> load(...)
;
|
A warning
Each tree grammar rule knows the text from which the associated subtree was created but only if the subtree has a single root. The following rule, because it has a single root, gives ANTLR a problem.
...