I am trying to implement a simple compiler using flex & bison, and got stuck in the postfix notation. (The compiler should behave like the C++ compiler)
Here is the problem: Given the following code:
    int x = 0;
    int y = x++ || x++  ; //y=1 , x = 2 this is understandable
    int z = x++ + x++ ;  // z = 0 , x=2
the first line is fine because of the following grammar:
    expression = expression || expression; //  x=0
    expression = 0 || expression   // x= 1
    expression = 0 || 1  //x=2
    expression = 1 // x=2 
    y = 1
However, I don't understand why z=0.
When my bison grammar sees 'variable' ++ it first returns the variables value, and only then increments it by 1. I used to think thats how C++ works, but it won't work for the 'z' variable.
Any advice on how to solve this case?
 
     
     
    