Consider the following extended grammar for arithmetic expressions:
start
: start PLUS term
| start MINUS term
| term
term
: term STAR factor
| term SLASH factor
| factor
factor
: IDENTIFIER
| LPAR start RPAR
| INTCONST
- Extend the above to an ocamlyacc grammar that produces appropriate abstract syntax trees.
- Write a Pretty Printer.
- Write a transformation that performs compile-time constant folding.
- Write a weeder that at compile-time rejects division by the contant zero.
- Write an evaluator that, given an appropriate environment, evaluates arithmetic expressions.