I ran tests on my own implementation, and from my tests, marcin's answer is correct. If I define the priority as:
%left OR %left AND
Then the expression A & B | C & D will be reduced to ((A & B) | (C & D))
If I define the priority as:
%left AND %left OR
Then the expression A & B | C & D will be reduced to ((A & (B | C)) & D)
One differentiating expression will be:
true & true | true & false
The previous definition of priority will set this to true, while the latter will make it false. I tested both scenarios and both work as described.
Double check your tests to make sure. Also note that this is the order of% left,% right, etc. Definitions in the header part, which determine the priority, and not the order, which you determine by the rules themselves. If it still doesn't work, maybe this is some other area of ββyour code that messed it up, or maybe your version of the bison is different (I'm just shooting in the dark at this point).
source share