Ambiguous grammar [message #989321] |
Wed, 05 December 2012 16:08 |
Marco Naddeo Messages: 62 Registered: November 2012 |
Member |
|
|
Hi
Houston, I have a problem with my Xtext grammar.
I refactored it to eliminate left recursion, but now this fragment:
Expression:
TerminalExpression ('.' ID '.' ID)? |
TerminalExpression ('.' ID '.' ID actualParams=ActualParameters)?
;
TerminalExpression returns Expression:
'this' |
'null' |
'false' |
'true ' |
STRING_LITERAL |
NUMBER_LITERAL |
ID |
objectCreation=ObjectCreation |
'super' actualParams=ActualParameters |
'(' expr=Expression ')'
;
results in these errors and warnings , when I try to generate the language infrastructure:
error(211): ../magda.xtext.Magda/src-gen/magda/xtext/parser/antlr/internal/InternalMagda.g:801:1: [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.
warning(200): ../magda.xtext.Magda/src-gen/magda/xtext/parser/antlr/internal/InternalMagda.g:801:1: Decision can match input such as "'this'" using multiple alternatives: 1, 2
As a result, alternative(s) 2 were disabled for that input
warning(200): ../magda.xtext.Magda/src-gen/magda/xtext/parser/antlr/internal/InternalMagda.g:801:1: Decision can match input such as "'null'" using multiple alternatives: 1, 2
As a result, alternative(s) 2 were disabled for that input
warning(200): ../magda.xtext.Magda/src-gen/magda/xtext/parser/antlr/internal/InternalMagda.g:801:1: Decision can match input such as "'false'" using multiple alternatives: 1, 2
As a result, alternative(s) 2 were disabled for that input
warning(200): ../magda.xtext.Magda/src-gen/magda/xtext/parser/antlr/internal/InternalMagda.g:801:1: Decision can match input such as "RULE_ID" using multiple alternatives: 1, 2
As a result, alternative(s) 2 were disabled for that input
warning(200): ../magda.xtext.Magda/src-gen/magda/xtext/parser/antlr/internal/InternalMagda.g:801:1: Decision can match input such as "RULE_NUMBER_LITERAL" using multiple alternatives: 1, 2
As a result, alternative(s) 2 were disabled for that input
warning(200): ../magda.xtext.Magda/src-gen/magda/xtext/parser/antlr/internal/InternalMagda.g:801:1: Decision can match input such as "RULE_STRING_LITERAL" using multiple alternatives: 1, 2
As a result, alternative(s) 2 were disabled for that input
warning(200): ../magda.xtext.Magda/src-gen/magda/xtext/parser/antlr/internal/InternalMagda.g:801:1: Decision can match input such as "'true '" using multiple alternatives: 1, 2
As a result, alternative(s) 2 were disabled for that input
I've tried to enable the backtrack=true option, but nothing change.
I suppose syntactic predicates are the solution here, but how I use them?
Could you also give me an example of an ambiguous phrase of this grammar, please?
Thanks in advance.
Marco
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.03104 seconds