try metalua <http://metalua.luaforge.net/>
On Wed, Jan 7, 2009 at 10:19 PM, Glenn Edgar <[hidden email]> wrote:
> Hi All
> Is there a package in Lua that approximates the Macro capabilities that are
> lisp or schema.
> Glenn Edgar
The main difference between MetaLua is that MetaLua builds a syntax
tree whereas luaSub does the filtering kind of on a running (token)
window. The ways to make syntax mods to the two are obviously
completely different. I believe any syntax mod can be made with either
Luiz Henrique de Figueiredo kirjoitti 7.1.2009 kello 18:36:
Token filter based solutions (luasub and raw token filters) are probably simpler to learn in the initial stages, if you have no significant experience in tree-manipulating macro systems such as Lisp dialects.
Metalua lets you see your code as concrete syntax or abstract syntax trees, indifferently. It also lets you switch from one view to the other. If you have already use multi-stage metaprogramming languages such as Template Haskell, MetaML or Converge, you'll be immediately at home.
Another key difference is that Metalua handles syntax extensions through a parser combinator library. I would argue that It's more flexible / modular than PEGs: it lets you easily define functors, can be modified dynamically, and lets you (relatively) easily generate proper error messages, when incorrect inputs are entered. However, it might have a slightly steeper learning curve for simple tasks; at least, it looks more intimidating.
This issue is acknowledged and I'm working on it: a DSL to define / extend grammars is under development. An example, a JSON parser, is accessible here (look at the stuff between << >>).
- macro hygiene is handled in a less than ideal way. I would love to adapt Clojure's brilliant approach to the issue, but it's difficult without breaking Lua compatibility (this is not relevant to other systems, which work at a much lower level)
- installation of version 0.4 is awfully messy, largely because the compiler is partly written in itself and therefore requires a bootstrapping step. A reorganized version is accessible here, although unreleased (click on the download button):