Assignment 4

Problem

This week’s homework is to extend a parser and interpreter for a simple calculator language. The starter code, which describes the initial language and provides an interpreter and parser, can be found here. The interpreter can be run by calling the interpret function from Main.hs in ghci.

The homework is simply to extend the language by modifying the code; no new functions need to be written. Modifications should be made to Main.hs, while Parser.hs provides parsing functionality basically as implemented in lecture on Wednesday 2/6.

As currently implemented, the language consists of expressions like the following.

1
(- 4)
(+ 1 2)
(+ (-5) (* 1 2))

You should extend the parsers, language datatype, and eval function to allow one or more arguments to + and * instead of exactly two.

Submission instructions

Send an email to cs43-win1819-staff@lists.stanford.edu with either: