I misread and thought someone created a C-compiler in Scratch. That'd have been extremely impressive... :))
Along the same lines, you may find this amusing: https://news.ycombinator.com/item?id=7882066
31–40 of 68 posts
I misread and thought someone created a C-compiler in Scratch. That'd have been extremely impressive... :))
Along the same lines, you may find this amusing: https://news.ycombinator.com/item?id=7882066
Do you know of similar types of tutorials / repos except for language parsers (like markdown or json) ? How difficult would it be to implement in comparison to a compiler ? Where should I start looking ? (I want to build a compiler at some point but I want to get my feet wet building a simple language parser first) Thanks in advance
There is not that much difference between parsing a programming language like C and something like JSON. JSON grammar is smaller but the ideas are the same. In fact, JSON is essentially a subset of JS, and JS has a C-like syntax.
What makes a compiler a compiler is what comes after the parser, i.e. code generation.
This might be relevant A Retargetable C Compiler: Design and Implementation by David Hanson and Chritopher Fraser https://www.amazon.com/Retargetable-Compiler-Design-Implemen... Written in a literate programming style.
Happy new year to you Ravi!
I feel that many introductions to scanning and parsing are based on old techniques when memory were scarce. In those times storing your files in memory, was simply impossible. But we live in times where we have gigabytes of ram and there are not many projects that could not be read into memory. (Tell me about a project that has a gigabyte of source files, please.) So, why not assume your input to be stored in a strin…
As for the idea of not starting with a string but instead reading the file on the fly, I think it is actually simpler. The point of storing the entire file in memory is to enable going back and forth, but why would you want to do that? State machine based parsers are fast, robust, and based on a solid theoretical grounds, at least for "simple" (context-free) languages.
Earlier quoted context omitted.
Compiler Construction Using Java, JavaCC, and Yacc Book by Anthony J. Dos Reis Uses similar approach with much more details on theory and implementation. I learned so much from this book. It teaches you to write a hand written compiler and by using tools like javacc/yacc as well. But I really love how the author explains the knots and bolts on creating a hand written compiler. Get this book if you're interested in cr…
JavaCC was my favorite way of playing with compilers back in early 2000, sadly it appears not to be developed any longer, with a couple of forks floating around the Internet. Any Idea what is the actual state?
Earlier quoted context omitted.
Interesting. But you have to register for this. Does anyone have any links to some good compiler classes on YouTube or elsewhere?
Is that an issue given the course is free?
I'm learning from the Compiler course offered freely from Stanford [0] and the dragon book. I still feel great about it. And I think this GitHub project submitted will be an excellent practical source for analysis of how real world compiler might looks like from its beginning. [0]: https://lagunita.stanford.edu/courses/Engineering/Compilers/...
Interesting. But you have to register for this. Does anyone have any links to some good compiler classes on YouTube or elsewhere?
https://www.youtube.com/playlist?list=PLDcmCgguL9rxPoVn2ykUF...
I'm learning from the Compiler course offered freely from Stanford [0] and the dragon book. I still feel great about it. And I think this GitHub project submitted will be an excellent practical source for analysis of how real world compiler might looks like from its beginning. [0]: https://lagunita.stanford.edu/courses/Engineering/Compilers/...
I applaud you for reading the dragon book. It's a pretty tough book to read.
Earlier quoted context omitted.
I want to dive into creating a language / compiler finally but I might do it with the Writing an Interpreter / Compiler series in Golang. Just so I can dive in and try to digest it all. Course I always heard of the dragon book and have wanted it since.
> Course I always heard of the dragon book and have wanted it since. I wouldn’t read it except out of historical interest - it’s not how we build compilers anymore, with its super-heavy emphasis on parsing and syntax-directed translation.