antlr4
antlr4 copied to clipboard
[Symbol Conflict] Use of "base" for label causes problems for CSharp target
This is a problem when using "base" for the name of a rule element label. When "base" is used, the CSharp target code does not compile.
grammar arithmetic;
file_ : equation* EOF;
equation : expression relop expression ;
expression
: base=expression POW exponent=expression
| expression (TIMES | DIV) expression
| expression (PLUS | MINUS) expression
| LPAREN expression RPAREN
| (PLUS | MINUS)* atom
;
atom : scientific | variable ;
scientific : SCIENTIFIC_NUMBER ;
variable : VARIABLE ;
relop : EQ | GT | LT ;
VARIABLE : VALID_ID_START VALID_ID_CHAR* ;
SCIENTIFIC_NUMBER : NUMBER (E SIGN? UNSIGNED_INTEGER)? ;
LPAREN : '(' ;
RPAREN : ')' ;
PLUS : '+' ;
MINUS : '-' ;
TIMES : '*' ;
DIV : '/' ;
GT : '>' ;
LT : '<' ;
EQ : '=' ;
POINT : '.' ;
POW : '^' ;
WS : [ \r\n\t] + -> skip ;
fragment VALID_ID_START : ('a' .. 'z') | ('A' .. 'Z') | '_' ;
fragment VALID_ID_CHAR : VALID_ID_START | ('0' .. '9') ;
fragment NUMBER : ('0' .. '9') + ('.' ('0' .. '9') +)? ;
fragment UNSIGNED_INTEGER : ('0' .. '9')+ ;
fragment E : 'E' | 'e' ;
fragment SIGN : ('+' | '-') ;
.... arithmeticParser.cs(342,17): error CS1001: Identifier expected
.... arithmeticParser.cs(342,17): error CS1002: ; expected