aboutsummaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
Diffstat (limited to 'core')
-rw-r--r--core/metaprogramming.nom24
-rw-r--r--core/operators.nom2
2 files changed, 13 insertions, 13 deletions
diff --git a/core/metaprogramming.nom b/core/metaprogramming.nom
index c999191..dbc45a4 100644
--- a/core/metaprogramming.nom
+++ b/core/metaprogramming.nom
@@ -22,10 +22,10 @@ lua> "\
lua> "\
..COMPILE_ACTIONS["1 -> 2"] = function(nomsu, tree, \%args, \%body)
local lua = LuaCode.Value(tree.source, "(function(")
- if AST.is_syntax_tree(\%args, "Action") then \%args = \%args:get_args() end
- local lua_args = table.map(\%args, function(a) return AST.is_syntax_tree(a) and nomsu:compile(a):as_smext() or a end)
+ if SyntaxTree:is_instance(\%args) and \%args.type == "Action" then \%args = \%args:get_args() end
+ local lua_args = table.map(\%args, function(a) return SyntaxTree:is_instance(a) and nomsu:compile(a):as_smext() or a end)
lua:concat_append(lua_args, ", ")
- local body_lua = AST.is_syntax_tree(\%body) and nomsu:compile(\%body):as_statements("return ") or \%body
+ local body_lua = SyntaxTree:is_instance(\%body) and nomsu:compile(\%body):as_statements("return ") or \%body
body_lua:remove_free_vars(lua_args)
body_lua:declare_locals()
lua:append(")\\n ", body_lua, "\\nend)")
@@ -177,13 +177,13 @@ test:
replacements[arg[1]] = nomsu:compile(arg):as_smext()
end
local function make_tree(t)
- if AST.is_syntax_tree(t, "Var") then
+ if SyntaxTree:is_instance(t) and t.type == "Var" then
if replacements[t[1]] then
return replacements[t[1]]
else
- return t.type.."{mangle("..t[1]:as_lua().."), source="..tostring(t.source):as_lua().."}"
+ return "SyntaxTree{mangle("..t[1]:as_lua().."), type="..t.type:as_lua()..", source="..tostring(t.source):as_lua().."}"
end
- elseif AST.is_syntax_tree(t) then
+ elseif SyntaxTree:is_instance(t) then
local ret = {}
local i = 1
for k, v in pairs(t) do
@@ -198,7 +198,7 @@ test:
ret[#ret+1] = "["..make_tree(k).."]= "..make_tree(v)
end
end
- return t.type.."{"..table.concat(ret, ", ").."}"
+ return "SyntaxTree{"..table.concat(ret, ", ").."}"
elseif lua_type_of_1(t) == 'number' then
return tostring(t)
else
@@ -241,8 +241,8 @@ test:
externally [%var as lua identifier, %var as lua id] all mean:
lua> "\
..if lua_type_of_1(\%var) == 'string' then return \%var:as_lua_id()
- elseif AST.is_syntax_tree(\%var, 'Var') then return \%var[1]:as_lua_id()
- elseif AST.is_syntax_tree(\%var) then
+ elseif SyntaxTree:is_instance(\%var, 'Var') then return \%var[1]:as_lua_id()
+ elseif SyntaxTree:is_instance(\%var) then
local lua = \(%var as lua expr)
if not lua:as_smext():match("^[_a-zA-Z][_a-zA-Z0-9]*$") then
nomsu:compile_error(\%var, "This is not a valid Lua identifier.")
@@ -253,9 +253,9 @@ externally [%var as lua identifier, %var as lua id] all mean:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-(% is syntax tree) compiles to (Lua value "AST.is_syntax_tree(\(% as lua expr))")
+(% is syntax tree) compiles to (Lua value "SyntaxTree:is_instance(\(% as lua expr))")
(% is %kind syntax tree) compiles to (..)
- Lua value "AST.is_syntax_tree(\(% as lua expr), \(%kind as lua expr))"
+ Lua value "SyntaxTree:is_instance(\(% as lua expr), \(%kind as lua expr))"
(%tree with %t -> %replacement) compiles to (..)
Lua value "\
@@ -295,7 +295,7 @@ externally (match %tree with %patt) means:
if #\%patt ~= #\%tree then return nil end
local matches = _Dict{}
for \%i=1,#\%patt do
- if AST.is_syntax_tree(\%tree[\%i]) then
+ if SyntaxTree:is_instance(\%tree[\%i]) then
local submatch = \(match %tree.%i with %patt.%i)
if not submatch then return nil end
for k,v in pairs(submatch) do
diff --git a/core/operators.nom b/core/operators.nom
index 489bbfe..bd93cd5 100644
--- a/core/operators.nom
+++ b/core/operators.nom
@@ -53,7 +53,7 @@ test:
for i, item in ipairs(\%assignments) do
local \%target, \%value = item[1], item[2]
\%value = \%value:map(function(t)
- if Action:is_instance(t) and t.stub == "?" then
+ if SyntaxTree:is_instance(t) and t.type == "Action" and t.stub == "?" then
return \%target
end
end)