2 ms·
Jack Crenshaw's "Let's Build a Compiler" gives a tutorial in Pascal of how to do this. My own StoneKnifeForth compiles itself in an AST-free way in less than 1
by kragen 18y ago
Jack Crenshaw's "Let's Build a Compiler" gives a tutorial in Pascal of how to do this. My own StoneKnifeForth compiles itself in an AST-free way in less than 120 lines of code, but I haven't released it yet.
Ur-Scheme (http://canonical.org/~kragen/sw/urscheme/ http://canonical.org/~kragen/sw/urscheme/) doesn't have any intermediate representation other than the S-expression representation of the code; it uses that to perform closure analysis. Probably an AST is the easiest form to perform this on. The Lua guys came up with an implementation technique for closures that doesn't require building a parse tree first, but it's quite a bit more complicated.