CS 341 - Principles of Programming Languages
Homework #8

Due: at the beginning of class 15

Note: This work is to be done in pairs.  Each pair will submit one assignment.  Although you may divide the work, both team members should be able to present/describe their partner's work upon request. 

To submit this homework, change into the directory containing all necessary files: MiniScheme3.jj and supporting abstract syntax tree .java files, and enter the command "submit341 ms3".

MiniScheme Project Phase 3

In this phase of the project, you will extend phase 2 to include Boolean values and operators, if-else, relational operators, and type predicates: #t, #f, and, or, not, if, eqv? (for integer and boolean), <, integer?, boolean?

Notes:

Grammar

Grammar notes:

<program> --> { <definition> | <expression> }*

<definition> --> ( define <variable> <expression> )

<variable> --> <any <identifier> that isn't also a keyword>
<identifier> --> <initial> { <subsequent> }*
<initial> --> [a-z!$%&*/:<=>?^_~]
<subsequent> --> <initial> | <digit> | [+-.@]
<digit> --> [0-9]

<expression> --> <variable>
| <literal>
| <conditional>
| <assignment>
| <derived expression>

<literal> --> <integer> | <boolean>
<integer> --> { + | - }? { <digit> }+
<boolean> --> #t | #f

<conditional> --> ( if <expression> <expression> { <expression> }? )

<assignment> --> ( set! <variable> <expression> )

<derived expression> --> ( read )
| ( write <expression> )
| ( newline )
| ( + <expression> <expression> )
| ( - <expression> <expression> )
| ( * <expression> <expression> )
| ( quotient <expression> <expression> )
| ( let ( { <binding spec> }* ) <body> )
| ( and { <expression> }* )
| ( or { <expression> }* )
| ( not <expression> )
| ( eqv? <expression> <expression> )
| ( < <expression> <expression> )
| ( integer? <expression> )
| ( boolean? <expression> )

<binding spec> --> ( <variable> <expression> )

<body> --> { <definition> }* { <expression> }+