Due: Friday, Sep 11th by 11:59 PM
Update Sep 10th
Your task for this assignment is to specify a context-free grammar for a subset of the Scheme programming language. The subset is described below.
Use BNF (as described in Chapter 3 of the textbook) to specify the grammar.
See the section "Deliverables" below for information on what you should submit as your solution to the assignment.
[Note that although this is a "programming assignment", it does not involve any programming per se. However, you will use the grammar you specify when you develop a parser in a later assignment.]
The scheme subset has the following terminal symbols
In the rest of this assignment description, words and symbols in bold refer to terminal symbols.
Two important constructs appear in many syntax rules, so we will define them here once and refer to them later.
A primitive-literal is one of the following
- an integer_literal
- a boolean_literal
- a string_literal
An atom is one of the following
- a primitive-literal
- an identifier
A list has the form
( list-items )
where list-items is a sequence of zero or more of the following (in any combination):
- an atom
- a list
An expression is one of the following:
- an atom
- a list-literal
- an if-expression
- a let-expression
- a lambda-expression
- a function-application
A list-literal has the form
( quote list-or-atom )
An if-expression has the form
( if expression expression expression )
A let-expression has the form
( let ( let-pair-list ) expression )
A let-pair-list is a sequence of zero or more occurrences of let-pair. A let-pair has the form
( identifier expression )
A lambda-expression has the form
( lambda ( formals-list ) expression )
A formals-list is a sequence of zero or more occurrences of identifier.
A function application has the form
( expression arg-list )
An arg-list is a sequence of zero or more occurrences of expression.
A top-level-item is one of the following:
- an expression
- a definition
A definition has the form
( define identifier expression )
A program is a sequence of one or more occurrences of top-level-item.
Submit a text document containing your BNF description of a grammar which derives a program from its start symbol. Make sure you clearly indicate which nonterminal symbol is the start symbol.
Upload your grammar as a plain text, MS Word, OpenOffice Writer, or PDF file as assign1. The URL of the submission server is: