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         
  1. Extend the above to an ocamlyacc grammar that produces appropriate abstract syntax trees.

  2. Write a Pretty Printer.

  3. Write a transformation that performs compile-time constant folding.

  4. Write a weeder that at compile-time rejects division by the contant zero.

  5. Write an evaluator that, given an appropriate environment, evaluates arithmetic expressions.