Exercise 13:

Parenthesized expressions over binary +, -, *, /, and ^ (^ with lowest precedence)
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”, “1^(1+0)/2-3”, “1/2^3”, whereas “0+”, “/6”, “1 2”, “^1”, “1/2*3+” are not. The generated AST must correspond to an interpretation of all operators as left-associative, except exponentiation, which is right-associative. The precedence is different than usual in that exponentiation have the lowest precedence. As an example, for input
1+2*3^4/5-6
the resulting AST must be
^(+(1,*(2,3)),-(/(4,5),6))
i.e., as if the implicit parenthesization was
(1+(2*3))^((4/5)-6)
Authors: Pau Fernández / Documentation:
To be able to submit you need to either log in, register, or become a guest.