Could you please tell me what could be the problem? It's expect {<EOF>, '(', NUMBER, VARIABLE}
, but if i insert this rules after -
, i got same error.
grammar Grammar;
@header {
package parser;
}
program: line* EOF ;
line: (expression | assignment) ('\n' | EOF);
assignment : VARIABLE '=' expression ;
expression : '(' expression ')' #parenthesisExpression
| left=expression OP1 right=expression #firstPriorityExpression
| left=expression OP2 right=expression #secondPriorityExpression
| number=NUMBER #numericExpression
| variable=VARIABLE #variableExpression
;
NUMBER : '-'? [0-9]+ ;
VARIABLE : [a-zA-Z][a-zA-Z0-9]* ;
OP1: '*' | '/' ;
OP2: '+' | '-' ;
WHITESPACE : (' ' | '\t' | '\n')+ -> skip ;