Exercise 19:

Parenthesized expressions over unary signs and not, and binary +, -, *, /, <, >, =, and and or
The set of tokens of the language is {+,-,*,/,<,>,=,not,and,or,(,),NUMBER}. The token NUMBER represents unsigned integers, i.e., non-empty sequences of digits. Examples of correct expressions are “-0+1<2*3”, “1>2/3 and 4<5*6”, “not -1=+15”, “1=2 and 0=0 and 1=1 or 3=4”, “not (3>4 or not 5<6)”, whereas “1+”, “/2”, “1 2”, “1<2=3”, are not. The generated AST must correspond to an interpretation of the following: Note that expressions such as “not 1”, “2 < (not 3=4)” and “5 + (6<7)” may be semantically nonsensical, but are syntactically correct and should be recognized. As an example, for input
not 1-2 or 3<4 and 5>6 and 7=8+9
the resulting AST must be
or(-(not(1),2),and(<(3,4),>(5,6),=(7,+(8,9))))
i.e., as if the implicit parenthesization was
((not 1)-2) or ((3<4) and (5>6) and (7=(8+9)))
Authors: Carles Creus, Nil Mamano / Documentation:
To be able to submit you need to either log in, register, or become a guest.