YCP Logo Assignment 1: CFG for a subset of Scheme

Due: Friday, Sep 11th by 11:59 PM

Update Sep 10th

  • Fixed one occurrence of identifier incorrectly designated as a nonterminal
  • Here are several example input strings. You should make sure your grammar can generate them, starting with your start symbol. (Try constructing a derivation for each one.)

Your Task

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.]

Terminal symbols

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.

Primitive Literals

A primitive-literal is one of the following

  1. an integer_literal
  2. a boolean_literal
  3. a string_literal


An atom is one of the following

  1. a primitive-literal
  2. 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):

  1. an atom
  2. a list


An expression is one of the following:

  1. an atom
  2. a list-literal
  3. an if-expression
  4. a let-expression
  5. a lambda-expression
  6. a function-application

List literals

A list-literal has the form

( quote list-or-atom )

If expressions

An if-expression has the form

( if expression expression expression )

Let expressions

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 )

Lambda expressions

A lambda-expression has the form

( lambda ( formals-list ) expression )

A formals-list is a sequence of zero or more occurrences of identifier.

Function application

A function application has the form

( expression arg-list )

An arg-list is a sequence of zero or more occurrences of expression.

Top-level items

A top-level-item is one of the following:

  1. an expression
  2. 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: