|
CSE 401: Assignment 1, Due Monday 4/9/01
|
|
Individual homework
#1 - #3 should be done and
turned in individually, not as a group.
- ASU 3.7abch. ("In order," or "in lexicographic order" means for
example that "p" preceeds "r", with or without arbitrary
intervening characters. You may not use the not operator
except for the simple case where not(a, b, ..., c) means
all single letters except the letters a, b, ... or
c.)
- ASU 3.16cd
- ASU 3.17 (for 3.16cd only) Be sure to use Algorithm 3.2.
Project
If you have formed a group, the following may be done by your group;
turn in only one solution per group.
To form a group, send email to our TA, douglas at cs, giving the
names an unix login of each group member. Max 3 persons per
group.
In this part of the project you will be extending the description of the PL/0 lexical
structure to include the new language features described in
the PL/0 Project Description.
In particular, note that the extensions will require the
scanner to handle
- Comments: A comment begins with a pound sign ("#") and
extends to the end of the line. Comments are treated as
whitespace (not tokens).
- Underscores ("_") in identifiers: They may appear
anywhere that a letter can appear in an identifier.
- New reserved words:
else
,
for
,
to
,
break
,
return
,
array
,
of
,
bool
,
true
,
false
,
and
,
or
.
[Note: don't use TRUE/FALSE as the token names for the Boolean
constants in the SYMBOL enum in token.h; those names conflict
with standard C #defines. Instead, I'd suggest
TRUETOKEN/FALSETOKEN.]
- New punctuation tokens:
[
and ]
.
Specifics:
- First, copy and build the base pl/0 compiler,
using the directions
here.
Test it on the sample program
here.
-
Extend the PL/0 scanner to scan the
extended language. Use the -T option to stop compiling after
scanning. You will also likely be interested in the
-t
option that prints tokens as they are read, and
perhaps the -c
(print characters) and
-l
(print lines) options.
For all implementation projects, you will be graded on
correctness of your implementation, on clarity and good design
of your implementation, and on sufficiency of your test cases.
See these pages for information on
printing and
electronically sumbitting your files
to us.