Skip to main content



      Home
Home » Modeling » TMF (Xtext) » Grammar ambiguity
Grammar ambiguity [message #1839411] Sat, 20 March 2021 07:56 Go to next message
Eclipse UserFriend
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 07:05 Go to previous message
Eclipse UserFriend
Any idea on this?
Previous Topic:Not valid for cross reference
Next Topic:Cross Referenced Objects not initialized in ProposalProvider
Goto Forum:
  


Current Time: Thu Jul 10 01:33:05 EDT 2025

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

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

Back to the top