CFWAE Interpreter
Introduction
In class we have discussed a simple interpreter that can evaluate arithmetic expressions, and added conditionals and functions. Now that we have identifiers, we can implement a full programming language.
Assignment
We will implement a variant of the CFWAE language, described on the PL
online page. You must also define two functions parse
and interp
,
these must be typed as specified in the CFWAE template I have provided
on github. The template also defines the datatypes you must use. For
this assignment, we will not use desugaring to implement any
feature. All features must be defined in the core language and core
interpeter.
Grammar
The pyret reader (sexpr parser) is a little different than racket’s so
we will modify the CFWAE grammar to use (
and )
instead of {
and
}
to delimit expressions.
<CFWAE> ::= <num> | (+ <CFWAE> <CFWAE>) | (- <CFWAE> <CFWAE>) | (* <CFWAE> <CFWAE>) | (/ <CFWAE> <CFWAE>) | <id> | (if0 <CFWAE> <CFWAE> <CFWAE>) | (with ((<id> <CFWAE>) ...) <CFWAE>) | (fun (<id> ...) <CFWAE>) | (<CFWAE> <CFWAE> ...)
where an id is not +
, -
, *
, /
, with
, if0
or fun
.
Grading
Remember that 20% of your grade will be determined by your comments, documentation, and style. Another 20% will be determined by your test cases. The remaining 60% will be determined by the functionality of your code.