Click here to Skip to main content
15,885,278 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have these rules :

Q_ID : Q_ID '.' Id
|Id;
classdecl : modifier CLASS Id IS END
|modifier CLASS Id INHERITS Q_ID IS END
|modifier CLASS Id IMPLEMENTS Q_ID_LIST IS END
|modifier CLASS Id INHERITS Q_ID IMPLEMENTS Q_ID IS END <<<<
|modifier CLASS Id IS feature_closer END
|modifier CLASS Id INHERITS Q_ID IS feature_closer END
|modifier CLASS Id IMPLEMENTS Q_ID_LIST IS feature_closer END
|modifier CLASS Id INHERITS Q_ID IMPLEMENTS Q_ID_LIST IS feature_closer END

| CLASS Id IS END
| CLASS Id INHERITS Q_ID IS END
| CLASS Id IMPLEMENTS Q_ID_LIST IS END
| CLASS Id INHERITS Q_ID IMPLEMENTS Q_ID IS END <<<<
| CLASS Id IS feature_closer END
| CLASS Id INHERITS Q_ID IS feature_closer END
| CLASS Id IMPLEMENTS Q_ID_LIST IS feature_closer END
| CLASS Id INHERITS Q_ID IMPLEMENTS Q_ID_LIST IS feature_closer END;

the parser stops on Q_ID . IS END
how can I solve this conflict
Posted
Updated 1-Dec-10 0:23am
v4
Comments
CPallini 1-Dec-10 6:11am    
It looks like an incomplete grammar to me...
fresh_girl 1-Dec-10 6:15am    
sure it is .. but this is the rule connected to the conflict
should I post it all ??
Manfred Rudolf Bihy 3-Dec-10 20:03pm    
Hey fresh, got any news on this?
fresh_girl 4-Dec-10 3:18am    
yup , just solved it
thanks alot for the help :)
God bless u
Manfred Rudolf Bihy 4-Dec-10 5:59am    
Care to elaborate what you did to make it work?

1 solution

Hi Fresh,

eventhough it's been some time since fooling around with Lex & Yacc (aka bison) I'll give this a shot. For reference reasons I've added line numbers to your grammar:

 1 Q_ID : Q_ID '.' Id |Id;
 2 classdecl : modifier CLASS Id IS END
 3 |modifier CLASS Id INHERITS Q_ID IS END
 4 |modifier CLASS Id IMPLEMENTS Q_ID_LIST IS END
 5 |modifier CLASS Id INHERITS Q_ID IMPLEMENTS Q_ID IS END <<<<
 6 |modifier CLASS Id IS feature_closer END
 7 |modifier CLASS Id INHERITS Q_ID IS feature_closer END
 8 |modifier CLASS Id IMPLEMENTS Q_ID_LIST IS feature_closer END
 9 |modifier CLASS Id INHERITS Q_ID IMPLEMENTS Q_ID_LIST IS feature_closer END
10
11 | CLASS Id IS END
12 | CLASS Id INHERITS Q_ID IS END
13 | CLASS Id IMPLEMENTS Q_ID_LIST IS END
14 | CLASS Id INHERITS Q_ID IMPLEMENTS Q_ID IS END <<<<
15 | CLASS Id IS feature_closer END
16 | CLASS Id INHERITS Q_ID IS feature_closer END
17 | CLASS Id IMPLEMENTS Q_ID_LIST IS feature_closer END
18 | CLASS Id INHERITS Q_ID IMPLEMENTS Q_ID_LIST IS feature_closer END;


The shift/reduce conflicts are probably based on the rules in lines 3 and 5 as well as lines 12 and 14. Most probable cause for that lies in the rule IMPLEMENTS which isn't listed. BTW is Id a terminal symbol or a rule?

If you're sure you're doing things right you can instruct bison to resolve this issue by forcing either resolve or shift to occur.
The best way to go for sure is to make your grammar conflict free, if it's possible to do so.
This one was a real time saver for me way back when:

O'Reilly, Lex & Yacc


Cheers

Manfred
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900