Skip to content

It seems that documents in http://metalua.luaforge.net/ are out of date #35

@tan-wei

Description

@tan-wei

For example, I can't run with the example in quick tour:

---------------------------------------------------------
-- the "-{...}" means that we're going to do compile-time
-- stuff (here, syntax extension) 
---------------------------------------------------------
-{ block:
   ------------------------------------------------------
   -- Register the additional keywords in mlp.lexer
   ------------------------------------------------------
   mlp.lexer:add{ "let", "in" }

   ------------------------------------------------------
   -- Extend the expression parser; code generation is
   -- delegated to the function let_in_builder() below.
   ------------------------------------------------------
   mlp.expr:add{ 
     "let", mlp.id, "=", mlp.expr, "in", mlp.expr, 
     builder = let_in_builder }

   ------------------------------------------------------
   -- This creates the code returned by the macro.
   -- Notice the holes-in-quote-in-splice.
   ------------------------------------------------------
   local function let_in_builder (x)
     local variable, value, expr = unpack (x)
     return +{
       function (-{variable}) 
         return -{expr} 
       end (-{value}) }
   end
} -- back to "normal" code
 
a, b, c = 1, 1, -2 
roots = let sqrt_delta = (b^2-4*a*c)^0.5 in 
        { (sqrt_delta-b)/(2*a), (-sqrt_delta-b)/(2*a) } 

It fails with these error messages:

C:\Program Files (x86)\LuaRocks\lua5.1: splice:9: attempt to index global 'mlp' (a nil value)
stack traceback:
        splice:9: in function 'f'
        ...stree/share/lua/5.1/metalua\compiler\parser\meta.lua:41: in function <...stree/share/lua/5.1/metalua\compiler\parser\meta.lua:37>
        (tail call): ?
        (tail call): ?
        ...\systree/share/lua/5.1/metalua\grammar\generator.lua:113: in function 'raw_parse_sequence'
        ...\systree/share/lua/5.1/metalua\grammar\generator.lua:216: in function <...\systree/share/lua/5.1/metalua\grammar\generator.lua:212>
        (tail call): ?
        (tail call): ?
        ...\systree/share/lua/5.1/metalua\grammar\generator.lua:332: in function <...\systree/share/lua/5.1/metalua\grammar\generator.lua:330>
        (tail call): ?
        ...
        (tail call): ?
        ...stree/share/lua/5.1/metalua\compiler\parser\misc.lua:164: in function 'e'
        ...\systree/share/lua/5.1/metalua\grammar\generator.lua:113: in function 'raw_parse_sequence'
        ...\systree/share/lua/5.1/metalua\grammar\generator.lua:216: in function <...\systree/share/lua/5.1/metalua\grammar\generator.lua:212>
        (tail call): ?
        ...\LuaRocks\systree/share/lua/5.1/metalua\compiler.lua:104: in function 'f'
        ...\LuaRocks\systree/share/lua/5.1/metalua\compiler.lua:153: in function 'srcfile_to_ast'
        ...e\lib\luarocks\rocks-5.1\metalua\0.7.3-1\bin\metalua:162: in function <...e\lib\luarocks\rocks-5.1\metalua\0.7.3-1\bin\metalua:105>
        (tail call): ?
        [C]: ?

Lots of examples shown in the website fail, I think it's because of the older documents. mlp, clist do not exist for now.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions