Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Grammar ambiguity
Grammar ambiguity [message #1839411] Sat, 20 March 2021 11:56 Go to next message
John Doe is currently offline John DoeFriend
Messages: 138
Registered: October 2020
Senior Member
Hi all,

I have the following grammar, and it allows some stuff it should not:
Condition A:
name=ID
;
Condition B:
"B" name=ID
;
Condition C:
"C" name=ID
;
Rule:
name= ID ("if" conditionA+=ConditionA)?
(conditionB+=ConditionB)?
(conditionC+=ConditionC)?
("," ( conditionA+=ConditionA)?
(conditionB+=ConditionB)?
(conditionC+=ConditionC)?)*
;
An example from this grammar would be

rule1 if x B y C z , C g

This is a bit complex but I will try to explain it.

1. conditionA, conditionB, and conditionC are optional, because this rule might contain only one of them, two of them or all three of them.

2. I might have a few similar rules, but the ones after the first should not start with an "if", there should only be a comma separating them.

Now my issue is that being that they are all optional, the grammar allows me to write the following:
rule1 , , , ,

What could be a way to fix that, but based on the rules that I mentioned above?

Thank you!

Re: Grammar ambiguity [message #1839433 is a reply to message #1839411] Sun, 21 March 2021 11:05 Go to previous message
John Doe is currently offline John DoeFriend
Messages: 138
Registered: October 2020
Senior Member
Any idea on this?
Previous Topic:Not valid for cross reference
Next Topic:Cross Referenced Objects not initialized in ProposalProvider
Goto Forum:
  


Current Time: Fri May 14 10:52:02 GMT 2021

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

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

Back to the top