I managed to get the lexer, syntax checker and semantics and now I want to move on intermediate code generation. The problem is that i don't know how to handle logical expressions. I read something about E.true and E.false. This example is everywhere but I didn't understand it.
For example if I have the following code
if x>y and x<y or x == 1 then
//super duper code here
x = x+1
else
//super duper wow code here
y = y+1
endif
The result must be something like this
1: > x y 3
2: jmp _ _ 9
3: < x y 7
4: jmp _ _ 5
5: == x 1 _
6: jmp _ _ 9
7: + 1 x $1
8: = $1 _ x
9: + 1 y $2
10: = $2 _ y
but the labels for the jumps are not known until you actually finish parsing the if statement.
So I have to generate quads and then backpatch them. How can I do it with the grammar of this post?
Can someone explain how it will go because I am really confused.