开发者

How to write a code-generator/compiler

I would like to know how you would generate some kind of bytecode from an abstract syntax tree.

I've searched the internet but I cannot find anything helpful.

I've seen some mention of using templates but cannot find someone that actually explains what it is, how it works or how to implement it.

Just one thing though, I don't have any real programming experience and I'm completely self-taught so I'm not looking for an 800 page book on the theory of writing a compiler, I'm looking for something a little more practical, some kind of tutor开发者_如何转开发ial working through an actual example.


I learned a lot by following Let's Build a Compiler, by Jack Crenshaw many moons ago. It uses Turbo Pascal for implementation and generates 68000 assembler, so there is some steps to get it running on a modern host but it works through a lot of steps that is still valid.


Take a look at Kaleidoscope tutorial in LLVM: http://llvm.org/docs/tutorial/

and for a somewhat different perspective, http://community.schemewiki.org/?90min-scheme2c

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜