Yacc/bison:conflicts: 1 shift/reduce problem
Its has something to do with the arg_list I know that but I dont know how to fix it. I just keep getting conflicts: 1 shift/reduce. Any help would be great.
Code:
%{ |
Hi.
To figure out what rule causes the conflict, add the `-rall' option to bison: Code:
$ bison -rall gram.y Code:
State 44 conflicts: 1 shift/reduce If I interpret it correctly, the conflict here is when there is SYMBOL on top of the stack and another SYMBOL in input stream. Parser can not decide whether to shift SYMBOL to the stack and then interpret it as `symbol' or to reduce SYMBOL on the stack to `symbol' (and keep input stream untouched). I can't suggest any fix yet, but at least using this method you may analyze further conflicts. Anyway, your grammar looks overcomplicated to me. It looks like you try to impose too much structure on a quite structureless s-expressions, which is hard to do unambiguously (when parsing). Another approach would be to construct an abstract syntax tree of the s-expression using simple parser and then evaluate/analyze it using a dedicated recursive function. Finally, I'd recommend to replace right recursion by left recursion, for example Code:
arg_list: arg_list symbol { $$ = argList($1,$2); } |
Thanks you for the info. You are right the symbol SYMBOL thing is the problem. I and my entire class have been working on this for a few days and no one can figure it out. I think our professor set up the grammer wrong. I think I could do it but I would have to completely redo the whole project and I dint have enough time because its do tomorrow afternoon.
The -rall though thing was very useful to know thanks for telling me about that. |
All times are GMT -5. The time now is 07:01 AM. |