A Compiler Construction Textbook
See Compiler Design.
This was the basis of a senior-level engineering course
in regular expressions, finite-state machines,
lexical analyzers, and context-free grammars. It then
digs into top-down and bottom-up parsing, and their
application to implementing a compiler for a high-level
language into 80386 machine language.
The book also reviews C++, the Intel 80x86 processor,
floating point numbers and the Intel floating-point unit,
Unix and Microsoft development tools, and more.
An appendix describes a recursive descent (top-down)
parser generator.
A Companion Tool Set
The book uses a companion set of tools
in Qparser. This contains a
parser generator tool, similar to YACC.
History of This Work
I became interested in the translation of a high-level
language into assembler while an associate professor
in the electrical engineering department of Lehigh
University, in the 1970s.
That led to a study of the classic two-volume
The Theory of Parsing, Translation and Compiling
by Alfred Aho and Jeffrey Ullman. And that led to teaching
a course from these books, then experimenting with
a bottom-up parser written in Lisp.
Programs were written and executed through punched
cards sent to a CDC 6400 system for batch processing.
Any reasonable program required hundreds of cards - one per
machine instruction. Despite the crude environment, and
the relatively slow Lisp environment, I managed to get
a critical piece of a bottom-up parser working well enough
for a class demonstration.
A few later, 1974-1978, I knew enough about top-down
and bottom-up parsing and translation to write a college
book on the subject, suitable for a senior-level course.
I followed that up with a compiler Yacc-like parser and
code generator system. My grammars also contained a
means of expressing the generation phase through syntax
trees.
I launched a small company that sold my system as a
product, advertising it in various computer journals.
Although it attracted several hundred customers, the
product never earned enough to support more than one
engineer.
I later taught computer engineering at San Jose State,
Computer Engineering department, and launched compiler
construction as a course, CE 152. Over the years, my
course notes turned into yet another book version, one
that I just offered to my students gratis instead of
going down the path of a published textbook.
I discovered that my students needed detailed training
in assembler for a target machine, and that also helped
justify the course, as a way of showing the students just
how a high-level language like C or Pascal is churned into
assembler. It was a bridge from the abstract, mathematical
world of java or C to the complexities of machine instructions.