Consider the following BNF of arithmetic expressions. ::= + | - | <
Posted: Sun Jul 03, 2022 12:01 pm
Consider the following BNF of arithmeticexpressions.<expression> ::= <term> + <expression> |<term> - <expression> | <term><term> ::= <factor> * <term> |<factor> / <term> | <factor><factor> ::= ( <expression> ) | <literal><literal> ::= 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9
Write code to build the expression tree of expressionswritten according to this syntax, assuming that:• You have a variable token that contains the first symbol of theexpression.• You have a function gettoken(token) which obtains the next tokenof the expression whenever you call it.• All the expressions submitted as input are compatible with thissyntax (no need to worry about error handling).
Write code to build the expression tree of expressionswritten according to this syntax, assuming that:• You have a variable token that contains the first symbol of theexpression.• You have a function gettoken(token) which obtains the next tokenof the expression whenever you call it.• All the expressions submitted as input are compatible with thissyntax (no need to worry about error handling).