Le 22 déc. 2013 à 21:17, Adam Smalin <acidzombi...@gmail.com> a écrit :
> > Please, post a self contained and minimal example. > > Ok. I didn't test it by parsing actual code. I only looked at the conflict > %left ',' > %right '=' > %left '.' > > %% > > program: > newline_many global_loop newline_many > global_loop: > global_expr > | global_loop global_expr > global_expr: > VAR '(' ')' code_block > > code_block: '{' newline_many body newline_one_or_more '}' > > newline_many: | newline_many '\n' > newline_one_or_more: '\n' | newline_one_or_more '\n' > body: > body_expr > | body newline_one_or_more body_expr > | body_expr '=' body_expr ',' body_expr %prec '.' > | body_expr ',' body_expr '=' body_expr > | body_expr ',' body_expr '=' body_expr ',' body_expr > body_expr: > body_expr '=' body_expr > | body_expr '.' VAR > | VAR > > %% Honestly, I find your grammar hard to read. Plenty of opportunities for ambiguities here, not just conflicts. It shows a lot of redundancy, which calls for refactoring. Have another look at my proposal with lvals and rvals. > state 27 > > 12 body: body_expr '=' body_expr . ',' body_expr > 15 body_expr: body_expr . '=' body_expr > 15 | body_expr '=' body_expr . [',', '\n'] > 16 | body_expr . '.' VAR > > '=' shift, and go to state 29 > '.' shift, and go to state 22 > > $default reduce using rule 15 (body_expr) > > Conflict between rule 15 and token ',' resolved as reduce (',' < '='). > Conflict between rule 15 and token '=' resolved as shift (%right '='). > Conflict between rule 15 and token '.' resolved as shift ('=' < '.'). > > As you can see it says "Conflict between rule 15 and token ',' resolved as > reduce (',' < '=').". As you can see my rule is written as "| body_expr '=' > body_expr ',' body_expr %prec '.'" You are referring to rule 12, bison is referring to rule 15. Rule 15 has no explicit precedence token, so the last one is issued, '=', whose precedence is greater than that of ','. The output file includes: 0 $accept: program $end 1 program: newline_many global_loop newline_many 2 global_loop: global_expr 3 | global_loop global_expr 4 global_expr: "VAR" '(' ')' code_block 5 code_block: '{' newline_many body newline_one_or_more '}' 6 newline_many: %empty 7 | newline_many '\n' 8 newline_one_or_more: '\n' 9 | newline_one_or_more '\n' 10 body: body_expr 11 | body newline_one_or_more body_expr 12 | body_expr '=' body_expr ',' body_expr 13 | body_expr ',' body_expr '=' body_expr 14 | body_expr ',' body_expr '=' body_expr ',' body_expr 15 body_expr: body_expr '=' body_expr 16 | body_expr '.' "VAR" 17 | "VAR" _______________________________________________ help-bison@gnu.org https://lists.gnu.org/mailman/listinfo/help-bison