@mike-lischke/antlr-tgen
Version:
A generator for antlr-ng runtime test cases
31 lines (24 loc) • 529 B
Plain Text
[notes]
We cannot collect predicates that are dependent on local context if
we are doing a global follow. They appear as if they were not there at all.
[type]
Parser
[grammar]
grammar T;
@parser::members {
<Declare_pred()>
}
s : a[99] ;
a[int i] : e {<ValEquals("$i","99"):Invoke_pred()>}? {<writeln("\"parse\"")>} '!' ;
b[int i] : e {<ValEquals("$i","99"):Invoke_pred()>}? ID ;
e : ID | ; // non-LL(1) so we use ATN
ID : 'a'..'z'+ ;
INT : '0'..'9'+;
WS : (' '|'\n') -> skip ;
[start]
s
[input]
a!
[output]
eval=true
parse