This site uses cookies only for the purpose of identifying user sessions.
This is required to properly register actions.
Exercise
‹9›:
Parenthesized expressions over binary + and * (with AST +(1,*(+(2,3,4),5,6)) for 1+(2+3+4)*5*6)
The set of tokens of the language is
{+,*,(,),NUMBER}. The token NUMBER
represents unsigned integers, i.e., non-empty sequences of digits. The
expressions 1, 2*(3+4), (5+6)*7+8 and 0*(2+1)*0+1
are correct but *, )2+, +(*), 1 2, *4,
()), 1*1*(2*) are not. The generated AST must have at most one
symbol + at the root of every sum, and a single * at the root of
every product. The usual precedence of * over + applies, and
parentheses are allowed. For example, for input 1+2+3*(4+5+6)*7 the
resulting AST must be +(1,2,*(3,+(4,5,6),7)), whereas 1 has AST
1 and 1*2*3 has AST *(1,2,3).
Authors: Pau Fernández
/
Documentation: