aboutsummaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorBruce Hill <bruce@bruce-hill.com>2018-11-19 17:21:08 -0800
committerBruce Hill <bruce@bruce-hill.com>2018-11-19 17:21:17 -0800
commitacd1191fb06a51f70f553c1dc8b47cf245a1c913 (patch)
tree993bb69cc050426644b98d10fb1a3133b3623be6 /tools
parent7f47d4204039258cec78c767f489b7809b4257ff (diff)
Tweaks and API cleanup.
Diffstat (limited to 'tools')
-rwxr-xr-xtools/find_action.nom9
-rwxr-xr-xtools/parse.nom13
-rwxr-xr-xtools/test.nom50
3 files changed, 40 insertions, 32 deletions
diff --git a/tools/find_action.nom b/tools/find_action.nom
index c51a144..1b7c4e1 100755
--- a/tools/find_action.nom
+++ b/tools/find_action.nom
@@ -11,10 +11,11 @@ use "lib/consolecolor.nom"
%stub = (command line args).1
say "Looking for stub: \%stub..."
-%files = [: for % in 2 to (size of (command line args)): add (command line args).%]
-for %path in %files:
- for file %filename in %path:
- unless (%filename::matches "%.nom$"): do next %filename
+for % in 2 to (size of (command line args)):
+ for %filename in (files for (command line args).%):
+ 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:
diff --git a/tools/parse.nom b/tools/parse.nom
index 6f88179..10d4dde 100755
--- a/tools/parse.nom
+++ b/tools/parse.nom
@@ -35,7 +35,12 @@ externally (print tree %t at indent %indent) means:
else:
say "\%indent \(quote %arg)"
-for %path in (=lua "arg"):
- for file %filename in %path:
- unless (%filename::matches "%.nom$"): do next %filename
- print tree (parse (read file %filename) from %filename) at indent ""
+for %path in (command line args):
+ for %filename in (files for %path):
+ 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)
+ print tree %tree at indent ""
diff --git a/tools/test.nom b/tools/test.nom
index f9ed2cb..32c9b7a 100755
--- a/tools/test.nom
+++ b/tools/test.nom
@@ -13,30 +13,32 @@ if (%args.1 == "-v"):
%args::remove index 1
%verbose = (yes)
+%to_run = [..]
+ :
+ 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
# Make sure all the files get run
-for %path in (command line args):
- for file %filename in %path:
- if (%filename::matches "%.nom$"): use %filename
-for %path in (command line args): use %path
+for %filename in %to_run: use %filename
%tests = {: for %s = %t in (tests): add (=lua "Source:from_string(\%s)") = %t}
-for %path in (command line args):
- for file %filename in %path:
- unless (%filename::matches "%.nom$"): do next %filename
- %file_tests = []
- for %src = %test in %tests:
- if (%src.filename == %filename):
- %file_tests::add {test: %test, source: %src}
-
- unless (%file_tests is empty):
- sort %file_tests by % -> %.source
- lua> "io.write('[ .. ] ', \%filename); io.flush()"
- if %verbose: say ""
- for % in %file_tests:
- if %verbose:
- say " \(yellow (%.test::with "\n" -> "\n "))"
- run %.test
-
+for %filename in %to_run:
+ %file_tests = []
+ for %src = %test in %tests:
+ if (%src.filename == %filename):
+ %file_tests::add {test: %test, source: %src}
+
+ unless (%file_tests is empty):
+ sort %file_tests by % -> %.source
+ lua> "io.write('[ .. ] ', \%filename); io.flush()"
+ if %verbose: say ""
+ for % in %file_tests:
if %verbose:
- say (green "PASS")
- ..else:
- say "\r[\(green "PASS")"
+ say " \(yellow (%.test::with "\n" -> "\n "))"
+ run %.test
+
+ if %verbose:
+ say (green "PASS")
+ ..else:
+ say "\r[\(green "PASS")"