Define an abstract syntax of the while language


Problem 1
Define an abstract syntax of the while language suitable for interpretation in either Haskell or Prolog. In Haskell, the definition should be the code of a few data types. In Prolog, no code may be necessary. In this is your case, move directly to Problem 2.

Problem 2
Code two simple while programs in the syntax of Problem 1. One program is the factorial shown above, the other is a program of your choice.

Problem 3
Code an interpreter of the while language in either Haskell or Prolog. Your interpreter should have a function (in Haskell) or a predicate (in Prolog) that takes the abstract syntax tree of a program of Problem 2 as one of its argument. The interpreter should execute the program statements and produce (return in Haskell or bind in Prolog or print, if you prefer) the value of the program variables at the end of the execution. The structure or format of these values is irrelevant as long as it is understandable, see below. You are free to implement only the portions of the interpreter that are needed for the execution of the two programs of Problem 2.

Request for Solution File

Ask an Expert for Answer!!
Basic Computer Science: Define an abstract syntax of the while language
Reference No:- TGS0112874

Expected delivery within 24 Hours