aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBruce Hill <bruce@bruce-hill.com>2019-03-27 15:22:46 -0700
committerBruce Hill <bruce@bruce-hill.com>2019-03-27 15:22:46 -0700
commita1849da175765350e013bdeecfa4e0ad3c066937 (patch)
tree616a115790271757148044e2b3228fb715c00726
parentbb07e6724118c431c3beed4060776678128905a1 (diff)
Autoformat (mostly just to do with the new
blank-line-after-end-of-multi-indent-block rule
-rw-r--r--examples/how_do_i.nom6
-rw-r--r--lib/base64/init.nom2
-rw-r--r--lib/commandline/init.nom1
-rw-r--r--lib/compatibility/2.3.nom1
-rw-r--r--lib/compatibility/2.4.nom13
-rw-r--r--lib/compatibility/2.5.5.5.nom1
-rw-r--r--lib/compatibility/2.5.nom1
-rw-r--r--lib/compatibility/2.nom4
-rw-r--r--lib/compatibility/3.5.5.6.nom1
-rw-r--r--lib/compatibility/3.6.nom1
-rw-r--r--lib/compatibility/3.7.nom1
-rw-r--r--lib/compatibility/3.8.nom1
-rw-r--r--lib/compatibility/3.nom1
-rw-r--r--lib/compatibility/4.10.12.7.nom4
-rw-r--r--lib/compatibility/4.11.nom3
-rw-r--r--lib/compatibility/4.12.nom1
-rw-r--r--lib/compatibility/4.8.10.nom2
-rw-r--r--lib/compatibility/4.9.nom2
-rw-r--r--lib/compatibility/6.15.9.nom3
-rw-r--r--lib/compatibility/6.15.nom1
-rw-r--r--lib/compatibility/compatibility.nom6
-rw-r--r--lib/compatibility/init.nom1
-rw-r--r--lib/consolecolor/init.nom1
-rw-r--r--lib/core/collections.nom3
-rw-r--r--lib/core/control_flow.nom3
-rw-r--r--lib/core/coroutines.nom3
-rw-r--r--lib/core/errors.nom5
-rw-r--r--lib/core/id.nom1
-rw-r--r--lib/core/init.nom1
-rw-r--r--lib/core/io.nom1
-rw-r--r--lib/core/math.nom6
-rw-r--r--lib/core/metaprogramming.nom3
-rw-r--r--lib/core/operators.nom7
-rw-r--r--lib/core/text.nom1
-rw-r--r--lib/core/things.nom3
-rw-r--r--lib/core/time.nom5
-rw-r--r--lib/file_hash/init.nom2
-rw-r--r--lib/filesystem/init.nom1
-rw-r--r--lib/progressbar/init.nom4
-rw-r--r--lib/shell/init.nom1
-rwxr-xr-xlib/tools/format.nom1
-rwxr-xr-xlib/tools/install.nom2
-rw-r--r--lib/tools/list.nom1
-rwxr-xr-xlib/tools/parse.nom1
-rwxr-xr-xlib/tools/repl.nom2
-rwxr-xr-xlib/tools/replace.nom5
-rwxr-xr-xlib/tools/test.nom1
-rwxr-xr-xlib/tools/tutorial.nom2
-rwxr-xr-xlib/tools/uninstall.nom1
-rwxr-xr-xlib/tools/upgrade.nom5
50 files changed, 60 insertions, 69 deletions
diff --git a/examples/how_do_i.nom b/examples/how_do_i.nom
index cdd8a07..9cfc0dc 100644
--- a/examples/how_do_i.nom
+++ b/examples/how_do_i.nom
@@ -1,5 +1,4 @@
#!/usr/bin/env nomsu -V7.0.0
-
### How do I...
### Write a comment? Put a # and go till the end of the line
### How do I write a multi-line comment?
@@ -199,6 +198,7 @@ say both "Hello" and also "world!"
$f2 = $tmp
if ($f2 > $n):
return $f2
+
say (first fibonacci above 10)
### Actions can have aliases, which may or may not have the arguments in different order
@@ -290,6 +290,7 @@ say "The square root of 2 is \(square root of 2)"
")
..else:
return (Lua "-- (debug code removed for production)")
+
$DEBUG_ENABLED = (yes)
### Constants can be defined as macros
@@ -318,6 +319,7 @@ debug only:
$key = ($key_fn $item)
if (($best == (nil)) or ($key > $best_key)):
[$best, $best_key] = [$item, $key]
+
return $best
### Function literals look like: $x -> ($x * $x)
@@ -338,6 +340,7 @@ say (best of [2, -3, 4, -8] according to $($ squared))
$key = $key_expr
if (($best == (nil)) or ($key > $best_key)):
[$best, $best_key] = [$item, $key]
+
return $best
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
@@ -352,4 +355,5 @@ say
$key = ($x * $x)
if (($best == (nil)) or ($key > $best_key)):
[$best, $best_key] = [$x, $key]
+
return $best \ No newline at end of file
diff --git a/lib/base64/init.nom b/lib/base64/init.nom
index 9028c99..6ae341b 100644
--- a/lib/base64/init.nom
+++ b/lib/base64/init.nom
@@ -1,5 +1,4 @@
#!/usr/bin/env nomsu -V7.0.0
-
###
This file defines actions for encoding/decoding base 64, as specified in:
https://tools.ietf.org/html/rfc4648
@@ -37,6 +36,7 @@ external:
$chars, add $b64_chars.((($bytes.1 & 3) << 4) + 1)
$chars, add "="
$chars, add "="
+
return ($chars, joined)
(chr $) means (=lua "string.char(\$)")
[decode base64 $str, $str base64 decoded, base64 decode $str] all mean:
diff --git a/lib/commandline/init.nom b/lib/commandline/init.nom
index 1451630..16110ef 100644
--- a/lib/commandline/init.nom
+++ b/lib/commandline/init.nom
@@ -1,5 +1,4 @@
#!/usr/bin/env nomsu -V7.0.0
-
###
A library defining some command line program functionality
diff --git a/lib/compatibility/2.3.nom b/lib/compatibility/2.3.nom
index a706c53..32d6c72 100644
--- a/lib/compatibility/2.3.nom
+++ b/lib/compatibility/2.3.nom
@@ -1,5 +1,4 @@
#!/usr/bin/env nomsu -V7.0.0
-
###
This file defines upgrades from Nomsu <2.3 to Nomsu 2.3
diff --git a/lib/compatibility/2.4.nom b/lib/compatibility/2.4.nom
index eca5d73..a035c4e 100644
--- a/lib/compatibility/2.4.nom
+++ b/lib/compatibility/2.4.nom
@@ -14,9 +14,7 @@ upgrade $tree to "2.4" as:
return $tree
$conditions = []
$new_lines = []
- $body =
- $tree.2 if ($tree.2 is "Block" syntax tree) else [$tree.2]
-
+ $body = ($tree.2 if ($tree.2 is "Block" syntax tree) else [$tree.2])
for $line in $body:
when:
(not ($line is "Action" syntax tree)):
@@ -48,9 +46,7 @@ upgrade $tree to "2.4" as:
"if 1 is ?" "if 1 = ?":
$values = []
$new_lines = []
- $body =
- $tree.5 if ($tree.5 is "Block" syntax tree) else [$tree.5]
-
+ $body = ($tree.5 if ($tree.5 is "Block" syntax tree) else [$tree.5])
for $line in $body:
when:
(not ($line is "Action" syntax tree)):
@@ -76,7 +72,4 @@ upgrade $tree to "2.4" as:
$values = []
return
- \(
- if \($tree.2) is
- \("Block" tree from $tree.5.source with (unpack $new_lines))
- )
+ \(if \$tree.2 is \("Block" tree from $tree.5.source with (unpack $new_lines))) \ No newline at end of file
diff --git a/lib/compatibility/2.5.5.5.nom b/lib/compatibility/2.5.5.5.nom
index dbe557d..d79e47a 100644
--- a/lib/compatibility/2.5.5.5.nom
+++ b/lib/compatibility/2.5.5.5.nom
@@ -1,5 +1,4 @@
#!/usr/bin/env nomsu -V7.0.0
-
###
This file defines upgrades from Nomsu <2.5.5.5 to Nomsu 2.5.5.5
diff --git a/lib/compatibility/2.5.nom b/lib/compatibility/2.5.nom
index e4c761c..aa14833 100644
--- a/lib/compatibility/2.5.nom
+++ b/lib/compatibility/2.5.nom
@@ -1,5 +1,4 @@
#!/usr/bin/env nomsu -V7.0.0
-
###
This file defines upgrades from Nomsu <2.5 to Nomsu 2.5
diff --git a/lib/compatibility/2.nom b/lib/compatibility/2.nom
index 17ead58..20000c6 100644
--- a/lib/compatibility/2.nom
+++ b/lib/compatibility/2.nom
@@ -15,7 +15,7 @@ upgrade $tree to "2" as:
$false_body = $tree.5
unless ($false_body is "Block" syntax tree):
$false_body = (=lua "Block(\$false_body.source, \$false_body)")
- return \(if \($tree.2) \$true_body else \$false_body)
+ return \(if \$tree.2 \$true_body else \$false_body)
$need_blocks = [
"if", "unless", "for 1 in", "for 1 = 2 in", "repeat while 1", "repeat 1 times"
@@ -30,4 +30,4 @@ upgrade $tree to "2" as:
unless (($bits, last) is "Block" syntax tree):
$body = ($bits, last)
$bits.(#$bits) = (=lua "SyntaxTree{type='Block', source=\$body.source, \$body}")
- return (=lua "SyntaxTree{type='Action', source=\$tree.source, unpack(\$bits)}")
+ return (=lua "SyntaxTree{type='Action', source=\$tree.source, unpack(\$bits)}") \ No newline at end of file
diff --git a/lib/compatibility/3.5.5.6.nom b/lib/compatibility/3.5.5.6.nom
index b5333b3..42ad195 100644
--- a/lib/compatibility/3.5.5.6.nom
+++ b/lib/compatibility/3.5.5.6.nom
@@ -1,5 +1,4 @@
#!/usr/bin/env nomsu -V7.0.0
-
###
This file defines upgrades from Nomsu <3.5.5.6 to Nomsu 3.5.5.6
diff --git a/lib/compatibility/3.6.nom b/lib/compatibility/3.6.nom
index c75be45..9242149 100644
--- a/lib/compatibility/3.6.nom
+++ b/lib/compatibility/3.6.nom
@@ -1,5 +1,4 @@
#!/usr/bin/env nomsu -V7.0.0
-
###
This file defines upgrades from Nomsu <3.6 to 3.6
diff --git a/lib/compatibility/3.7.nom b/lib/compatibility/3.7.nom
index 1062362..6746406 100644
--- a/lib/compatibility/3.7.nom
+++ b/lib/compatibility/3.7.nom
@@ -1,5 +1,4 @@
#!/usr/bin/env nomsu -V7.0.0
-
###
This file defines upgrades from Nomsu <3.7 to 3.7
diff --git a/lib/compatibility/3.8.nom b/lib/compatibility/3.8.nom
index d86028d..fce3772 100644
--- a/lib/compatibility/3.8.nom
+++ b/lib/compatibility/3.8.nom
@@ -1,5 +1,4 @@
#!/usr/bin/env nomsu -V7.0.0
-
###
This file defines upgrades from Nomsu <3.8 to 3.8 (Text method changes)
diff --git a/lib/compatibility/3.nom b/lib/compatibility/3.nom
index 94cf24e..5181fba 100644
--- a/lib/compatibility/3.nom
+++ b/lib/compatibility/3.nom
@@ -1,5 +1,4 @@
#!/usr/bin/env nomsu -V7.0.0
-
###
This file defines upgrades from Nomsu <=2 to Nomsu 3
diff --git a/lib/compatibility/4.10.12.7.nom b/lib/compatibility/4.10.12.7.nom
index 529b3d8..53816ca 100644
--- a/lib/compatibility/4.10.12.7.nom
+++ b/lib/compatibility/4.10.12.7.nom
@@ -1,5 +1,4 @@
#!/usr/bin/env nomsu -V7.0.0
-
###
This file defines upgrades from Nomsu <4.10.12.7 to 4.10.12.7
use "compatibility/compatibility"
@@ -59,6 +58,7 @@ upgrade $tree to "4.10.12.7" as:
..else:
if $has_use:
go to (insert chunk)
+
$i += 1
return
--- (insert chunk) ---
@@ -74,4 +74,4 @@ upgrade $tree to "4.10.12.7" as:
$new_tree = ("FileChunks" tree from $tree.source with $chunk1 $chunk2)
for $i in (2 to #$tree):
$new_tree.($i + 1) = $tree.$i
- return $new_tree
+ return $new_tree \ No newline at end of file
diff --git a/lib/compatibility/4.11.nom b/lib/compatibility/4.11.nom
index e263c1e..9a50e77 100644
--- a/lib/compatibility/4.11.nom
+++ b/lib/compatibility/4.11.nom
@@ -14,6 +14,7 @@ upgrade action "call 1 with" to "4.11" via
for ($i = $arg) in $tree.4:
$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]
@@ -95,4 +96,4 @@ upgrade action [
upgrade action [
unless none of $items $body else $else
unless none of $items then $body else $else
-] to "4.11" as (if (any of $items) $body else $else)
+] to "4.11" as (if (any of $items) $body else $else) \ No newline at end of file
diff --git a/lib/compatibility/4.12.nom b/lib/compatibility/4.12.nom
index 8d73895..9af4ebe 100644
--- a/lib/compatibility/4.12.nom
+++ b/lib/compatibility/4.12.nom
@@ -1,5 +1,4 @@
#!/usr/bin/env nomsu -V7.0.0
-
###
This file defines upgrades from Nomsu <4.11 to Nomsu 4.11
(overhaul of function literals, deleting (if all of ...), etc. shorthand)
diff --git a/lib/compatibility/4.8.10.nom b/lib/compatibility/4.8.10.nom
index e278efd..bdc3484 100644
--- a/lib/compatibility/4.8.10.nom
+++ b/lib/compatibility/4.8.10.nom
@@ -65,4 +65,4 @@ upgrade action "parse 1 as" to "4.8.10" via
return \(\$spec parse as \$body)
upgrade action (compile as $) to "4.8.10" as (what $ compiles to)
-upgrade action (remove action $) to "4.8.10" as (($'s meaning) = (nil))
+upgrade action (remove action $) to "4.8.10" as (($'s meaning) = (nil)) \ No newline at end of file
diff --git a/lib/compatibility/4.9.nom b/lib/compatibility/4.9.nom
index 3e6aaee..55a5025 100644
--- a/lib/compatibility/4.9.nom
+++ b/lib/compatibility/4.9.nom
@@ -9,4 +9,4 @@ upgrade action "if" to "4.9" via
for $tree:
if (#$tree > 2):
return $tree
- return \(when \$tree.2)
+ return \(when \$tree.2) \ No newline at end of file
diff --git a/lib/compatibility/6.15.9.nom b/lib/compatibility/6.15.9.nom
index 91f7267..1691af9 100644
--- a/lib/compatibility/6.15.9.nom
+++ b/lib/compatibility/6.15.9.nom
@@ -1,5 +1,4 @@
#!/usr/bin/env nomsu -V7.0.0
-
###
This file defines upgrades from Nomsu <6.15.9 to 6.15.9
@@ -18,4 +17,4 @@ upgrade action (for $x in $start to $stop $body) to "6.15.9" as
upgrade action [
for $x in $start to $stop by $step $body
for $x in $start to $stop via $step $body
-] to "6.15.9" as (for $x in ($start to $stop by $step) $body)
+] to "6.15.9" as (for $x in ($start to $stop by $step) $body) \ No newline at end of file
diff --git a/lib/compatibility/6.15.nom b/lib/compatibility/6.15.nom
index 88a4064..c6cf799 100644
--- a/lib/compatibility/6.15.nom
+++ b/lib/compatibility/6.15.nom
@@ -1,5 +1,4 @@
#!/usr/bin/env nomsu -V7.0.0
-
###
This file defines upgrades from Nomsu <6.15 to 6.15
diff --git a/lib/compatibility/compatibility.nom b/lib/compatibility/compatibility.nom
index 4cc5d74..4ccd469 100644
--- a/lib/compatibility/compatibility.nom
+++ b/lib/compatibility/compatibility.nom
@@ -28,6 +28,7 @@ external:
for $i in (1 to #$action):
if ($action.$i is "Var" syntax tree):
$replacements.($action.$i.1) = "\(\$tree as lua id)[\$i]"
+
define mangler
(make tree $t) means:
when:
@@ -47,6 +48,7 @@ external:
$args, add (make tree $v)
..else:
$args, add "\($k)=\(make tree $v)"
+
return "SyntaxTree{\($args, joined with ", ")}"
else:
@@ -63,6 +65,7 @@ external:
return \$retval
end)
")
+
return $lua
[
@@ -110,6 +113,7 @@ external:
$tree =
SyntaxTree
{: for ($k = $v) in $tree: add $k = ($v upgraded from $curr_version to $ver)}
+
if (($tree.type == "Action") and $ACTION_UPGRADES.$ver):
$(upgrade 1) = $ACTION_UPGRADES.$ver.($tree, get stub)
if $(upgrade 1):
@@ -140,4 +144,4 @@ external:
$tree upgraded from ($tree.version or $(NOMSU VERSION)) to $end_version
($tree upgraded) means
- $tree upgraded from ($tree.version or $(NOMSU VERSION)) to $(NOMSU VERSION)
+ $tree upgraded from ($tree.version or $(NOMSU VERSION)) to $(NOMSU VERSION) \ No newline at end of file
diff --git a/lib/compatibility/init.nom b/lib/compatibility/init.nom
index ded3eb8..5af4bad 100644
--- a/lib/compatibility/init.nom
+++ b/lib/compatibility/init.nom
@@ -1,5 +1,4 @@
#!/usr/bin/env nomsu -V7.0.0
-
export "compatibility/compatibility"
export "compatibility/2"
export "compatibility/2.3"
diff --git a/lib/consolecolor/init.nom b/lib/consolecolor/init.nom
index 3bb7edb..34aa80d 100644
--- a/lib/consolecolor/init.nom
+++ b/lib/consolecolor/init.nom
@@ -1,5 +1,4 @@
#!/usr/bin/env nomsu -V7.0.0
-
###
This file defines actions for ANSI console color escape codes.
diff --git a/lib/core/collections.nom b/lib/core/collections.nom
index e9da70c..1b7dadb 100644
--- a/lib/core/collections.nom
+++ b/lib/core/collections.nom
@@ -1,5 +1,4 @@
#!/usr/bin/env nomsu -V7.0.0
-
###
This file contains code that supports manipulating and using collections like lists
and dictionaries.
@@ -163,6 +162,7 @@ external:
unless $seen.$:
$unique, add $
$seen.$ = (yes)
+
return $unique
### Ranges:
@@ -196,6 +196,7 @@ $range_mt = {
..else:
if ($i < $self.last):
return (nil)
+
return $i
return $range_mt.$key
diff --git a/lib/core/control_flow.nom b/lib/core/control_flow.nom
index 4dfe5f8..ca2450b 100644
--- a/lib/core/control_flow.nom
+++ b/lib/core/control_flow.nom
@@ -218,6 +218,7 @@ test:
..else:
$loop =
Lua "for _i,\($value as lua identifier) in _ipairs(\($iterable as lua expr)) do"
+
--- (loop set) ---
### TODO: don't always wrap in block
@@ -276,6 +277,7 @@ test:
$nums, add $inner
if ($inner == 5):
stop $outer
+
assume ($nums == [1, -2, 3, -2, 3, 4, 3, 4, 5])
### repeat $n times is a shorthand:
@@ -454,6 +456,7 @@ test:
recurse $ on $2
..else:
$flat, add $
+
assume (sorted $flat) == [1, 2, 3, 4, 5, 6]
### Recurion control flow
diff --git a/lib/core/coroutines.nom b/lib/core/coroutines.nom
index a11d6ee..3102d70 100644
--- a/lib/core/coroutines.nom
+++ b/lib/core/coroutines.nom
@@ -1,5 +1,4 @@
#!/usr/bin/env nomsu -V7.0.0
-
###
This file defines the code that creates and manipulates coroutines
@@ -16,6 +15,7 @@ test:
yield 5
repeat 3 times:
yield 6
+
$nums = []
for $ in (coroutine from $fn): $nums, add $
assume ($nums == [4, 5, 6, 6, 6])
@@ -27,6 +27,7 @@ test:
$d.x += 1
yield
$d.x += 1
+
repeat while ((coroutine status of $co) != "dead"): resume $co
assume $d.x == 3
$(co) = (coroutine: yield 5)
diff --git a/lib/core/errors.nom b/lib/core/errors.nom
index 0b5479d..ef5412e 100644
--- a/lib/core/errors.nom
+++ b/lib/core/errors.nom
@@ -1,5 +1,4 @@
#!/usr/bin/env nomsu -V7.0.0
-
###
This file contains basic error reporting code
@@ -27,6 +26,7 @@ use "core/control_flow"
end
end
")
+
if ($condition.type == "Action"):
when $condition.stub is:
"1 ==":
@@ -132,6 +132,7 @@ test:
$fallback_lua, prepend "\n\$msg_lua = _result[2]\n"
if ($msg_lua, text, is lua id):
$fallback_lua, add free vars [($msg_lua, text)]
+
$fallback_lua, prepend "-- Failure:\n"
return Lua ("
do
@@ -191,4 +192,4 @@ test:
if not _results[1] then error(_results[2], 0) end
if not _fell_through then return table.unpack(_results, 2) end
end
-")
+") \ No newline at end of file
diff --git a/lib/core/id.nom b/lib/core/id.nom
index 7324eea..2a1e8a3 100644
--- a/lib/core/id.nom
+++ b/lib/core/id.nom
@@ -1,5 +1,4 @@
#!/usr/bin/env nomsu -V7.0.0
-
###
A simple UUID function based on RFC 4122: http://www.ietf.org/rfc/rfc4122.txt
diff --git a/lib/core/init.nom b/lib/core/init.nom
index 84fd3cd..bf5852a 100644
--- a/lib/core/init.nom
+++ b/lib/core/init.nom
@@ -1,5 +1,4 @@
#!/usr/bin/env nomsu -V7.0.0
-
### Export everything
export "core/metaprogramming"
export "core/operators"
diff --git a/lib/core/io.nom b/lib/core/io.nom
index c4f74d9..43960ce 100644
--- a/lib/core/io.nom
+++ b/lib/core/io.nom
@@ -1,5 +1,4 @@
#!/usr/bin/env nomsu -V7.0.0
-
###
This file contains basic input/output code
diff --git a/lib/core/math.nom b/lib/core/math.nom
index 9b53385..945ad13 100644
--- a/lib/core/math.nom
+++ b/lib/core/math.nom
@@ -1,5 +1,4 @@
#!/usr/bin/env nomsu -V7.0.0
-
###
This file defines some common math literals and functions
@@ -19,6 +18,7 @@ external:
$nan = (NaN)
unless ($nan != $nan):
fail "NaN failed"
+
[infinity, inf] all compile to "math.huge"
[not a number, NaN, nan] all compile to "(0/0)"
[pi, Pi, PI] all compile to "math.pi"
@@ -73,12 +73,14 @@ external:
for $ in $items:
unless $:
return (no)
+
return (yes)
[not all of $items, not all $items] all parse as (not (all of $items))
[any of $items, any $items] all mean:
for $ in $items:
if $:
return (yes)
+
return (no)
[none of $items, none $items] all parse as (not (any of $items))
@@ -123,6 +125,7 @@ external:
if (($best == (nil)) or ($key < $best_key)):
$best = $item
$best_key = $key
+
return $best
(max of $items by $item = $value_expr) parses as
@@ -134,6 +137,7 @@ external:
if (($best == (nil)) or ($key > $best_key)):
$best = $item
$best_key = $key
+
return $best
test:
diff --git a/lib/core/metaprogramming.nom b/lib/core/metaprogramming.nom
index bd0b6d7..a9649c6 100644
--- a/lib/core/metaprogramming.nom
+++ b/lib/core/metaprogramming.nom
@@ -248,6 +248,7 @@ test:
with external [$x]:
$x = "inner"
$y = "inner"
+
set external x local y
unless (($x == "inner") and ($y == "outer")):
fail "'with external' failed."
@@ -516,4 +517,4 @@ test:
($tree with $t -> $replacement) parses as ($tree, with ($t -> $replacement))
[tree $tree with vars $replacements, $tree with vars $replacements] all parse as
$tree, with $replacements
-($tree has subtree $match_tree) parses as ($tree, contains $match_tree)
+($tree has subtree $match_tree) parses as ($tree, contains $match_tree) \ No newline at end of file
diff --git a/lib/core/operators.nom b/lib/core/operators.nom
index dbc0b18..229d846 100644
--- a/lib/core/operators.nom
+++ b/lib/core/operators.nom
@@ -1,5 +1,4 @@
#!/usr/bin/env nomsu -V7.0.0
-
###
This file contains definitions of operators like "+" and "and".
@@ -136,6 +135,7 @@ test:
unless ($calls == 1):
fail "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)
@@ -213,7 +213,7 @@ lua> "end"
### Unary operators
test:
- assume (-(5) == -5)
+ assume ((- 5) == -5)
assume ((not (yes)) == (no))
-$ compiles to "(-(\($ as lua expr)))"
(not $) compiles to "(not \($ as lua expr))"
@@ -246,6 +246,7 @@ test:
wrap $x around 3
unless ($x == 1):
fail "wrap around failed"
+
($var += $) parses as ($var = (($var or 0) + $))
($var -= $) parses as ($var = (($var or 0) - $))
($var *= $) parses as ($var = (($var or 1) * $))
@@ -253,4 +254,4 @@ test:
($var ^= $) parses as ($var = ($var ^ $))
($var and= $) parses as ($var = ($var and $))
($var or= $) parses as ($var = ($var or $))
-(wrap $var around $) parses as ($var = ($var wrapped around $))
+(wrap $var around $) parses as ($var = ($var wrapped around $)) \ No newline at end of file
diff --git a/lib/core/text.nom b/lib/core/text.nom
index 42f2e41..38025da 100644
--- a/lib/core/text.nom
+++ b/lib/core/text.nom
@@ -1,5 +1,4 @@
#!/usr/bin/env nomsu -V7.0.0
-
###
This file contains some definitions of text escape sequences, including ANSI console
color codes.
diff --git a/lib/core/things.nom b/lib/core/things.nom
index 42e4c62..a76a917 100644
--- a/lib/core/things.nom
+++ b/lib/core/things.nom
@@ -1,5 +1,4 @@
#!/usr/bin/env nomsu -V7.0.0
-
###
A library for simple object oriented programming.
@@ -122,4 +121,4 @@ external:
")
$lua, add free vars [$class_id]
- return $lua
+ return $lua \ No newline at end of file
diff --git a/lib/core/time.nom b/lib/core/time.nom
index 88241d6..aa59d7a 100644
--- a/lib/core/time.nom
+++ b/lib/core/time.nom
@@ -1,5 +1,4 @@
#!/usr/bin/env nomsu -V7.0.0
-
###
This file defines time-related actions.
@@ -37,7 +36,7 @@ external:
if ($other is "a Time"):
return ($os.difftime $self ($os.time $other))
return (a Time ($os.date "*t" ($self - $other, rounded)))
-
+
($self, <$other) means (($self, since epoch) < ($other, since epoch))
($self, <=$other) means (($self, since epoch) <= ($other, since epoch))
($self, as text) means ($os.date "%I:%M%p %a %b %e %Y" ($os.time $self))
@@ -51,4 +50,4 @@ external:
### Lua does not come with a sleep() function, only an os.clock() function,
so this busy-loop is necessary for cross-platform compatibility.
$deadline = (($os.clock()) + $t)
- repeat while (($os.clock()) < $deadline): do nothing
+ repeat while (($os.clock()) < $deadline): do nothing \ No newline at end of file
diff --git a/lib/file_hash/init.nom b/lib/file_hash/init.nom
index 81061f9..0fa5725 100644
--- a/lib/file_hash/init.nom
+++ b/lib/file_hash/init.nom
@@ -1,5 +1,4 @@
#!/usr/bin/env nomsu -V7.0.0
-
###
This file defines some actions for hashing files and looking up files by hash.
@@ -60,4 +59,5 @@ external:
$file_hash = (hash $contents)
if ($file_hash == $hash):
return $filename
+
(hash of file $filename) parses as (hash (read file $filename)) \ No newline at end of file
diff --git a/lib/filesystem/init.nom b/lib/filesystem/init.nom
index 13bcad2..1d6b8cf 100644
--- a/lib/filesystem/init.nom
+++ b/lib/filesystem/init.nom
@@ -1,5 +1,4 @@
#!/usr/bin/env nomsu -V7.0.0
-
###
This file defines some actions that interact with the filesystem.
diff --git a/lib/progressbar/init.nom b/lib/progressbar/init.nom
index e5418d0..9356a05 100644
--- a/lib/progressbar/init.nom
+++ b/lib/progressbar/init.nom
@@ -1,5 +1,4 @@
#!/usr/bin/env nomsu -V7.0.0
-
### A progress bar
use "consolecolor"
@@ -16,10 +15,11 @@ external:
$bits = [" ", "▏", "▎", "▍", "▌", "▋", "▊", "▉", "█"]
$middle = ("" if ($x == $w) else $bits.(1 + (floor (#$bits * ($x mod 1)))))
return ("
- \(reset color)[\(green)\($bits, last, rep (floor $x))\$middle\
+ \(reset color)[\(green)\($bits, last, rep (floor $x))\($middle)\
..\(" ", rep ($w - ((floor $x) + 1)))\(reset color)]
")
..else:
### Probably not unicode support either:
return "[\("#", rep ($x, rounded down))\("-", rep ($w - ($x, rounded down)))]"
+
($w wide $ progress bar) means (($ * $w) / $w progress bar) \ No newline at end of file
diff --git a/lib/shell/init.nom b/lib/shell/init.nom
index c120807..352473d 100644
--- a/lib/shell/init.nom
+++ b/lib/shell/init.nom
@@ -14,6 +14,7 @@ external:
..else:
at $callsite fail
"Command failure: Command `\($cmd)` was terminated by signal \$return"
+
return $contents
(at $callsite sh> $cmd) means:
diff --git a/lib/tools/format.nom b/lib/tools/format.nom
index e20adbd..4d490de 100755
--- a/lib/tools/format.nom
+++ b/lib/tools/format.nom
@@ -1,5 +1,4 @@
#!/usr/bin/env nomsu -V7.0.0
-
###
Auto-format Nomsu code. Usage:
nomsu -t format [-i] file1 file2...
diff --git a/lib/tools/install.nom b/lib/tools/install.nom
index afd6069..f84416d 100755
--- a/lib/tools/install.nom
+++ b/lib/tools/install.nom
@@ -1,5 +1,4 @@
#!/usr/bin/env nomsu -V7.0.0
-
###
A tool to install third party Nomsu packages
@@ -57,4 +56,5 @@ command line program with $args:
$cmd = ($filename, with $patt -> $action.cmd)
run command $cmd
do next $filename
+
fail "Not sure what to do with \$filename" \ No newline at end of file
diff --git a/lib/tools/list.nom b/lib/tools/list.nom
index 77bb8a7..fd283e4 100644
--- a/lib/tools/list.nom
+++ b/lib/tools/list.nom
@@ -1,5 +1,4 @@
#!/usr/bin/env nomsu -V7.0.0
-
###
A tool to list installed third party Nomsu packages
diff --git a/lib/tools/parse.nom b/lib/tools/parse.nom
index 7224901..1201040 100755
--- a/lib/tools/parse.nom
+++ b/lib/tools/parse.nom
@@ -1,5 +1,4 @@
#!/usr/bin/env nomsu -V7.0.0
-
###
Tool to print out a parse tree of files in an easy-to-read format. Usage:
nomsu tools/parse.nom file1 file2 directory1 ...
diff --git a/lib/tools/repl.nom b/lib/tools/repl.nom
index 2e0c7da..fef2984 100755
--- a/lib/tools/repl.nom
+++ b/lib/tools/repl.nom
@@ -1,5 +1,4 @@
#!/usr/bin/env nomsu -V7.0.0
-
###
This file defines a Read-Evaluate-Print-Loop (REPL) for Nomsu
@@ -54,6 +53,7 @@ command line program with $args:
### clear the line
if $(COLOR ENABLED):
say "\027[1A\027[2K" inline
+
go to (run buffer)
$buff, add ($line, with "\t" -> " ")
say (dim (yellow ".. ")) inline
diff --git a/lib/tools/replace.nom b/lib/tools/replace.nom
index aea1b03..fe07140 100755
--- a/lib/tools/replace.nom
+++ b/lib/tools/replace.nom
@@ -1,5 +1,4 @@
#!/usr/bin/env nomsu -V7.0.0
-
###
This is a tool to replace syntax trees with something new.
@@ -63,6 +62,7 @@ command line program with $args:
..else:
$substitution_values.($patt.1) = $tree
return $substitution_values
+
($tree.type != $patt.type): return (nil)
($tree.type == "Action"):
if (($tree, get stub) != ($patt, get stub)): return (nil)
@@ -135,6 +135,7 @@ command line program with $args:
if ($user_answers.$t == "n"): return (nil)
$replaced.$t = (yes)
return $ret
+
$tree2 = ($tree with replacements)
if $args.i:
if (#$user_answers > 0): say ""
@@ -145,4 +146,4 @@ command line program with $args:
if (#$replaced > 0):
write "\($tree2 as nomsu)" to file $filename
..else:
- say ($tree2 as nomsu)
+ say ($tree2 as nomsu) \ No newline at end of file
diff --git a/lib/tools/test.nom b/lib/tools/test.nom
index 8244f70..fce2694 100755
--- a/lib/tools/test.nom
+++ b/lib/tools/test.nom
@@ -1,5 +1,4 @@
#!/usr/bin/env nomsu -V7.0.0
-
###
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 ...
diff --git a/lib/tools/tutorial.nom b/lib/tools/tutorial.nom
index ca5e109..921d8c3 100755
--- a/lib/tools/tutorial.nom
+++ b/lib/tools/tutorial.nom
@@ -558,4 +558,4 @@ command line program with $args:
\\(^\("ᴗ" if $(COLOR ENABLED) else "_")^)/
- ")
+ ") \ No newline at end of file
diff --git a/lib/tools/uninstall.nom b/lib/tools/uninstall.nom
index f5dbaa3..bcc77cc 100755
--- a/lib/tools/uninstall.nom
+++ b/lib/tools/uninstall.nom
@@ -1,5 +1,4 @@
#!/usr/bin/env nomsu -V7.0.0
-
###
A tool to uninstall third party Nomsu packages (the inverse of the install tool)
diff --git a/lib/tools/upgrade.nom b/lib/tools/upgrade.nom
index 65e9e68..f188276 100755
--- a/lib/tools/upgrade.nom
+++ b/lib/tools/upgrade.nom
@@ -1,5 +1,4 @@
#!/usr/bin/env nomsu -V7.0.0
-
###
Tool to automatically update code from old versions of Nomsu. Usage:
nomsu tools/upgrade.nom [-i] file1 file2 directory1 ...
@@ -19,6 +18,7 @@ command line program with $args:
if $start_version:
try:
use $start_version
+
$version = ($args."upgrade-to" or $(NOMSU VERSION))
$test = ($args.t or $args.test)
for $filename in $args.extras:
@@ -31,6 +31,7 @@ command line program with $args:
$uptree =
$tree upgraded from ($start_version or ($tree.version or $(NOMSU VERSION))) to
$version
+
$text = "\$leading_indent\($uptree as nomsu, text, with "\n" -> "\n\$leading_indent")"
when:
$inplace:
@@ -44,4 +45,4 @@ command line program with $args:
say (bright "\$filename will be changed")
else:
- say $text inline
+ say $text inline \ No newline at end of file