Exercise 14:

Expressions over unary signs and binary +, -, * and /
The set of tokens of the language is {+,-,*,/,NUMBER}. The token NUMBER represents unsigned integers, i.e., non-empty sequences of digits. Examples of correct expressions are 1, 2+3/4, 5-6+7*8 and 1/-0/+1 (even strange expressions like --2+++3, which is equivalent to 2+3), whereas 1+, /2, 1 2, 1/2*3+ are not. The generated AST must correspond to an interpretation of all binary operators as left-associative. The usual precedence rules of products and divisions over sums and subtractions, and unary operators over the rest, apply. For example, for input 1+2*3/-4-5 the resulting AST must be -(+(1,/(*(2,3),-(4))),5), i.e., as if the implicit parenthesization was (1+((2*3)/(-4)))-5.
Authors: Pau Fernández / Documentation:
To be able to submit you need to either log in, register, or become a guest.