Syntax

The syntax of the language you should implement can be captured with the following grammar:

<WAE> ::= <num>
    | {+ <WAE> <WAE>}
    | {- <WAE> <WAE>}
    | {* <WAE> <WAE>}
    | {/ <WAE> <WAE>}
    | {with {{<id> <WAE>} ...} <WAE>}
    | <id>
where an <id> is not +, -, *, /, or with.

In this grammar, the ellipsis (...) means that the previous non-terminal is present zero or more times.

If a with expression has duplicate identifiers, we consider it a syntax error. Therefore, such errors must be detected in parse. For example, parsing the following expression must signal an error:

{with {{x 10} {x 20}} 50}