[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: [ANN] Metalua 0.7.2
- From: Michal Kottman <michal.kottman@...>
- Date: Thu, 30 Jan 2014 20:20:03 +0100
diff --git a/metalua/compiler/ast_to_src.mlua b/metalua/compiler/ast_to_src.mlua
index 9054088..03c632e 100644
--- a/metalua/compiler/ast_to_src.mlua
+++ b/metalua/compiler/ast_to_src.mlua
@@ -602,6 +602,13 @@ function M:Index (node, table, key)
end
end
+local function to_ident(name)
+ if type(name) == "table" and name.tag == "Id" then
+ return name[1]
+ end
+ return name
+end
+
function M:Id (node, name)
if is_ident (name) then
self:acc (name)
@@ -613,6 +620,14 @@ function M:Id (node, name)
end
end
+function M:Label(node, name)
+ self:acc("::" .. to_ident(name) .. "::")
+end
+
+function M:Goto(node, name)
+ self:acc("goto " .. to_ident(name))
+end
+
M.TDyn = '*'
M.TDynbar = '**'
diff --git a/metalua/grammar/generator.lua b/metalua/grammar/generator.lua
index 2680d8a..e6d7557 100644
--- a/metalua/grammar/generator.lua
+++ b/metalua/grammar/generator.lua
@@ -61,7 +61,8 @@ local gensymidx = 0
function M.gensym (arg)
gensymidx = gensymidx + 1
- return { tag="Id", string.format(".%i.%s", gensymidx, arg or "")}
+ return { tag="Id", string.format("__TMP_%i_%s", gensymidx,
+ arg and arg:gsub("[^%w]", "_") or "")}
end
require 'metalua.loader'
local c = require 'metalua.compiler'.new()
local ast = assert(c:srcfile_to_ast(arg[1]))
io.write(c:ast_to_src(ast))