CIT 594 Assignment 6:
Spring 2009, David Matuszek
In this assignment I will define, using BNF, a small programming language. This language is a simplified and greatly modified version of the language Logo.
Your assignment is to write a recognizer for programs in this language. A recognizer is a program that, given a stream of tokens, decides whether or not that stream of tokens constitutes a grammatically correct program in the language. The meaning of the program, if any, is outside the scope of this assignment.
This program will require the use of your Tokenizer and its associated classes (from Assignment 4). It will not require your BnfTokenizer--the grammar listed here is to be hard-wired into your program, not read in as data.
Here is the grammar you will be using. This is standard BNF, with quotes around all terminals, but to help you read it a bit more easily, I've put terminals (keywords and symbols) in red and other Token types in GREEN.
Here are the values for the various colors:
Color class has a constructor that takes a single integer; this allows
you to construct any other colors you like.
To get started, do the following:
Recognizerproject, and in it a
recognizerpackage, and in that a
tokenizerpackage to your Java build path (
Project -> Properties -> Java build path -> Projects). Do not copy those classes into your new project--remember the DRY principle.
Recognizerclass, add stubs for each method you will need. This will be one method stub for every nonterminal (
<move>, etc.). Note that you do not need method stubs for NAME, NUMBER, or EOL, because your tokenizer provides these.
Recognizerclass. Have it generate all the test method stubs for you.
I believe you will find that the easiest way to do this assignment is as follows:
RecognizerTest.javaand fill it with actual tests. This should be some test that doesn't depend on code you haven't yet written. For example,
<comparator>doesn't depend on anything else, but
<comparator>, so write the test code for
public boolean nonterminal(), for each nonterminal defined in the above grammar. Use the exact names as given, with two exceptions: use
The above are requirements. You may have additional classes and methods as needed, and they should be documented and unit tested as appropriate.
Thursday, March 19, before midnight.Turn in a jar file, not a zip file. Use Eclipse's Export.. to a jar file, and follow the steps to include all source code and all code on the build path. This is necessary because we will need your Tokenizer classes in order to test your Recognizer.
The jar file should also include your generated Javadoc files.