In this assignment you are going to implement the run
and eval functions for your Clite AST.
Currently Clite programs have no way of providing output to the user to see the effect of
running a program. Add a
simple print statement to our grammar by modifying the Statement non-terminal.
Statement ⇒ ; | Block | Assignment |
IfStatement | WhileStatement | PrintStatement
PrintStatement ⇒ print(Expression) ;
You will need to modify your parser and add a new print statement class to your AST.
Implement the run function for the program class. To do this you will need to complete the implementation of eval on expressions. Your
run function on a print statement should simply
print the value of the expression to the console.
Don't worry about improperly typed Clite programs. If a program is improperly typed then just let your program crash. (Is this similar to static or dynamic typing?)
The program is due on Monday April 21 at the begninng of class. Turn in a print out of the AST classes that have an eval or run function. (I don't need to see type classes.)