Course Project for 488/2107
Spring 1998
Last revised on January 26, 1998.
The project is to design and implement a small compiler system for a given
programming language.š You will work in teams of 3-4 on this 6-phase
project.
ššš Phases:
-
Write programs in project language (will be used for testing).
-
Implement parsing.
-
Generate an abstract syntax tree from a given grammar; implement symbol table and partial type checking
-
Design code generation, complete type checking.
-
Implement code generator
-
Add more language features
Teams
-
Work in teams of 4 (self-selected, list due on January 13)
-
Selecting a hard-working, compatible team is important for success in the
course project, so choose carefully!
- All students on a team will get the same mark for the
assignment they hand in!!!!
-
Team management and conflict resolution is part of your course mark.
What to turn in
For every phase of the project, turn in
-
List of group members with description who was responsible for each part
of the work.
-
A brief report of problems (and their resolution), should they arise.š 5%
of your project mark is for problem management.
-
Careful documentation (documentation is worth at least 5% for every phase,
but this percentage can go up).
Testing
For each assignment in which you modify the project compiler,
hand in test runs to demonstrate that you have implemented
the required features. As a minimum, these tests should illustrate:
- Correct handling of normal cases
- Correct handling of tricky or difficult cases
- Any error handling that you have implemented
For some assignments, we will also test your code on our testcases.
Watch the newsgroup for announcements.
Version Control
Use of CVS version control system is mandatory
for managing the project software. The CVS version control system will be
discussed in tutorial. You should start a new CVS major revision level
corresponding to each Assignment.
Assignment Description
- Assignment 0, due January 13 [0%].
Turn in a list of your team members.
- Assignment 1, due January 20 [5%].
Write each of the following in CSC488 Source Language. Store them in Unix files and hand in a printed copy.
(These programs will be useful later for testing your compiler.)
- three short programs (10 to 20 statements) that do not use arrays, functions, or procedures
- a program using arrays but not functions or procedures
- a program using loops including nested loops
- a program using non-recursive procedures without parameters
- a program using non-recursive functions with parameters
- a program using recursive functions with parameters
- a program using input and output
- a program that uses a procedure or function declared within
another procedure or function
- Assignment 2, due February 3 [10%].
Using flex and bison, build a parser for the translation grammar. This parser
should include the proper operator precedence and associativity
(so that it is LR(1)). Your parser should stop at the first parse
error, after reporting it. If the program passes the parse, your
parser should not write anything. No semantic actions are required
in the bison file.
Obtain set of files containing the skeleton
parser from
/homes/u2/csc488h/project. Do not modify the lexical analyzer.
Write the parser using the skeleton file provided.
Submit and hand in a copy of parser.y, and some test runs.
A correct parser will not have any shift/reduce and reduce/reduce
conflicts.
Solutions to the
assignment will be made available on February 6. You may not turn in this
assignment after February 6, 9 a.m.
- Assignment 3, due February 24 [10%].
A file containing the
skeleton compiler, as well as solutions to Assignment 2, will be
available on February 6. Your job is the following:
- Modify the parser to
create an abstract syntax tree. printTree() routine and
the data structures will be available to you.
-
Construct a symbol table module, and a semantics module,
omitting arrays, functions, and procedures. These modules should
not interface with the parser, just with the abstract syntax tree.
Note that you may have to modify AST data structures for semantic
analysis!
Add your modules
to the skeleton compiler, and test them.
Submit electronically and hand in a copy of each module you modified,
and some test
runs, showing the tree and the symbol table. Note that this
part of the assignment is very coding-intensive, so budget
your time accordingly.
- Assignment 4, due March 3 [5%].
Design code generation templates for
the statements in the CSC488S Source Language.
(A code generation template is a generic description of the machine
code that will be generated for a statement). Hand in a written description
of these templates including a description of any decisions you have
made about how programs should be represented.
Show how the programs in Assignment 1 would be translated into the CSC488S
machine language.
Add arrays, functions and procedures to the semantics module
of your compiler. Submit electronically and hand in a copy of the semantics module, and tests
to show that these constructs are
processed correctly.
- Assignment 5, due March 17 [15%].
Construct a code generator.
Add it to the compiler and test it. (Do not change the interpreter.)
Submit electronically and hand in a copy of the code generator, and tests to demonstrate its operation.
- Assignment 6, due April 6 [10%].
Choose one or more of the
following, and add it to your compiler.
That means, modify whichever modules necessary to get this job done.
The intent of these language additions will be discussed in tutorial.
The total hardness estimate of the constructs you add should
be greater than or equal to 6.
HINT: Don't wait to start this assignment until the last week
or you will not finish it. Test it, and submit it electronically
(with test cases), and hand the paper copy in. [Hardness estimate is
in square brackets].
- multi-dimensional arrays with static bounds [3]
- one-dimensional arrays with arbitrary starting index and size
determined by an arbitrary expression [2]
- string variables, string operations and string builtin functions [6]
- records[6]
- var parameters [2]
- for loop (up and down counting)[3]
- case statement [3]
- ability to declare and use named constants [3]
- case expressions [3]
- goto statements [5]
- initialization in declarations (e.g. int i := 3 ) [2]
- assert statement [2]
- ability to declare and use named types [2]
- conditional loop exit (e.g. leave when expression ) [3]
Marsha Chechik
Back to csc488 homepage
Last modified on January 7, 1998