aboutsummaryrefslogtreecommitdiff
path: root/tools/replace.nom
diff options
context:
space:
mode:
authorBruce Hill <bruce@bruce-hill.com>2019-01-01 17:15:51 -0800
committerBruce Hill <bruce@bruce-hill.com>2019-01-01 17:17:23 -0800
commit3e89092833a6d407e711fe4ae5f44474ff34cf64 (patch)
tree5ffe2df86f648b604347b59999992d74f71a796c /tools/replace.nom
parente68eb04d690454428216a0f0f1b11399feeb7dc1 (diff)
Some changes to the error API, a fix for statement block parsing, and
replacing ((foo 1 baz)'s meaning) with $(foo 1 baz).
Diffstat (limited to 'tools/replace.nom')
-rwxr-xr-xtools/replace.nom14
1 files changed, 6 insertions, 8 deletions
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