Use the following command on tinman server to submit source files: sudo handin 1 file1 file2 ... Here 1 refers to assignment number and file1, file2,... refer to individual files to be submitted. For this assignment you must submit Makefile .flex file .cup file all .java files that were created by you (do not submit Lexer.java etc).
Write a Java program (using JFlex/Cup) to interpret WAE expressions. The CFG for WAE expressions is given below:
<WAEStart> ::= <WAE> SEMI <WAE> ::= <num> | {+ <WAE> <WAE>} | {- <WAE> <WAE>} | {with {<id> <WAE>} <WAE>} | <id>You will write a main program, called WAE.java, that prompts the user with WAE> . The user can enter a WAE expression at the prompt or type exit to exit the WAE interpreter. If the user enters a WAE expression, your program should verify that it is a valid expression. If the expression is valid, it should be evaluated and the value of the expression should be printed; Otherwise and error message should be reported.
Sample Run:
$ java WAE WAE> {with {x 3} {with {y 4} {with {z 5} {+ x {+ y z}} } } } The value is 12 WAE> {with {x 3} {with {y 4} {+ y z} } Syntax Error WAE> {with {x 3} {with {y 4} {+ y z} } } Semantic Error