Reputation: 3
in the following simple grammar, on the conflict at state 4, can 'shift' become the taken action without changing the rules ? (I thought that by default shift was bison's preferred action)
%token one two three
%%
start : a;
a : X Y Z;
X : one;
Z : two | three;
Y : two | ;
%%
Upvotes: 0
Views: 155
Reputation: 126478
Shift is the default, but that results in the generated parser giving an error for the input one two
so that is probably not what you want. Instead, follow rici's advice and fix the grammar.
Upvotes: 1
Reputation: 241911
shift is bison's preferred action, and you can see in the state output that it will shift two
in state 4. It will still report a shift-reduce conflict, but you can take that as a warning if you like. (See %expect
.) You'd probably be better off fixing the grammar:
start : a;
a : X Z | X Y Z;
X : one;
Y : two;
Z : two | three;
Upvotes: 3