4 ms·
Any specific resources you've used that you could recommend in line with compiler construction?
by kinga254 5y ago
Any specific resources you've used that you could recommend in line with compiler construction?
- r1chardnl 5y agoYou could use https://en.wikipedia.org/wiki/Yacc https://en.wikipedia.org/wiki/Yacc I decided to write my own lexer/parser/compiler it's pretty straightforward. Sources I use(d) to program this, e.g look at resulting assembly from other compilers or look at how the AST is generated for other languages. https://en.wikipedia.org/wiki/Recursive_descent_parser https://en.wikipedia.org/wiki/Recursive_descent_parser https://en.cppreference.com/w/c/language/operator_precedence https://en.cppreference.com/w/c/language/operator_precedence https://godbolt.org/ https://godbolt.org/ https://astexplorer.net/ https://astexplorer.net/ I didn't start writing C yesterday, and most of the things are just stuff I've learned over the years and seeing how other languages work and then just use what I know to try to program in a logical manner. Also I've written a implementation of a scripting language (compiler and VM) before in similar fashion. https://github.com/riicchhaarrd/gsc https://github.com/riicchhaarrd/gsc
- blcArmadillo 5y agoThis is specific to interpreters but the beginning part related to parsing and AST is common: http://craftinginterpreters.com/contents.html http://craftinginterpreters.com/contents.html
- optymizer 5y agoI wrote a C compiler* using flex [1] and bison [2] that generated MIPS code. The biggest downside was the rather complex glue code. At some point ANTLR [3] looked promising, but these days I'd probably write a lexer and recursive descent parser by hand, then generate LLVM IR [4]. [1] https://github.com/westes/flex https://github.com/westes/flex [2] https://www.gnu.org/software/bison/ https://www.gnu.org/software/bison/ [3] https://www.antlr.org/ https://www.antlr.org/ [4] https://llvm.org/ https://llvm.org/ * for a subset of the full C89 spec
- MH15 5y agoI've had good luck with ANTLR4 and ObjWeb ASM for my JVM language Imp https://github.com/mh15/imp https://github.com/mh15/imp