@mike-lischke/antlr-tgen
Version:
A generator for antlr-ng runtime test cases
27 lines (21 loc) • 493 B
Plain Text
[type]
Parser
[grammar]
grammar T;
s : a ';' a;
// ';' helps us to resynchronize without consuming
// 2nd 'a' reference. We our testing that the DFA also
// throws an exception if the validating predicate fails
a : {<False()>}? ID {<writeln("\"alt 1\"")>}
| {<True()>}? INT {<writeln("\"alt 2\"")>}
;
ID : 'a'..'z'+ ;
INT : '0'..'9'+;
WS : (' '|'\n') -> skip ;
[start]
s
[input]
x ; y
[errors]
line 1:0 no viable alternative at input 'x'
line 1:4 no viable alternative at input 'y'