Exercise 17:

Parenthesized 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 whereas are not. The generated AST must correspond to an interpretation of the + and - binary operators as left-associative and exponentiation as right-associative. The precedence is as usual, with unary operators having the highest precedence, followed by exponentiation. As an example, for input
1^(-2+-3)^4
the resulting AST must be
^(1,^(+(-(2),-(3)),4))
i.e., as if the implicit parenthesization was
1^(((-2)+(-3))^4)
Authors: Nil Mamano / Documentation:
To be able to submit you need to either log in, register, or become a guest.