diff options
Diffstat (limited to 'core')
| -rw-r--r-- | core/collections.nom | 4 | ||||
| -rw-r--r-- | core/metaprogramming.nom | 13 | ||||
| -rw-r--r-- | core/operators.nom | 18 |
3 files changed, 9 insertions, 26 deletions
diff --git a/core/collections.nom b/core/collections.nom index 0bf5cef..a8a28b2 100644 --- a/core/collections.nom +++ b/core/collections.nom @@ -134,10 +134,6 @@ immediately self[\(%key as lua expr)] = value return value end}) - -immediately - parse [new counter] as: {} with fallback % -> 0 - parse [new default dict] as: {} with fallback % -> {} # Sorting immediately diff --git a/core/metaprogramming.nom b/core/metaprogramming.nom index c54a72f..8ad9448 100644 --- a/core/metaprogramming.nom +++ b/core/metaprogramming.nom @@ -132,7 +132,7 @@ immediately lua> ".." local lua = nomsu:tree_to_lua(\%tree) if not lua.is_value then - error("Invalid thing to convert to lua expr: "..\%tree) + error("Invalid thing to convert to lua expr: "..tostring(\%tree)) end return lua @@ -164,8 +164,9 @@ immediately parse [to %var write %code] as: lua> "\%var:append(\%code);" immediately - compile [repr %obj] to: Lua value "repr(\(%obj as lua expr))" - compile [%obj as text] to: Lua value "tostring(\(%obj as lua expr))" + compile [quote %s] to + Lua value ".." + ('"'..\(%s as lua expr):gsub("\\\\", "\\\\\\\\"):gsub("\n","\\\\n"):gsub('"', '\\\\"')..'"') compile [type of %obj] to: Lua value "type(\(%obj as lua expr))" immediately @@ -175,7 +176,7 @@ immediately # Compiler tools immediately compile [run %code] to - Lua "nomsu:run(Nomsu(\"\(%code.source as text)\", \(%code as lua expr)))" + Lua value "nomsu:run(Nomsu(\(quote "\(%code.source)"), \(%code as lua expr)))" immediately compile [show lua %block] to @@ -189,7 +190,7 @@ immediately if \%message.type == "Text" then return Lua(tree.source, "print(", \(%message as lua expr), ");"); else - return Lua(tree.source, "print(stringify(", \(%message as lua expr), "));"); + return Lua(tree.source, "print(tostring(", \(%message as lua expr), "));"); end # Return @@ -208,7 +209,7 @@ immediately return Lua ".." if not \(%condition as lua expr) then - error(\(repr %assumption), 0); + error(\(quote "\%assumption"), 0); end compile [assume %condition or barf %message] to diff --git a/core/operators.nom b/core/operators.nom index dd57cea..4ec8ff1 100644 --- a/core/operators.nom +++ b/core/operators.nom @@ -23,23 +23,9 @@ immediately compile [%x <= %y] to: Lua value "(\(%x as lua expr) <= \(%y as lua expr))" compile [%x >= %y] to: Lua value "(\(%x as lua expr) >= \(%y as lua expr))" compile [%a is %b, %a = %b, %a == %b] to - lua> ".." - local safe = {Text=true, Number=true} - local a_lua, b_lua = \(%a as lua), \(%b as lua) - if safe[\%a.type] or safe[\%b.type] then - return Lua.Value(tree.source, "(", a_lua, " == ", b_lua, ")") - else - return Lua.Value(tree.source, "utils.equivalent(", a_lua, ", ", b_lua, ")") - end + Lua value "(\(%a as lua expr) == \(%b as lua expr))" 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 = \(%a as lua), \(%b as lua) - if safe[\%a.type] or safe[\%b.type] then - return Lua.Value(tree.source, "(", a_lua, " ~= ", b_lua, ")") - else - return Lua.Value(tree.source, "(not utils.equivalent(", a_lua, ", ", b_lua, "))") - end + Lua value "(\(%a as lua expr) ~= \(%b as lua expr))" # For strict identity checking, use (%x's id) is (%y's id) compile [%'s id, id of %] to: Lua value "nomsu.ids[\(% as lua expr)]" |
