Homework 6

This homework is based on homework 5.

Problem

You are asked to implement in Prolog the prettyprinter and interpreter of the "while language" of homework 5.

Prettyprint and execute the factorial program proposed by the instructor and another program of your choice (can be the same as that of homework 5, or another one).

Submit: (1) your code and (2) a trace of prettyprinting and executing your "while programs."

Hints

Since Prolog is dynamically typed, there is no declaration of a class hierarchy for the abstract syntax of a "while program." However, it may be convenient to use (uninterpreted) functions, with the same name as those of the OO solution, for representing a "while program."

The predicate for interpreting a "while program" is likely to have more arguments than in the OO solution. In particular, you may want to pass in and out the symbol table holding the bindings of the "while program" variables.