lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


On Wed, Sep 30, 2009 at 12:46 PM, David Given <dg@cowlark.com> wrote:
This sounds like perfect fodder for something like metalua.

-- The extension itself: --
-{ block:
   mlp.lexer:add "chunk"
   mlp.expr:add{ "chunk", mlp.block, "end",
                 builder = |x|`String {mlc.ast_to_luacstring(x[1])} } }

-- simple test case: --
local ch = chunk return 123 end
assert (ch :match "^\027Lua")
assert (dostring(ch) == 123)
print  "Test passed"