aboutsummaryrefslogtreecommitdiff
path: root/lib/tools
diff options
context:
space:
mode:
authorBruce Hill <bruce@bruce-hill.com>2019-03-14 16:30:43 -0700
committerBruce Hill <bruce@bruce-hill.com>2019-03-14 16:30:43 -0700
commitddb839bfd4ba8dbdd214f3e885629fc8fe57e68c (patch)
treeaee183d005229b21a5ce636685f416f97bd5aa9e /lib/tools
parent7f138199078a2fc2b6d6ee8d31da940120c8216a (diff)
Replacing (size of $) with (#$) as should have been done before.
Diffstat (limited to 'lib/tools')
-rwxr-xr-xlib/tools/find.nom4
-rwxr-xr-xlib/tools/repl.nom25
-rwxr-xr-xlib/tools/replace.nom4
-rwxr-xr-xlib/tools/upgrade.nom4
4 files changed, 17 insertions, 20 deletions
diff --git a/lib/tools/find.nom b/lib/tools/find.nom
index db7a2c5..e28681a 100755
--- a/lib/tools/find.nom
+++ b/lib/tools/find.nom
@@ -60,7 +60,7 @@ command line program with $args:
$file = (read file $filename)
unless $file:
fail "File does not exist: \$filename"
- $code = (NomsuCode from ($Source $filename 1 (size of $file)) $file)
+ $code = (NomsuCode from ($Source $filename 1 (#$file)) $file)
try:
$tree = ($code parsed)
..if it fails with $msg:
@@ -96,4 +96,4 @@ command line program with $args:
..else:
sort $results by $ -> $.line
for $ in $results:
- say $.text
+ say $.text \ No newline at end of file
diff --git a/lib/tools/repl.nom b/lib/tools/repl.nom
index 716c899..76b35cb 100755
--- a/lib/tools/repl.nom
+++ b/lib/tools/repl.nom
@@ -15,7 +15,7 @@ external:
You can type in Nomsu code here and hit 'enter' twice to run it.
To exit, type 'exit' or 'quit' and hit enter twice.
")
-
+
(tutorial) means:
(use "tools/tutorial").run_with {.extras = []}
exit
@@ -29,19 +29,18 @@ command line program with $args:
type 'tutorial' to run the tutorial
")
-
+
# Best way I know of to detect the number of return values and only
print if it's >0:
(say results of (*extra arguments*)) means:
$N = (select "#" (*extra arguments*))
- if ($N == 0):
- return
+ if ($N == 0): return
for $ in 1 to $N:
$ret = (select $ (*extra arguments*))
if ($ret is "Text"):
$ret = (quote $ret)
say "\$ret"
-
+
repeat:
say (bright (yellow ">> ")) inline
$buff = []
@@ -50,7 +49,7 @@ command line program with $args:
$line = ($io.read "*L")
say (reset color) inline
if (($line == "\n") or (not $line)):
- if ((size of $buff) > 0):
+ if ((#$buff) > 0):
# clear the line
if $(COLOR ENABLED):
say "\027[1A\027[2K" inline
@@ -58,7 +57,7 @@ command line program with $args:
$buff, add ($line, with "\t" -> " ")
say (dim (yellow ".. ")) inline
--- (run buffer) ---
- if ((size of $buff) == 0): stop
+ if ((#$buff) == 0): stop
$buff = ($buff, joined)
spoof file $buff
try:
@@ -69,14 +68,12 @@ command line program with $args:
unless $tree:
do next
-
+
if ($tree.type == "Comment"):
say (dim "Comment:\($tree.1)")
do next
-
- if ($tree.type != "FileChunks"):
- $tree = [$tree]
-
+
+ if ($tree.type != "FileChunks"): $tree = [$tree]
for $chunk in $tree:
try:
$lua = ($chunk as lua)
@@ -91,7 +88,7 @@ command line program with $args:
$lua, remove free vars
if (load "return \($lua, text)"):
$lua, prepend "return "
-
+
try:
say results of (run $lua)
- ..if it fails with $err: say $err
+ ..if it fails with $err: say $err \ No newline at end of file
diff --git a/lib/tools/replace.nom b/lib/tools/replace.nom
index 314834e..3a56002 100755
--- a/lib/tools/replace.nom
+++ b/lib/tools/replace.nom
@@ -90,7 +90,7 @@ command line program with $args:
$file = (read file $filename)
unless $file:
fail "File does not exist: \$filename"
- $code = (NomsuCode from ($Source $filename 1 (size of $file)) $file)
+ $code = (NomsuCode from ($Source $filename 1 (#$file)) $file)
try:
$tree = ($code parsed)
..if it fails with $msg:
@@ -142,4 +142,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/upgrade.nom b/lib/tools/upgrade.nom
index f4a2b8c..debce62 100755
--- a/lib/tools/upgrade.nom
+++ b/lib/tools/upgrade.nom
@@ -27,7 +27,7 @@ command line program with $args:
unless $file:
fail "File does not exist: \$filename"
$leading_indent = ($file, matching "\n*([ ]*)")
- $code = (NomsuCode from (Source $filename 1 (size of $file)) $file)
+ $code = (NomsuCode from (Source $filename 1 (#$file)) $file)
$tree = ($code parsed $start_version)
$uptree =
$tree upgraded from ($start_version or ($tree.version or $(NOMSU VERSION))) to
@@ -45,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