Rule has non-LL(*) decision even tho its copied from a lecture [message #1811127] |
Tue, 27 August 2019 09:05 |
Jakob Sachs Messages: 15 Registered: May 2018 |
Junior Member |
|
|
Hi
I need to parse Expressions in my DSL and copied the grammar pretty much exactly from here: http://dsl-course.org/
But when I parse it I get two errors:
Quote:
InternalXtextTest.g:6065:3: [fatal] rule ruleOr 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.
InternalXtextTest.g:6131:3: [fatal] rule ruleAnd 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.
I'm really confused why this is happening since my version is practically 1 to 1 what is used everywhere else.
Heres my code for the expressions:
Expression:
Or;
Or returns Expression:
And ({Or.left=current} ('OR' | 'or') right=And)*;
And returns Expression:
Equality ({And.left=current} ('AND' | 'and') right=Equality)*;
Equality returns Expression:
Comparison ({Equality.left=current} ('!=' | '==') right=Comparison)*;
Comparison returns Expression:
PlusOrMinus ({Comparison.left=current} ('>=' | '<=' | '<' | '>') right=PlusOrMinus)*;
PlusOrMinus returns Expression:
MultiOrDivide ({PlusOrMinus.left=current} ('+' | '-') right=MultiOrDivide)*;
MultiOrDivide returns Expression:
Primary ({MultiOrDivide.left=current} ('*' | '/') right=Primary)*;
Primary returns Expression:
'(' Expression ')' | '!' expression=Primary | '-' expression=Primary | Atomic;
Atomic returns Expression:
{Expression} DOUBLE | {Expression} INT | {Expression} STRING | var=[VariableName];
Update:
I found out that it has to do with my VariableName definition. If I exclude that part of the expression that says " | var=[VariableName]" it works fine.
This confuses me even more.
This is my code for VariableAssignments:
VariableAssignment:
name=VariableName '=' value=Expression ';';
VariableName:
name=(ID | TERMINAL_CONSTANT);
[Updated on: Tue, 27 August 2019 09:11] Report message to a moderator
|
|
|
|
|
|
|
|
|
|
Re: Rule has non-LL(*) decision even tho its copied from a lecture [message #1814051 is a reply to message #1814041] |
Mon, 02 September 2019 10:24 |
|
here is a much more minified version of the grammar
Model:
statements+=SelectTableEntry;
OR_KEYWORD:
'OR' | 'or';
COMPARISON_OPERATOR:
'==' | '<=' | '>=' | '!=' | '<' | '>';
SelectTableEntry:
'(' selCond=GeneralSelectionCondition ')';
GeneralSelectionCondition:
'!' GeneralSelectionCondition
({GeneralSelectionCondition.left=current} op=(OR_KEYWORD ) right=GeneralSelectionComposition)*;
GeneralSelectionComposition:
tableFieldName=ID op=(COMPARISON_OPERATOR) expr=Expression;
Expression:
Or;
Or returns Expression:
Comparison ({Or.left=current} OR_KEYWORD right=Comparison)*;
Comparison returns Expression:
Primary ({Comparison.left=current} ('>=' | '<=' | '<' | '>') right=Primary)*;
Primary returns Expression:
'!' expression=Primary | Atomic;
Atomic returns Expression:
{VarRef} var=ID;
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
[Updated on: Mon, 02 September 2019 10:27] Report message to a moderator
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.01786 seconds