Assignments
In there quarter, there are total of four projects. These four projects are
the four phases of of a compiler for SRC3 language.
- Project 1: Scanner
- EXTENSION: PROJECT 1 DUE DATE CHANGED TO TUES, APRIL 22, before Midnight.
- Test Cases
- Project 2: Parser
- The AST Handout is avalaible here now. The handout was designed for a language very similar to SRC3. You can use the handout as a guide to designing your own data structures for theSRC3 language.
- The output format for project 2b is available now. Please adhere to it strictly.
- Late Policy: 70% credit for a 24 hour delay. 50% credit for a 48 hour delay. If you submit an improved version late, 70% or 50% extra credit will be granted for the improvements, as per your submission time. Name your late files as FileName_late24.extension or Filename_late48.extension, as appropriate. All files are timestamped, so do not overwrite your previous submissions.
-
The reference implemenation of the lexer and parser for
project 2 has been modified (even though you only need the pasring rules
from the reference implementation parser for project 2b).
The modification was to fix a interface problem between
project 1 and 2. The problem caused a string fed to parser with an extra
double quote. Thanks to everyone who pointed the problem out.
-
Again, any reference implementations posted by TAs are
for reference only. You have to take the risk of using them. They are not
guaranteed to be bug-free nor is there a service contract for maintenance.
For project 2b
you only need to follow the parsing rules defined in the reference
implementation, you are not required to use the reference implemenation
as it is. We welcome any bug reports, though.
Project 3: Semantic Analysis
-
A semantic spec has been released here.
- Here is a hash map that was
designed for integers rather than strings. You must revise it if
you choose to use it. It may not support duplicate hash values.
It will not be supported by TAs.
-
SEAS labs will be closed on the planned due day, thus,
the due day is postponed to 23:59 May 27, 2003 (Tuesday)
-
Deadline for project 3 is 23:59 May 26, 2003 (Monday).
-
Another possible candidate for symbol table
implementation is the 'hsearch' utility in UNIX.
It does provide a char* to void* map, but again
it is not an API that you can simply use off the shelf.
You should read the man page very carefully.
-
The grading TA will write a lot of small SRC3
programs with syntactically correct statements
that may be semantically right or wrong. (You are
welcome to contribute testing cases.) You will
need to write an AST tree-transversal routine to
a) generate a symbol table b) compute inherited
and synthesized attributes in order to do semantic
analysis and later on to do code generation.
There are several kinds of output for project 3:
a) symbol table dump b) type promotion c) errors.
-
Here is the spec
semantic analysis output
for project 3 output.
Again, you should pack all your source code including
a Makefile file and a README.txt file.
-
Here are an implementation of the
AST for the parser.
No tree-transversal routine is provided. NOTE: in
project 3, you are required to print out the line
number for a symbol, i.e. ID, in the parser.
Therefore, you may have to modify your parse
rule a little bit. For example, for the paser posted
for project 2, you need to add a new non-terminal,
id, that takes on one ID as its RHS and
record the line number in its action block.
All other parse rules that use ID in its RHS should
reference id instead. See the difference between
parser before
and
parser after.
-
Again, all code posted for are reference only, they
are actual source files that are currently
under development
by a TA for the third project. There is no
guarantee and maintenance for them, but you are welcome
for any bug report.
Project 4: Code Generation
-
Generate assembly code for Java Virtual Machine and
use Jasmine to compile your output. Please visit
Jasmine
Home Page for its manual. Jasmine is installed
on seas. Run "
jasmin" and see if it
works. Also the directory
/w/class.01/cs/cs132/cs132ta/risc/jasmin-1.06/
contains some examples.
-
project 3 implementation:
It is not necessarily 100% perfect for project 3,
but since no tests would contain semantic errors,
it should work fine. Update
please download it again if you downloaded before
12:38pm June 9th The changes are:
- some modifications in expmatch.c.
- Fix a bug in
traverse_SubHeading function in traverse.c
- Bug fix in expmatch.c for functions
checkValidExp_OR and checkValidExp_AND
- Here is a simple test
script which you may use to automate your own
tests. After you downloaded the file, do
chmod 755 testscript
to make the script executable. Then run
./testscript
to display the help information.
- Test Cases. It
is an incomplete list of things which will be tested.
Some of these will appear in the grading test. They
are provided so that you are more/less confident of
what you have turned in. Also, it may help if you
accidentally forget to consider a type of situation.