CS 341 - Principles of Programming Languages
Homework #10 |
Due: at the beginning of class 18
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: MiniScheme5.jj and supporting abstract syntax tree .java files, and enter the command "submit341 ms5".
In this phase of the project, you will extend phase 4 to include pair-related structures and procedures: cons, list, pair?, null?, car, cdr, set-car!, and set-cdr!.
Notes:
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> )
| ( pair? <expression> )
| ( null?
<expression> )
| ( cons <expression> <expression> )
| ( list {
<expression> }* )
| ( car <expression> )
| ( cdr <expression> )
| (
set-car! <expression> <expression> )
| ( set-cdr! <expression> <expression> )
<binding spec> --> ( <variable> <expression> )
<lambda expression> --> (
lambda ( { <variable> }* ) <body> )
<body> --> { <definition> }* {
<expression> }+
<procedure call> --> ( { <expression> }+ )