| 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.
|
Construct a regular.Specification that specifies the lexical-level syntax of the language. |
|
Construct a context_free.Grammar that specifies the phrase-level syntax of the language. |
|
Construct a semantic.Definition that specifies the semantics of the language. |
|
Construct an Interpreter that reads and interprets characters from an InputStream, according to your language. |
Public Documentation
http://www.csupomona.edu/~carich/classes/cs541/199904/hw4/gi-0.5/overview-tree.htmlPrivate Documentation and Source Code
http://www.csupomona.edu/~carich/classes/cs541/199904/hw4/gi-0.5/src/overview-tree.htmlExample Instances
http://www.csupomona.edu/~carich/classes/cs541/199904/hw4/gi-0.5/instance/Expr.javahttp://www.csupomona.edu/~carich/classes/cs541/199904/hw4/gi-0.5/instance/ExprLL1.javahttp://www.csupomona.edu/~carich/classes/cs541/199904/hw4/gi-0.5/instance/Lisp.javahttp://www.csupomona.edu/~carich/classes/cs541/199904/hw4/gi-0.5/instance/AdaCodeGenerator.java
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 yourCLASSPATHenvironment 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
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