is there a simple compiler for a small language

2019-03-07 17:35发布

I am looking for a simple compiler that compiles a simple language, I need it to write a paper about it and to learn how compilers work, I am not looking for a sophisticated thing just a simple language (by simple I mean a small code because for example gcc is toooooo big). any help is appreciated.

18条回答
Animai°情兽
2楼-- · 2019-03-07 18:15

You should read a book on compiler design; it should have the theory you want to know, as well as some appropriately simple examples.

I recommend "the dragon book": Principles of Compiler Design, by Aho and Ullman. It has been many years since I read it, so I don't recall exactly what examples are available, but it is a very good text.

查看更多
太酷不给撩
3楼-- · 2019-03-07 18:17

This one is only 300 lines of normal code and implements a simple universal language link text , is something like that what you were looking for?

查看更多
Luminary・发光体
4楼-- · 2019-03-07 18:19

If you want to look at code, I'm very impressed with Eijiro Sumii's MinCaml compiler.

  • It's only 2000 lines long.

  • It compiles a pretty interesting source language.

  • It generates real machine code, none of this namby-pamby C or LLVM stuff :-)

  • Speed of compiled code is competetive with gcc and the native OCaml compilers.

  • The compiler is designed for teaching.

Did I mention I've been very impressed?

查看更多
太酷不给撩
5楼-- · 2019-03-07 18:23

I've started a video tutorial on writing an ANTLR 3.x compiler - check out

http://javadude.com/articles/antlr3xtut

I'll be adding more to it soon! -- Scott

查看更多
孤傲高冷的网名
6楼-- · 2019-03-07 18:24

Google UCSD Pascal. It was a ground-breaker in the 70s. Maybe it's more than you want, but it was easily ported to lot of "micro" chips back then.

查看更多
萌系小妹纸
7楼-- · 2019-03-07 18:24

The standard Stack Overflow resource for resources on compiler writing is Learning to write a compiler

查看更多
登录 后发表回答