CSIS 480 - Compiler Project
This course includes a non-trivial programming project - the development
of a functional compiler. The following documents provide information
about the programming langage we will be implementing, dubbed
Hansen by previous students:
You should print these documents out, as they are made available, and
keep them with you for reference purposes. Initially, only the grammar for
HansenLite is available.
The Compiler Project
The project will proceed in three phases:
A fourth phase may include extending the compiler to accommodate
additional features added to the basic programming language. While
extending our existing compiler should be relatively simple, we may
instead use this phase to learn how to use a practical compiler-compiler tool.
- 1) Lexical Analyzer
Implement a stand-alone lexical analyzer that accepts a text file
containing a source program as input and produces a stream of tokens
representing the program as output, showing lexemes for the tokens
such as identifier, number, and
arithmetic_operator. The program should be designed using a
table-driven approach to a finite-state-automata. Code should be
designed with ease of maintenance and extension in mind, making
extensive use of named constants, for example, and avoiding hard-coded
values wherever possible.
- 2) Predictive Parser
Implement a non-recursive top-down predictive parser that uses the context-free
grammar given for our language to analyze the syntax of a source
program. Like the lexical analyzer, the parser will be a table-driven
finite-state-automata with the addition of one or more pushdown stacks.
As before, code should be carefully designed for extensability and
readability. The lexical analyzer from the previous phase of the project
will be used to supply your parser with a stream of
tokens for parsing. Your parser should accept a text file containing
a source program as input and produce a leftmost derivation of the
program in the given context-free grammar as output. Any lexical or syntax errors
found should be noted with an indication of their location in the program.
The symbol table(s) should be printed out at the end of the program.
- 3) Compiler
Implement a compiler that translates the source program into
assembly-code using a syntax-directed definition of semantic rules
for our grammar. Your compiler will generate assembly-code for the Java
virtual machine. An assembler will be provided to you for
translating your compiler's output into a JVM executable.
Your programs may be written in any approved language. Do not use
automated tools for generating portions of the compiler (e.g., Lex,
Yacc). Programs should be well designed, implemented, and
documented - I
can not over-emphasize the importance of documenting your
code for this project.
A significant portion of your course grade will depend on how well you
accomplish the programming tasks.
Last modified: ,
by David M. Hansen