The following tasks should be solved in the order below. Write tests for each step!
?
and :
tokens to the lexical analyser! Extend the grammar with the following new expression type:a := (x<3 ? 0 : 1) + 1
write(2 * (b ? x : y+1))
(x<3 ? 0 : 1)
: If x<3, then the result is 0 and 1 otherwise.?
has to be booleans.:
have to have the same type.(a?b:c)
expression is the type of b
(and c
).