diff options
Diffstat (limited to 'lib/tools')
| -rwxr-xr-x | lib/tools/find.nom | 10 | ||||
| -rwxr-xr-x | lib/tools/format.nom | 4 | ||||
| -rwxr-xr-x | lib/tools/parse.nom | 4 | ||||
| -rwxr-xr-x | lib/tools/repl.nom | 19 | ||||
| -rwxr-xr-x | lib/tools/replace.nom | 16 | ||||
| -rwxr-xr-x | lib/tools/test.nom | 14 | ||||
| -rwxr-xr-x | lib/tools/upgrade.nom | 2 |
7 files changed, 35 insertions, 34 deletions
diff --git a/lib/tools/find.nom b/lib/tools/find.nom index a4db987..db7a2c5 100755 --- a/lib/tools/find.nom +++ b/lib/tools/find.nom @@ -1,4 +1,4 @@ -#!/usr/bin/env nomsu -V6.14 +#!/usr/bin/env nomsu -V6.15.13.8 # 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 @@ -55,7 +55,7 @@ command line program with $args: Warning: searching stdin (ctrl-d to abort). To avoid this message, use nomsu -t find - ") $filenames = ["stdin"] - + for $filename in $filenames: $file = (read file $filename) unless $file: @@ -79,7 +79,11 @@ command line program with $args: if ($t matches $pattern_tree): $line_num = ($file, line number at $t.source.start) $results, add { - .line = $line_num, .text = "\(blue "\$filename:\$line_num:")\n\(source lines of $t)" + .line = $line_num + .text = (" + \(blue "\$filename:\$line_num:") + \(source lines of $t) + ") } for $sub in $t: diff --git a/lib/tools/format.nom b/lib/tools/format.nom index 445f35e..eee1316 100755 --- a/lib/tools/format.nom +++ b/lib/tools/format.nom @@ -1,4 +1,4 @@ -#!/usr/bin/env nomsu -V6.14 +#!/usr/bin/env nomsu -V6.15.13.8 # Auto-format Nomsu code. Usage: nomsu -t format [-i] file1 file2... @@ -19,7 +19,7 @@ command line program with $args: Warning: reading from stdin (ctrl-d to abort). To avoid this message, use nomsu -t format - ") $filenames = ["stdin"] - + for $filename in $filenames: $file = (read file $filename) unless $file: diff --git a/lib/tools/parse.nom b/lib/tools/parse.nom index 63cc247..a7e306e 100755 --- a/lib/tools/parse.nom +++ b/lib/tools/parse.nom @@ -1,4 +1,4 @@ -#!/usr/bin/env nomsu -V6.14 +#!/usr/bin/env nomsu -V6.15.13.8 # Tool to print out a parse tree of files in an easy-to-read format. Usage: nomsu tools/parse.nom file1 file2 directory1 ... @@ -8,7 +8,7 @@ use "commandline" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -externally (print tree $t at indent $indent) means: +(print tree $t at indent $indent) means: if $t.type is: "Action": say "\($indent)Action (\($t.stub)):" diff --git a/lib/tools/repl.nom b/lib/tools/repl.nom index 2c0d3df..63d9e30 100755 --- a/lib/tools/repl.nom +++ b/lib/tools/repl.nom @@ -1,4 +1,4 @@ -#!/usr/bin/env nomsu -V6.14 +#!/usr/bin/env nomsu -V6.15.13.8 # This file defines a Read-Evaluate-Print-Loop (REPL) for Nomsu @@ -8,12 +8,13 @@ use "commandline" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -externally (help) means: - say (" - This is the Nomsu v\(Nomsu version) interactive console. - You can type in Nomsu code here and hit 'enter' twice to run it. - To exit, type 'exit' or 'quit' and hit enter twice. - ") +external: + (help) means: + say (" + This is the Nomsu v\(Nomsu version) interactive console. + You can type in Nomsu code here and hit 'enter' twice to run it. + To exit, type 'exit' or 'quit' and hit enter twice. + ") command line program with $args: say (" @@ -23,7 +24,7 @@ command line program with $args: press 'enter' twice to run a command ") - + repeat: say (bright (yellow ">> ")) inline $buff = [] @@ -38,9 +39,7 @@ command line program with $args: go to (run buffer) $buff, add ($line, with "\t" -> " ") say (dim (yellow ".. ")) inline - --- (run buffer) --- - if ((size of $buff) == 0): stop $buff = ($buff, joined) spoof file $buff diff --git a/lib/tools/replace.nom b/lib/tools/replace.nom index efc4d09..d9926cf 100755 --- a/lib/tools/replace.nom +++ b/lib/tools/replace.nom @@ -1,4 +1,4 @@ -#!/usr/bin/env nomsu -V6.14 +#!/usr/bin/env nomsu -V6.15.13.8 # This is a tool to replace syntax trees with something new. @@ -34,10 +34,10 @@ command line program with $args: if $args.literal: for $var in ($args.literal, all matches of "$([^ ]*)"): $literal_vars.$var = (yes) - + if (($pattern_tree.type == "Var") and (not $literal_vars.($pattern_tree.1))): fail "Pattern matches every part of the file." - + $pattern_vars = { : for $ in recursive $pattern_tree: if (($.type == "Var") and (not $literal_vars.($.1))): add $.1 @@ -45,7 +45,7 @@ command line program with $args: if ($child is a "Syntax Tree"): recurse $ on $child } - + # TODO: support wildcards and unpacking e.g. nomsu -t replace "test(: $test; *$more_tests)" "*$more_tests; *$test" ($tree matches $patt with $substitution_values) means: @@ -85,7 +85,7 @@ command line program with $args: Warning: searching stdin (ctrl-d to abort). To avoid this message, use nomsu -t find - ") $filenames = ["stdin"] - + for $filename in $filenames: $file = (read file $filename) unless $file: @@ -95,7 +95,8 @@ command line program with $args: $tree = ($code parsed) ..if it fails with $msg: if $args.q: - unless $args.i: say $code + unless $args.i: + say $code ..else: say $msg @@ -124,13 +125,10 @@ command line program with $args: ..\(reset color) ") say "\(bright)..be replaced with:" - say (" \(bright)\(blue)\("\($ret as nomsu)", with "\n" -> "\n ")\(reset color) ") - $user_answers.$t = (ask "\(bright)..? [Y/n]\(reset color) ") - if ($user_answers.$t == "n"): return (nil) $replaced.$t = (yes) return $ret diff --git a/lib/tools/test.nom b/lib/tools/test.nom index 4663bd4..761ec55 100755 --- a/lib/tools/test.nom +++ b/lib/tools/test.nom @@ -1,4 +1,4 @@ -#!/usr/bin/env nomsu -V6.14 +#!/usr/bin/env nomsu -V6.15.13.8 # 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 ... @@ -14,7 +14,6 @@ command line program with $args: $file = (read file $filename) unless $file: fail "Couldn't find \$filename" - $(test environment) = (new environment) $(test environment), export $filename $version = @@ -24,7 +23,7 @@ command line program with $args: ]*) ") $file_tests = [] - for $src = $test in $(test environment).TESTS: + for $src = $test in (nomsu environment, Module $filename).TESTS: if $version: $test = (" #!/usr/bin/env nomsu -V\$version @@ -36,20 +35,22 @@ command line program with $args: sort $file_tests by $ -> $.source say "[ .. ] \$filename" inline $io.flush() - if $args.v: say "" - $failures = [] for $ in $file_tests: if $args.v: say " \(yellow ($.test, with "\n" -> "\n "))" + try: $(test environment), run $.test ..if it fails with $msg: $src = ($Source, from string $.source) $l1 = ($file, line number at $src.start) $l2 = ($file, line number at $src.stop) - $failures, add "\(yellow "\($src.filename):\($l1)-\$l2:")\n\(bright (red ($msg, indented)))" + $failures, add (" + \(yellow "\($src.filename):\($l1)-\$l2:") + \(bright (red ($msg, indented))) + ") if ($failures is empty): if $args.v: @@ -62,4 +63,3 @@ command line program with $args: ..else: say "\r[\(red (bright "FAIL"))" say "\($failures, joined with "\n", indented)" - diff --git a/lib/tools/upgrade.nom b/lib/tools/upgrade.nom index 2c63411..30b6cab 100755 --- a/lib/tools/upgrade.nom +++ b/lib/tools/upgrade.nom @@ -1,4 +1,4 @@ -#!/usr/bin/env nomsu -V6.14 +#!/usr/bin/env nomsu -V6.15.13.8 # Tool to automatically update code from old versions of Nomsu. Usage: nomsu tools/upgrade.nom [-i] file1 file2 directory1 ... |
