aboutsummaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
authorBruce Hill <bitbucket@bruce-hill.com>2018-04-25 16:04:46 -0700
committerBruce Hill <bitbucket@bruce-hill.com>2018-04-25 16:04:55 -0700
commit50a092e4b5cb82131c0c8f6f46c7d21a42198858 (patch)
tree2ed0726076e7cd7b8170b139cc3ab07808d763db /core
parentcb28f52b410f3fbcb01bcc8ef8668de46d8aba68 (diff)
Got nomsu codegen working again.
Diffstat (limited to 'core')
-rw-r--r--core/operators.nom16
-rw-r--r--core/text.nom2
2 files changed, 9 insertions, 9 deletions
diff --git a/core/operators.nom b/core/operators.nom
index 1ea1df2..073936e 100644
--- a/core/operators.nom
+++ b/core/operators.nom
@@ -26,7 +26,7 @@ immediately:
compile [%a is %b, %a = %b, %a == %b] to:
lua> ".."
local safe = {Text=true, Number=true};
- local a_lua, b_lua = nomsu:tree_to_lua(\%a), nomsu:tree_to_lua(\%b);
+ local a_lua, b_lua = \%a:as_lua(nomsu), \%b:as_lua(nomsu);
if safe[\%a.type] or safe[\%b.type] then
return Lua.Value(tree.source, "(", a_lua, " == ", b_lua, ")");
else
@@ -35,7 +35,7 @@ immediately:
compile [%a isn't %b, %a is not %b, %a not= %b, %a != %b] to:
lua> ".."
local safe = {Text=true, Number=true};
- local a_lua, b_lua = nomsu:tree_to_lua(\%a), nomsu:tree_to_lua(\%b);
+ local a_lua, b_lua = \%a:as_lua(nomsu), \%b:as_lua(nomsu);
if safe[\%a.type] or safe[\%b.type] then
return Lua.Value(tree.source, "(", a_lua, " ~= ", b_lua, ")");
else
@@ -47,9 +47,9 @@ immediately:
# Variable assignment operator
immediately:
compile [%var <- %value] to:
- lua> "local \%var_lua = nomsu:tree_to_lua(\%var);"
+ lua> "local \%var_lua = \%var:as_lua(nomsu);"
assume %var_lua.is_value or barf "Invalid target for assignment: \(%var's source code)"
- lua> "local \%value_lua = nomsu:tree_to_lua(\%value);"
+ lua> "local \%value_lua = \%value:as_lua(nomsu);"
assume %value_lua.is_value or barf "Invalid value for assignment: \(%value's source code)"
lua> ".."
local lua = Lua(tree.source, \%var_lua, ' = ', \%value_lua, ';');
@@ -67,9 +67,9 @@ immediately:
local lhs, rhs = Lua(tree.source), Lua(\%assignments.source);
for i, item in ipairs(\%assignments.value) do
local target, value = item.key, item.value;
- local target_lua = nomsu:tree_to_lua(target);
+ local target_lua = target:as_lua(nomsu);
if not target_lua.is_value then error("Invalid target for assignment: "..target:get_src()); end
- local value_lua = nomsu:tree_to_lua(value);
+ local value_lua = value:as_lua(nomsu);
if not value_lua.is_value then error("Invalid value for assignment: "..value:get_src()); end
if target.type == "Var" then
lhs:add_free_vars(target);
@@ -106,8 +106,8 @@ immediately:
if not target.type == "Var" then
error("Invalid target for 'with' assignment: "..tostring(target.source:get_text()));
end
- local target_lua = nomsu:tree_to_lua(target);
- local value_lua = nomsu:tree_to_lua(value);
+ local target_lua = target:as_lua(nomsu);
+ local value_lua = value:as_lua(nomsu);
if not value_lua.is_value then
error("Invalid value for assignment: "..tostring(value.source:get_text()));
end
diff --git a/core/text.nom b/core/text.nom
index d877de7..71e1ce1 100644
--- a/core/text.nom
+++ b/core/text.nom
@@ -49,7 +49,7 @@ lua> ".."
local reset = "'"..colors["reset color"].."'";
nomsu:define_compile_action(name, \(!! code location !!), function(tree) return Lua.Value(tree.source, color); end);
nomsu:define_compile_action(name.." %", \(!! code location !!), function(\%)
- return Lua.Value(tree.source, color, "..", nomsu:tree_to_lua(\%), "..", reset);
+ return Lua.Value(tree.source, color, "..", \%:as_lua(nomsu), "..", reset);
end);
end
end