user34537
user34537

Reputation:

Telling Bison/Yacc to shift and not reduce to resolve a conflict

I have a situation where there is a rule with a shift/reduce conflict that i understand. I want a rule to never reduce until at the last moment possible (end of line). So I would like to say always shift. How do i do this?

Upvotes: 1

Views: 850

Answers (2)

Chris Dodd
Chris Dodd

Reputation: 126175

As Craig notes, when there's a shift reduce conflict, bison does the shift. If the warning about it bothers you, you can use bison's %expect directive to specify the expected number of shift-reduce conflicts. This way it will be silent if that's the only conflict, but if there are additional conflicts, the warning will come back.

Upvotes: 2

Craig
Craig

Reputation: 4840

By default Bison will shift when there is a shift/reduce conflict. You can use precedence declarations to change the behavior.

Upvotes: 0

Related Questions