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.py contains 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.py contains our interpreter's reader. The function read calls the functions tokenize and read_expr to turn an expression string into an Expr object (you don't have to completely understand all the code in this file).
  • expr.py contains our interpreter's representation of expressions and values. The subclasses of Expr and Value encapsulate 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.