tags:

views:

102

answers:

1

I am using bison and its difficult to figure out the conflicts by looking at y.output. Is there a tool to make or filter y.output so its more useful? i would love to see the full path to the state with the conflict but anything helpful is what i would like.

A: 

I assume you know what shift/reduce and reduce/reduce conflicts are and when they occur. Given that, what I did was just use vim...

At the top of y.output, it lists which states have how many conflicts. If you just type "/statenumber" and press 'n' a couple of times, you should be able to go straight to the transitions for that state.

There, you'll see the production rules you typed with a '.' in them. The dot indicates the place in the production rule up to which it has parsed. If the dot is at the end, that means that it'll attempt a 'reduce', and if not, a 'shift'. A reduce production occurs if the next token is in the FOLLOWSET of the LHS non-terminal (the next token is a symbol that can follow that non-terminal), and a shift occurs for the terminal or FIRST(non-terminal) that is after the '.'.

A conflict occurs if you have two possible moves (shift/reduce or reduce/reduce) for a possible next token.

When you find conflicts, simply go to that state, find out which production rules are giving you the conflict, and either: a -- modify your grammar to remove that conflict, or b -- specify production rule precedence using the %prec notation.

Hope that helped :)

Vanwaril