Now repeat for C++.
Considering that a considerably large subset of C is valid C++, it should be easy to modify 8cc to be valid C++ (e.g. by replacing implicit void*-casts to explicit ones), and then you already have a "self-hosting C++ compiler", but that could be considered cheating by some...
How I wrote a self-hosting C compiler in 40 days
51–60 of 128 posts
Re: How I wrote a self-hosting C compiler in 40 days
#52Earlier quoted context omitted.
Please could you recommend an alternative?
Modern Compiler Implementation in C
Re: How I wrote a self-hosting C compiler in 40 days
#53Re: How I wrote a self-hosting C compiler in 40 days
#54For anyone interested in compiler writing and looking for a good resource to start, probably one of the best is the "Dragon Book": http://www.amazon.com/Compilers-Principles-Techniques-Tools-... I highly recommend it, but it's heavy stuff. There are probably simpler guides out there that just cover the basics.
Please stop recommending the Dragon Book already. It is not just heavy, it is mostly outdated and irrelevant.
Re: How I wrote a self-hosting C compiler in 40 days
#55Re: How I wrote a self-hosting C compiler in 40 days
#56Re: How I wrote a self-hosting C compiler in 40 days
#57Earlier quoted context omitted.
Please stop recommending the Dragon Book already. It is not just heavy, it is mostly outdated and irrelevant.
It's fairly heavy in lexing and parsing theory, especially around finite automata, pushdown automata, etc. It's the kind of book you might want to read if you're reimplementing yacc. Modern code generation has moved on a bit, so I wouldn't dig too deeply into the latter third or so of the book. All in all, for a hobby compiler, it would be a poor choice; heavy on unnecessary theory in the front end and outdated on on…
Re: How I wrote a self-hosting C compiler in 40 days
#58For anyone interested in compiler writing and looking for a good resource to start, probably one of the best is the "Dragon Book": http://www.amazon.com/Compilers-Principles-Techniques-Tools-... I highly recommend it, but it's heavy stuff. There are probably simpler guides out there that just cover the basics.
Re: How I wrote a self-hosting C compiler in 40 days
#59Earlier quoted context omitted.
Please stop recommending the Dragon Book already. It is not just heavy, it is mostly outdated and irrelevant.
Since technologies changes before the book is out, how does that hold in compiler domain? Are there any modern compiler book that explains around llvm/gcc as an example compiler?
Grune at al., "Modern Compiler Design",
Appel, "Modern Compiler Implementation in ML",
and many more.
P.S. Because of a slow-ban, adding another one to this answer. This is the best source on SSA:
http://www.cri.ensmp.fr/people/pop/papers/2006-12-thesis.pdf
Re: How I wrote a self-hosting C compiler in 40 days
#601) write compiler 2) get a job at google . . 4) profit