Exp -> Exp + Exp | Exp * Exp | ( Exp ) | - Exp | id | numUsing this grammar (a) write a left derivation for the string "(A + C) * (8 + B + -(B + C))", and (b) show the parse tree for your derivation. Assume that * has precedence over + and that all operators are left associative.
type name (type param1, type param2, ..., type param n) body
pgm -> (stmt | exp)+ stmt -> = ID exp exp -> + exp exp | - exp exp | * exp exp | / exp exp ID | NUMYour productions should perform the following actions:
Each value should be printed on a separate line. If you have a question about whether or not an expression is valid or what value should be printed for an expression or statement, you can run the antlr expression evaluator that I have written which is in /home/bvz/cs365/hw/hw5. You will need to copy the .class and .tokens files to your directory, and then type:
java -cp .:..:/usr/share/java/antlr3.jar ExprEvaluator < inputfilewhere inputfile is the name of the file containing your expressions.
Name your antlr specification Prefix.g and your driver file ExprEvaluator.java (you can use an appropriately modified version of the Test.java file discussed in class).
Submit the following files (do not jar them--the submit script will pack them into a tar file):