Grammar ambiguity [message #1839411] |
Sat, 20 March 2021 07:56  |
Eclipse User |
|
|
|
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!
|
|
|
|
Powered by
FUDForum. Page generated in 0.06468 seconds