On Saturday 29 November 2008, Fabien wrote: > I've just written and put online an AST --> Lua source converter. While it > doesn't translate into a different target language, it shows how to > systematically walk through an AST, to produce a different representation > of it. This makes it a decent starting point for a Lua --> anything-else > converter, although it wasn't its original purpose that's interesting; just yesterday i was checking the source of pyjs (Python->JavaScript compiler, part of the Pyjamas project). it's very simple, because Python includes some libraries to analyse the AST of compiled chunks. Of course, a language like Python, where most of the power comes from extensive syntactic sugar, seems almost trivial when you read the AST instead of the source. In Lua, most of the power comes from the choice in primitives, so you're still facing the reimplementation of most of what makes Lua, Lua. prime examples are the flexibility of tables (versus Python dictionaries and JS objects), and coroutines (versus generator-specific constructs in Python and.... well, i don't think JS has anything like this). still, having the AST easily readable is a big first step towards a Lua -->anything-else compiler. -- Javier
Attachment:
signature.asc
Description: This is a digitally signed message part.