2 Please use the following syntax for the arithmetic express
2. Please use the following syntax for the arithmetic expressions that I want you to process:
<expression> ::= <term> | <term> + <expression> | <term> - <expression>
<term> ::= <factor> | <factor> * <term> | <factor> / <term>
<factor> ::= <constant> | ( <expression> )
<constant> ::= 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9
You can make it slightly more complex by allowing greater integers than 9,
but you can let your constants range from 0 to 9 only.
Solution
1. The reason of the exercising is to exercise constructing and traversing an expression
tree; so I want you to construct a tree to hold the expression, and to evaluate the expression
by means of traversing the tree. you have to build the expression tree, then traverse it to evaluate
the expression. for every expression, you should produce
- a graphical representation of the tree,
- the numeric fee of the expression.
2. Please use the following syntax for the mathematics expressions that I need you to procedure ( <expression> )
<constant> ::= zero 1 3 4 five 8 9
you can make it barely extra complicated by means of allowing extra integers than nine,
but you could let your constants variety from zero to nine most effective.
3. ensure you recognize how this syntax defines operator priority and associativity
rule.
operator precedence: 3*5+4 is interpreted as (three*five)+four in preference to 3*(5+four).
associativity rule: 3-5-4 is interpreted as three-(five-four) in place of (3-5)-4.

