سؤال

I have 2 shift reduces when writting this sentence in yacc:

%%
%token blablabla
%%

expresion: expresion + expresion { ; }
         |/*lambda*/
;

Does anyone know how to delete the warnings shift-reduce? I looked over this link but i got bison errors and did not work http://nereida.deioc.ull.es/~pl/perlexamples/node160.html

هل كانت مفيدة؟

المحلول

You can use

 %left '+'

to tell YACC how to resolve the shift reduce conflict. That's the best way to do it.

You can make the grammar unambiguous by making a different term

expression = lower_expression + expression ;

That method gets tedious when there are a lot of operators and different levels of precedence.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top