Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Ambiguous rules and Predicate behavior
Ambiguous rules and Predicate behavior [message #1861641] Tue, 24 October 2023 23:25 Go to next message
Sohaib Hamioud is currently offline Sohaib HamioudFriend
Messages: 4
Registered: September 2023
Junior Member
I am stuck with the following ambiguous rules in Xtext:

UnaryExpression returns ExpressionAtom:

..................

| EXISTS? '(' SelectStatement ')'

| '(' Expressions ')'
//nestedExpression
;

When I generate artifacts I get a warning about multiple alternatives. The '(' token is the source of ambiguity.

If I use a predicate "=>" to select the first alternative (i.e., the SelectStatement rule), I ended up with a never-reached alternative2. the SelectStatement rule starts with the 'select' keyword. I thought that if the selected alternative fails, the parser will automatically try the second alternative, but it seems that it is a one-way parsing. What should I do to force the parser to try other alternatives if the chosen one fails?
Re: Ambiguous rules and Predicate behavior [message #1862547 is a reply to message #1861641] Mon, 11 December 2023 12:17 Go to previous message
Oscar Ablinger is currently offline Oscar AblingerFriend
Messages: 6
Registered: August 2023
Junior Member
The issue is that if EXISTS is not found, then a ( could both refer to the first as well as the second alternative.
If you want to make it LL(1) you could for instance write it like this:

| EXISTS '(' SelectStatement ')'
| '(' (Expressions | SelectStatement) ')
Previous Topic:Identity preservation in Xtend
Next Topic:Nested Conditional Formatters always create Conflict
Goto Forum:
  


Current Time: Sun May 26 20:39:44 GMT 2024

Powered by FUDForum. Page generated in 0.03311 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top