aboutsummaryrefslogtreecommitdiff
path: root/core/metaprogramming.nom
diff options
context:
space:
mode:
authorBruce Hill <bitbucket@bruce-hill.com>2018-06-12 20:15:52 -0700
committerBruce Hill <bitbucket@bruce-hill.com>2018-06-12 20:15:56 -0700
commit968b5da15050d6804404833ea258bdb531dca9ea (patch)
tree25ce49ffefe8d8d2e9469ffbf152c8f6db537da9 /core/metaprogramming.nom
parent63a19db0dc817d2929d8ef4bf12a15d5e9dbd015 (diff)
Fixed some bugs.
Diffstat (limited to 'core/metaprogramming.nom')
-rw-r--r--core/metaprogramming.nom17
1 files changed, 6 insertions, 11 deletions
diff --git a/core/metaprogramming.nom b/core/metaprogramming.nom
index 2a95950..83179f5 100644
--- a/core/metaprogramming.nom
+++ b/core/metaprogramming.nom
@@ -5,10 +5,10 @@
# Compile-time action to make compile-time actions:
immediately
lua> ".."
- _ENV['ACTION'..string.as_lua_id("compile % to %")] = function(tree, \%actions, \%lua)
+ _ENV['ACTION'..string.as_lua_id("compile % to %")] = compile_time(function(tree, \%actions, \%lua)
local lua = Lua(tree.source)
local canonical = \%actions[1]
- lua:append("ACTION", string.as_lua_id(canonical.stub), ' = function(tree')
+ lua:append("ACTION", string.as_lua_id(canonical.stub), ' = compile_time(function(tree')
local args = {}
for i,tok in ipairs(canonical) do
if tok.type == "Var" then args[#args+1] = tok end
@@ -21,8 +21,7 @@ immediately
local body_lua = nomsu:tree_to_lua(\%lua):as_statements("return ")
body_lua:remove_free_vars(args)
body_lua:declare_locals()
- lua:append(")\n ", body_lua, "\nend")
- lua:append("\nCOMPILE_TIME[ACTION", string.as_lua_id(canonical.stub), "] = true")
+ lua:append(")\n ", body_lua, "\nend)")
for i=2,#\%actions do
local action = \%actions[i]
@@ -35,7 +34,6 @@ immediately
end
end
lua:append("\n", "ARG_ORDERS[", repr(action.stub), "] = ", repr(arg_positions))
- lua:append("\nCOMPILE_TIME[ACTION", string.as_lua_id(action.stub), "] = true")
end
lua:append("\nALIASES[ACTION", string.as_lua_id(canonical.stub), "] = {")
for i,action in ipairs(\%actions) do
@@ -44,8 +42,7 @@ immediately
end
lua:append("}")
return lua
- end
- COMPILE_TIME[_ENV['ACTION'..string.as_lua_id("compile % to %")]] = true
+ end)
# Compile-time action to make actions
immediately
@@ -95,7 +92,7 @@ immediately
lua> ".."
local lua = Lua(tree.source)
local canonical = \%shorthand[1]
- lua:append("ACTION", string.as_lua_id(canonical.stub), ' = function(tree')
+ lua:append("ACTION", string.as_lua_id(canonical.stub), ' = compile_time(function(tree')
local args = {}
for i,tok in ipairs(canonical) do
if tok.type == "Var" then args[#args+1] = tok end
@@ -129,8 +126,7 @@ immediately
return t.type.."("..table.concat(bits, ", ")..")"
end
end
- lua:append(")\n local tree = ", make_tree(\%longhand), "\n return nomsu:tree_to_lua(tree)\nend")
- lua:append("\nCOMPILE_TIME[ACTION", string.as_lua_id(canonical.stub), "] = true")
+ lua:append(")\n local tree = ", make_tree(\%longhand), "\n return nomsu:tree_to_lua(tree)\nend)")
for i=2,#\%shorthand do
local action = \%shorthand[i]
@@ -143,7 +139,6 @@ immediately
end
end
lua:append("\n", "ARG_ORDERS[", repr(action.stub), "] = ", repr(arg_positions))
- lua:append("\nCOMPILE_TIME[ACTION", string.as_lua_id(action.stub), "] = true")
end
lua:append("\nALIASES[ACTION", string.as_lua_id(canonical.stub), "] = {")
for i,action in ipairs(\%shorthand) do