]> git.lizzy.rs Git - metalua.git/commitdiff
cleanup in mlp, a couple of relevant entries made public
authorFabien Fleutot <fabien@MacFabien.home>
Sat, 31 Jan 2009 11:42:33 +0000 (12:42 +0100)
committerFabien Fleutot <fabien@MacFabien.home>
Sat, 31 Jan 2009 11:42:33 +0000 (12:42 +0100)
src/compiler/mlp_expr.lua
src/compiler/mlp_meta.lua
src/compiler/mlp_stat.lua

index 761d9cf8cd10405cd4e8ef82d73c615463741c73..091f92e2c26bf381ec574d2ef5555e0704113a57 100644 (file)
@@ -71,12 +71,12 @@ expr_list = gg.list{ _expr, separators = "," }
 --------------------------------------------------------------------------------
 -- Helpers for function applications / method applications
 --------------------------------------------------------------------------------
-local func_args_content = gg.list { 
+func_args_content = gg.list { 
    name = "function arguments",
    _expr, separators = ",", terminators = ")" } 
 
 -- Used to parse methods
-local method_args = gg.multisequence{
+method_args = gg.multisequence{
    name = "function argument(s)",
    { "{", table_content, "}" },
    { "(", func_args_content, ")", builder = fget(1) },
@@ -105,10 +105,11 @@ local _func_val = function (lx) return func_val(lx) end
 --------------------------------------------------------------------------------
 -- Default parser for primary expressions
 --------------------------------------------------------------------------------
-local function id_or_literal (lx)
+function id_or_literal (lx)
    local a = lx:next()
    if a.tag~="Id" and a.tag~="String" and a.tag~="Number" then
-      gg.parse_error (lx, "Unexpected expr token %s", _G.table.tostring(a))
+      gg.parse_error (lx, "Unexpected expr token %s",
+                      _G.table.tostring (a, 'nohash'))
    end
    return a
 end
index 60a8d457704dd4f0b24ba8c824593b5d3f3937ac..27d476a157410b7089aa1c6831649e6a82f76600 100644 (file)
 -- for details.
 --
 ----------------------------------------------------------------------
--- History:
--- $Log: mlp_meta.lua,v $
--- Revision 1.4  2006/11/15 09:07:50  fab13n
--- debugged meta operators.
---
--- Revision 1.2  2006/11/09 09:39:57  fab13n
--- some cleanup
---
--- Revision 1.1  2006/11/07 21:29:02  fab13n
--- improved quasi-quoting
---
--- Revision 1.3  2006/11/07 04:38:00  fab13n
--- first bootstrapping version.
---
--- Revision 1.2  2006/11/05 15:08:34  fab13n
--- updated code generation, to be compliant with 5.1
---
-----------------------------------------------------------------------
 
 
 --------------------------------------------------------------------------------
@@ -39,9 +21,6 @@
 --
 --------------------------------------------------------------------------------
 
---require "compile"
---require "ldump"
-
 module ("mlp", package.seeall)
 
 --------------------------------------------------------------------------------
@@ -51,12 +30,7 @@ module ("mlp", package.seeall)
 --------------------------------------------------------------------------------
 
 function splice (ast)
-   --printf(" [SPLICE] Ready to compile:\n%s", _G.table.tostring (ast, "nohash", 60))
    local f = mlc.function_of_ast(ast, '=splice')
-   --printf " [SPLICE] Splice Compiled."
-   --local status, result = pcall(f)
-   --printf " [SPLICE] Splice Evaled."
-   --if not status then print 'ERROR IN SPLICE' end
    local result=f()
    return result
 end
@@ -106,12 +80,6 @@ function splice_content (lx)
       lx:next() -- skip ":"
       assert (a.tag=="Id", "Invalid splice parser name")
       parser_name = a[1]
---       printf("this splice is a %s", parser_name)
---    else
---       printf("no splice specifier:\npeek(1)")
---       _G.table.print(lx:peek(1))
---       printf("peek(2)")
---       _G.table.print(lx:peek(2))
    end
    local ast = mlp[parser_name](lx)
    if in_a_quote then
@@ -132,25 +100,18 @@ end
 --------------------------------------------------------------------------------
 function quote_content (lx)
    local parser 
-   if lx:is_keyword (lx:peek(1), ":") then -- +{:parser: content }
-      lx:next()
-      errory "NOT IMPLEMENTED"
-   elseif lx:is_keyword (lx:peek(2), ":") then -- +{parser: content }
+   if lx:is_keyword (lx:peek(2), ":") then -- +{parser: content }
       parser = mlp[id(lx)[1]]
       lx:next()
    else -- +{ content }
       parser = mlp.expr
    end
 
-   --assert(not in_a_quote, "Nested quotes not handled yet")
    local prev_iq = in_a_quote
    in_a_quote = true
    --print("IN_A_QUOTE")
    local content = parser (lx)
    local q_content = quote (content)
---     printf("/IN_A_QUOTE:\n* content=\n%s\n* q_content=\n%s\n",
---            _G.table.tostring(content, "nohash", 60),
---            _G.table.tostring(q_content, "nohash", 60))
    in_a_quote = prev_iq
    return q_content
 end
index bf19c6fc3c720fef4ac439c992bf0f3faf7b0174..b959d96551bc3908b46d8c9faf7c1c874a35c451 100644 (file)
@@ -179,7 +179,7 @@ local function assign_or_call_stat_parser (lx)
    end
 end
 
-local local_stat_parser = gg.multisequence{
+local_stat_parser = gg.multisequence{
    -- local function <name> <func_val>
    { "function", id, func_val, builder = 
       function(x)