Summary for the impatient: I'm searching for good references on generating code for common language constructs but not parsing.
I am interested in programming languages and try to read the literature as much as possible. But most of them covers the topic in a functional and theoretical perspective that, I find them hard to understand let alone implement the ideas.
So the question is; Which resources do you suggest about programming language implementations that covers the topic in a more imperative and practical fashion?
For example, I find "The Implementation of Lua 5.0" paper very instructive.
Note that, I am not seeking articles about parsing or tokenizing.
Here are a bunch of good textbooks:
Modern Compiler Implementation in Java (Tiger book) A.W. Appel Cambridge University Press, 1998 ISBN 0-52158-388-8 A textbook tutorial on compiler implementation, including techniques for many language features
Compilers: Principles, Techniques and Tools (Dragon book) Aho, Lam, Sethi and Ullman Addison-Wesley, 2006 ISBN 0321486811 The classic compilers textbook, although its front-end emphasis reflects its age.
Advanced Compiler Design and Implementation (Whale book) Steven Muchnick Morgan Kaufman Publishers, 1997 ISBN 1-55860-320-4 Essentially a recipe book of optimizations; very complete and suited for industrial practitioners and researchers.
Engineering a Compiler (Ark book) Keith D. Cooper, Linda Torczon Morgan Kaufman Publishers, 2003 ISBN 1-55860-698-X A modern classroom textbook, with increased emphasis on the back-end and implementation techniques.
Optimizing Compilers for Modern Architectures Randy Allen and Ken Kennedy Morgan Kaufman Publishers, 2001 ISBN 1-55860-286-0 A modern textbook that focuses on optimizations including parallelization and memory hierarchy optimizations.
Programming Languages Pragmatics Michael L. Scott Morgan Kaufmann Publishers, 2005 ISBN 0126339511
Supposedly (I read through it, but haven't done it), An Incremental Approach to Compiler Construction is excellent. It describes how the author teaches his compilers course.
From the abstract:
Compilers are perceived to be magical artifacts, carefully crafted by the wizards, and unfathomable by the mere mortals. Books on compilers are better described as wizard-talk: written by and for a clique of all-knowing practitioners. Real-life compilers are too complex to serve as an educational tool. And the gap between real-life compilers and the educational toy compilers is too wide. The novice compiler writer stands puzzled facing an impenetrable barrier, “better write an interpreter instead.”
The goal of this paper is to break that barrier. We show that building a compiler can be as easy as building an interpreter. The compiler we construct accepts a large subset of the Scheme programming language and produces assembly code for the Intel-x86 architecture, the dominant architecture of personal computing. The development of the compiler is broken into many small incremental steps. Every step yields a fully working compiler for a progressively expanding subset of Scheme. Every compiler step produces real assembly code that can be assembled then executed directly by the hardware. We assume that the reader is familiar with the basic computer architecture: its components and execution model. Detailed knowledge of the Intel-x86 architecture is not required.
The development of the compiler is described in detail in an extended tutorial. Supporting material for the tutorial such as an automated testing facility coupled with a comprehensive test suite are provided with the tutorial. It is our hope that current and future implementors of Scheme find in this paper the motivation for developing high-performance compilers and the means for achieving that goal.
I suggest playing with ANTLR. I used it awhile back and found it very easy to use.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With