3 ms·
Thanks for the advice, I've tried before to build a compiler with the vertical approach and it got really frustrating at some point. I will try again with the h
by Zababa 5y ago
Thanks for the advice, I've tried before to build a compiler with the vertical approach and it got really frustrating at some point. I will try again with the horizontal approach.
- p4bl0 5y agoCool :). The thing is to have an always start-to-end working compiler for an increasingly (even if the steps are very small) complex language. Another point would be to use simple tools at least to begin with. Racket [1] provides good lexer/parser tools [2] and you can use pattern matching [3] to browse and transform your AST. You can also target MIPS assembly [4] using the SPIM platform [5] for example, it is easy to learn and has very good debugging tools (basically the whole platform behaves like a gdb session). For the compiler implementation language OCaml is also a very good choice (even better because static typing will actually help you a lot with the horizontal approach) but it is less easier to setup as you need to install a lot more tools: ocaml itself, ocamllex (lexer), menhir (parser), ocamlbuild (automated build system), etc. [1] https://racket-lang.org/ https://racket-lang.org/ [2] https://docs.racket-lang.org/parser-tools/ https://docs.racket-lang.org/parser-tools/ [3] https://docs.racket-lang.org/guide/match.html https://docs.racket-lang.org/guide/match.html [4] http://www.cburch.com/cs/330/reading/mips-ref.pdf http://www.cburch.com/cs/330/reading/mips-ref.pdf [5] http://spimsimulator.sourceforge.net/ http://spimsimulator.sourceforge.net/
- Zababa 5y agoThanks for all the pointers, I didn't know about MIPS assembly, I'll take a look at it.