@mike-lischke/antlr-tgen
Version:
A generator for antlr-ng runtime test cases
30 lines (24 loc) • 478 B
Plain Text
[type]
Parser
[grammar]
grammar T;
s @after {<ToStringTree("$ctx"):writeln()>} : declarator EOF ; // must indicate EOF can follow
declarator
: declarator '[' e ']'
| declarator '[' ']'
| declarator '(' ')'
| '*' declarator // binds less tight than suffixes
| '(' declarator ')'
| ID
;
e : INT ;
ID : 'a'..'z'+ ;
INT : '0'..'9'+ ;
WS : (' '|'\n') -> skip ;
[start]
s
[input]
a
[output]
"""(s (declarator a) <EOF>)
"""