aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/control_flow.nom12
-rw-r--r--lib/operators.nom4
-rw-r--r--lib/utils.nom4
-rw-r--r--lib/utils2.nom2
4 files changed, 11 insertions, 11 deletions
diff --git a/lib/control_flow.nom b/lib/control_flow.nom
index 825e1c2..2ac6cff 100644
--- a/lib/control_flow.nom
+++ b/lib/control_flow.nom
@@ -169,7 +169,7 @@ compile [when %body] to code:
Invalid format for 'when' statement. Only '*' blocks are allowed.
%tokens = (%func_call's "value")
%star = (%tokens -> 1)
- assert (=lua "vars.star and vars.star.type == 'Word' and vars.star.value == '*'") ".."
+ assert (=lua "\%star and \%star.type == 'Word' and \%star.value == '*'") ".."
Invalid format for 'when' statement. Lines must begin with '*'
%condition = (%tokens -> 2)
@@ -178,10 +178,10 @@ compile [when %body] to code:
%action = (%tokens -> 3)
if (%action == (nil)):
- lua do> "table.insert(vars.fallthroughs, vars.condition)"
+ lua do> "table.insert(\%fallthroughs, \%condition)"
do next %func_call
- if (=lua "vars.condition.type == 'Word' and vars.condition.value == 'else'"):
+ if (=lua "\%condition.type == 'Word' and \%condition.value == 'else'"):
%result join= ".."
else
@@ -213,7 +213,7 @@ compile [when %branch_value == ? %body] to code:
Invalid format for 'when' statement. Only '*' blocks are allowed.
%tokens = (%func_call's "value")
%star = (%tokens -> 1)
- assert (=lua "vars.star and vars.star.type == 'Word' and vars.star.value == '*'") ".."
+ assert (=lua "\%star and \%star.type == 'Word' and \%star.value == '*'") ".."
Invalid format for 'when' statement. Lines must begin with '*'
%condition = (%tokens -> 2)
@@ -222,10 +222,10 @@ compile [when %branch_value == ? %body] to code:
%action = (%tokens -> 3)
if (%action == (nil)):
- lua> "table.insert(vars.fallthroughs, vars.condition)"
+ lua> "table.insert(\%fallthroughs, \%condition)"
do next %func_call
- if (=lua "vars.condition.type == 'Word' and vars.condition.value == 'else'"):
+ if (=lua "\%condition.type == 'Word' and \%condition.value == 'else'"):
%result join= ".."
else
diff --git a/lib/operators.nom b/lib/operators.nom
index 23de2b3..9250214 100644
--- a/lib/operators.nom
+++ b/lib/operators.nom
@@ -62,7 +62,7 @@ lua do> ".."
nomsu_alias, op = unpack(op);
end
nomsu:defmacro("%a "..nomsu_alias.." %b", (function(nomsu, vars)
- return "("..nomsu:tree_to_lua(vars.a).." "..op.." "..nomsu:tree_to_lua(vars.b)..")";
+ return "("..nomsu:tree_to_lua(\%a).." "..op.." "..nomsu:tree_to_lua(\%b)..")";
end), [["(\\%a ]]..op..[[ \\%b)"]]);
end
@@ -112,7 +112,7 @@ lua do> ".."
-- Chained comparisons need to be functions to avoid re-evaluating their arguments :
nomsu:def(spec, function(nomsu, vars)
for i,op in ipairs(chain) do
- local a, b, result = vars[i], vars[i+1];
+ local a, b, result = vars[tostring(i)], vars[tostring(i+1)];
if op == "<" then; result = a < b;
elseif op == "<=" then; result = a <= b;
elseif op == ">" then; result = a > b;
diff --git a/lib/utils.nom b/lib/utils.nom
index a67b056..e46326e 100644
--- a/lib/utils.nom
+++ b/lib/utils.nom
@@ -16,8 +16,8 @@ parse [assert %condition] as: assert %condition (nil)
rule [join %strs with glue %glue] =:
lua do> ".."
local str_bits = {}
- for i,bit in ipairs(vars.strs) do str_bits[i] = nomsu:stringify(bit) end
- return table.concat(str_bits, vars.glue)
+ for i,bit in ipairs(\%strs) do str_bits[i] = nomsu:stringify(bit) end
+ return table.concat(str_bits, \%glue)
parse [join %strs] as: join %strs with glue ""
compile [capitalize %str, %str capitalized] to:
diff --git a/lib/utils2.nom b/lib/utils2.nom
index d2fda8b..07ff008 100644
--- a/lib/utils2.nom
+++ b/lib/utils2.nom
@@ -24,7 +24,7 @@ compile [with %assignments %action] to code:
%tokens = (%assignment's "value")
%var = (%tokens -> 1)
%eq = (%tokens -> 2)
- assert (=lua "vars.eq and vars.eq.type == 'Word' and vars.eq.value == '='") ".."
+ assert (=lua "\%eq and \%eq.type == 'Word' and \%eq.value == '='") ".."
Invalid format for 'with' statement. List entries must have the form %var = (value)
%value = (%tokens -> 3)
add {i=%i, var=%var, value=%value} to %data