xvi PREFACE
• Includes a chapter on optimization that is just right for an introductory course. Stu-
dents do not simply read about optimization techniques—they implement a variety
of techniques, such as constant folding, peephole optimization, and register
allocation.
• The book uses a Java-like form of grammars that students can easily understand and
use.
This is the same form that JavaCC uses. Thus, students can make transition to
JavaCC quickly and easily.
• Provides enough theory that the book can be used for a combined compiler/automa-
ta/formal languages course. The book covers most of the topics covered in an au-
tomata/formal languages course: finite automata, stack parsers, regular expressions,
regular grammars, context-free grammars, context-sensitive grammars, unrestricted
grammars, Chomsky's hierarchy, and the pumping lemmas. Pushdown automata,
Turing machines, computability, and complexity are discussed in supplements in
the software package. The software package also includes a pushdown automaton
simulator and Turing machine simulator.
• Covers every topic that should be in a first course or in an only course on compilers.
Students will learn not only the theory and practice of compiler design but also im-
portant system concepts.
SOFTWARE PACKAGE
The software package for the textbook has some unusual features. When students run one
of their compiler-generated programs, the software produces a log file. The log file con-
tains a time stamp, the student's name, the output produced by the compiler-generated
program, and an evaluation of the compiler-generated program with respect to correct-
ness,
program size, and execution time. If the output is not correct (indicating that the stu-
dent's compiler is generating incorrect code), the log file is marked with NOT COR-
RECT. If the compiled program is too big or the execution time too long, the log file is
marked with OVER LIMIT.
The name of
a
log file contains the student's name. For example, the log file for the S3
project of a student whose last name is Dos Reis would be S3.dosreis.log. Because each
log file name is unique, an instructor can store all the log files for a class in a single direc-
tory. A single command will then produce a report for the entire class.
The software supports two instruction sets: the stack instruction set and the register in-
struction set. The stack instruction set is the default instruction set. To use the register in-
struction set, a single directive is placed in the assembly language source program. The
software then automatically reconfigures itself
to
use the register instruction set.
The three principal programs in the software package are a (the assembler/linker), e
(the executor), and
1
(the library maker). The software package also includes p (a push-
down automaton simulator) and t (a Turing machine simulator).
The software package for this book is available from the publisher. The compiler tools
are available on the Web. At the time of this writing, JavaCC is at http://java.net/down-
loads/javacc, Byacc/j is at http://byaccj.sourceforge.net/, and Jflex is at http://jflex.de/.
PROJECTS
This textbook specifies many well-defined projects. The source language has six levels of
increasing complexity. A student can write a compiler for each level that translates to the