How is operator priority performed in ANTLR?
I am using the XText / Antlr package at the moment.
Edit:
I did what sepp2k suggested, and now the priority of the operators works, but now everything works like 3 + *. Operators basically “fall” through the tree.
Also, I tried C grammar on the ANTLR website, and the same thing happened in ANTLRworks.
Does anyone know what the problem is?
BinaryExpression:
'or'? AndOp; //or op
AndOp:
'and'? ComparisonOp;
ComparisonOp:
('>'|'<'|'>='|'<='|'=='|'~=')? ConcatOp;
ConcatOp:
'..'? AddSubOp;
AddSubOp:
('+' | '-')? MultDivOp;
MultDivOp:
('*' | '/')? ExpOp;
ExpOp:
'^'? expr=Expression;
source
share