Problem 0: Prologue (0 pts)
Before we write any code, let's try to understand the parts of the interpreter that are already written.
Here is the breakdown of our implementation:
repl.pycontains the logic for the REPL loop, which repeatedly reads expressions as user input, evaluates them, and prints out their values (you don't have to completely understand all the code in this file).reader.pycontains our interpreter's reader. The functionreadcalls the functionstokenizeandread_exprto turn an expression string into anExprobject (you don't have to completely understand all the code in this file).expr.pycontains our interpreter's representation of expressions and values. The subclasses ofExprandValueencapsulate all the types of expressions and values in the PyCombinator language. The global environment, a dictionary containing the bindings for primitive functions, is also defined at the bottom of this file.
Use Ok to test your understanding of the reader. It will be helpful to refer to reader.py to answer these questions.
python ok -q prologue_reader -u
Use Ok to test your understanding of the Expr and Value objects. It will be helpful to refer to expr.py to answer these questions.
python ok -q prologue_expr -u
Although this problem is not scored, it can help you understand the structure of PyCombinator to facilitate your solutions to the following scored problems. Please take it seriously.