Homework 4
CS 541
Fall 1999
Craig A. Rich


Design a language, including a syntax and semantic specification, and construct an interpreter for the language using the Generic Interpreter (gi). The language can be a new language or part of an existing language. "Language" should be considered in a broad sense, and is not restricted to programming languages.

1
Construct a regular.Specification that specifies the lexical-level syntax of the language.
2
Construct a context_free.Grammar that specifies the phrase-level syntax of the language.
3
Construct a semantic.Definition that specifies the semantics of the language.
4
Construct an Interpreter that reads and interprets characters from an InputStream, according to your language.

The Generic Interpreter

Public Documentation

http://www.csupomona.edu/~carich/classes/cs541/199904/hw4/gi-0.5/overview-tree.html

Private Documentation and Source Code

http://www.csupomona.edu/~carich/classes/cs541/199904/hw4/gi-0.5/src/overview-tree.html

Example Instances

http://www.csupomona.edu/~carich/classes/cs541/199904/hw4/gi-0.5/instance/Expr.java
http://www.csupomona.edu/~carich/classes/cs541/199904/hw4/gi-0.5/instance/ExprLL1.java
http://www.csupomona.edu/~carich/classes/cs541/199904/hw4/gi-0.5/instance/Lisp.java
http://www.csupomona.edu/~carich/classes/cs541/199904/hw4/gi-0.5/instance/AdaCodeGenerator.java

Using the Cal Poly Pomona Intranet Development Environment

Sun's Java Development Kit (JDK) v1.2--including a compiler (javac) and interpreter (java)--is provided. Generic Interpreter v0.5 is installed in my user directory, from which you can import classes directly to construct your interpreter. Include the appropriate directory in your CLASSPATH environment variable before compiling and interpreting a source file:

% setenv CLASSPATH /dfs/user/carich/classes/cs541/199904/hw4/gi-0.5/src:.
...
% javac Language.java
% java Language < sourcefile

Using your own Development Environment

Java is relatively portable, so you should be able to develop your language interpreter in other development environments as well. You will need an environment that supports Java v1.2, since the Generic Interpreter relies extensively on the Collection classes (e.g., Sets, Maps) introduced in v1.2. Generic Interpreter v0.5 is distributed as a Java archive (jar) file containing the classes, public documentation, and example instances:

http://www.csupomona.edu/~carich/classes/cs541/199904/hw4/gi-0.5.jar