diff options
| author | Bruce Hill <bruce@bruce-hill.com> | 2018-11-08 15:23:22 -0800 |
|---|---|---|
| committer | Bruce Hill <bruce@bruce-hill.com> | 2018-11-08 15:24:15 -0800 |
| commit | 652c29bdef1f0991cc13bef59d6dc78b657ae9a4 (patch) | |
| tree | 8e335399e77b1893657b9fa985db0738034daac3 /lib | |
| parent | 1f3660f393c1a17988a15b89f18686b28e51a9e7 (diff) | |
Major overhaul, splitting nomsu_compiler into nomsu_environment,
nomsu_compiler, and nomsu_decompiler. Also added comprehensions.
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/consolecolor.nom | 4 | ||||
| -rw-r--r-- | lib/file_hash.nom | 2 | ||||
| -rw-r--r-- | lib/object.nom | 2 | ||||
| -rw-r--r-- | lib/os.nom | 3 | ||||
| -rw-r--r-- | lib/things.nom | 14 |
5 files changed, 15 insertions, 10 deletions
diff --git a/lib/consolecolor.nom b/lib/consolecolor.nom index fe7da4c..4b231a9 100644 --- a/lib/consolecolor.nom +++ b/lib/consolecolor.nom @@ -3,7 +3,7 @@ This file defines actions for ANSI console color escape codes. test: - bright "\(green)Color test passed." + % = (bright "\(green)Color test passed.") %colors = {..} normal:0, "reset color":0, bright:1, bold:1, dim:2, italic:3, underscore:4 "slow blink":5, "fast blink":6, reverse:7, inverse:7, inverted:7, hidden:8 @@ -16,7 +16,7 @@ for %name = %colornum in %colors: %colornum = "\%colornum" #(=lua "COMPILE_ACTIONS").%name = (..) [%nomsu, %tree] -> (Lua value "'\\027[\(%colornum)m'") - (=lua "COMPILE_ACTIONS")."\%name" = (..) + %compile.action.%name = (..) [%nomsu, %tree, %text] ->: if %text: return (Lua value "('\\027[\(%colornum)m'..\(%text as lua expr)..'\\027[0m')") diff --git a/lib/file_hash.nom b/lib/file_hash.nom index 6c815f5..ba2f95c 100644 --- a/lib/file_hash.nom +++ b/lib/file_hash.nom @@ -5,6 +5,8 @@ use "lib/os.nom" use "lib/base64.nom" +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + lua> "local \%use_sha1, \%hashlib = pcall(require, 'openssl.digest')" test: diff --git a/lib/object.nom b/lib/object.nom index 6f6fc20..101499d 100644 --- a/lib/object.nom +++ b/lib/object.nom @@ -95,7 +95,7 @@ test: return inst end, }) - nomsu.environment[class.name:as_lua_id()] = class + _ENV[class.name:as_lua_id()] = class class.__index = class class.class = class class.__tostring = function(inst) @@ -69,3 +69,6 @@ externally (source lines of %tree) means: (line % in %file) for % in (line number of %source.start in %file) to (..) line number of %source.stop in %file ..::joined with "\n" + +externally (spoof file %text) means (%Files.spoof %text) +externally (spoof file %filename = %text) means (%Files.spoof %filename %text) diff --git a/lib/things.nom b/lib/things.nom index 2f6c95a..f11ca23 100644 --- a/lib/things.nom +++ b/lib/things.nom @@ -72,9 +72,9 @@ test: lua:append("class.", fn_name) else lua:append("function(") - lua:concat_append(table.map(\%alias_args, function(a) return nomsu:compile(a) end), ", ") + lua:concat_append(table.map(\%alias_args, function(a) return compile(a) end), ", ") lua:append(")\\n return class.", fn_name, "(") - 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), ", ") lua:append(")\\nend") end end @@ -113,11 +113,11 @@ test: end, }) class.__members = \(%members as lua expr) - nomsu.environment[("a "..class.name):as_lua_id()] = class - nomsu.environment[("an "..class.name):as_lua_id()] = class - nomsu.environment[("a "..class.name.." with"):as_lua_id()] = class - nomsu.environment[("an "..class.name.." with"):as_lua_id()] = class - nomsu.environment[class.name:as_lua_id()] = function() return class end + _ENV[("a "..class.name):as_lua_id()] = class + _ENV[("an "..class.name):as_lua_id()] = class + _ENV[("a "..class.name.." with"):as_lua_id()] = class + _ENV[("an "..class.name.." with"):as_lua_id()] = class + _ENV[class.name:as_lua_id()] = function() return class end class.__index = class class.class = class local dict_tostring = getmetatable(Dict{}).__tostring |
