5 ms·
Can anyone recommend good resources on writing a compiler from scratch ?
by simula67 8y ago
Can anyone recommend good resources on writing a compiler from scratch ?
- earenndil 8y agoCrafting interpreters, also the dragon book.
- arundelo 8y agohttps://compilers.iecc.com/crenshaw/ https://compilers.iecc.com/crenshaw/
- faitswulff 8y agoDestroy All Software has (as usual) an excellent screencast on it: https://www.destroyallsoftware.com/screencasts/catalog/a-compiler-from-scratch/ https://www.destroyallsoftware.com/screencasts/catalog/a-com...
- charlysl 8y agoStanford CS143 - Compilers [1] and [2] MOOC: This self-paced course will discuss the major ideas used today in the implementation of programming language compilers, including lexical analysis, parsing, syntax-directed translation, abstract syntax trees, types and type checking, intermediate languages, dataflow analysis, program optimization, code generation, and runtime systems. As a result, you will learn how a program written in a high-level language designed for humans is systematically translated into a program written in low-level assembly more suited to machines. Along the way we will also touch on how programming languages are designed, programming language semantics, and why there are so many different kinds of programming languages. MIT 6.035 - Computer Language Engineering [3]: This course analyzes issues associated with the implementation of higher-level programming languages. Topics covered include: fundamental concepts, functions, and structures of compilers, the interaction of theory and practice, and using tools in building software. The course includes a multi-person project on compiler design and implementation. [1] https://lagunita.stanford.edu/courses/Engineering/Compilers/Fall2014/about https://lagunita.stanford.edu/courses/Engineering/Compilers/... [2] http://web.stanford.edu/class/cs143/ http://web.stanford.edu/class/cs143/ [3] https://ocw.mit.edu/courses/electrical-engineering-and-computer-science/6-035-computer-language-engineering-spring-2010/ https://ocw.mit.edu/courses/electrical-engineering-and-compu...
- GeorgeTirebiter 8y agoI think the best first book is: James E. Hendrix, The Small-C Handbook, Reston 1984, ISBN 0-8359-7012-4 He explains every detail, goes through every routine, and you can see exactly what the compiler does. It's 'Small-C' so it doesn't have any fancy features, like floats or structs. But the basic machinery is there, and one can add features as desired. It does compile itself. The compiler outputs x86 assembly, which must be assembled and linked with standard programs. The original Small-C was done by Ron Cain, and produced 8080 code. I like Mr. Hendrix' better because I have lots of x86 around (I specifically wanted it for my HP-200 LX palmtop, which I still have and works great!); and because the book is fantastic. It's fully understandable in a small quantity of time. And, the back end is re-targetable, so you could, say, output to ARM or RISC-V or whatever. I spoke with Mr. Hendrix some years ago, maybe 10 or so, and asked if he would consider putting the compiler into the public domain. He did.
- bogomipz 8y agoThanks for this suggestion. In case anyone else is interested, there is a freely available ISO of the the book available from Dr Dobbs Journal. From the README in the ISO: >"Welcome to Dr. Dobb's Small-C Resource CD-ROM, the definitive collection of Small-C related information and source code. This CD-ROM includes the full text to James Hendrix's book "A Small-C Compiler: Language, Usage, Theory, and Design," selected articles on Small-C from "Dr. Dobb's Journal" magazine, and Small-C implementations for a number of processor platforms, including the 8080, Z80, 6502, and others." It's available here: http://www.drdobbs.com/developer-network-small-c-compiler-book/184415519 http://www.drdobbs.com/developer-network-small-c-compiler-bo...
- pjmlp 8y agoWirth's book, "Compiler Construction" https://www.inf.ethz.ch/personal/wirth/ https://www.inf.ethz.ch/personal/wirth/ On the way you can also grab "Project Oberon" from there, both 1992 and 2013 editions, to see how to write an OS from scratch, including an FPGA board, in a GC enabled systems programming language. There are also the tiger books, in C, Java and ML variants. https://www.cs.princeton.edu/~appel/modern/ https://www.cs.princeton.edu/~appel/modern/
- gilmi 8y agohttps://gist.github.com/soupi/73ab7dfd4d65fc68b62868d56b720bee https://gist.github.com/soupi/73ab7dfd4d65fc68b62868d56b720b...
- IronBacon 8y agoThere are already a lot of suggestions here, I've added to my always increasing reading list this one[1] because, being based on Scheme (Racket to be exact), I'm curious on how a Lisp dialect compiler works internally. [1] https://github.com/IUCompilerCourse/Essentials-of-Compilation https://github.com/IUCompilerCourse/Essentials-of-Compilatio...
- oxryly1 8y agoHere's a great description of compiling from a largish subset of Scheme all the way to x86 assembly language: http://schemeworkshop.org/2006/11-ghuloum.pdf http://schemeworkshop.org/2006/11-ghuloum.pdf
- IronBacon 8y agoThe author is mentioned it that book in the introduction chapter and in the acknowledgments. Thanks, I'll put in the pile of things to read.