Re: Compilers in six hours (Steve Hobbs)
Thu, 26 May 1994 01:35:27 GMT

          From comp.compilers

Related articles
[7 earlier articles]
Re: Compilers in six hours chase@Think.COM (1994-05-19)
Re: Compilers in six hours (1994-05-20)
Re: Compilers in six hours (Stefan Monnier) (1994-05-22)
Re: Compilers in six hours (1994-05-24)
Re: Compilers in six hours (1994-05-24)
Re: Compilers in six hours (1994-05-25)
Re: Compilers in six hours (1994-05-26)
| List of all articles for this month |

Newsgroups: comp.compilers
From: (Steve Hobbs)
Keywords: courses
Organization: Digital Equipment Corporation
References: 94-05-066 94-05-106
Date: Thu, 26 May 1994 01:35:27 GMT

The discussions on "Compilers in six hours" caused me to dig up the
compiler course project I used to assign when I taught evening courses at
U. Mass. at Lowell. Back then most of the students had taken a Pascal
course so I only assumed the students knew the Pascal programming
language. I did not assume any machine language or assembly language

Attached is my project assignment. It is tailored for the Pascal
programmer but there are options for students that prefer other languages.
In particular, evening students usually do their assignments using a
variety of different machines off campus.

The interesting part of the assignment is the definition of the "object
language". This object language is understandable by any student who
knows Pascal and has mastered the lectures on BNF notation. Students who
can generate this object language can probably also generate machine
language even though they do not yet have any assembly language
experience. The assignment talks about subprojects. The first subproject
was to build a lexical analyzer, the second built a syntax analyzer, the
third subproject generated unoptimized code for expressions, the forth
subproject generated unoptimized code for statements and procedures.

If I were still teaching this course I would probably use C rather than
Pascal for the source and object languages.


16.523 Compiler Project

Students in the 16.523 course will be required to work on the following
compiler project. The project may be done using any computer and any
implementation language that the student finds convenient. If an
implementation language other than Pascal is chosen then please consult
the instructor first. It must be possible for the student to hand in
printed listings of his work. Therefore access to a high speed printer is

The compiler project consists a program that accepts a textfile as input
and produces a textfile as output. The input textfile will be a program
written in the Pascal subset described in Appendix B of the Dragon Book.
The output textfile will contain data in the syntax described below as
object-code. The definition of object-code below is a another subset of
Pascal. If the computer on which the student chooses to do this project
does not have a Pascal compiler then the student should see the instructor
in order to negotiate a different definition of the object-code.

object-code =
"PROGRAM" "Machine" "(" "INPUT" "," "OUTPUT" ")" ";"
"CONST "Maxmem" "=" int-constant ";"
"TYPE" "Word" "=" "RECORD" "CASE" "BOOLEAN" "OF"
        "FALSE" ":" "(" "i" ":" "INTEGER" ")" ";"
        "TRUE" ":" "(" "r" ":" "REAL" ")"
        "END" ";"
        "R0" "," "R1" "," "R2" "," "R3" ","
        "R4" "," "R5" "," "R6" "," "R7" ":" "Word" ";"
        "M" ":" "ARRAY" "[" "0" ".." "Maxmem" "]" "OF" "Word" ";"
"PROCEDURE" "CALL" "(" "Entry" ":" "INTEGER" ")" ";"
        [ "LABEL" int-constant-list ";" ]
"CASE" "Entry" "OF"
"END" ";"
        "END" ";"
"CALL" "(" "0" ")" ";"
"END" "."

Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.