aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/metaprogramming.nom8
-rw-r--r--lib/operators.nom2
-rw-r--r--lib/utils.nom10
-rw-r--r--lib/utils2.nom4
4 files changed, 12 insertions, 12 deletions
diff --git a/lib/metaprogramming.nom b/lib/metaprogramming.nom
index b4c1283..4b47ddf 100644
--- a/lib/metaprogramming.nom
+++ b/lib/metaprogramming.nom
@@ -66,15 +66,15 @@ lua> ".."
rule [remove rule %stub] =:
lua> ".."
- local def = nomsu.defs[\(%stub)];
+ local def = nomsu.defs[\%stub];
for _, alias in ipairs(def.aliases) do
nomsu.defs[alias] = false;
end
rule [%tree as lua] =:
- =lua "nomsu:tree_to_lua(\(%tree))"
+ =lua "nomsu:tree_to_lua(\%tree)"
rule [%tree as value] =:
- =lua "nomsu:tree_to_value(\(%tree), vars)"
+ =lua "nomsu:tree_to_value(\%tree, vars)"
compile [repr %obj] to:
"nomsu:repr(\(%obj as lua))"
compile [indented %obj] to:
@@ -91,7 +91,7 @@ parse [lua do> %block] as:
rule [%tree as lua statement] =:
lua do> ".."
- local _,statement = nomsu:tree_to_lua(\(%tree));
+ local _,statement = nomsu:tree_to_lua(\%tree);
return statement;
rule [%tree as lua statements] =:
lua do> ".."
diff --git a/lib/operators.nom b/lib/operators.nom
index 198a8ff..23de2b3 100644
--- a/lib/operators.nom
+++ b/lib/operators.nom
@@ -63,7 +63,7 @@ lua do> ".."
end
nomsu:defmacro("%a "..nomsu_alias.." %b", (function(nomsu, vars)
return "("..nomsu:tree_to_lua(vars.a).." "..op.." "..nomsu:tree_to_lua(vars.b)..")";
- end), [["(\\%a ]]..op..[[ \\(%b))"]]);
+ end), [["(\\%a ]]..op..[[ \\%b)"]]);
end
# TODO: implement OR, XOR, AND for multiple operands
diff --git a/lib/utils.nom b/lib/utils.nom
index 11f0ccf..a67b056 100644
--- a/lib/utils.nom
+++ b/lib/utils.nom
@@ -43,7 +43,7 @@ compile [random int %n, random integer %n, randint %n] to: "math.random(\(%n as
compile [random from %low to %high, random number from %low to %high, rand %low %high] to:
"math.random(\(%low as lua), \(%high as lua))"
rule [random choice from %elements, random choice %elements, random %elements] =:
- =lua "\(%elements)[math.random(#\(%elements))]"
+ =lua "\%elements[math.random(#\%elements)]"
# Math functions
compile [% as number] to: "tonumber(\(% as lua))"
@@ -66,7 +66,7 @@ compile [log % base %base] to: "math.log(\(% as lua), \(%base as lua))"
compile [floor %] to: "math.floor(\(% as lua))"
compile [round %, % rounded] to: "math.floor(\(% as lua) + .5)"
rule [%n rounded to the nearest %rounder] =:
- =lua "(\(%rounder))*math.floor(\(%n)/\(%rounder) + .5)"
+ =lua "(\%rounder)*math.floor((\%n / \%rounder) + .5)"
compile [tau] to: "(2*math.pi)"
compile [pi] to: "math.pi"
compile [e] to: "math.e"
@@ -78,7 +78,7 @@ compile [product of %items, product %items] to: "nomsu.utils.product(\(%items as
compile [all of %items] to: "nomsu.utils.all(\(%items as lua))"
compile [any of %items] to: "nomsu.utils.any(\(%items as lua))"
rule [avg of %items, average of %items] =:
- =lua "(nomsu.utils.sum(\(%items))/#\(%items))"
+ =lua "(nomsu.utils.sum(\%items)/#\%items)"
compile [min of %items, smallest of %items, lowest of %items] to:
"nomsu.utils.min(\(%items as lua))"
compile [max of %items, biggest of %items, largest of %items, highest of %items] to:
@@ -95,8 +95,8 @@ compile [max of %items by %value_expr] to: ".."
end)
compile [sort %items] to: "table.sort(\(%items as lua))"
rule [sort %items by %key] =: =lua ".."
- nomsu.utils.sort(\(%items), function(x)
- return (\(%key))(nomsu, {['']=x});
+ nomsu.utils.sort(\%items, function(x)
+ return (\%key)(nomsu, {['']=x});
end)
# String utilities
diff --git a/lib/utils2.nom b/lib/utils2.nom
index cdaf5fa..d2fda8b 100644
--- a/lib/utils2.nom
+++ b/lib/utils2.nom
@@ -28,14 +28,14 @@ compile [with %assignments %action] to code:
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
- %foo = (..)
+ %setup = (..)
join (..)
"local old_value\(%->"i") = \((%->"var") as lua); \((%->"var") as lua) = \((%->"value") as lua);"
..for all %data
..with glue "\n "
".."
do
- \(%foo)
+ \%setup
local fell_through = false;
local ok, ret1, ret2 = pcall(function(nomsu, vars)
\(%action as lua statements);