diff options
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/base64.nom | 2 | ||||
| -rw-r--r-- | lib/consolecolor.nom | 2 | ||||
| -rw-r--r-- | lib/file_hash.nom | 4 | ||||
| -rw-r--r-- | lib/object.nom | 2 | ||||
| -rw-r--r-- | lib/os.nom | 30 | ||||
| -rw-r--r-- | lib/things.nom | 30 |
6 files changed, 31 insertions, 39 deletions
diff --git a/lib/base64.nom b/lib/base64.nom index ea951c8..04003a2 100644 --- a/lib/base64.nom +++ b/lib/base64.nom @@ -1,4 +1,4 @@ -#!/usr/bin/env nomsu -V4.10.12.7 +#!/usr/bin/env nomsu -V4.11.12.8 # This file defines actions for encoding/decoding base 64, as specified in: https://tools.ietf.org/html/rfc4648 diff --git a/lib/consolecolor.nom b/lib/consolecolor.nom index 0114d01..2c3665a 100644 --- a/lib/consolecolor.nom +++ b/lib/consolecolor.nom @@ -1,4 +1,4 @@ -#!/usr/bin/env nomsu -V4.10.12.7 +#!/usr/bin/env nomsu -V4.11.12.8 # This file defines actions for ANSI console color escape codes. diff --git a/lib/file_hash.nom b/lib/file_hash.nom index 547afb5..bda79d5 100644 --- a/lib/file_hash.nom +++ b/lib/file_hash.nom @@ -1,4 +1,4 @@ -#!/usr/bin/env nomsu -V4.10.12.7 +#!/usr/bin/env nomsu -V4.11.12.8 # This file defines some actions for hashing files and looking up files by hash. @@ -44,7 +44,7 @@ if %use_sha1: return "\%hash" externally (file with hash %hash) means: - for file %filename in ".": + for %filename in (files for "."): %contents = (read file %filename) %file_hash = (hash %contents) if (%file_hash == %hash): diff --git a/lib/object.nom b/lib/object.nom index 103f2d7..94ca9f0 100644 --- a/lib/object.nom +++ b/lib/object.nom @@ -1,4 +1,4 @@ -#!/usr/bin/env nomsu -V4.10.12.7 +#!/usr/bin/env nomsu -V4.11.12.8 # This file contains the implementation of an Object-Oriented programming system. @@ -1,4 +1,4 @@ -#!/usr/bin/env nomsu -V4.10.12.7 +#!/usr/bin/env nomsu -V4.11.12.8 # This file defines some actions that interact with the operating system and filesystem. @@ -7,13 +7,15 @@ test: externally (files for %path) means: %files = (=lua "Files.list(\%path)") - if %files: %files = (List %files) + if %files: + %files = (List %files) return %files externally (nomsu files for %path) means: for %nomsupath in (%package.nomsupath::all matches of "[^;]+"): - %files = (files for "\%nomsupath/\%path") - if %files: return %files + %files = (files for "\(%nomsupath)/\%path") + if %files: + return %files externally (sh> %cmd) means: lua> "\ @@ -26,20 +28,6 @@ test: read file "lib/os.nom" externally (read file %filename) means (=lua "Files.read(\%filename)") -test: - for file %f in "core": do nothing - -(for file %f in %path %body) parses as (for %f in (nomsu files for %path) %body) - -# TODO: deprecate -#(%expr for file %f in %path) compiles to "\ - ..(function() - local ret = List{} - for i,\(%f as lua expr) in Files.walk(\(%path as lua expr)) do - ret[#ret+1] = \(%expr as lua) - end - return ret - end)()" externally [..] write to file %filename %text, to file %filename write %text @@ -57,9 +45,9 @@ externally (source lines of %tree) means: return (..) [..] : - for % in (line number of %source.start in %file) to (..) - line number of %source.stop in %file - ..: add (line % in %file) + for % in (%file::line number at %source.start) to (..) + %file::line number at %source.stop + ..: add (%file::line %) ..::joined with "\n" externally (spoof file %text) means (%Files.spoof %text) diff --git a/lib/things.nom b/lib/things.nom index 731c206..2562815 100644 --- a/lib/things.nom +++ b/lib/things.nom @@ -1,4 +1,4 @@ -#!/usr/bin/env nomsu -V4.10.12.7 +#!/usr/bin/env nomsu -V4.11.12.8 # A library for simple object oriented programming. @@ -13,8 +13,7 @@ test: %barks = [: for % in 1 to %its.barks: add "Bark!"] return (%barks::joined with " ") - (%it::gets pissed off) means: - %it.barks += 1 + (%it::gets pissed off) means: %it.barks += 1 (Dog).genus = "Canus" %d = (a Dog with {barks: 2}) assume "\%d" == "Dog {barks: 2}" @@ -38,7 +37,7 @@ test: a (Corgi) is a thing: [%it, %its] = [Corgi, Corgi] %it [set up, gets pissed off] like a (Dog) - (%it::as text) means "Dogloaf \({: for %k = %v in %it: add %k = %v })" + (%it::as text) means "Dogloaf \{: for %k = %v in %it: add %k = %v}" (%its::sploot) means "sploooot" [%its::bark, %its::woof] all mean: %barks = [: for % in 1 to %its.barks: add "Yip!"] @@ -54,13 +53,14 @@ test: with {%d: a Dog with {barks: 2}}: assume ((%d::bark) == "Bark! Bark!") - + a (Vec) is a thing with {x, y}: %its = (Vec) (%its::+ %other) means (Vec {x: %its.x + %other.x, y: %its.y + %other.y}) - assume ((Vec {x: 1, y:2 }) + (Vec {x: 10, y: 10})) == (Vec {x: 11, y: 12}) - assume (((Vec {x: 1, y:2 }) + (Vec {x: 10, y: 10})) != (Vec {x: 0, y: 0})) + assume ((Vec {x: 1, y: 2}) + (Vec {x: 10, y: 10})) == (Vec {x: 11, y: 12}) + assume (((Vec {x: 1, y: 2}) + (Vec {x: 10, y: 10})) != (Vec {x: 0, y: 0})) + [..] %it can %actions like a %class, %it can %actions like an %class %it has %actions like a %class, %it has %actions like an %class @@ -70,7 +70,8 @@ test: %class_expr = (%class as lua expr) %lines = [] for %a in %actions: - %lines::add "\(%it as lua expr).\(%a.stub::as lua id) = \%class_expr.\(%a.stub::as lua id)" + %lines::add "\ + ..\(%it as lua expr).\(%a.stub::as lua id) = \%class_expr.\(%a.stub::as lua id)" %lua::add %lines joined with "\n" return %lua @@ -82,9 +83,7 @@ test: "set 1 =": "__newindex", size: "__len", iterate: "__ipairs", "iterate all": "__pairs" ((% as text like a dict)'s meaning) = ({}'s metatable).__tostring - -externally (..) - a class named %classname with %members ((initialize %it)'s meaning) +externally (a class named %classname with %members ((initialize %it)'s meaning)) \ ..means: %class = {__type: %classname} %class.__index = %class @@ -100,18 +99,22 @@ externally (..) rawset %its %key %value ..else: barf "Cannot set \%key, it's not one of the allowed member fields." + set %class's metatable to {..} - __tostring: (%class) -> %class.__type + __tostring: %class -> %class.__type __call: for (%class with %initial_values): if (%initial_values == (nil)): return %class set %initial_values's metatable to %class - if %initial_values.set_up: %initial_values::set up + if %initial_values.set_up: + %initial_values::set up return %initial_values + if ((initialize)'s meaning): initialize %class for %stub = %metamethod in %METAMETHOD_MAP: if %class.(%stub::as lua id): %class.%metamethod = %class.(%stub::as lua id) + return %class [..] @@ -123,6 +126,7 @@ externally (..) %body_lua = (%class_body as lua) %body_lua::remove free vars [%class_id] %body_lua::declare locals + return (..) Lua "\ ..\%class_id = a_class_named_1_with(\(quote %classname.stub), \(%members as lua)\(..) |
