
“Compiler Construction” by Niklaus Wirth (2014) [pdf] - networked
https://www.inf.ethz.ch/personal/wirth/CompilerConstruction/index.html
======
userbinator
I remember Wirth's approach of preferring recursive-descent over the bottom-up
LR, LALR, SLR, etc., was quite controversial at the time, since prevailing
wisdom was that bottom-up parser-generators could parse more complex grammars
and were widely believed to be more efficient. Now it seems things have turned
in the opposite direction, with both large production-quality compilers and
simple educational "toy" ones using some variant of recursive-descent. When
GCC switched from a Bison-generated parser to recursive-descent, it actually
made it
faster([https://gcc.gnu.org/wiki/New_C_Parser](https://gcc.gnu.org/wiki/New_C_Parser)
). The fact that LL languages are theoretically a subset of LR has not stopped
recursive-descent from being used to successfully parse languages like C++
whose grammar is actually Turing-complete.

~~~
WalterBright
The Digital Mars C++ compiler used recursive descent since 1987 or so. It's
certainly practical.

~~~
logicchains
Slightly off topic, but as one of the only people in the world who's written a
C++ compiler by themselves, how many manhours would you estimate it would take
to update a C++03 compiler to fully support C++14? Or how many years; I think
I remember reading you say somewhere that DMC++ took 10 years to code.

~~~
WalterBright
I think I'm the only person who's written a complete C++ compiler by himself -
preprocessor, parser, semantic analyzer, optimizer, and code generation. I
also mean a C++98 compiler, because that's pretty much where I stopped.

I don't know how much is involved in going from that to C++14, as I haven't
done that.

10 man years is a good estimate for creating a C++ compiler, not including the
C part nor the optimizer/codegen.

------
tokenrove
It's great to see this available and updated. It was one of my favorite
compiler books growing up because it's so small and straight-forward. I feel
it's a much better starting point for someone actually interested in building
a compiler than say, the Dragon book.

Even more immediate and hands-on is Abdulaziz Ghuloum's "An Incremental
Approach to Compiler Construction" paper:
[http://scheme2006.cs.uchicago.edu/11-ghuloum.pdf](http://scheme2006.cs.uchicago.edu/11-ghuloum.pdf)
(which chides Wirth for oversimplifying)

------
nickpsecurity
It's a classic. Also helps you understand and start to play with a well-
documented OS and compiler suite coded in a safe, GC language. Good start on
developments where countering subversion of toolchain is a requirement.
Wirth's stuff is one of least likely to be subverted & easiest to spot such
things.

------
505
I didn't realise this book existed. My university was really into Pascal and
Modula-2 and had a second or third year course called Compiler Construction.
We used the Dragon book (which I really enjoyed), and recursive descent. I'm
not sure if we actually used lex or yacc.

------
tobiasu
The 2014 version is available here:

[https://www.inf.ethz.ch/personal/wirth/CompilerConstruction/...](https://www.inf.ethz.ch/personal/wirth/CompilerConstruction/index.html)

~~~
dang
Thanks, we changed to that from
[http://www.ethoberon.ethz.ch/WirthPubl/CBEAll.pdf](http://www.ethoberon.ethz.ch/WirthPubl/CBEAll.pdf).

~~~
iheartmemcache
I actually prefer the '05 edition, as it targets a RISC ISA. (I also reach for
my 2nd ed of The Art of Electronics more than my 3rd, take that as you will).
Thanks for linking that out, a classic read along with Crenshaw.

