All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.antlr.v4.test.runtime.templates.LeftRecursion.MultipleAlternativesWithCommonLabel.stg Maven / Gradle / Ivy

There is a newer version: 4.9.0
Show newest version
/*
 * This is a regression test for antlr/antlr4#433 "Not all context accessor
 * methods are generated when an alternative rule label is used for multiple
 * alternatives".
 * https://github.com/antlr/antlr4/issues/433
 */

TestType() ::= "Parser"

Options ::= [
	"Debug": false
]

Grammar ::= [
	"T": {}
]

Rule() ::= "s"

grammar(grammarName) ::= <<
grammar ;
s : e {};
e returns [int v]
  : e '*' e     {$v = .e(0).v * .e(1).v;}  # binary
  | e '+' e     {$v = .e(0).v + .e(1).v;}  # binary
  | INT         {$v = $INT.int;}                   # anInt
  | '(' e ')'   {$v = $e.v;}                       # parens
  | left=e INC  {$v = $left.v + 1;}      # unary
  | left=e DEC  {$v = $left.v - 1;}      # unary
  | ID          {}                                                     # anID
  ;
ID : 'a'..'z'+ ;
INT : '0'..'9'+ ;
INC : '++' ;
DEC : '--' ;
WS : (' '|'\n') -> skip ;
>>




© 2015 - 2025 Weber Informatics LLC | Privacy Policy