Hello good programmers,
I have built following grammar in happy (haskell):
P : program C {Prog $2}
E : int {Num $1}
| ident {Id $1}
| true {BoolConst True}
| false {BoolConst False}
| read {ReadInput}
| '(' E ')' {Parens $2}
| E '+' E { Add $1 $3 }
| E '-' E { Sub $1 $3 }
| E '*' E { Mult $1 $3 }
| E '/' E { Div $1 $3 }
| E '=' E { Eq $1 $3 }
| E '>' E { Gt $1 $3 }
| E '<' E { Lt $1 $3 }
C : '(' C ')' {$2}
| ident assign E {Assign $1 $3}
| if E then C else C {Cond $2 $4 $6}
| output E {OutputComm $2}
| while E do C {While $2 $4 }
| begin D ';' C end {Declare $2 $4}
| C ';' C {Seq $1 $3 }
D : D ';' D {DSeq $1 $3 }
| '(' D ')' {$2}
| var ident assign E {Var $2 $4}
Now, While loop includes all the commands that follow after 'do'. How to change this behavior? I've already tried %left, %right... :(