diff options
| author | Bruce Hill <bruce@bruce-hill.com> | 2018-11-19 17:37:37 -0800 |
|---|---|---|
| committer | Bruce Hill <bruce@bruce-hill.com> | 2018-11-19 17:37:37 -0800 |
| commit | a89d69e843ba83df928051005d02a932a9981f46 (patch) | |
| tree | 17f99cda2d4e5f0a7983ed14f4ac559b64944207 /tools | |
| parent | 43ff3892f39188163446f1a00ee8d2aad59e0392 (diff) | |
Autoformatted/auto-upgraded.
Diffstat (limited to 'tools')
| -rwxr-xr-x | tools/autoformat.nom | 13 | ||||
| -rwxr-xr-x | tools/find_action.nom | 9 | ||||
| -rwxr-xr-x | tools/parse.nom | 7 | ||||
| -rw-r--r-- | tools/repl.nom | 4 | ||||
| -rwxr-xr-x | tools/replace.nom | 4 | ||||
| -rwxr-xr-x | tools/test.nom | 12 | ||||
| -rwxr-xr-x | tools/upgrade.nom | 4 |
7 files changed, 32 insertions, 21 deletions
diff --git a/tools/autoformat.nom b/tools/autoformat.nom index 8626c91..96b732b 100755 --- a/tools/autoformat.nom +++ b/tools/autoformat.nom @@ -1,7 +1,7 @@ -#!/usr/bin/env nomsu -V4.10.12.7 +#!/usr/bin/env nomsu -V4.11.12.8 # Auto-format Nomsu code. Usage: - nomsu tools/autoformat.nom [-i] file1 file2 directory1 ... + nomsu tools/autoformat.nom [-i] file1 file2 directory1 ... If the first argument is "-i", modifications will be performed in-place. Otherwise, the formatted code will be printed. @@ -16,9 +16,12 @@ if (%args.1 is "-i"): %args::remove index 1 for %path in %args: - if (%path == "-"): %path = "stdin" - for file %filename in %path: - unless ((%filename::matches "%.nom$") or (%filename == "stdin")): do next %filename + if (%path == "-"): + %path = "stdin" + + for %filename in (files for %path): + unless ((%filename::matches "%.nom$") or (%filename == "stdin")): + do next %filename %contents = (read file %filename) %code = (NomsuCode from (Source %filename 1 (size of %contents)) %contents) %tree = (%code parsed) diff --git a/tools/find_action.nom b/tools/find_action.nom index 1b7c4e1..c6cbe36 100755 --- a/tools/find_action.nom +++ b/tools/find_action.nom @@ -1,4 +1,4 @@ -#!/usr/bin/env nomsu -V4.10.12.7 +#!/usr/bin/env nomsu -V4.11.12.8 # Find an action by its stub. Usage: nomsu tools/find_action.nom "foo %" file1 file2 directory1 ... @@ -13,9 +13,12 @@ use "lib/consolecolor.nom" say "Looking for stub: \%stub..." for % in 2 to (size of (command line args)): for %filename in (files for (command line args).%): - if (%filename == "-"): %filename = "stdin" + 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: @@ -30,7 +33,7 @@ for % in 2 to (size of (command line args)): %results = [] for %t in recursive %tree: if ((%t is "Action" syntax tree) and (%t.stub is %stub)): - %line_num = (line number of %t.source.start in %file) + %line_num = (%file::line number at %t.source.start) %results::add {..} line: %line_num, text: "\(blue "\%filename:\%line_num:")\n\(yellow (source lines of %t))" diff --git a/tools/parse.nom b/tools/parse.nom index 10d4dde..9e43c88 100755 --- a/tools/parse.nom +++ b/tools/parse.nom @@ -1,4 +1,4 @@ -#!/usr/bin/env nomsu -V4.10.12.7 +#!/usr/bin/env nomsu -V4.11.12.8 # Tool to print out a parse tree of files in an easy-to-read format. Usage: nomsu tools/parse.nom file1 file2 directory1 ... @@ -37,9 +37,12 @@ externally (print tree %t at indent %indent) means: for %path in (command line args): for %filename in (files for %path): - if (%filename == "-"): %filename = "stdin" + 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) diff --git a/tools/repl.nom b/tools/repl.nom index daa39d0..39d6360 100644 --- a/tools/repl.nom +++ b/tools/repl.nom @@ -1,7 +1,7 @@ -#!/usr/bin/env nomsu -V4.10.12.7 +#!/usr/bin/env nomsu -V4.11.12.8 # This file defines a Read-Evaluate-Print-Loop (REPL) for Nomsu - + use "lib/consolecolor.nom" use "lib/os.nom" diff --git a/tools/replace.nom b/tools/replace.nom index ffd96c1..1ec8ecc 100755 --- a/tools/replace.nom +++ b/tools/replace.nom @@ -1,4 +1,4 @@ -#!/usr/bin/env nomsu -V4.10.12.7 +#!/usr/bin/env nomsu -V4.11.12.8 # Tool to find and replace one tree with another. nomsu tools/replace.nom [-i] tree_to_replace replacement file1 file2 directory1 ... @@ -22,7 +22,7 @@ if ((size of %args) < 3): %pattern = (parse (%args::remove index 1)) %replacement = (parse (%args::remove index 1)) for %path in %args: - for file %filename in %path: + for %filename in (files for %path): unless (any [%filename::matches "%.nom$", %filename == "-", %filename == "stdin"]): do next %filename %tree = (parse (read file %filename) from %filename) diff --git a/tools/test.nom b/tools/test.nom index 32c9b7a..bdbec54 100755 --- a/tools/test.nom +++ b/tools/test.nom @@ -1,4 +1,4 @@ -#!/usr/bin/env nomsu -V4.10.12.7 +#!/usr/bin/env nomsu -V4.11.12.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 ... @@ -17,11 +17,13 @@ if (%args.1 == "-v"): : 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 + if (%filename == "-"): + %filename = "stdin" + if ((%filename::matches "%.nom$") or (%filename == "stdin")): add %filename + # Make sure all the files get run -for %filename in %to_run: use %filename +for %filename in %to_run: + use %filename %tests = {: for %s = %t in (tests): add (=lua "Source:from_string(\%s)") = %t} for %filename in %to_run: %file_tests = [] diff --git a/tools/upgrade.nom b/tools/upgrade.nom index 5f50f73..56d67a5 100755 --- a/tools/upgrade.nom +++ b/tools/upgrade.nom @@ -1,4 +1,4 @@ -#!/usr/bin/env nomsu -V4.10.12.7 +#!/usr/bin/env nomsu -V4.11.12.8 # Tool to automatically update code from old versions of Nomsu. Usage: nomsu tools/upgrade.nom [-i] file1 file2 directory1 ... @@ -38,7 +38,7 @@ repeat: else: stop for %path in %args: - for file %filename in %path: + for %filename in (files for %path): unless (%filename::matches "%.nom$"): do next %filename %file = (read file %filename) %code = (NomsuCode from (%Source %filename 1 (size of %file)) %file) |
