aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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.nom8
-rw-r--r--compatibility/4.11.nom2
-rw-r--r--compatibility/4.12.nom2
-rw-r--r--compatibility/4.8.10.nom2
-rw-r--r--compatibility/4.9.nom2
-rw-r--r--compatibility/compatibility.nom10
-rw-r--r--core/collections.nom8
-rw-r--r--core/control_flow.nom22
-rw-r--r--core/coroutines.nom7
-rw-r--r--core/errors.nom44
-rw-r--r--core/id.nom2
-rw-r--r--core/io.nom2
-rw-r--r--core/math.nom24
-rw-r--r--core/metaprogramming.nom53
-rw-r--r--core/operators.nom55
-rw-r--r--core/text.nom2
-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.nom17
-rw-r--r--lib/object.nom14
-rw-r--r--lib/os.nom13
-rw-r--r--lib/things.nom23
-rw-r--r--nomsu.6.peg6
-rw-r--r--nomsu_compiler.lua7
-rw-r--r--nomsu_compiler.moon6
-rw-r--r--nomsu_decompiler.lua7
-rw-r--r--nomsu_decompiler.moon7
-rw-r--r--syntax_tree.lua8
-rw-r--r--syntax_tree.moon7
-rwxr-xr-xtools/find.nom8
-rwxr-xr-xtools/format.nom6
-rwxr-xr-xtools/parse.nom4
-rwxr-xr-xtools/repl.nom10
-rwxr-xr-xtools/replace.nom14
-rwxr-xr-xtools/test.nom2
-rwxr-xr-xtools/upgrade.nom4
47 files changed, 252 insertions, 184 deletions
diff --git a/compatibility/2.3.nom b/compatibility/2.3.nom
index bbe868b..5b62bc3 100644
--- a/compatibility/2.3.nom
+++ b/compatibility/2.3.nom
@@ -1,4 +1,4 @@
-#!/usr/bin/env nomsu -V6.13.12.8
+#!/usr/bin/env nomsu -V6.14
#
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 8c948b0..213966b 100644
--- a/compatibility/2.4.nom
+++ b/compatibility/2.4.nom
@@ -1,4 +1,4 @@
-#!/usr/bin/env nomsu -V6.13.12.8
+#!/usr/bin/env nomsu -V6.14
#
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 6ee5959..52f21eb 100644
--- a/compatibility/2.5.5.5.nom
+++ b/compatibility/2.5.5.5.nom
@@ -1,4 +1,4 @@
-#!/usr/bin/env nomsu -V6.13.12.8
+#!/usr/bin/env nomsu -V6.14
#
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 a32bbaf..92fb2ac 100644
--- a/compatibility/2.5.nom
+++ b/compatibility/2.5.nom
@@ -1,4 +1,4 @@
-#!/usr/bin/env nomsu -V6.13.12.8
+#!/usr/bin/env nomsu -V6.14
#
This file defines upgrades from Nomsu <2.5 to Nomsu 2.5
diff --git a/compatibility/2.nom b/compatibility/2.nom
index 6335df0..cd84546 100644
--- a/compatibility/2.nom
+++ b/compatibility/2.nom
@@ -1,4 +1,4 @@
-#!/usr/bin/env nomsu -V6.13.12.8
+#!/usr/bin/env nomsu -V6.14
#
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 a93c9a9..4323749 100644
--- a/compatibility/3.5.5.6.nom
+++ b/compatibility/3.5.5.6.nom
@@ -1,4 +1,4 @@
-#!/usr/bin/env nomsu -V6.13.12.8
+#!/usr/bin/env nomsu -V6.14
#
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 8925bc4..2f1a460 100644
--- a/compatibility/3.6.nom
+++ b/compatibility/3.6.nom
@@ -1,4 +1,4 @@
-#!/usr/bin/env nomsu -V6.13.12.8
+#!/usr/bin/env nomsu -V6.14
#
This file defines upgrades from Nomsu <3.6 to 3.6
diff --git a/compatibility/3.7.nom b/compatibility/3.7.nom
index 914c3aa..b68d64c 100644
--- a/compatibility/3.7.nom
+++ b/compatibility/3.7.nom
@@ -1,4 +1,4 @@
-#!/usr/bin/env nomsu -V6.13.12.8
+#!/usr/bin/env nomsu -V6.14
#
This file defines upgrades from Nomsu <3.7 to 3.7
diff --git a/compatibility/3.8.nom b/compatibility/3.8.nom
index 89d2970..feaa593 100644
--- a/compatibility/3.8.nom
+++ b/compatibility/3.8.nom
@@ -1,4 +1,4 @@
-#!/usr/bin/env nomsu -V6.13.12.8
+#!/usr/bin/env nomsu -V6.14
#
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 0a745f6..9606073 100644
--- a/compatibility/3.nom
+++ b/compatibility/3.nom
@@ -1,4 +1,4 @@
-#!/usr/bin/env nomsu -V6.13.12.8
+#!/usr/bin/env nomsu -V6.14
#
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 c423f6c..e8a3161 100644
--- a/compatibility/4.10.12.7.nom
+++ b/compatibility/4.10.12.7.nom
@@ -1,4 +1,4 @@
-#!/usr/bin/env nomsu -V6.13.12.8
+#!/usr/bin/env nomsu -V6.14
#
This file defines upgrades from Nomsu <4.10.12.7 to 4.10.12.7
use "compatibility/compatibility.nom"
@@ -24,8 +24,10 @@ upgrade action ($e for $i in $start to $stop by $step) to "4.10.12.7" as
upgrade action ($e for $i in $start to $stop via $step) to "4.10.12.7" as
[: for $i in $start to $stop by $step: add $e]
-upgrade action ($k = $v for $ in $items) to "4.10.12.7" as
- {: for $ in $items: add $k = $v}
+upgrade action ($k = $v for $ in $items) to "4.10.12.7" as {
+ : for $ in $items:
+ add $k = $v
+}
upgrade action ($k = $v for $k0 = $v0 in $items) to "4.10.12.7" as
{: for $k0 = $v0 in $items: add $k = $v}
diff --git a/compatibility/4.11.nom b/compatibility/4.11.nom
index a5c9c12..8ca9edc 100644
--- a/compatibility/4.11.nom
+++ b/compatibility/4.11.nom
@@ -1,4 +1,4 @@
-#!/usr/bin/env nomsu -V6.13.12.8
+#!/usr/bin/env nomsu -V6.14
#
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/compatibility/4.12.nom b/compatibility/4.12.nom
index 7ca2e3b..215c114 100644
--- a/compatibility/4.12.nom
+++ b/compatibility/4.12.nom
@@ -1,4 +1,4 @@
-#!/usr/bin/env nomsu -V6.13.12.8
+#!/usr/bin/env nomsu -V6.14
#
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/compatibility/4.8.10.nom b/compatibility/4.8.10.nom
index 66fdfa1..0752744 100644
--- a/compatibility/4.8.10.nom
+++ b/compatibility/4.8.10.nom
@@ -1,4 +1,4 @@
-#!/usr/bin/env nomsu -V6.13.12.8
+#!/usr/bin/env nomsu -V6.14
#
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 c2064ec..c1b5d3e 100644
--- a/compatibility/4.9.nom
+++ b/compatibility/4.9.nom
@@ -1,4 +1,4 @@
-#!/usr/bin/env nomsu -V6.13.12.8
+#!/usr/bin/env nomsu -V6.14
#
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 e017728..60baf17 100644
--- a/compatibility/compatibility.nom
+++ b/compatibility/compatibility.nom
@@ -1,4 +1,4 @@
-#!/usr/bin/env nomsu -V6.13.12.8
+#!/usr/bin/env nomsu -V6.14
#
This file contains code for defining ways to upgrade code between different versions
of Nomsu.
@@ -85,16 +85,16 @@ externally [
$tree with $ ->:
if (($ is "Action" syntax tree) and $ACTION_UPGRADES.$ver.($.stub)):
$with_upgraded_args = {
- : for $k = $v in $: add $k = ($v upgraded from $start_version to $end_version)
+ : for $k = $v in $:
+ add $k = ($v upgraded from $start_version to $end_version)
}
set $with_upgraded_args's metatable to ($'s metatable)
return ($ACTION_UPGRADES.$ver.($.stub) $with_upgraded_args $end_version)
if $UPGRADES.$ver:
$with_upgraded_args = {
- :
- for $k = $v in $tree:
- add $k = ($v upgraded from $start_version to $end_version)
+ : for $k = $v in $tree:
+ add $k = ($v upgraded from $start_version to $end_version)
}
set $with_upgraded_args's metatable to ($tree's metatable)
$tree = ($UPGRADES.$ver $with_upgraded_args $end_version)
diff --git a/core/collections.nom b/core/collections.nom
index 6aac861..18b1af6 100644
--- a/core/collections.nom
+++ b/core/collections.nom
@@ -1,4 +1,4 @@
-#!/usr/bin/env nomsu -V6.13.12.8
+#!/usr/bin/env nomsu -V6.14
#
This file contains code that supports manipulating and using collections like lists
and dictionaries.
@@ -60,8 +60,10 @@ externally ($lists flattened) means:
test:
assume ((entries in {.x = 1}) == [{.key = "x", .value = 1}])
-(entries in $dict) parses as
- [: for $k = $v in $dict: add {.key = $k, .value = $v}]
+(entries in $dict) parses as [
+ : for $k = $v in $dict:
+ add {.key = $k, .value = $v}
+]
test:
assume ((keys in {.x = 1}) == ["x"])
diff --git a/core/control_flow.nom b/core/control_flow.nom
index f066767..5c90bcc 100644
--- a/core/control_flow.nom
+++ b/core/control_flow.nom
@@ -1,4 +1,4 @@
-#!/usr/bin/env nomsu -V6.13.12.8
+#!/usr/bin/env nomsu -V6.14
#
This file contains compile-time actions that define basic control flow structures
like "if" statements and loops.
@@ -16,7 +16,7 @@ test:
# Conditionals
test:
if (no):
- barf "conditional fail"
+ fail "conditional fail"
(if $condition $if_body) compiles to ("
if \($condition as lua expr) then
@@ -26,7 +26,7 @@ test:
test:
unless (yes):
- barf "conditional fail"
+ fail "conditional fail"
(unless $condition $unless_body) parses as (if (not $condition) $unless_body)
[
@@ -134,7 +134,7 @@ test:
$x += 1
if (yes):
do next
- barf "Failed to 'do next'"
+ fail "Failed to 'do next'"
assume ($x == 20)
(repeat while $condition $body) compiles to:
@@ -311,16 +311,16 @@ test:
test:
when:
(1 == 2) (100 < 0):
- barf "bad conditional"
+ fail "bad conditional"
(1 == 0) (1 == 1) $not_a_variable.x: do nothing
(1 == 1):
- barf "bad conditional"
+ fail "bad conditional"
(1 == 2):
- barf "bad conditional"
+ fail "bad conditional"
else:
- barf "bad conditional"
+ fail "bad conditional"
# Multi-branch conditional (if..elseif..else)
(when $body) compiles to:
@@ -374,16 +374,16 @@ test:
test:
if 5 is:
1 2 3:
- barf "bad switch statement"
+ fail "bad switch statement"
4 5:
do nothing
5 6:
- barf "bad switch statement"
+ fail "bad switch statement"
else:
- barf "bad switch statement"
+ fail "bad switch statement"
# Switch statement
[if $branch_value is $body, when $branch_value is $body] all compile to:
diff --git a/core/coroutines.nom b/core/coroutines.nom
index 1a164a9..4b4639a 100644
--- a/core/coroutines.nom
+++ b/core/coroutines.nom
@@ -1,4 +1,4 @@
-#!/usr/bin/env nomsu -V6.13.12.8
+#!/usr/bin/env nomsu -V6.14
#
This file defines the code that creates and manipulates coroutines
@@ -18,7 +18,10 @@ test:
$nums = []
for $ in coroutine $co:
$nums, add $
- assume ($nums == [4, 5, 6, 6, 6]) or barf "Coroutine iteration failed"
+
+ unless ($nums == [4, 5, 6, 6, 6]):
+ fail "Coroutine iteration failed"
+
$d = {.x = 0}
$co2 =
coroutine:
diff --git a/core/errors.nom b/core/errors.nom
index 0b63b5b..bd9e1c4 100644
--- a/core/errors.nom
+++ b/core/errors.nom
@@ -1,4 +1,4 @@
-#!/usr/bin/env nomsu -V6.13.12.8
+#!/usr/bin/env nomsu -V6.14
#
This file contains basic error reporting code
@@ -7,9 +7,7 @@ use "core/operators.nom"
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-(fail $msg) compiles to
- "error(\(($msg as lua expr) if $msg else "nil"), 0);"
-
+(fail $msg) compiles to "error(\(($msg as lua expr) if $msg else "nil"), 0);"
(assume $condition) compiles to:
lua> ("
local \$assumption = 'Assumption failed: '..tostring((\$condition):get_source_code())
@@ -41,26 +39,34 @@ use "core/operators.nom"
test:
try: fail
$worked = (no)
- try: fail
- ..if it fails:
+ try:
+ fail "xx"
+ ..if it fails with $failure:
$worked = (yes)
..if it succeeds:
fail "'try' incorrectly ran success case."
-
+ assume $failure == "xx"
unless $worked:
fail "'try' failed to recover from failure"
+
# Try/except
[
- try $action if it succeeds $success if it fails $fallback
- try $action if it fails $fallback if it succeeds $success
+ try $action if it succeeds $success if it fails with $msg $fallback
+ try $action if it fails with $msg $fallback if it succeeds $success
] all compile to:
$success_lua = ($success as lua)
- if ((#"\$success_lua") > 0): $success_lua, add "\n"
+ if ((#"\$success_lua") > 0):
+ $success_lua, add "\n"
$success_lua, prepend "-- Success:\n"
- $success_lua, add "if not _fell_through then return table.unpack(_result, 2) end"
+ $success_lua,
+ add "if not _fell_through then return table.unpack(_result, 2) end"
$fallback_lua = ($fallback as lua)
if ((#"\$fallback_lua") > 0):
- $fallback_lua, prepend "\nlocal function failure() return _result[2] end\n"
+ $msg_lua = ($msg as lua expr)
+ if ((#"\$msg_lua") > 0):
+ $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:"
return
Lua ("
@@ -83,14 +89,20 @@ test:
(try $action) parses as
try $action if it succeeds (do nothing) if it fails (do nothing)
-(try $action if it fails $msg $fallback) parses as
- try $action if it succeeds (do nothing) if it fails $msg $fallback
+(try $action if it fails $fallback) parses as
+ try $action if it succeeds (do nothing) if it fails $fallback
+
+(try $action if it fails with $msg $fallback) parses as
+ try $action if it succeeds (do nothing) if it fails with $msg $fallback
(try $action if it succeeds $success) parses as
try $action if it succeeds $success if it fails (do nothing)
(try $action if it fails $fallback if it succeeds $success) parses as
- try $action if it succeeds $success if it fails $fallback
+ try $action if it fails with (=lua "") $fallback if it succeeds $success
+
+(try $action if it succeeds $success if it fails $fallback) parses as
+ try $action if it succeeds $success if it fails with (=lua "") $fallback
test:
$success = (no)
@@ -117,7 +129,7 @@ test:
end
")
-~~~
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
(barf $) parses as (fail $)
(assume $1 or barf $2) parses as (unless $1: fail $2)
diff --git a/core/id.nom b/core/id.nom
index d5f747a..61ffeaa 100644
--- a/core/id.nom
+++ b/core/id.nom
@@ -1,4 +1,4 @@
-#!/usr/bin/env nomsu -V6.13.12.8
+#!/usr/bin/env nomsu -V6.14
#
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 6333292..f1abe32 100644
--- a/core/io.nom
+++ b/core/io.nom
@@ -1,4 +1,4 @@
-#!/usr/bin/env nomsu -V6.13.12.8
+#!/usr/bin/env nomsu -V6.14
#
This file contains basic input/output code
diff --git a/core/math.nom b/core/math.nom
index 04388cb..f7a0afb 100644
--- a/core/math.nom
+++ b/core/math.nom
@@ -1,4 +1,4 @@
-#!/usr/bin/env nomsu -V6.13.12.8
+#!/usr/bin/env nomsu -V6.14
#
This file defines some common math literals and functions
@@ -12,10 +12,11 @@ use "core/collections.nom"
# Literals:
test:
- assume (all of [inf, NaN, pi, tau, golden ratio, e]) or barf
- "math constants failed"
+ unless (all of [inf, NaN, pi, tau, golden ratio, e]):
+ fail "math constants failed"
$nan = (NaN)
- assume ($nan != $nan) or barf "NaN failed"
+ 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"
@@ -26,19 +27,18 @@ test:
# Functions:
test:
assume (("5" as a number) == 5)
-(($ as a number)'s meaning) = ((tonumber $)'s meaning)
-(($ as number)'s meaning) = ((tonumber $)'s meaning)
+external $($ as a number) = $(tonumber $)
+external $($ as number) = $(tonumber $)
test:
- assume
+ unless
all of [
abs 5, | 5 |, sqrt 5, √ 5, sine 5, cosine 5, tangent 5, arc sine 5, arc cosine 5
arc tangent 5, arc tangent 5 / 10, hyperbolic sine 5, hyperbolic cosine 5
hyperbolic tangent 5, e^ 5, ln 5, log base 2 of 5, floor 5, ceiling 5, round 5
]
- ..or barf "math functions failed"
-
+ ..:
+ fail "math functions failed"
[absolute value $, | $ |, abs $] all compile to "math.abs(\($ as lua expr))"
-
[square root $, square root of $, √ $, sqrt $] all compile to
"math.sqrt(\($ as lua expr))"
[sine $, sin $] all compile to "math.sin(\($ as lua expr))"
@@ -60,8 +60,8 @@ test:
[ceiling $, ceil $] all compile to "math.ceil(\($ as lua expr))"
[round $, $ rounded] all compile to "math.floor(\($ as lua expr) + .5)"
test:
- assume ((463 to the nearest 100) == 500) or barf "rounding failed"
- assume ((2.6 to the nearest 0.25) == 2.5) or barf "rounding failed"
+ unless ((463 to the nearest 100) == 500): fail "rounding failed"
+ unless ((2.6 to the nearest 0.25) == 2.5): fail "rounding failed"
externally ($n to the nearest $rounder) means
=lua "(\$rounder)*math.floor((\$n / \$rounder) + .5)"
diff --git a/core/metaprogramming.nom b/core/metaprogramming.nom
index b4297dd..c950e97 100644
--- a/core/metaprogramming.nom
+++ b/core/metaprogramming.nom
@@ -1,9 +1,9 @@
-#!/usr/bin/env nomsu -V6.13.12.8
+#!/usr/bin/env nomsu -V6.14
#
This File contains actions for making actions and compile-time actions and some helper
functions to make that easier.
-lua> "NOMSU_CORE_VERSION = 13"
+lua> "NOMSU_CORE_VERSION = 14"
lua> "NOMSU_LIB_VERSION = 8"
lua> ("
do
@@ -62,22 +62,27 @@ test:
(five) compiles to "5"
test:
- assume ((five) == 5) or barf "Compile to expression failed."
+ unless ((five) == 5):
+ fail "Compile to expression failed."
(loc x) compiles to "local x = 99;"
test:
lua> "do"
loc x
- assume ($x is 99) or barf "Compile to statements with locals failed."
+ unless ($x is 99):
+ fail "Compile to statements with locals failed."
lua> "end"
- assume ($x is (nil)) or barf "Failed to properly localize a variable."
+ unless ($x is (nil)):
+ fail "Failed to properly localize a variable."
+
(asdf) compiles to:
$tmp = ""
return (Lua $tmp)
test:
asdf
- assume ($tmp is (nil)) or barf "compile to is leaking variables"
+ unless ($tmp is (nil)):
+ fail "compile to is leaking variables"
lua> ("
compile.action["1 compiles to"] = function(compile, \$action, \$body)
@@ -121,12 +126,17 @@ lua> ("
test:
(foo $x) means "outer"
- with [(foo $)'s meaning]:
+ with [$(foo $)]:
(foo $x) means:
$y = ($x + 1)
return $y
- assume ((foo 10) == 11) or barf "Action didn't work."
- assume ($y is (nil)) or barf "Action leaked a local into globals."
+
+ unless ((foo 10) == 11):
+ fail "Action didn't work."
+
+ unless ($y is (nil)):
+ fail "Action leaked a local into globals."
+
(baz $) parses as (foo $)
assume ((foo 1) == "outer")
@@ -196,10 +206,6 @@ test:
")
test:
- assume (((say $)'s meaning) == (=lua "say"))
-
-($action's meaning) compiles to (Lua ($action, get stub, as lua id))
-test:
(swap $x and $y) parses as
do:
$tmp = $x
@@ -209,12 +215,12 @@ test:
test:
[$1, $2] = [1, 2]
swap $1 and $2
- assume (($1 == 2) and ($2 == 1)) or barf
- "'parse $ as $' failed on 'swap $ and $'"
+ unless (($1 == 2) and ($2 == 1)):
+ fail "'parse $ as $' failed on 'swap $ and $'"
[$tmp, $tmp2] = [1, 2]
swap $tmp and $tmp2
- assume (($tmp == 2) and ($tmp2 == 1)) or barf
- "'parse $ as $' variable mangling failed."
+ unless (($tmp == 2) and ($tmp2 == 1)):
+ fail "'parse $ as $' variable mangling failed."
($actions all parse as $body) compiles to:
lua> ("
@@ -227,10 +233,10 @@ test:
end
local function make_tree(t)
if SyntaxTree:is_instance(t) and t.type == "Var" then
- if replacements[t[1]] then
- return replacements[t[1]]
+ if replacements[t:as_var()] then
+ return replacements[t:as_var()]
else
- return "SyntaxTree{mangle("..t[1]:as_lua().."), type="..t.type:as_lua()..", \
+ return "SyntaxTree{mangle("..t:as_var():as_lua().."), type="..t.type:as_lua()..", \
..source="..tostring(t.source):as_lua().."}"
end
elseif SyntaxTree:is_instance(t) then
@@ -265,7 +271,6 @@ test:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
[$action parses as $body] all parse as ([$action] all parse as $body)
-
externally ($tree as lua expr) means:
lua> ("
local tree_lua = compile(\$tree)
@@ -320,7 +325,7 @@ externally ($tree with vars $replacements) means
=lua ("
\$tree:map(function(\$t)
if \$t.type == "Var" then
- return \$replacements[\$t[1]]
+ return \$replacements[\$t:as_var()]
end
end)
")
@@ -328,7 +333,7 @@ externally ($tree with vars $replacements) means
(tree $tree with vars $replacements) compiles to ("
\(=lua "(\$tree):as_lua()"):map(function(t)
if t.type == "Var" then
- return \($replacements as lua expr)[t[1]]
+ return \($replacements as lua expr)[t:as_var()]
end
end)
")
@@ -344,7 +349,7 @@ externally ($tree with vars $replacements) means
externally (match $tree with $patt) means:
lua> ("
- if \$patt.type == "Var" then return Dict{[\$patt[1]]=\$tree} end
+ if \$patt.type == "Var" then return Dict{[\$patt:as_var()]=\$tree} end
if \$patt.type == "Action" and \$patt:get_stub() ~= \$tree:get_stub() then return nil end
if #\$patt ~= #\$tree then return nil end
local matches = Dict{}
diff --git a/core/operators.nom b/core/operators.nom
index 6c089a6..fa37a11 100644
--- a/core/operators.nom
+++ b/core/operators.nom
@@ -1,4 +1,4 @@
-#!/usr/bin/env nomsu -V6.13.12.8
+#!/usr/bin/env nomsu -V6.14
#
This file contains definitions of operators like "+" and "and".
@@ -24,12 +24,15 @@ test:
$x = 10
assume ($x == 10)
[$x, $y] = [10, 20]
- assume (($x == 10) and ($y == 20)) or barf "mutli-assignment failed."
+ unless (($x == 10) and ($y == 20)):
+ fail "mutli-assignment failed."
[$x, $y] = [$y, $x]
- assume (($y == 10) and ($x == 20)) or barf "swapping vars failed."
+ unless (($y == 10) and ($x == 20)):
+ fail "swapping vars failed."
$vals = [4, 5]
[$x, $y] = (unpack $vals)
- assume (($x == 4) and ($y == 5)) or barf "unpacking failed"
+ unless (($x == 4) and ($y == 5)):
+ fail "unpacking failed"
# Variable assignment operator
($var = $value) compiles to:
@@ -80,7 +83,7 @@ test:
external $foozle = "inner"
$y = "inner"
set global x local y
- assume (($foozle == "inner") and ($y == "outer")) or barf "external failed."
+ unless (($foozle == "inner") and ($y == "outer")): fail "external failed."
(external $var = $value) compiles to "\($var as lua) = \($value as lua)"
test:
[$foozle, $y] = ["outer", "outer"]
@@ -89,8 +92,8 @@ test:
$foozle = "inner"
$y = "inner"
set global x local y
- assume (($foozle == "inner") and ($y == "outer")) or barf
- "'with external' failed."
+ unless (($foozle == "inner") and ($y == "outer")):
+ fail "'with external' failed."
(with external $externs $body) compiles to:
$body_lua = ($body as lua)
@@ -104,10 +107,17 @@ test:
with [$z, $x = 999]:
assume $z == (nil)
$z = 999
- assume ($z == 999) or barf "'with' failed."
- assume ($x == 999) or barf "'with' assignment failed."
- assume ($x == 1) or barf "'with' scoping failed"
- assume ($z == (nil)) or barf "'with' scoping failed"
+ unless ($z == 999):
+ fail "'with' failed."
+
+ unless ($x == 999):
+ fail "'with' assignment failed."
+
+ unless ($x == 1):
+ fail "'with' scoping failed"
+
+ unless ($z == (nil)):
+ fail "'with' scoping failed"
(with $assignments $body) compiles to:
lua> ("
@@ -132,7 +142,8 @@ test:
# Math Operators
test:
- assume ((5 wrapped around 2) == 1) or barf "mod not working"
+ unless ((5 wrapped around 2) == 1):
+ fail "mod not working"
[$x wrapped around $y, $x mod $y] all compile to
"((\($x as lua expr)) % (\($y as lua expr)))"
@@ -144,9 +155,12 @@ test:
(one) means:
external $calls = ($calls + 1)
return 1
- assume (0 <= (one) <= 2) or barf "Three-way chained comparison failed."
- assume ($calls == 1) or barf
- "Three-way comparison evaluated middle value multiple times"
+
+ unless (0 <= (one) <= 2):
+ fail "Three-way chained comparison failed."
+
+ 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)
@@ -159,7 +173,7 @@ test:
# TODO: optimize for common case where x,y,z are all either variables or number literals
# Boolean Operators
test:
- (barfer) means (barf "short circuiting failed")
+ (barfer) means (fail "short circuiting failed")
assume (((no) and (barfer)) == (no))
assume ((no) or (yes))
assume ((yes) or (barfer))
@@ -228,11 +242,14 @@ test:
test:
$x = 1
$x += 1
- assume ($x == 2) or barf "+= failed"
+ unless ($x == 2):
+ fail "+= failed"
$x *= 2
- assume ($x == 4) or barf "*= failed"
+ unless ($x == 4):
+ fail "*= failed"
wrap $x around 3
- assume ($x == 1) or barf "wrap around failed"
+ 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) * $))
diff --git a/core/text.nom b/core/text.nom
index 80f5ac9..ad57498 100644
--- a/core/text.nom
+++ b/core/text.nom
@@ -1,4 +1,4 @@
-#!/usr/bin/env nomsu -V6.13.12.8
+#!/usr/bin/env nomsu -V6.14
#
This file contains some definitions of text escape sequences, including ANSI console
color codes.
diff --git a/examples/how_do_i.nom b/examples/how_do_i.nom
index 61a2b18..9645be1 100644
--- a/examples/how_do_i.nom
+++ b/examples/how_do_i.nom
@@ -1,5 +1,4 @@
-#!/usr/bin/env nomsu -V6.13.12.8
-
+#!/usr/bin/env nomsu -V6.14
# How do I...
# Write a comment? Put a # and go till the end of the line
# How do I write a multi-line comment?
@@ -250,6 +249,7 @@ say (2 + 3)
# If you need to keep going after an indented region, you can start the next line with ".."
say both "Very very very very long first argument that needs its own line"
..and also "short second arg"
+
(my favorite number) means (21 + 2)
# This can be nested:
diff --git a/lib/base64.nom b/lib/base64.nom
index f0c40b2..54f785f 100644
--- a/lib/base64.nom
+++ b/lib/base64.nom
@@ -1,4 +1,4 @@
-#!/usr/bin/env nomsu -V6.13.12.8
+#!/usr/bin/env nomsu -V6.14
#
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 6c5e176..db29b9f 100644
--- a/lib/consolecolor.nom
+++ b/lib/consolecolor.nom
@@ -1,4 +1,4 @@
-#!/usr/bin/env nomsu -V6.13.12.8
+#!/usr/bin/env nomsu -V6.14
#
This file defines actions for ANSI console color escape codes.
diff --git a/lib/file_hash.nom b/lib/file_hash.nom
index a708249..ec39e29 100644
--- a/lib/file_hash.nom
+++ b/lib/file_hash.nom
@@ -1,4 +1,4 @@
-#!/usr/bin/env nomsu -V6.13.12.8
+#!/usr/bin/env nomsu -V6.14
#
This file defines some actions for hashing files and looking up files by hash.
@@ -10,11 +10,12 @@ 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:
- (hash "hello world") = \(hash "hello world")
- (hash "goodbye") = \(hash "goodbye")
- ")
+ if ((hash "hello world") == (hash "goodbye")):
+ fail ("
+ Hash collision:
+ (hash "hello world") = \(hash "hello world")
+ (hash "goodbye") = \(hash "goodbye")
+ ")
assume
(
@@ -24,8 +25,8 @@ test:
")
) != "inf"
- assume ((hash "\000") != (hash "\000\000\000\000\000")) or barf
- "Incorrect hashing of null strings"
+ if ((hash "\000") == (hash "\000\000\000\000\000")):
+ fail "Incorrect hashing of null strings"
if $use_sha1:
assume ((hash "hello world") == "Kq5sNclPz7QV2+lfQIuc6R7oRu0=")
diff --git a/lib/object.nom b/lib/object.nom
index fa746b6..13a9ec5 100644
--- a/lib/object.nom
+++ b/lib/object.nom
@@ -1,4 +1,4 @@
-#!/usr/bin/env nomsu -V6.13.12.8
+#!/usr/bin/env nomsu -V6.14
#
This file contains the implementation of an Object-Oriented programming system.
@@ -37,7 +37,9 @@ test:
assume ($d.genus == "Canus")
assume ($d.barks == 3)
$d2 = (Dog {})
- assume ($d2.barks == 0) or barf "Default initializer failed"
+ unless ($d2.barks == 0):
+ fail "Default initializer failed"
+
with [$d = (Dog {.barks = 1})]:
assume (($d, bark) == "Bark!")
@@ -50,8 +52,12 @@ test:
$corg = (Corgi {})
assume ($corg.barks == 0)
with [$d = (Corgi {.barks = 1})]:
- assume (($d, sploot) == "splooted") or barf "subclass method failed"
- assume (($d, bark) == "Yip!") or barf "inheritance failed"
+ unless (($d, sploot) == "splooted"):
+ fail "subclass method failed"
+
+ unless (($d, bark) == "Yip!"):
+ fail "inheritance failed"
+
assume (($d, woof) == "Yip!")
with [$d = (Dog {.barks = 2})]:
diff --git a/lib/os.nom b/lib/os.nom
index 8c05836..2e4cd86 100644
--- a/lib/os.nom
+++ b/lib/os.nom
@@ -1,4 +1,4 @@
-#!/usr/bin/env nomsu -V6.13.12.8
+#!/usr/bin/env nomsu -V6.14
#
This file defines some actions that interact with the operating system and filesystem.
@@ -33,7 +33,9 @@ externally [
write to file $filename $text, to file $filename write $text
write $text to file $filename
] all mean:
- assume ($filename != "stdin") or barf "Cannot write to stdin"
+ unless ($filename != "stdin"):
+ fail "Cannot write to stdin"
+
lua> ("
local file = io.open(\$filename, 'w')
file:write(\$text)
@@ -45,10 +47,9 @@ externally (source lines of $tree) means:
$file = (read file $source.filename)
return
[
- :
- for $ in ($file, line number at $source.start) to
- $file, line number at $source.stop
- ..: add ($file, line $)
+ : 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 2820328..32942d9 100644
--- a/lib/things.nom
+++ b/lib/things.nom
@@ -1,4 +1,4 @@
-#!/usr/bin/env nomsu -V6.13.12.8
+#!/usr/bin/env nomsu -V6.14
#
A library for simple object oriented programming.
@@ -30,7 +30,9 @@ test:
assume ($d.genus == "Canus")
assume ($d.barks == 3)
$d2 = (a Dog)
- assume ($d2.barks == 0) or barf "Default initializer failed"
+ unless ($d2.barks == 0):
+ fail "Default initializer failed"
+
with [$d = (a Dog with {.barks = 1})]:
assume (($d, bark) == "Bark!")
@@ -47,8 +49,12 @@ test:
assume ($corg.barks == 0)
assume "\$corg" == "Dogloaf {barks: 0}"
with [$d = (a Corgi with {.barks = 1})]:
- assume (($d, sploot) == "sploooot") or barf "subclass method failed"
- assume (($d, bark) == "Yip!") or barf "inheritance failed"
+ unless (($d, sploot) == "sploooot"):
+ fail "subclass method failed"
+
+ unless (($d, bark) == "Yip!"):
+ fail "inheritance failed"
+
assume (($d, woof) == "Yip!")
with [$d = (a Dog with {.barks = 2})]:
@@ -87,9 +93,8 @@ $METAMETHOD_MAP = {
.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))
-..means:
+$($ as text like a dict) = ({}'s metatable).__tostring
+externally (a class named $classname with $members $(initialize $)) means:
$class = {.__type = $classname}
$class.__index = $class
$class.class = $class
@@ -103,7 +108,7 @@ externally (a class named $classname with $members ((initialize $it)'s meaning))
if $members.$key:
rawset $its $key $value
..else:
- barf "Cannot set \$key, it's not one of the allowed member fields."
+ fail "Cannot set \$key, it's not one of the allowed member fields."
set $class's metatable to {
.__tostring = ($class -> $class.__type)
@@ -116,7 +121,7 @@ externally (a class named $classname with $members ((initialize $it)'s meaning))
return $initial_values
}
- if ((initialize)'s meaning):
+ if $(initialize $):
initialize $class
for $stub = $metamethod in $METAMETHOD_MAP:
if $class.($stub, as lua id):
diff --git a/nomsu.6.peg b/nomsu.6.peg
index 344f679..9a9393f 100644
--- a/nomsu.6.peg
+++ b/nomsu.6.peg
@@ -99,14 +99,14 @@ indented_index_chain <-
-- Actions need 1 argument and either another argument or a word.
inline_action (Action) <-
!section_division
- ( word (ws* arg)*
- / inline_expression ((ws* arg)+ / "(" ws* ")"))
+ ( word (ws* inline_arg)*
+ / inline_expression ((ws* inline_arg)+ / "(" ws* ")"))
inline_arg <- inline_expression / word
action (Action) <-
!section_division
( word ((linesplit / ws*) arg)*
- / arg (((linesplit / ws*) arg)+ / "(" ws* ")"))
+ / !statement_block arg (((linesplit / ws*) arg)+ / "(" ws* ")"))
arg <- expression / indented_naked_expression / word
linesplit <- eol nl_nodent ".." ws*
diff --git a/nomsu_compiler.lua b/nomsu_compiler.lua
index c9f8fd6..cbe0c61 100644
--- a/nomsu_compiler.lua
+++ b/nomsu_compiler.lua
@@ -473,12 +473,7 @@ local compile = setmetatable({
elseif "Number" == _exp_0 then
return LuaCode:from(tree.source, tostring(tree[1]))
elseif "Var" == _exp_0 then
- if type(tree[1]) == 'string' then
- return LuaCode:from(tree.source, (concat(tree, " ")):as_lua_id())
- else
- assert(tree[1].type == 'Action')
- return LuaCode:from(tree.source, tree[1]:get_stub():as_lua_id())
- end
+ return LuaCode:from(tree.source, tree:as_var():as_lua_id())
elseif "FileChunks" == _exp_0 then
return error("Can't convert FileChunks to a single block of lua, since each chunk's " .. "compilation depends on the earlier chunks")
elseif "Comment" == _exp_0 then
diff --git a/nomsu_compiler.moon b/nomsu_compiler.moon
index 0602f63..5cd7863 100644
--- a/nomsu_compiler.moon
+++ b/nomsu_compiler.moon
@@ -370,11 +370,7 @@ compile = setmetatable({
return LuaCode\from(tree.source, tostring(tree[1]))
when "Var"
- if type(tree[1]) == 'string'
- return LuaCode\from(tree.source, (concat(tree, " "))\as_lua_id!)
- else
- assert(tree[1].type == 'Action')
- return LuaCode\from(tree.source, tree[1]\get_stub!\as_lua_id!)
+ return LuaCode\from(tree.source, tree\as_var!\as_lua_id!)
when "FileChunks"
error("Can't convert FileChunks to a single block of lua, since each chunk's "..
diff --git a/nomsu_decompiler.lua b/nomsu_decompiler.lua
index bf04f4a..02f2426 100644
--- a/nomsu_decompiler.lua
+++ b/nomsu_decompiler.lua
@@ -506,7 +506,10 @@ tree_to_nomsu = function(tree)
else
nomsu:add("\\")
local interp_nomsu = recurse(bit)
- if not (interp_nomsu:is_multiline()) then
+ if interp_nomsu:is_multiline() then
+ local curr_indent = nomsu:text():match("\n( *)[^\n]*$") or nomsu:text():match("^( *)")
+ interp_nomsu = NomsuCode((interp_nomsu:text():gsub("\n", "\n" .. curr_indent)))
+ else
local space = max_line - nomsu:trailing_line_len()
if bit.type == "Var" then
local next_str = tree[i + 1]
@@ -524,6 +527,8 @@ tree_to_nomsu = function(tree)
interp_nomsu2 = tree_to_nomsu(bit)
end
if #interp_nomsu2:text():lines() > 3 or #interp_nomsu2:text() >= MAX_LINE * GOLDEN_RATIO then
+ local curr_indent = nomsu:text():match("\n( *)[^\n]*$") or nomsu:text():match("^( *)")
+ interp_nomsu2 = NomsuCode((interp_nomsu2:text():gsub("\n", "\n" .. curr_indent)))
interp_nomsu = interp_nomsu2
else
nomsu:add("\n..\\")
diff --git a/nomsu_decompiler.moon b/nomsu_decompiler.moon
index 9d4face..bc5c986 100644
--- a/nomsu_decompiler.moon
+++ b/nomsu_decompiler.moon
@@ -385,7 +385,10 @@ tree_to_nomsu = (tree)->
else
nomsu\add "\\"
interp_nomsu = recurse(bit)
- unless interp_nomsu\is_multiline!
+ if interp_nomsu\is_multiline!
+ curr_indent = nomsu\text!\match("\n( *)[^\n]*$") or nomsu\text!\match("^( *)")
+ interp_nomsu = NomsuCode((interp_nomsu\text!\gsub("\n", "\n"..curr_indent)))
+ else
space = max_line - nomsu\trailing_line_len!
if bit.type == "Var"
next_str = tree[i+1]
@@ -400,6 +403,8 @@ tree_to_nomsu = (tree)->
tree_to_nomsu(bit)
if #interp_nomsu2\text!\lines! > 3 or #interp_nomsu2\text! >= MAX_LINE*GOLDEN_RATIO
+ curr_indent = nomsu\text!\match("\n( *)[^\n]*$") or nomsu\text!\match("^( *)")
+ interp_nomsu2 = NomsuCode((interp_nomsu2\text!\gsub("\n", "\n"..curr_indent)))
interp_nomsu = interp_nomsu2
else
nomsu\add "\n..\\"
diff --git a/syntax_tree.lua b/syntax_tree.lua
index a091e86..2365681 100644
--- a/syntax_tree.lua
+++ b/syntax_tree.lua
@@ -185,6 +185,14 @@ do
stub_bits[#stub_bits] = nil
end
return concat(stub_bits, " ")
+ end,
+ as_var = function(self)
+ assert(self.type == "Var")
+ if type(self[1]) == 'string' then
+ return self[1]
+ else
+ return self[1]:get_stub()
+ end
end
}
_base_0.__index = _base_0
diff --git a/syntax_tree.moon b/syntax_tree.moon
index 2579fad..ba854e1 100644
--- a/syntax_tree.moon
+++ b/syntax_tree.moon
@@ -99,6 +99,13 @@ class SyntaxTree
stub_bits[#stub_bits] = nil
return concat stub_bits, " "
+ as_var: =>
+ assert(@type == "Var")
+ if type(@[1]) == 'string'
+ return @[1]
+ else
+ return @[1]\get_stub!
+
@is_instance: (t)=>
type(t) == 'table' and getmetatable(t) == @__base
diff --git a/tools/find.nom b/tools/find.nom
index 781ca3f..8f2bc9f 100755
--- a/tools/find.nom
+++ b/tools/find.nom
@@ -1,4 +1,4 @@
-#!/usr/bin/env nomsu -V6.13.12.8
+#!/usr/bin/env nomsu -V6.14
#
This is a tool to find syntax trees matching a pattern. "*" is a wildcard
that will match any subtree, and "**" is a wildcard that will match any
@@ -24,7 +24,7 @@ use "lib/consolecolor.nom"
$wildcard = ($(COMMAND LINE ARGS).wildcard or "%*")
$pattern = $(COMMAND LINE ARGS).extras.1
if (any of [not $pattern, $pattern == "*", $pattern == "**"]):
- barf ("
+ fail ("
Usage: nomsu -t find [-l] [--wildcard=<wildcard>] <pattern>, where <pattern> is valid Nomsu code
")
$pattern = ($pattern, with "\$wildcard\$wildcard" -> "$multi_wildcard")
@@ -57,11 +57,11 @@ if ((#$filenames) == 0):
for $filename in $filenames:
$file = (read file $filename)
unless $file:
- barf "File does not exist: \$filename"
+ fail "File does not exist: \$filename"
$code = (NomsuCode from ($Source $filename 1 (size of $file)) $file)
try:
$tree = ($code parsed)
- ..and if it barfs $msg:
+ ..if it fails $msg:
say
red ("
\$filename failed to parse:
diff --git a/tools/format.nom b/tools/format.nom
index df89635..4915e46 100755
--- a/tools/format.nom
+++ b/tools/format.nom
@@ -1,4 +1,4 @@
-#!/usr/bin/env nomsu -V6.13.12.8
+#!/usr/bin/env nomsu -V6.14
#
Auto-format Nomsu code. Usage:
nomsu -t format [-i] file1 file2...
@@ -21,12 +21,12 @@ if ((#$filenames) == 0):
for $filename in $filenames:
$file = (read file $filename)
unless $file:
- barf "File does not exist: \$filename"
+ fail "File does not exist: \$filename"
$leading_indent = ($file, matching "\n*([ ]*)")
$code = (NomsuCode from ($Source $filename 1 (size of $file)) $file)
try:
$tree = ($code parsed)
- ..and if it barfs $msg:
+ ..if it fails $msg:
if $(COMMAND LINE ARGS).q:
$formatted = $file
..else:
diff --git a/tools/parse.nom b/tools/parse.nom
index ac9c42f..ab2c583 100755
--- a/tools/parse.nom
+++ b/tools/parse.nom
@@ -1,4 +1,4 @@
-#!/usr/bin/env nomsu -V6.13.12.8
+#!/usr/bin/env nomsu -V6.14
#
Tool to print out a parse tree of files in an easy-to-read format. Usage:
nomsu tools/parse.nom file1 file2 directory1 ...
@@ -39,7 +39,7 @@ externally (print tree $t at indent $indent) means:
for $filename in $(COMMAND LINE ARGS).extras:
$file = (read file $filename)
unless $file:
- barf "File does not exist: \$filename"
+ fail "File does not exist: \$filename"
$nomsu = (NomsuCode from (Source $filename 1 (size of $file)) $file)
$tree = ($nomsu parsed)
print tree $tree at indent ""
diff --git a/tools/repl.nom b/tools/repl.nom
index 4240ddc..c35abc5 100755
--- a/tools/repl.nom
+++ b/tools/repl.nom
@@ -1,4 +1,4 @@
-#!/usr/bin/env nomsu -V6.13.12.8
+#!/usr/bin/env nomsu -V6.14
#
This file defines a Read-Evaluate-Print-Loop (REPL) for Nomsu
@@ -45,7 +45,7 @@ repeat:
spoof file $buff
try:
$tree = ($buff parsed)
- ..and if it barfs $err:
+ ..if it fails $err:
say $err
do next
@@ -55,7 +55,7 @@ repeat:
for $chunk in $tree:
try:
$lua = ($chunk as lua)
- ..and if it barfs $err: say $err
+ ..if it fails $err: say $err
unless $lua:
do next
@@ -66,8 +66,8 @@ repeat:
$lua, remove free vars
try:
$ret = (run $lua)
- ..and if it barfs $err: say $err
- ..or if it succeeds:
+ ..if it fails $err: say $err
+ ..if it succeeds:
if (type of $ret) is:
"nil":
do nothing
diff --git a/tools/replace.nom b/tools/replace.nom
index 9d96c54..aa5d08c 100755
--- a/tools/replace.nom
+++ b/tools/replace.nom
@@ -1,4 +1,4 @@
-#!/usr/bin/env nomsu -V6.13.12.8
+#!/usr/bin/env nomsu -V6.14
#
This is a tool to replace syntax trees with something new.
@@ -21,7 +21,7 @@ use "lib/consolecolor.nom"
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
if ((#$(COMMAND LINE ARGS).extras) < 2):
- barf ("
+ fail ("
Usage: nomsu -t replace [--literal="$v1 $v2..."] <pattern> <replacement> file1 file2...
")
$pattern = $(COMMAND LINE ARGS).extras.1
@@ -34,7 +34,7 @@ if $(COMMAND LINE ARGS).literal:
$literal_vars.$var = (yes)
if (($pattern_tree.type == "Var") and (not $literal_vars.($pattern_tree.1))):
- barf "Pattern matches every part of the file."
+ fail "Pattern matches every part of the file."
$pattern_vars = {
: for $ in recursive $pattern_tree:
@@ -77,7 +77,6 @@ $pattern_vars = {
if ((#$tree) != (#$patt)): return (nil)
return $substitution_values
-
$filenames = ($(COMMAND LINE ARGS).extras, from 3 to -1)
if ((#$filenames) == 0):
say ("
@@ -88,14 +87,13 @@ if ((#$filenames) == 0):
for $filename in $filenames:
$file = (read file $filename)
unless $file:
- barf "File does not exist: \$filename"
+ fail "File does not exist: \$filename"
$code = (NomsuCode from ($Source $filename 1 (size of $file)) $file)
try:
$tree = ($code parsed)
- ..and if it barfs $msg:
+ ..if it fails $msg:
if $(COMMAND LINE ARGS).q:
- unless $(COMMAND LINE ARGS).i:
- say $code
+ unless $(COMMAND LINE ARGS).i: say $code
..else:
say $msg
diff --git a/tools/test.nom b/tools/test.nom
index d9e9269..f8373d8 100755
--- a/tools/test.nom
+++ b/tools/test.nom
@@ -1,4 +1,4 @@
-#!/usr/bin/env nomsu -V6.13.12.8
+#!/usr/bin/env nomsu -V6.14
#
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/tools/upgrade.nom b/tools/upgrade.nom
index 5cf7d60..01040c8 100755
--- a/tools/upgrade.nom
+++ b/tools/upgrade.nom
@@ -1,4 +1,4 @@
-#!/usr/bin/env nomsu -V6.13.12.8
+#!/usr/bin/env nomsu -V6.14
#
Tool to automatically update code from old versions of Nomsu. Usage:
nomsu tools/upgrade.nom [-i] file1 file2 directory1 ...
@@ -18,7 +18,7 @@ $test = ($(COMMAND LINE ARGS).t or $(COMMAND LINE ARGS).test)
for $filename in $(COMMAND LINE ARGS).extras:
$file = (read file $filename)
unless $file:
- barf "File does not exist: \$filename"
+ fail "File does not exist: \$filename"
$leading_indent = ($file, matching "\n*([ ]*)")
$code = (NomsuCode from (Source $filename 1 (size of $file)) $file)
$tree = ($code parsed $start_version)