Interactive Introduction to Compiler Construction
This book is a short introduction to compiler construction using JavaScript as the implementation language, recursive descent parsing with the EBNF parser generator and SLR(1) parsing with BNF as case studies for tools, and a little programming language with several extensions as working example. Here are the chapters:
1. Compiler Terminology
What's in a Compiler?
What's in a Parser Generator?
2. Writing Grammars
What's in a Rule?
A Language for Rules
Summary
3. Scanning Input
Terminals, Tokens, and Literals
Taking Input Apart
Summary
4. Recognizing Sentences
What's in a Sentence?
Check Before You Call!
Summary
5. Translating Sentences
What's in a Parse Tree?
What's with the Brackets?
Summary
6. Compiling Little Languages
Interpret Now, Compile for Later
Functions and a Stack Machine
Summary
7. Language Features
Type Checking
Functions, Scopes, and Nesting
Summary
8. Functions as Values
First-Order Functions
Stack versus Closure
Summary
9. Compiling Grammars
What's in a Parser Generator?
Grammar (De-)Constructed
Summary
10. Recognition Revisited
Try (Almost) Everything?
Conflicts and Errors
Summary
11. Compiling Revisited
What's in a Tree?
What's with a Tree?
Summary
A: The Practice Page
The Model
Scripting and Buttons Explained
B: The Stack Machine
Machine Architecture
Instructions
C: The One-Pass Compilers
The Method Browser
Rules and Actions
Symbol Table
D: The Compiler Kit
Tree Builders
Visitors
References
All references are links. Undecorated links are references within the book itself. Decorated links reference the book's website:
-
Examples are linked to the practice page where they are automatically loaded to be executed, studied, changed, and executed again.
-
Classes and methods developed in the examples are linked to their documentation, to the documentation for classes and methods of the EBNF and BNF parser generators developed in the book, and to the documentation for scripting the practice page. Documentation in turn links to the appropriate files and lines with the syntax-colored source code.
-
Some links, mostly in chapter eight, reference the method browser where one can study how the implementation of a little programming language in this book evolves.
Other decorated links reference the World Wide Web:
- For JavaScript information, links point to the excellent MDN Web Docs,
- a few links point to specific web pages, such as the original announcement of JavaScript,
- and terminology is linked to definitions in Wikipedia so that additional information is easily available — further references should be consulted from there.
Altogether, the book contains over 1100 unique links.