UNPKG

@mike-lischke/antlr-tgen

Version:

A generator for antlr-ng runtime test cases

73 lines (67 loc) 1.34 kB
[type] Parser [grammar] grammar T; s @after {<ToStringTree("$ctx"):writeln()>} : e EOF ; // must indicate EOF can follow expressionList : e (',' e)* ; e : '(' e ')' | 'this' | 'super' | INT | ID | typespec '.' 'class' | e '.' ID | e '.' 'this' | e '.' 'super' '(' expressionList? ')' | e '.' 'new' ID '(' expressionList? ')' | 'new' typespec ( '(' expressionList? ')' | ('[' e ']')+) | e '[' e ']' | '(' typespec ')' e | e ('++' | '--') | e '(' expressionList? ')' | ('+'|'-'|'++'|'--') e | ('~'|'!') e | e ('*'|'/'|'%') e | e ('+'|'-') e | e ('\<\<' | '>>>' | '>>') e | e ('\<=' | '>=' | '>' | '\<') e | e 'instanceof' e | e ('==' | '!=') e | e '&' e |\<assoc=right> e '^' e | e '|' e | e '&&' e | e '||' e | e '?' e ':' e |\<assoc=right> e ('=' |'+=' |'-=' |'*=' |'/=' |'&=' |'|=' |'^=' |'>>=' |'>>>=' |'\<\<=' |'%=') e ; typespec : ID | ID '[' ']' | 'int' | 'int' '[' ']' ; ID : ('a'..'z'|'A'..'Z'|'_'|'$')+; INT : '0'..'9'+ ; WS : (' '|'\n') -> skip ; [start] s [input] new T[((n-1) * x) + 1] [output] """(s (e new (typespec T) [ (e (e ( (e (e ( (e (e n) - (e 1)) )) * (e x)) )) + (e 1)) ]) <EOF>) """