CS301 Fall 1998
Project Part #1: The Scanner
Out: Tuesday September 29
Due: Thursday, October 15
Now it is the time to start applying all the neat tricks we
learned in Chapter 2 of the text to implement the scanner. As usual,
make a new directory called Scanner under your CS301 directory
to place your work.
- You will need to copy 6 of the TINY files plus Makefile into
the new directory and modify them to be used as template for the
Scanner.
- In order to have consistent output, edit the main.c
file to set TraceScan to TRUE, EchoSource to
TRUE and NO_PARSE to TRUE. Before you move
on, it makes sense to recompile and run the TINY compiler again on
sample.tny. Verify that the tokens are written to the
screen, and that no code is generated.
- Meet with your teammate to design your scanner as a DFA on
paper and persuade yourselves about its correctness.
- Decide whether you want to implement the C- scanner using the
technique used in TINY (the nested case-statements like in
Figure 2.7) or the table-driven technique (described in
page 63).
- Decide whether you want to implement the lookup function using
binary search or using a hash function. Sequential search
implementation (like in TINY) is not an option here.
- In the same meeting, discuss with your teammate whether you
would like to work together through the implementation of this
phase or if you would rather split the implementation into two
pieces of roughly equal length and difficulty. This negotiation
you should carry seriously and frankly. It is important that both
of you understand what you agreed upon and that you feel it is
fair.
- Implement and test your code thoroughly. Write sample C- code
to test your scanner on. Additional sample programs are on p. 496
of the book. For testing the scanner, the C- programs do not need
to be syntactically or semantically correct. Demonstrate that you
test the generation of every token and every error message you
should produce. Remember that the C- source code file should have
the .cm extension.
- Make sure you have appropriate comments in your files
including header comments describing the name(s) of the file
creator/modifier, date of modifications and summary of the file
contents and use. When needed, have in-line comments to explain
elaborate coding that your instructor or your colleagues might
have troubles understand.
- Hand in the DFA, printouts of your code and your tests.
- Party!
Happy programming!