Primary:
[Skip To Body]
[Front Door]
[Current]
[Glance]
[Honesty]
[Instructions]
[Links]
[Search]
[Syllabus]
Sets:
[EBoards]
[Examples]
[Exams]
[Handouts]
[Homework]
[Labs]
[Outlines]
[Project]
[Readings]
[Reference]
ECA:
[About]
[Grades]
[Quizzes]
[Submit Work]
[Change Password]
[Reset Password]
Miscellaneous:
[2001S]
[98F]
[SamR]
[Glimmer Labs]
Warning! This lab is less polished than most!
Summary: In today's lab, you will experiment with a simple type checker that I've written for your edification. I hope that this lab and the related code will help you think about the design of your parser, your parse trees, your type checker, and other tree walker.
Collaboration: Feel free to work on this lab in pairs or trios.
Turning It In: You don't need to bother turning in this lab.
Grading: Since you're not turning in the lab, I won't grade it.
Since Pascal is a fairly big language, at times in the construction of a compiler or the consideration of pieces, it's worthwhile working with smaller pieces of the language. For the problem of type checking, two key program parts are the declarations and assignment statements.
I've designed a simple language that consists only of declarations and
assignment statements. You can find the formal definition of the syntax
of the language in the file AssignLangParser.java in the
assignment below. In essence, a program looks something like
var id1,id2,id3: type; id4,id5: type; begin id := exp; id := exp; end
a. Make sure that /home/rebelsky/Web/Courses/CS362/2002F/Examples
is in your classpath. The easiest way to do so is
export CLASSPATH=".:/home/rebelsky/Web/Courses/CS362/2002F/Examples:
or
export CLASSPATH="/home/rebelsky/Web/Courses/CS362/2002F/Examples:$CLASSPATH"
b. Make a copy of the directory
/home/rebelsky/Web/Courses/CS362/2002F/Examples/TypeCheck.
In that directory you will find some Java programs and some al programs.
c. Read AssignLangParser.java to ensure that you understand
the syntax of the language.
d. Run TestAL on the sample programs (and a few of your own) to ensure that you understand what the parse trees I build look like.
1. Given your understanding of the Assignment Language, make a list of the kinds of type errors that might occur in programs.
2. Uncomment the instructions to type check in TestAL and recompile. See what kinds of errors the type checker currently catches.
3. Look at AssignLangChecker.java to see what kinds of
errors the checker is intended to catch.
4. Make AssignLangChecker.java catch more errors (you can
choose which other ones to catch). For example, you might check whether
a variable is defined before being used or you might handle expressions
that involve operations.
5. Make AssignLangChecker.java permit the assignment of
reals to integers.
Primary:
[Skip To Body]
[Front Door]
[Current]
[Glance]
[Honesty]
[Instructions]
[Links]
[Search]
[Syllabus]
Sets:
[EBoards]
[Examples]
[Exams]
[Handouts]
[Homework]
[Labs]
[Outlines]
[Project]
[Readings]
[Reference]
ECA:
[About]
[Grades]
[Quizzes]
[Submit Work]
[Change Password]
[Reset Password]
Miscellaneous:
[2001S]
[98F]
[SamR]
[Glimmer Labs]
Disclaimer:
I usually create these pages on the fly
, which means that I rarely
proofread them and they may contain bad grammar and incorrect details.
It also means that I tend to update them regularly (see the history for
more details). Feel free to contact me with any suggestions for changes.
This document was generated by
Siteweaver on Tue Dec 10 08:53:32 2002.
The source to the document was last modified on Tue Oct 29 14:04:23 2002.
This document may be found at http://www.cs.grinnell.edu/~rebelsky/Courses/CS362/2002F/Labs/lab.08.html.
You may wish to
validate this document's HTML
;
;
Check with Bobby