Homework #9
CS 341 - Principles of Programming Languages
Homework #9

Due: at the beginning of class 16

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: MiniScheme4.jj and supporting abstract syntax tree .java files, and enter the command "submit341 ms4".

MiniScheme Project Phase 4

In this phase of the project, you will extend phase 3 to include lambda expressions and procedure calls.

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>
| <lambda expression>
| <procedure call>

<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> )
<lambda expression> --> ( lambda ( { <variable> }* ) <body> )
<body> --> { <definition> }* { <expression> }+
<procedure call> --> ( { <expression> }+ )