yacc - Types of conflicts in Bison -
%token<val>num %left '+' '-'
example shift/reduce
conflict:
expr:num {$$=$1}; |expr '+' expr;{}; |expr '-' expr;{};
i want recognize reduce/reduce
conflict. occurs when 2 or more rules apply same sequence of input (token)
for example:
prod: proda|prodb proda :'x' prodb : 'x'
could give ideas how recognise reduce/reduce
conflict easily?
easiest way create y.output file.
use command yacc -v parser_name.y
. create output how yacc works. find state yacc says conflict is, , important understand point sign . in file means.
if output file says this:
4 |expr. '+' expr;{};
point sign after expression saying you: "i've read expr , on input have '+'.
reduce-reduce conflicts appear when have situation this:
non_terminal1: expr. non_terminal2: expr.
in situation, have expr. @ end of rule yacc doesn't know reduce , reduce-reduce conflict.
Comments
Post a Comment