I have the following XText grammar which uses ANTLR3 under the hood. In my grammar I want to support cast expressions like TYPE(EXPRESSION)
and (TYPE)(EXPRESSION)
. A Type definition usually contains other types (I think that is the problem but I cannot change this requirement). Besides that I also want to allow parenthesis around expressions.
Is it possible to solve the recursion by left-factoring? I always get the following error message.
[fatal] rule ruleExpression has non-LL(*) decision due to recursive rule invocations reachable from alts 1,2. Resolve by left-factoring or using syntactic predicates or using backtrack=true option.
Model:
e=Expression;
Expression:
e=castExpression | e=parExpression | "VAR";
castExpression:
(Type | '(' Type ')') e=parExpression;
parExpression:
'(' Expression ')';
Type:
"MYTYPE" t=Type | "TYPE_ID";