diff options
Diffstat (limited to 'core')
| -rw-r--r-- | core/collections.nom | 2 | ||||
| -rw-r--r-- | core/control_flow.nom | 2 | ||||
| -rw-r--r-- | core/coroutines.nom | 2 | ||||
| -rw-r--r-- | core/errors.nom | 6 | ||||
| -rw-r--r-- | core/id.nom | 2 | ||||
| -rw-r--r-- | core/io.nom | 6 | ||||
| -rw-r--r-- | core/math.nom | 4 | ||||
| -rw-r--r-- | core/metaprogramming.nom | 197 | ||||
| -rw-r--r-- | core/operators.nom | 32 | ||||
| -rw-r--r-- | core/scopes.nom | 2 | ||||
| -rw-r--r-- | core/text.nom | 6 |
11 files changed, 119 insertions, 142 deletions
diff --git a/core/collections.nom b/core/collections.nom index ae7f5f1..684f3f6 100644 --- a/core/collections.nom +++ b/core/collections.nom @@ -7,6 +7,8 @@ use "core/metaprogramming.nom" use "core/control_flow.nom" use "core/operators.nom" +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + # List functionality: test: %list = [1, 2, 3, 4, 5] diff --git a/core/control_flow.nom b/core/control_flow.nom index a692f95..f7a8423 100644 --- a/core/control_flow.nom +++ b/core/control_flow.nom @@ -8,6 +8,8 @@ use "core/text.nom" use "core/operators.nom" use "core/errors.nom" +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + # No-Op test: do nothing (do nothing) compiles to (Lua "") diff --git a/core/coroutines.nom b/core/coroutines.nom index 246a2ef..f03cfc8 100644 --- a/core/coroutines.nom +++ b/core/coroutines.nom @@ -4,6 +4,8 @@ use "core/metaprogramming.nom" +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + test: %nums = [] %co = (..) diff --git a/core/errors.nom b/core/errors.nom index 0b0a6a3..74c0a54 100644 --- a/core/errors.nom +++ b/core/errors.nom @@ -4,6 +4,8 @@ use "core/metaprogramming.nom" +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + (barf %msg) compiles to (Lua "error(\(=lua "\%msg and \(%msg as lua expr) or 'nil'"), 0);") (compile error at %tree %msg) compiles to (..) Lua "nomsu:compile_error(\(%tree as lua expr), \(%msg as lua expr))" @@ -12,7 +14,7 @@ use "core/metaprogramming.nom" (assume %condition) compiles to: lua> "\ - ..local \%assumption = 'Assumption failed: '..tostring(nomsu:tree_to_nomsu(\%condition))" + ..local \%assumption = 'Assumption failed: '..tostring((\%condition):get_source_code())" return (..) Lua "\ ..if not \(%condition as lua expr) then @@ -21,7 +23,7 @@ use "core/metaprogramming.nom" (assume %a == %b) compiles to: lua> "\ - ..local \%assumption = 'Assumption failed: '..tostring(nomsu:tree_to_nomsu(\(\(%a == %b))))" + ..local \%assumption = 'Assumption failed: '..tostring(\(\(%a == %b) as nomsu))" define mangler return (..) Lua "\ diff --git a/core/id.nom b/core/id.nom index a9231b9..46aeaa9 100644 --- a/core/id.nom +++ b/core/id.nom @@ -8,6 +8,8 @@ use "core/math.nom" use "core/collections.nom" use "core/control_flow.nom" +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + %NaN_surrogate = {} %nil_surrogate = {} %obj_by_id = {} diff --git a/core/io.nom b/core/io.nom index 6b67b50..e12e4eb 100644 --- a/core/io.nom +++ b/core/io.nom @@ -4,7 +4,9 @@ use "core/metaprogramming.nom" -(say %message) compiles to (..) +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +(say %message) compiles to: lua> "\ ..if \%message.type == "Text" then return LuaCode(tree.source, "print(", \(%message as lua expr), ");"); @@ -12,7 +14,7 @@ use "core/metaprogramming.nom" return LuaCode(tree.source, "print(tostring(", \(%message as lua expr), "));"); end" -(ask %prompt) compiles to (..) +(ask %prompt) compiles to: lua> "\ ..if \%prompt.type == "Text" then return LuaCode.Value(tree.source, "(io.write(", \(%prompt as lua expr), ") and io.read())"); diff --git a/core/math.nom b/core/math.nom index 3bad78a..36d1d90 100644 --- a/core/math.nom +++ b/core/math.nom @@ -8,6 +8,8 @@ use "core/operators.nom" use "core/control_flow.nom" use "core/collections.nom" +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + # Literals: test: assume (all of [inf, NaN, pi, tau, golden ratio, e]) or barf "\ @@ -204,7 +206,7 @@ test: return %best # Random functions -externally (seed random with %) means (..) +externally (seed random with %) means: lua> "\ ..math.randomseed(\%); for i=1,20 do math.random(); end" diff --git a/core/metaprogramming.nom b/core/metaprogramming.nom index b104987..be7450a 100644 --- a/core/metaprogramming.nom +++ b/core/metaprogramming.nom @@ -3,7 +3,9 @@ This File contains actions for making actions and compile-time actions and some helper functions to make that easier. -lua> "NOMSU_CORE_VERSION = 9" +lua> "\ + ..NOMSU_CORE_VERSION = 10 + NOMSU_LIB_VERSION = 7" lua> "\ ..do local mangle_index = 0 @@ -15,17 +17,18 @@ lua> "\ end end end - COMPILE_ACTIONS["define mangler"] = function(nomsu, tree) + compile.action["define mangler"] = function(compile, tree) return LuaCode(tree.source, "local mangle = mangler()") end" lua> "\ - ..COMPILE_ACTIONS["1 ->"] = function(nomsu, tree, \%args, \%body) - local lua = LuaCode.Value(tree.source, "(function(") + ..compile.action["1 ->"] = function(compile, tree, \%args, \%body) + local lua = LuaCode(tree.source, "(function(") 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):text() or a end) + local lua_args = table.map(\%args, function(a) return SyntaxTree:is_instance(a) and compile(a):text() or a end) lua:concat_append(lua_args, ", ") - local body_lua = SyntaxTree:is_instance(\%body) and nomsu:compile(\%body):as_statements("return ") or \%body + local body_lua = SyntaxTree:is_instance(\%body) and compile(\%body) or \%body + if SyntaxTree:is_instance(\%body) and \%body.type ~= "Block" then body_lua:prepend("return ") end body_lua:remove_free_vars(lua_args) body_lua:declare_locals() lua:append(")\\n ", body_lua, "\\nend)") @@ -33,10 +36,10 @@ lua> "\ end" lua> "\ - ..COMPILE_ACTIONS["what 1 compiles to"] = function(nomsu, tree, \%action) - local lua = LuaCode.Value(tree.source, "COMPILE_ACTIONS[", \%action.stub:as_lua(), "](") - local lua_args = table.map(\%action:get_args(), function(a) return nomsu:compile(a) end) - table.insert(lua_args, 1, "nomsu") + ..compile.action["what 1 compiles to"] = function(compile, tree, \%action) + local lua = LuaCode(tree.source, "compile.action[", \%action.stub:as_lua(), "](") + local lua_args = table.map(\%action:get_args(), function(a) return compile(a) end) + table.insert(lua_args, 1, "compile") table.insert(lua_args, 2, "tree") lua:concat_append(lua_args, ", ") lua:append(")") @@ -46,10 +49,10 @@ lua> "\ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ test: - (five) compiles to (Lua value "5") + (five) compiles to "5" test: assume ((five) == 5) or barf "Compile to expression failed." - (loc x) compiles to (Lua "local x = 99;") + (loc x) compiles to "local x = 99;" test: lua> "do" loc x @@ -63,9 +66,12 @@ test: asdf assume (%tmp is (nil)) or barf "compile to is leaking variables" lua> "\ - ..COMPILE_ACTIONS["1 compiles to"] = function(nomsu, tree, \%action, \%body) - local \%args = List{\(\%nomsu), \(\%tree), unpack(\%action:get_args())} - local lua = LuaCode(tree.source, "COMPILE_ACTIONS[", \%action.stub:as_lua(), + ..compile.action["1 compiles to"] = function(compile, tree, \%action, \%body) + local \%args = List{\(\%compile), \(\%tree), unpack(\%action:get_args())} + if \%body.type == "Text" then + \%body = SyntaxTree{source=\%body.source, type="Action", "Lua", \%body} + end + local lua = LuaCode(tree.source, "compile.action[", \%action.stub:as_lua(), "] = ", \(what (%args -> %body) compiles to)) return lua end" @@ -75,16 +81,16 @@ lua> "\ (%actions all compile to %body) compiles to: lua> "\ ..if \%actions.type ~= "List" then - nomsu:compile_error(\%actions, "This should be a list of actions.") + compile_error(\%actions, "This should be a list of actions.") end local lua = LuaCode(tree.source, \(what (%actions.1 compiles to %body) compiles to)) - local \%args = List{\(\%nomsu), \(\%tree), unpack(\%actions[1]:get_args())} + local \%args = List{\(\%compile), \(\%tree), unpack(\%actions[1]:get_args())} for i=2,#\%actions do local alias = \%actions[i] - local \%alias_args = List{\(\%nomsu), \(\%tree), unpack(alias:get_args())} - lua:append("\\nCOMPILE_ACTIONS[", alias.stub:as_lua(), "] = ") + local \%alias_args = List{\(\%compile), \(\%tree), unpack(alias:get_args())} + lua:append("\\ncompile.action[", alias.stub:as_lua(), "] = ") if \%alias_args == \%args then - lua:append("COMPILE_ACTIONS[", \%actions[1].stub:as_lua(), "]") + lua:append("compile.action[", \%actions[1].stub:as_lua(), "]") else lua:append(\(what (%alias_args -> \(what %actions.1 compiles to)) compiles to)) end @@ -95,17 +101,17 @@ lua> "\ (call %fn with %args) compiles to: lua> "\ - ..local lua = LuaCode.Value(tree.source, nomsu:compile(\%fn), "(") + ..local lua = LuaCode(tree.source, compile(\%fn), "(") if \%args.type == 'List' then - lua:concat_append(table.map(\%args, function(a) return nomsu:compile(a) end), ", ") + lua:concat_append(table.map(\%args, function(a) return compile(a) end), ", ") else - lua:append('unpack(', nomsu:compile(\%args), ')') + lua:append('unpack(', compile(\%args), ')') end lua:append(")") return lua" test: - (foo %x) means (return "outer") + (foo %x) means "outer" with local [(foo %)'s meaning]: (foo %x) means: %y = (%x + 1) @@ -162,7 +168,7 @@ test: test: assume (((say %)'s meaning) == (=lua "say")) -(%action's meaning) compiles to (Lua value (%action.stub as lua id)) +(%action's meaning) compiles to (Lua (%action.stub as lua id)) test: (swap %x and %y) parses as (..) @@ -183,10 +189,10 @@ test: lua> "\ ..local replacements = {} if \%actions.type ~= "List" then - nomsu:compile_error(\%actions, "This should be a list.") + compile_error(\%actions, "This should be a list.") end for i,arg in ipairs(\%actions[1]:get_args()) do - replacements[arg[1]] = nomsu:compile(arg):text() + replacements[arg[1]] = compile(arg):text() end local function make_tree(t) if SyntaxTree:is_instance(t) and t.type == "Var" then @@ -227,27 +233,17 @@ test: [%action parses as %body] all parse as ([%action] all parse as %body) -# TODO: add check for .is_value -(%tree as lua expr) compiles to (..) - Lua value "nomsu:compile(\(=lua "nomsu:compile(\%tree, nil, true)"), nil, true)" +(%tree as lua expr) compiles to "\ + ..compile(\(=lua "compile(\%tree, nil, true)"), nil, true)" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -(%tree as lua) compiles to (Lua value "nomsu:compile(\(%tree as lua expr))") -(%tree as lua statements) compiles to (..) - Lua value "nomsu:compile(\(%tree as lua expr)):as_statements()" - -(%tree as lua return) compiles to (..) - Lua value "nomsu:compile(\(%tree as lua expr)):as_statements('return ')" - -test: - assume ("\(\(foo \%x) as nomsu)" == "foo %x") or barf "\ - ..action source code failed." -(%tree as nomsu) compiles to (..) - Lua value "nomsu:tree_to_nomsu(\(%tree as lua expr))" +(%tree as lua) compiles to "compile(\(%tree as lua expr))" +(%tree as lua statements) compiles to "\ + ..compile(\(%tree as lua expr)):as_statements()" -(%tree as inline nomsu) compiles to (..) - Lua value "nomsu:tree_to_inline_nomsu(\(%tree as lua expr), true)" +(%tree as lua return) compiles to "\ + ..compile(\(%tree as lua expr)):as_statements('return ')" externally [%var as lua identifier, %var as lua id] all mean: lua> "\ @@ -256,7 +252,7 @@ externally [%var as lua identifier, %var as lua id] all mean: elseif SyntaxTree:is_instance(\%var) then local lua = \(%var as lua expr) if not lua:text():match("^[_a-zA-Z][_a-zA-Z0-9]*$") then - nomsu:compile_error(\%var, "This is not a valid Lua identifier.") + compile_error(\%var, "This is not a valid Lua identifier.") end return lua else error("Unknown type: "..tostring(\%var)) @@ -264,15 +260,14 @@ externally [%var as lua identifier, %var as lua id] all mean: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -(% is syntax tree) compiles to (Lua value "SyntaxTree:is_instance(\(% as lua expr))") -(% is %kind syntax tree) compiles to (..) - Lua value "SyntaxTree:is_instance(\(% as lua expr), \(%kind as lua expr))" +(% is syntax tree) compiles to "SyntaxTree:is_instance(\(% as lua expr))" +externally (% is %kind syntax tree) means (..) + =lua "SyntaxTree:is_instance(\%) and \%.type == \%kind" -(%tree with %t -> %replacement) compiles to (..) - Lua value "\ - ..\(%tree as lua expr):map(function(\(%t as lua expr)) - \(%replacement as lua return) - end)" +(%tree with %t -> %replacement) compiles to "\ + ..\(%tree as lua expr):map(function(\(%t as lua expr)) + \(%replacement as lua return) + end)" externally (%tree with vars %replacements) means (..) =lua "\ @@ -282,22 +277,20 @@ externally (%tree with vars %replacements) means (..) end end)" -(tree %tree with vars %replacements) compiles to (..) - Lua value "\ - ..\(=lua "(\%tree):as_lua()"):map(function(t) - if t.type == "Var" then - return \(%replacements as lua expr)[t[1]] - end - end)" +(tree %tree with vars %replacements) compiles to "\ + ..\(=lua "(\%tree):as_lua()"):map(function(t) + if t.type == "Var" then + return \(%replacements as lua expr)[t[1]] + end + end)" -(%tree has subtree %match_tree) compiles to (..) - Lua value "\ - ..(function() - local match_tree = \(%match_tree as lua expr) - for subtree in coroutine.wrap(function() \(%tree as lua expr):map(coroutine.yield) end) do - if subtree == match_tree then return true end - end - end)()" +(%tree has subtree %match_tree) compiles to "\ + ..(function() + local match_tree = \(%match_tree as lua expr) + for subtree in coroutine.wrap(function() \(%tree as lua expr):map(coroutine.yield) end) do + if subtree == match_tree then return true end + end + end)()" externally (match %tree with %patt) means: lua> "\ @@ -339,7 +332,7 @@ test: ..one "two"" ..== "\"one\\n\\\"two\\\"\"" -(quote %s) compiles to (Lua value "tostring(\(%s as lua expr)):as_lua()") +(quote %s) compiles to (Lua "tostring(\(%s as lua expr)):as_lua()") test: assume (lua type of {}) == "table" @@ -368,63 +361,43 @@ externally (type of %) means: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ test: - assume ((parse "foo %") == \(foo \%)) - %a = (parse "\\1") - %b = \(\(1)) - assume ((parse "\\1") == \(\(1))) -(parse %text) compiles to (Lua value "nomsu:parse(\(%text as lua expr))") -(parse %text from %filename) compiles to (..) - Lua value "\ - ..nomsu:parse(NomsuCode(Source(\(%filename as lua expr), 1, #\(%text as lua expr)), \(..) - %text as lua expr - ..))" - -test: assume ((run "return (2 + 99)") == 101) external %passed = (no) run "external %passed = (yes)" assume %passed -(run %nomsu_code) compiles to (..) - Lua value "\ - ..nomsu:run(NomsuCode(\(=lua "tostring(\(%nomsu_code.source)):as_lua()"), \(..) - %nomsu_code as lua expr - ..))" + assume (run \(return \(\(5) + \(5)))) == 10 +(run %nomsu_code) compiles to "\ + ..run_1_in(\(%nomsu_code as lua expr), _ENV)" -test: - assume ((\(\(5) + \(5)) as value) == 10) or barf "%tree as value failed." -[run tree %tree, %tree as value] all compile to (..) - Lua value "nomsu:run(\(%tree as lua expr))" - -[compile %block, compiled %block, %block compiled] all compile to (..) - Lua value "nomsu:compile(\(%block as lua))" +[compile %block, compiled %block, %block compiled] all compile to "\ + ..compile(\(%block as lua))" # Return statement is wrapped in a do..end block because Lua is unhappy if you put code after a return statement, unless you wrap it in a block. -(return) compiles to (Lua "do return; end") -(return %return_value) compiles to (..) - Lua "do return \(%return_value as lua expr) end" +(return) compiles to "do return; end" +(return %return_value) compiles to "do return \(%return_value as lua expr) end" # Literals -(yes) compiles to (Lua value "true") -(no) compiles to (Lua value "false") -[nothing, nil, null] all compile to (Lua value "nil") -(Nomsu syntax version) compiles to (Lua value "NOMSU_SYNTAX_VERSION") -(Nomsu compiler version) compiles to (Lua value "NOMSU_COMPILER_VERSION") -(core version) compiles to (Lua value "NOMSU_CORE_VERSION") -(lib version) compiles to (Lua value "NOMSU_LIB_VERSION") -(command line args) compiles to (Lua value "arg") +(yes) compiles to "true" +(no) compiles to "false" +[nothing, nil, null] all compile to "nil" +(Nomsu syntax version) compiles to "NOMSU_SYNTAX_VERSION" +(Nomsu compiler version) compiles to "NOMSU_COMPILER_VERSION" +(core version) compiles to "NOMSU_CORE_VERSION" +(lib version) compiles to "NOMSU_LIB_VERSION" +(command line args) compiles to "command_line_args" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -(with local compile actions %body) compiles to (..) - Lua "\ - ..do - local nomsu = nomsu:fork() - local COMPILE_ACTIONS = nomsu.environment.COMPILE_ACTIONS - \(%body as lua statements) - end" +(with local compile actions %body) compiles to "\ + ..do + --local compile = _1_forked(compile) + local old_action = compile.action + compile.action = _1_forked(old_action) + \(%body as lua statements) + compile.action = old_action + end" externally (Nomsu version) means: - use "lib/version.nom" return "\ ..\(Nomsu syntax version).\(core version).\(Nomsu compiler version).\(lib version)" diff --git a/core/operators.nom b/core/operators.nom index 6d574b7..1d8e63f 100644 --- a/core/operators.nom +++ b/core/operators.nom @@ -5,6 +5,8 @@ use "core/metaprogramming.nom" use "core/errors.nom" +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + test: assume (all [1 < 2, 2 > 1, 1 <= 2, 2 >= 1, 1 == 1, 1 != 2]) @@ -27,14 +29,12 @@ test: # Variable assignment operator (%var = %value) compiles to: - lua> "local \%var_lua = \(%var as lua expr)" - assume %var_lua.is_value or barf "Invalid target for assignment: \%var" - lua> "local \%value_lua = \(%value as lua expr)" - assume %value_lua.is_value or barf "Invalid value for assignment: \%value" lua> "\ - ..local lua = LuaCode(tree.source, \%var_lua, ' = ', \%value_lua, ';') + ..local \%var_lua = \(%var as lua expr) + local \%value_lua = \(%value as lua expr) + local lua = LuaCode(tree.source, \%var_lua, ' = ', \%value_lua, ';') if \%var.type == 'Var' then - lua:add_free_vars({nomsu:compile(\%var):text()}) + lua:add_free_vars({compile(\%var):text()}) end return lua" @@ -58,13 +58,7 @@ test: end end) local target_lua = \(%target as lua) - if not target_lua.is_value then error("Invalid target for assignment: "..\(..) - %target as text - ..) end local value_lua = \(%value as lua) - if not value_lua.is_value then error("Invalid value for assignment: "..\(..) - %value as text - ..) end if \%target.type == "Var" then lhs:add_free_vars({target_lua:text()}) end @@ -87,16 +81,11 @@ test: set global x local y assume ((%foozle == "inner") and (%y == "outer")) or barf "external failed." -(external %var = %value) compiles to: - %var_lua = (%var as lua) - assume %var_lua.is_value or barf "Invalid target for assignment: \%var" - %value_lua = (%value as lua) - assume %value_lua.is_value or barf "Invalid value for assignment: \%value" - return (Lua "\%var_lua = \%value_lua;") +(external %var = %value) compiles to "\(%var as lua) = \(%value as lua)" test: set {%foozle:"outer", %y:"outer"} - externally (set global x local y) means (..) + externally (set global x local y) means: with external [%foozle]: %foozle = "inner" %y = "inner" @@ -107,7 +96,7 @@ test: (with external %externs %body) compiles to: %body_lua = (%body as lua statements) lua> "\ - ..\%body_lua:remove_free_vars(table.map(\%externs, function(v) return nomsu:compile(v):text() end))" + ..\%body_lua:remove_free_vars(table.map(\%externs, function(v) return compile(v):text() end))" return %body_lua test: @@ -131,9 +120,6 @@ test: end local target_lua = \(%target as lua) local value_lua = \(%value as lua) - if not value_lua.is_value then - error("Invalid value for assignment: "..tostring(\%value)) - end if i > 1 then lhs:append(", ") rhs:append(", ") diff --git a/core/scopes.nom b/core/scopes.nom index 2d86ca4..47960d8 100644 --- a/core/scopes.nom +++ b/core/scopes.nom @@ -7,6 +7,8 @@ use "core/operators.nom" use "core/collections.nom" use "core/control_flow.nom" +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + test: %x = "outer" with local %x: diff --git a/core/text.nom b/core/text.nom index 40eb895..38fa08b 100644 --- a/core/text.nom +++ b/core/text.nom @@ -5,6 +5,8 @@ use "core/metaprogramming.nom" +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + test: assume "\[1, 2, 3]" == "[1, 2, 3]" assume "foo = \(1 + 2)!" == "foo = 3!" @@ -52,8 +54,8 @@ lua> "\ }; for name, e in pairs(escapes) do local lua = "'"..e.."'" - COMPILE_ACTIONS[name] = function(nomsu, tree) - return LuaCode.Value(tree.source, lua) + compile.action[name] = function(compile, tree) + return LuaCode(tree.source, lua) end end end" |
