diff options
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/base64.nom | 11 | ||||
| -rw-r--r-- | lib/consolecolor.nom | 10 | ||||
| -rw-r--r-- | lib/file_hash.nom | 24 | ||||
| -rw-r--r-- | lib/object.nom | 14 | ||||
| -rw-r--r-- | lib/os.nom | 30 | ||||
| -rw-r--r-- | lib/training_wheels.nom | 2 | ||||
| -rw-r--r-- | lib/version.nom | 2 |
7 files changed, 44 insertions, 49 deletions
diff --git a/lib/base64.nom b/lib/base64.nom index 366ac3e..8fc4e6b 100644 --- a/lib/base64.nom +++ b/lib/base64.nom @@ -1,4 +1,4 @@ -#!/usr/bin/env nomsu -V3.8.7.6 +#!/usr/bin/env nomsu -V4.8.8.6 # This file defines actions for encoding/decoding base 64, as specified in: https://tools.ietf.org/html/rfc4648 @@ -11,13 +11,8 @@ test: %cases = ["", "Zg==", "Zm8=", "Zm9v", "Zm9vYg==", "Zm9vYmE=", "Zm9vYmFy"] for %len = %encoded in %cases: %plain = "foobar".[1, %len - 1] - assume ((base64 %plain) == %encoded) or barf ".." - \(quote %plain) base64 encoded to \(quote (base64 %plain)) \ - ..instead of \(quote %encoded) - - assume ((base64 decode %encoded) == %plain) or barf ".." - \(quote %encoded) base64 decoded to \(quote (base64 decode %encoded)) \ - ..instead of \(quote %plain) + assume (base64 %plain) == %encoded + assume (base64 decode %encoded) == %plain action [base64 %str, base64 encode %str, %str base64]: %chars = [] for %i in 1 to (size of %str) via 3: diff --git a/lib/consolecolor.nom b/lib/consolecolor.nom index c86e6d1..ba40bda 100644 --- a/lib/consolecolor.nom +++ b/lib/consolecolor.nom @@ -1,4 +1,4 @@ -#!/usr/bin/env nomsu -V3.8.7.6 +#!/usr/bin/env nomsu -V4.8.8.6 # This file defines actions for ANSI console color escape codes. @@ -14,9 +14,9 @@ test: for %name = %colornum in %colors: with {%escapecode:"\027[\(%colornum)m"}: - run ".." - compile [\%name] to (..) + run "\ + ..compile [\%name] to (..) Lua value (quote \(quote %escapecode)) compile [\%name %text] to (..) - Lua value ".." - (\\(quote \(quote %escapecode))..\\(%text as lua expr).."\\27[0m") + Lua value "\\ + ..(\\(quote \(quote %escapecode))..\\(%text as lua expr).."\\27[0m")"" diff --git a/lib/file_hash.nom b/lib/file_hash.nom index 5553b35..6fdb2f4 100644 --- a/lib/file_hash.nom +++ b/lib/file_hash.nom @@ -1,4 +1,4 @@ -#!/usr/bin/env nomsu -V3.8.7.6 +#!/usr/bin/env nomsu -V4.8.8.6 # This file defines some actions for hashing files and looking up files by hash. @@ -8,21 +8,21 @@ use "lib/base64.nom" lua> "local \%use_sha1, \%hashlib = pcall(require, 'openssl.digest')" test: - assume ((hash "hello world") == (hash "hello world")) - assume ((hash "hello world") != (hash "goodbye")) or barf ".." - Hash collision: + assume (hash "hello world") == (hash "hello world") + assume ((hash "hello world") != (hash "goodbye")) or barf "\ + ..Hash collision: (hash "hello world") = \(hash "hello world") - (hash "goodbye") = \(hash "goodbye") + (hash "goodbye") = \(hash "goodbye")" assume (..) (..) - hash ".." - This is a really long string meant to stress test the hashing function and - ensure that it's not overflowing with long inputs. + hash "\ + ..This is a really long string meant to stress test the hashing function and + ensure that it's not overflowing with long inputs." ..!= "inf" - assume ((hash "\000") != (hash "\000\000\000\000\000")) or barf ".." - Incorrect hashing of null strings + assume ((hash "\000") != (hash "\000\000\000\000\000")) or barf "\ + ..Incorrect hashing of null strings" if %use_sha1: assume ((hash "hello world") == "Kq5sNclPz7QV2+lfQIuc6R7oRu0=") if %use_sha1: @@ -31,8 +31,8 @@ if %use_sha1: return (base64 %hash) ..else: # TODO: remove warning? - say ".." - \027[31;1mWARNING: OpenSSL module not found. Defaulting to a non-cryptographically secure hash function.\027[0m + say "\ + ..\027[31;1mWARNING: OpenSSL module not found. Defaulting to a non-cryptographically secure hash function.\027[0m" action [hash %]: %bytes = (%::bytes) %hash = (%bytes.1 << 7) diff --git a/lib/object.nom b/lib/object.nom index 1645a28..88b9d1e 100644 --- a/lib/object.nom +++ b/lib/object.nom @@ -1,4 +1,4 @@ -#!/usr/bin/env nomsu -V3.8.7.6 +#!/usr/bin/env nomsu -V4.8.8.6 # This file contains the implementation of an Object-Oriented programming system. @@ -43,8 +43,8 @@ test: with {%d:new Dog {barks:2}}: assume ((%d::bark) == "Bark! Bark!") compile [my action %actions %body] to: - lua> ".." - local fn_name = \%actions[1].stub:as_lua_id() + lua> "\ + ..local fn_name = \%actions[1].stub:as_lua_id() local \%args = table.map(\%actions[1]:get_args(), function(a) return tostring(nomsu:compile(a)) end) table.insert(\%args, \(\%me as lua id)) local lua = LuaCode(tree.source, "class.", fn_name, " = ", \(..) @@ -66,12 +66,12 @@ compile [my action %actions %body] to: lua:append(")\\nend") end end - return lua + return lua" compile [object %classname extends %parent %class_body] to: return (..) - Lua ".." - do + Lua "\ + ..do local class = {name=\(%classname as lua expr)} setmetatable(class, { __index=\(%parent as lua expr), @@ -106,7 +106,7 @@ compile [object %classname extends %parent %class_body] to: for stub,metamethod in pairs(metamethod_map) do class[metamethod] = class[stub:as_lua_id()] end - end + end" parse [object %classname %class_body] as (..) object %classname extends (nil) %class_body @@ -1,4 +1,4 @@ -#!/usr/bin/env nomsu -V3.8.7.6 +#!/usr/bin/env nomsu -V4.8.8.6 # This file defines some actions that interact with the operating system and filesystem. @@ -9,11 +9,11 @@ action [path of Nomsu file %filename]: barf "Could not find file: \%filename" action [sh> %cmd]: - lua> ".." - local result = io.popen(\%cmd) + lua> "\ + ..local result = io.popen(\%cmd) local contents = result:read("*a") result:close() - return contents + return contents" test: read file "lib/os.nom" @@ -22,39 +22,39 @@ action [read file %filename] (=lua "Files.read(\%filename)") test: for file %f in "core": do nothing compile [for file %f in %path %body] to (..) - Lua ".." - for i,\(%f as lua expr) in Files.walk(\(%path as lua expr)) do + Lua "\ + ..for i,\(%f as lua expr) in Files.walk(\(%path as lua expr)) do \(%body as lua statements) \(compile as (===next %f ===)) end - \(compile as (===stop %f ===)) + \(compile as (===stop %f ===))" compile [%expr for file %f in %path] to (..) - Lua value ".." - (function() + Lua value "\ + ..(function() local ret = _List{} for i,\(%f as lua expr) in Files.walk(\(%path as lua expr)) do ret[#ret+1] = \(%expr as lua statements) end return ret - end)() + end)()" action [..] write to file %filename %text, to file %filename write %text write %text to file %filename ..: assume (%filename != "stdin") or barf "Cannot write to stdin" - lua> ".." - local file = io.open(\%filename, 'w') + lua> "\ + ..local file = io.open(\%filename, 'w') file:write(\%text) - file:close() + file:close()" test: - assume ((line number of 3 in "x\ny") == 2) + assume (line number of 3 in "x\ny") == 2 action [line number of %pos in %str] (=lua "Files.get_line_number(\%str, \%pos)") test: - assume ((line 2 in "one\ntwo\nthree") == "two") + assume (line 2 in "one\ntwo\nthree") == "two" action [line %line_num in %str] (=lua "Files.get_line(\%str, \%line_num)") test: diff --git a/lib/training_wheels.nom b/lib/training_wheels.nom index 8e197c4..6155069 100644 --- a/lib/training_wheels.nom +++ b/lib/training_wheels.nom @@ -1,4 +1,4 @@ -#!/usr/bin/env nomsu -V3.8.7.6 +#!/usr/bin/env nomsu -V4.8.8.6 # This file contains a set of definitions that bring some familiar language features from other languages into nomsu (e.g. "||" and "continue") diff --git a/lib/version.nom b/lib/version.nom index 3c876b8..afb9e14 100644 --- a/lib/version.nom +++ b/lib/version.nom @@ -1,3 +1,3 @@ -#!/usr/bin/env nomsu -V3.8.7.6 +#!/usr/bin/env nomsu -V4.8.8.6 # This file sets the current library version. lua> "NOMSU_LIB_VERSION = 6" |
