aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBruce Hill <bruce@bruce-hill.com>2018-11-19 17:37:37 -0800
committerBruce Hill <bruce@bruce-hill.com>2018-11-19 17:37:37 -0800
commita89d69e843ba83df928051005d02a932a9981f46 (patch)
tree17f99cda2d4e5f0a7983ed14f4ac559b64944207
parent43ff3892f39188163446f1a00ee8d2aad59e0392 (diff)
Autoformatted/auto-upgraded.
-rw-r--r--compatibility/2.3.nom2
-rw-r--r--compatibility/2.4.nom2
-rw-r--r--compatibility/2.5.5.5.nom2
-rw-r--r--compatibility/2.5.nom2
-rw-r--r--compatibility/2.nom2
-rw-r--r--compatibility/3.5.5.6.nom2
-rw-r--r--compatibility/3.6.nom2
-rw-r--r--compatibility/3.7.nom2
-rw-r--r--compatibility/3.8.nom2
-rw-r--r--compatibility/3.nom2
-rw-r--r--compatibility/4.10.12.7.nom15
-rw-r--r--compatibility/4.11.nom14
-rw-r--r--compatibility/4.8.10.nom2
-rw-r--r--compatibility/4.9.nom2
-rw-r--r--compatibility/compatibility.nom4
-rw-r--r--core/collections.nom2
-rw-r--r--core/control_flow.nom4
-rw-r--r--core/coroutines.nom16
-rw-r--r--core/errors.nom2
-rw-r--r--core/id.nom2
-rw-r--r--core/io.nom2
-rw-r--r--core/math.nom26
-rw-r--r--core/metaprogramming.nom12
-rw-r--r--core/operators.nom6
-rw-r--r--core/text.nom3
-rw-r--r--examples/how_do_i.nom4
-rw-r--r--lib/base64.nom2
-rw-r--r--lib/consolecolor.nom2
-rw-r--r--lib/file_hash.nom4
-rw-r--r--lib/object.nom2
-rw-r--r--lib/os.nom30
-rw-r--r--lib/things.nom30
-rwxr-xr-xtools/autoformat.nom13
-rwxr-xr-xtools/find_action.nom9
-rwxr-xr-xtools/parse.nom7
-rw-r--r--tools/repl.nom4
-rwxr-xr-xtools/replace.nom4
-rwxr-xr-xtools/test.nom12
-rwxr-xr-xtools/upgrade.nom4
39 files changed, 134 insertions, 125 deletions
diff --git a/compatibility/2.3.nom b/compatibility/2.3.nom
index a07729c..1664429 100644
--- a/compatibility/2.3.nom
+++ b/compatibility/2.3.nom
@@ -1,4 +1,4 @@
-#!/usr/bin/env nomsu -V4.11
+#!/usr/bin/env nomsu -V4.11.12.8
#
This file defines upgrades from Nomsu <2.3 to Nomsu 2.3
diff --git a/compatibility/2.4.nom b/compatibility/2.4.nom
index ef78a89..dbc6517 100644
--- a/compatibility/2.4.nom
+++ b/compatibility/2.4.nom
@@ -1,4 +1,4 @@
-#!/usr/bin/env nomsu -V4.10.12.7
+#!/usr/bin/env nomsu -V4.11.12.8
#
This file defines upgrades from Nomsu <2.4 to Nomsu 2.4
diff --git a/compatibility/2.5.5.5.nom b/compatibility/2.5.5.5.nom
index 9bbee06..6da70d4 100644
--- a/compatibility/2.5.5.5.nom
+++ b/compatibility/2.5.5.5.nom
@@ -1,4 +1,4 @@
-#!/usr/bin/env nomsu -V4.10.12.7
+#!/usr/bin/env nomsu -V4.11.12.8
#
This file defines upgrades from Nomsu <2.5.5.5 to Nomsu 2.5.5.5
diff --git a/compatibility/2.5.nom b/compatibility/2.5.nom
index 816691e..a1a33b7 100644
--- a/compatibility/2.5.nom
+++ b/compatibility/2.5.nom
@@ -1,4 +1,4 @@
-#!/usr/bin/env nomsu -V4.10.12.7
+#!/usr/bin/env nomsu -V4.11.12.8
#
This file defines upgrades from Nomsu <2.5 to Nomsu 2.5
diff --git a/compatibility/2.nom b/compatibility/2.nom
index 2ca4526..311002d 100644
--- a/compatibility/2.nom
+++ b/compatibility/2.nom
@@ -1,4 +1,4 @@
-#!/usr/bin/env nomsu -V4.10.12.7
+#!/usr/bin/env nomsu -V4.11.12.8
#
This file defines upgrades from Nomsu 1 to Nomsu 2
diff --git a/compatibility/3.5.5.6.nom b/compatibility/3.5.5.6.nom
index aebd0a5..de6cc1f 100644
--- a/compatibility/3.5.5.6.nom
+++ b/compatibility/3.5.5.6.nom
@@ -1,4 +1,4 @@
-#!/usr/bin/env nomsu -V4.10.12.7
+#!/usr/bin/env nomsu -V4.11.12.8
#
This file defines upgrades from Nomsu <3.5.5.6 to Nomsu 3.5.5.6
diff --git a/compatibility/3.6.nom b/compatibility/3.6.nom
index 1a9edb1..fad8a32 100644
--- a/compatibility/3.6.nom
+++ b/compatibility/3.6.nom
@@ -1,4 +1,4 @@
-#!/usr/bin/env nomsu -V4.10.12.7
+#!/usr/bin/env nomsu -V4.11.12.8
#
This file defines upgrades from Nomsu <3.6 to 3.6
diff --git a/compatibility/3.7.nom b/compatibility/3.7.nom
index 874b113..26b643f 100644
--- a/compatibility/3.7.nom
+++ b/compatibility/3.7.nom
@@ -1,4 +1,4 @@
-#!/usr/bin/env nomsu -V4.10.12.7
+#!/usr/bin/env nomsu -V4.11.12.8
#
This file defines upgrades from Nomsu <3.7 to 3.7
diff --git a/compatibility/3.8.nom b/compatibility/3.8.nom
index 583b52b..d70e6e8 100644
--- a/compatibility/3.8.nom
+++ b/compatibility/3.8.nom
@@ -1,4 +1,4 @@
-#!/usr/bin/env nomsu -V4.10.12.7
+#!/usr/bin/env nomsu -V4.11.12.8
#
This file defines upgrades from Nomsu <3.8 to 3.8 (Text method changes)
diff --git a/compatibility/3.nom b/compatibility/3.nom
index 69f8d25..a1ce99b 100644
--- a/compatibility/3.nom
+++ b/compatibility/3.nom
@@ -1,4 +1,4 @@
-#!/usr/bin/env nomsu -V4.10.12.7
+#!/usr/bin/env nomsu -V4.11.12.8
#
This file defines upgrades from Nomsu <=2 to Nomsu 3
diff --git a/compatibility/4.10.12.7.nom b/compatibility/4.10.12.7.nom
index 2e42bdc..fe1511c 100644
--- a/compatibility/4.10.12.7.nom
+++ b/compatibility/4.10.12.7.nom
@@ -1,4 +1,4 @@
-#!/usr/bin/env nomsu -V4.10.12.7
+#!/usr/bin/env nomsu -V4.11.12.8
#
This file defines upgrades from Nomsu <4.10.12.7 to 4.10.12.7
use "compatibility/compatibility.nom"
@@ -56,20 +56,25 @@ upgrade %tree to "4.10.12.7" as:
if ((%first_chunk.%i.type == "Action") and (%first_chunk.%i.stub == "use")):
%has_use = (yes)
..else:
- if %has_use: go to (insert chunk)
+ if %has_use:
+ go to (insert chunk)
%i += 1
return
-
=== (insert chunk) ===
[%chunk1, %chunk2] = [..]
SyntaxTree {type: "Block", source: %first_chunk.source}
SyntaxTree {type: "Block", source: %first_chunk.source}
+
for %j in 1 to (%i - 1):
%chunk1.%j = %first_chunk.%j
+
for %j in %i to (size of %first_chunk):
%chunk2.(%j - %i + 1) = %first_chunk.%j
-
- %new_tree = (SyntaxTree {source: %tree.source, type: "FileChunks", 1: %chunk1, 2: %chunk2})
+
+ %new_tree = (..)
+ SyntaxTree {source: %tree.source, type: "FileChunks", 1: %chunk1, 2: %chunk2}
+
for %i in 2 to (size of %tree):
%new_tree.(%i + 1) = %tree.%i
+
return %new_tree
diff --git a/compatibility/4.11.nom b/compatibility/4.11.nom
index 05edfea..71bf3ee 100644
--- a/compatibility/4.11.nom
+++ b/compatibility/4.11.nom
@@ -1,4 +1,4 @@
-#!/usr/bin/env nomsu -V4.11
+#!/usr/bin/env nomsu -V4.11.12.8
#
This file defines upgrades from Nomsu <4.11 to Nomsu 4.11
(overhaul of function literals, deleting (if all of ...), etc. shorthand)
@@ -14,7 +14,6 @@ upgrade action "call 1 with" to "4.11" via (..)
for %arg in %tree.4 at %i:
%tree2.(%i + 1) = %arg
return (SyntaxTree %tree2)
-
upgrade action (-> %yield_value) to "4.11" as (yield %yield_value)
# Replace set {%x:1, %y:2} with [%x, %y] = [1, 2]
@@ -29,10 +28,15 @@ upgrade action "set" to "4.11" via (..)
return (SyntaxTree {type: "Action", source: %tree.source, 1: %lhs, 2: "=", 3: %rhs})
# Changing filesystem API:
-upgrade action (for file %f in %path %body) to "4.11" as (for %f in (files for %path) %body)
-upgrade action (%expr for file %f in %path) to "4.11" as [: for %f in (files for %path): add %expr]
+upgrade action (for file %f in %path %body) to "4.11" as (..)
+ for %f in (files for %path) %body
+
+upgrade action (%expr for file %f in %path) to "4.11" as [..]
+ : for %f in (files for %path): add %expr
+
upgrade action (line %n in %text) to "4.11" as (%text::line %n)
-upgrade action (line number of %pos in %text) to "4.11" as (%text::line number at %pos)
+upgrade action (line number of %pos in %text) to "4.11" as (..)
+ %text::line number at %pos
# Deprecating shorthand functions:
upgrade action [if all of %items %body, if all of %items then %body] to "4.11" as (..)
diff --git a/compatibility/4.8.10.nom b/compatibility/4.8.10.nom
index 9049830..f20886f 100644
--- a/compatibility/4.8.10.nom
+++ b/compatibility/4.8.10.nom
@@ -1,4 +1,4 @@
-#!/usr/bin/env nomsu -V4.10.12.7
+#!/usr/bin/env nomsu -V4.11.12.8
#
This file defines upgrades from Nomsu <4.8.10 to 4.8.10 (renaming "action" -> "means")
use "compatibility/compatibility.nom"
diff --git a/compatibility/4.9.nom b/compatibility/4.9.nom
index ab58a86..5dc0d29 100644
--- a/compatibility/4.9.nom
+++ b/compatibility/4.9.nom
@@ -1,4 +1,4 @@
-#!/usr/bin/env nomsu -V4.10.12.7
+#!/usr/bin/env nomsu -V4.11.12.8
#
This file defines upgrades from Nomsu <4.9 to 4.9
use "compatibility/compatibility.nom"
diff --git a/compatibility/compatibility.nom b/compatibility/compatibility.nom
index 23ec703..5be8eeb 100644
--- a/compatibility/compatibility.nom
+++ b/compatibility/compatibility.nom
@@ -1,4 +1,4 @@
-#!/usr/bin/env nomsu -V4.10.12.7
+#!/usr/bin/env nomsu -V4.11.12.8
#
This file contains code for defining ways to upgrade code between different versions
of Nomsu.
@@ -105,7 +105,7 @@ externally (%tree upgraded) means (..)
%tree upgraded from (%tree.version or (Nomsu version)) to (Nomsu version)
externally (use %path from version %version) means:
- for file %filename in %path:
+ for %filename in (files for %path):
if (=lua "LOADED[\%filename]"):
do next %filename
%file = (read file %filename)
diff --git a/core/collections.nom b/core/collections.nom
index a586882..9272d13 100644
--- a/core/collections.nom
+++ b/core/collections.nom
@@ -1,4 +1,4 @@
-#!/usr/bin/env nomsu -V4.10.12.7
+#!/usr/bin/env nomsu -V4.11.12.8
#
This file contains code that supports manipulating and using collections like lists
and dictionaries.
diff --git a/core/control_flow.nom b/core/control_flow.nom
index 9432a92..27ff96d 100644
--- a/core/control_flow.nom
+++ b/core/control_flow.nom
@@ -1,4 +1,4 @@
-#!/usr/bin/env nomsu -V4.10.12.7
+#!/usr/bin/env nomsu -V4.11.12.8
#
This file contains compile-time actions that define basic control flow structures
like "if" statements and loops.
@@ -54,7 +54,7 @@ test:
..all compile to:
# If %when_true_expr is guaranteed to be truthy, we can use Lua's idiomatic
equivalent of a conditional expression: (cond and if_true or if_false)
- if {"Text", "List", "Dict", "Number"}.(%when_true_expr.type):
+ if {Text, List, Dict, Number}.(%when_true_expr.type):
return (Lua "(\(%condition as lua expr) and \(%when_true_expr as lua expr) or \(%when_false_expr as lua expr))")
..else:
# Otherwise, need to do an anonymous inline function (yuck, too bad lua
diff --git a/core/coroutines.nom b/core/coroutines.nom
index 0a625c2..73b6854 100644
--- a/core/coroutines.nom
+++ b/core/coroutines.nom
@@ -1,4 +1,4 @@
-#!/usr/bin/env nomsu -V4.10.12.7
+#!/usr/bin/env nomsu -V4.11.12.8
#
This file defines the code that creates and manipulates coroutines
@@ -13,16 +13,13 @@ test:
->:
yield 4
yield 5
- repeat 3 times: yield 6
-
+ repeat 3 times:
+ yield 6
%nums = []
for % in coroutine %co:
%nums::add %
-
assume (%nums == [4, 5, 6, 6, 6]) or barf "Coroutine iteration failed"
-
-
- %d = {x:0}
+ %d = {x: 0}
%co2 = (..)
coroutine:
%d.x += 1
@@ -30,12 +27,9 @@ test:
%d.x += 1
yield
%d.x += 1
- repeat while ((coroutine status of %co2) != "dead"):
- resume %co2
+ repeat while ((coroutine status of %co2) != "dead"): resume %co2
assume %d.x == 3
-
(coroutine %body) parses as (coroutine from (-> %body))
-
(for % in coroutine %co %body) compiles to "\
..for \(% as lua expr) in coroutine_wrap(\(%co as lua expr)) do
\(%body as lua)
diff --git a/core/errors.nom b/core/errors.nom
index 12a5b29..aa5346b 100644
--- a/core/errors.nom
+++ b/core/errors.nom
@@ -1,4 +1,4 @@
-#!/usr/bin/env nomsu -V4.10.12.7
+#!/usr/bin/env nomsu -V4.11.12.8
#
This file contains basic error reporting code
diff --git a/core/id.nom b/core/id.nom
index 7de38f9..9ee961d 100644
--- a/core/id.nom
+++ b/core/id.nom
@@ -1,4 +1,4 @@
-#!/usr/bin/env nomsu -V4.10.12.7
+#!/usr/bin/env nomsu -V4.11.12.8
#
A simple UUID function based on RFC 4122: http://www.ietf.org/rfc/rfc4122.txt
diff --git a/core/io.nom b/core/io.nom
index c667466..04efb91 100644
--- a/core/io.nom
+++ b/core/io.nom
@@ -1,4 +1,4 @@
-#!/usr/bin/env nomsu -V4.10.12.7
+#!/usr/bin/env nomsu -V4.11.12.8
#
This file contains basic input/output code
diff --git a/core/math.nom b/core/math.nom
index 38fb984..ae01620 100644
--- a/core/math.nom
+++ b/core/math.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 common math literals and functions
@@ -72,16 +72,16 @@ externally [all of %items, all %items] all mean:
#[all of %items, all %items] all compile to:
unless (%items.type is "List"):
- return \(all of %items)
+ return \(all of %items)
if ((size of %items) == 0):
- return (Lua "true")
+ return (Lua "true")
%lua = (Lua "(")
%lua::add [: for % in %items: add (% as lua expr)] joined with " and "
%lua::append ")"
return %lua
-
+
[not all of %items, not all %items] all parse as (not (all of %items))
externally [any of %items, any %items] all mean:
for % in %items:
@@ -91,16 +91,16 @@ externally [any of %items, any %items] all mean:
#[any of %items, any %items] all compile to:
unless (%items.type is "List"):
- return \(any of %items)
+ return \(any of %items)
if ((size of %items) == 0):
- return (Lua "false")
+ return (Lua "false")
%lua = (Lua "(")
%lua::add [: for % in %items: add (% as lua expr)] joined with " or "
%lua::append ")"
return %lua
-
+
[none of %items, none %items] all parse as (not (any of %items))
# Sum/product
@@ -112,16 +112,16 @@ externally [sum of %items, sum %items] all mean:
#[sum of %items, sum %items] all compile to:
unless (%items.type is "List"):
- return \(sum of %items)
+ return \(sum of %items)
if ((size of %items) == 0):
- return (Lua "0")
+ return (Lua "0")
%lua = (Lua "(")
%lua::add [: for % in %items: add (% as lua expr)] joined with " + "
%lua::append ")"
return %lua
-
+
externally [product of %items, product %items] all mean:
%prod = 1
for % in %items:
@@ -130,16 +130,16 @@ externally [product of %items, product %items] all mean:
#[product of %items, product %items] all compile to:
unless (%items.type is "List"):
- return \(product of %items)
+ return \(product of %items)
if ((size of %items) == 0):
- return (Lua "1")
+ return (Lua "1")
%lua = (Lua "(")
%lua::add [: for % in %items: add (% as lua expr)] joined with " * "
%lua::append ")"
return %lua
-
+
externally [avg of %items, average of %items] all mean (..)
(sum of %items) / (size of %items)
diff --git a/core/metaprogramming.nom b/core/metaprogramming.nom
index fe97527..c89b1df 100644
--- a/core/metaprogramming.nom
+++ b/core/metaprogramming.nom
@@ -1,4 +1,4 @@
-#!/usr/bin/env nomsu -V4.10.12.7
+#!/usr/bin/env nomsu -V4.11.12.8
#
This File contains actions for making actions and compile-time actions and some helper
functions to make that easier.
@@ -253,16 +253,16 @@ test:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
[%action parses as %body] all parse as ([%action] all parse as %body)
+
#(%tree as lua expr) compiles to "compile(\(=lua "compile(\%tree, true)"), true)"
externally (%tree as lua expr) means:
lua> "\
..local tree_lua = compile(\%tree)
if \%tree.type == 'Block' then
- tree_lua = LuaCode:from(\%tree.source, '(function()\n ', tree_lua, '\nend)()')
+ tree_lua = LuaCode:from(\%tree.source, '(function()\\n ', tree_lua, '\\nend)()')
end
return tree_lua"
-
externally [%var as lua identifier, %var as lua id] all mean:
lua> "\
..if lua_type_of(\%var) == 'string' then return \%var:as_lua_id()
@@ -283,8 +283,8 @@ test:
assume (extra args 1 2 3) == [1, 2, 3]
(third arg (*extra arguments*)) means (select 3 (*extra arguments*))
assume (third arg 5 6 7 8) == 7
-(*extra arguments*) compiles to "..."
+(*extra arguments*) compiles to "..."
(% is syntax tree) compiles to "SyntaxTree:is_instance(\(% as lua expr))"
externally (% is %kind syntax tree) means (..)
=lua "SyntaxTree:is_instance(\%) and \%.type == \%kind"
@@ -394,8 +394,10 @@ test:
..compile(\(%block as lua))"
test:
- (foo) means: return 100 200 300
+ (foo) means:
+ return 100 200 300
assume (select 2 (foo)) == 200
+
# 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 (*extra arguments*)) compiles to:
diff --git a/core/operators.nom b/core/operators.nom
index 2f79b8f..1a28a6a 100644
--- a/core/operators.nom
+++ b/core/operators.nom
@@ -1,4 +1,4 @@
-#!/usr/bin/env nomsu -V4.10.12.7
+#!/usr/bin/env nomsu -V4.11.12.8
#
This file contains definitions of operators like "+" and "and".
@@ -51,7 +51,8 @@ test:
if #\%value ~= #\%var then
compile_error_at(\%value,
"This assignment has too "..(#\%value > #\%var and "many" or "few").." values.",
- "Make sure it has the same number of values on the left and right hand side of the '=' operator.")
+ "Make sure it has the same number of values on the left and right hand side of the '\
+ ..=' operator.")
end
for i, \%val in ipairs(\%value) do
if i > 1 then lua:append(", ") end
@@ -149,7 +150,6 @@ test:
assume (0 <= (one) <= 2) or barf "Three-way chained comparison failed."
assume (%calls == 1) or barf "\
..Three-way comparison evaluated middle value multiple times"
-
(%x < %y < %z) parses as (((%a %b %c) -> ((%a < %b) and (%b < %c))) %x %y %z)
(%x <= %y < %z) parses as (((%a %b %c) -> ((%a <= %b) and (%b < %c))) %x %y %z)
(%x < %y <= %z) parses as (((%a %b %c) -> ((%a < %b) and (%b <= %c))) %x %y %z)
diff --git a/core/text.nom b/core/text.nom
index 62b6656..1245235 100644
--- a/core/text.nom
+++ b/core/text.nom
@@ -1,4 +1,4 @@
-#!/usr/bin/env nomsu -V4.10.12.7
+#!/usr/bin/env nomsu -V4.11.12.8
#
This file contains some definitions of text escape sequences, including ANSI console
color codes.
@@ -50,6 +50,7 @@ test:
test:
assume (0xDEADBEEF as hex) == "0xDEADBEEF"
+
externally (%num as hex) means:
if (%num < 0):
return ("-0x%X"::formatted with (- %num))
diff --git a/examples/how_do_i.nom b/examples/how_do_i.nom
index bae1379..39e9bdb 100644
--- a/examples/how_do_i.nom
+++ b/examples/how_do_i.nom
@@ -1,4 +1,4 @@
-#!/usr/bin/env nomsu -V4.10.12.7
+#!/usr/bin/env nomsu -V4.11.12.8
# How do I...
# Write a comment? Put a # and go till the end of the line
# How do I write a multi-line comment?
@@ -65,7 +65,7 @@ say "\
Similarly, you can put a long interpolated indented value like: \(..)
1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9
.. between a backslash and two periods."
-
+
say "Single-line text can contain escape sequences like \", \\, \000, and \n"
# How do I define a list?
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.
diff --git a/lib/os.nom b/lib/os.nom
index 5fb2a1f..9f9f637 100644
--- a/lib/os.nom
+++ b/lib/os.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 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)\(..)
diff --git a/tools/autoformat.nom b/tools/autoformat.nom
index 8626c91..96b732b 100755
--- a/tools/autoformat.nom
+++ b/tools/autoformat.nom
@@ -1,7 +1,7 @@
-#!/usr/bin/env nomsu -V4.10.12.7
+#!/usr/bin/env nomsu -V4.11.12.8
#
Auto-format Nomsu code. Usage:
- nomsu tools/autoformat.nom [-i] file1 file2 directory1 ...
+ nomsu tools/autoformat.nom [-i] file1 file2 directory1 ...
If the first argument is "-i", modifications will be performed in-place. Otherwise,
the formatted code will be printed.
@@ -16,9 +16,12 @@ if (%args.1 is "-i"):
%args::remove index 1
for %path in %args:
- if (%path == "-"): %path = "stdin"
- for file %filename in %path:
- unless ((%filename::matches "%.nom$") or (%filename == "stdin")): do next %filename
+ if (%path == "-"):
+ %path = "stdin"
+
+ for %filename in (files for %path):
+ unless ((%filename::matches "%.nom$") or (%filename == "stdin")):
+ do next %filename
%contents = (read file %filename)
%code = (NomsuCode from (Source %filename 1 (size of %contents)) %contents)
%tree = (%code parsed)
diff --git a/tools/find_action.nom b/tools/find_action.nom
index 1b7c4e1..c6cbe36 100755
--- a/tools/find_action.nom
+++ b/tools/find_action.nom
@@ -1,4 +1,4 @@
-#!/usr/bin/env nomsu -V4.10.12.7
+#!/usr/bin/env nomsu -V4.11.12.8
#
Find an action by its stub. Usage:
nomsu tools/find_action.nom "foo %" file1 file2 directory1 ...
@@ -13,9 +13,12 @@ use "lib/consolecolor.nom"
say "Looking for stub: \%stub..."
for % in 2 to (size of (command line args)):
for %filename in (files for (command line args).%):
- if (%filename == "-"): %filename = "stdin"
+ if (%filename == "-"):
+ %filename = "stdin"
+
unless ((%filename == "stdin") or (%filename::matches "%.nom$")):
do next %filename
+
%file = (read file %filename)
%code = (NomsuCode from (%Source %filename 1 (size of %file)) %file)
try:
@@ -30,7 +33,7 @@ for % in 2 to (size of (command line args)):
%results = []
for %t in recursive %tree:
if ((%t is "Action" syntax tree) and (%t.stub is %stub)):
- %line_num = (line number of %t.source.start in %file)
+ %line_num = (%file::line number at %t.source.start)
%results::add {..}
line: %line_num, text: "\(blue "\%filename:\%line_num:")\n\(yellow (source lines of %t))"
diff --git a/tools/parse.nom b/tools/parse.nom
index 10d4dde..9e43c88 100755
--- a/tools/parse.nom
+++ b/tools/parse.nom
@@ -1,4 +1,4 @@
-#!/usr/bin/env nomsu -V4.10.12.7
+#!/usr/bin/env nomsu -V4.11.12.8
#
Tool to print out a parse tree of files in an easy-to-read format. Usage:
nomsu tools/parse.nom file1 file2 directory1 ...
@@ -37,9 +37,12 @@ externally (print tree %t at indent %indent) means:
for %path in (command line args):
for %filename in (files for %path):
- if (%filename == "-"): %filename = "stdin"
+ if (%filename == "-"):
+ %filename = "stdin"
+
unless ((%filename == "stdin") or (%filename::matches "%.nom$")):
do next %filename
+
%text = (read file %filename)
%nomsu = (NomsuCode from (Source %filename 1 (size of %text)) %text)
%tree = (%nomsu parsed)
diff --git a/tools/repl.nom b/tools/repl.nom
index daa39d0..39d6360 100644
--- a/tools/repl.nom
+++ b/tools/repl.nom
@@ -1,7 +1,7 @@
-#!/usr/bin/env nomsu -V4.10.12.7
+#!/usr/bin/env nomsu -V4.11.12.8
#
This file defines a Read-Evaluate-Print-Loop (REPL) for Nomsu
-
+
use "lib/consolecolor.nom"
use "lib/os.nom"
diff --git a/tools/replace.nom b/tools/replace.nom
index ffd96c1..1ec8ecc 100755
--- a/tools/replace.nom
+++ b/tools/replace.nom
@@ -1,4 +1,4 @@
-#!/usr/bin/env nomsu -V4.10.12.7
+#!/usr/bin/env nomsu -V4.11.12.8
#
Tool to find and replace one tree with another.
nomsu tools/replace.nom [-i] tree_to_replace replacement file1 file2 directory1 ...
@@ -22,7 +22,7 @@ if ((size of %args) < 3):
%pattern = (parse (%args::remove index 1))
%replacement = (parse (%args::remove index 1))
for %path in %args:
- for file %filename in %path:
+ for %filename in (files for %path):
unless (any [%filename::matches "%.nom$", %filename == "-", %filename == "stdin"]):
do next %filename
%tree = (parse (read file %filename) from %filename)
diff --git a/tools/test.nom b/tools/test.nom
index 32c9b7a..bdbec54 100755
--- a/tools/test.nom
+++ b/tools/test.nom
@@ -1,4 +1,4 @@
-#!/usr/bin/env nomsu -V4.10.12.7
+#!/usr/bin/env nomsu -V4.11.12.8
#
Tool to run all tests in a file (i.e. the code block inside a call to 'test %'). Usage:
nomsu tools/test.nom file1 file2 directory1 ...
@@ -17,11 +17,13 @@ if (%args.1 == "-v"):
:
for %path in (command line args):
for %filename in (files for %path):
- if (%filename == "-"): %filename = "stdin"
- if ((%filename::matches "%.nom$") or (%filename == "stdin")):
- add %filename
+ if (%filename == "-"):
+ %filename = "stdin"
+ if ((%filename::matches "%.nom$") or (%filename == "stdin")): add %filename
+
# Make sure all the files get run
-for %filename in %to_run: use %filename
+for %filename in %to_run:
+ use %filename
%tests = {: for %s = %t in (tests): add (=lua "Source:from_string(\%s)") = %t}
for %filename in %to_run:
%file_tests = []
diff --git a/tools/upgrade.nom b/tools/upgrade.nom
index 5f50f73..56d67a5 100755
--- a/tools/upgrade.nom
+++ b/tools/upgrade.nom
@@ -1,4 +1,4 @@
-#!/usr/bin/env nomsu -V4.10.12.7
+#!/usr/bin/env nomsu -V4.11.12.8
#
Tool to automatically update code from old versions of Nomsu. Usage:
nomsu tools/upgrade.nom [-i] file1 file2 directory1 ...
@@ -38,7 +38,7 @@ repeat:
else: stop
for %path in %args:
- for file %filename in %path:
+ for %filename in (files for %path):
unless (%filename::matches "%.nom$"): do next %filename
%file = (read file %filename)
%code = (NomsuCode from (%Source %filename 1 (size of %file)) %file)