aboutsummaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorBruce Hill <bruce@bruce-hill.com>2018-11-02 15:17:48 -0700
committerBruce Hill <bruce@bruce-hill.com>2018-11-02 15:17:49 -0700
commit0f17c5eb9ac4660f2f969bd1e67af42713e45eac (patch)
tree279ca7da2de0efe2f363684f3c84a540635f11a8 /tools
parentacd9c2acd4688f2301b091daad910c04e402bd6a (diff)
parentdc41f30c73c9686685e3a4183c1213fb4ba55c90 (diff)
Merge branch 'master' into working
Diffstat (limited to 'tools')
-rwxr-xr-xtools/autoformat.nom4
-rwxr-xr-xtools/find_action.nom22
-rwxr-xr-xtools/parse.nom6
-rwxr-xr-xtools/replace.nom4
-rwxr-xr-xtools/test.nom5
-rwxr-xr-xtools/upgrade.nom41
6 files changed, 55 insertions, 27 deletions
diff --git a/tools/autoformat.nom b/tools/autoformat.nom
index a915fa4..13f54ef 100755
--- a/tools/autoformat.nom
+++ b/tools/autoformat.nom
@@ -1,7 +1,7 @@
-#!/usr/bin/env nomsu -V4.8.8.6
+#!/usr/bin/env nomsu -V4.8.10
#
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.
diff --git a/tools/find_action.nom b/tools/find_action.nom
index e6fe90a..02abdbc 100755
--- a/tools/find_action.nom
+++ b/tools/find_action.nom
@@ -1,7 +1,7 @@
-#!/usr/bin/env nomsu -V4.8.8.6
+#!/usr/bin/env nomsu -V4.8.10
#
Find an action by its stub. Usage:
- nomsu tools/find_action.nom "foo %" file1 file2 directory1 ...
+ nomsu tools/find_action.nom "foo %" file1 file2 directory1 ...
Will print all the code locations and code that uses the stub.
use "lib/os.nom"
@@ -14,13 +14,25 @@ for %path in %files:
for file %filename in %path:
unless (%filename::matches "%.nom$") (do next %filename)
%file = (read file %filename)
- %tree = (parse %file from %filename)
+ try:
+ %tree = (parse %file from %filename)
+ ..and if it barfs:
+ say (red "\%filename failed to parse")
+ %tree = (nil)
+ unless %tree: do next %filename
+ %results = []
for %t in recursive %tree:
if (%t is "Action" syntax tree):
if (%t.stub is %stub):
%line_num = (line number of %t.source.start in %file)
- say (blue "\%filename:\%line_num:")
- say (yellow (source lines of %t))
+ %results::add {..}
+ line: %line_num
+ text: "\
+ ..\(blue "\%filename:\%line_num:")
+ \(yellow (source lines of %t))"
if (%t is syntax tree):
for %sub in %t: recurse %t on %sub
+
+ sort %results by % -> %.line
+ for % in %results: say %.text
diff --git a/tools/parse.nom b/tools/parse.nom
index 9d728e8..de6aff4 100755
--- a/tools/parse.nom
+++ b/tools/parse.nom
@@ -1,11 +1,11 @@
-#!/usr/bin/env nomsu -V4.8.8.6
+#!/usr/bin/env nomsu -V4.8.10
#
Tool to print out a parse tree of files in an easy-to-read format. Usage:
- nomsu tools/parse.nom file1 file2 directory1 ...
+ nomsu tools/parse.nom file1 file2 directory1 ...
use "lib/os.nom"
-action [print tree %t at indent %indent]:
+externally (print tree %t at indent %indent) means:
if %t.type is:
"Action":
say "\(%indent)Action (\(%t.stub)):"
diff --git a/tools/replace.nom b/tools/replace.nom
index c55793a..25ae0ae 100755
--- a/tools/replace.nom
+++ b/tools/replace.nom
@@ -1,7 +1,7 @@
-#!/usr/bin/env nomsu -V4.8.8.6
+#!/usr/bin/env nomsu -V4.8.10
#
Tool to find and replace one tree with another.
- nomsu tools/replace.nom [-i] tree_to_replace replacement file1 file2 directory1 ...
+ nomsu tools/replace.nom [-i] tree_to_replace replacement file1 file2 directory1 ...
If "-i" is the first argument, replacements will be performed in-place. Otherwise, the
upgraded code will be printed.
diff --git a/tools/test.nom b/tools/test.nom
index 6d557ea..fb70d1c 100755
--- a/tools/test.nom
+++ b/tools/test.nom
@@ -1,7 +1,7 @@
-#!/usr/bin/env nomsu -V4.8.8.6
+#!/usr/bin/env nomsu -V4.8.10
#
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 ...
+ nomsu tools/test.nom file1 file2 directory1 ...
use "lib/os.nom"
use "lib/consolecolor.nom"
@@ -17,7 +17,6 @@ for %path in (command line args):
if (%filename::matches "%.nom$"): use %filename
for %path in (command line args): use %path
-
%tests = ((=lua "Source:from_string(\%s)") = %t for %s = %t in (tests))
for %path in (command line args):
for file %filename in %path:
diff --git a/tools/upgrade.nom b/tools/upgrade.nom
index cd3fbbb..575646e 100755
--- a/tools/upgrade.nom
+++ b/tools/upgrade.nom
@@ -1,7 +1,7 @@
-#!/usr/bin/env nomsu -V4.8.8.6
+#!/usr/bin/env nomsu -V4.8.10
#
Tool to automatically update code from old versions of Nomsu. Usage:
- nomsu tools/upgrade.nom [-i] file1 file2 directory1 ...
+ nomsu tools/upgrade.nom [-i] file1 file2 directory1 ...
If "-i" is the first argument, upgrades will be performed in-place. Otherwise, the
upgraded code will be printed.
@@ -10,22 +10,39 @@ use "lib/os.nom"
%args = (command line args)
%inplace = (no)
-if (%args.1 is "-i"):
- %inplace = (yes)
- %args::remove index 1
-
-if (%args.1 is "-t"):
- use "lib/consolecolor.nom"
- %test = (yes)
- %args::remove index 1
+%start_version = (nil)
+%version = (Nomsu version)
+repeat:
+ if %args.1 is:
+ "-i":
+ %inplace = (yes)
+ %args::remove index 1
+
+ "-t":
+ use "lib/consolecolor.nom"
+ %test = (yes)
+ %args::remove index 1
+
+ "-V":
+ %version = %args.2
+ %args::remove index 1
+ %args::remove index 1
+
+ "-S":
+ %start_version = %args.2
+ %args::remove index 1
+ %args::remove index 1
+
+ else: stop
for %path in %args:
for file %filename in %path:
unless (%filename::matches "%.nom$"): do next %filename
%tree = (parse (read file %filename) from %filename)
- %uptree = (%tree upgraded)
+ %uptree = (..)
+ %tree upgraded from (%start_version or (%tree.version or (Nomsu version))) to %version
%text = "\
- ..#!/usr/bin/env nomsu -V\(Nomsu version)
+ ..#!/usr/bin/env nomsu -V\%version
\(%uptree as nomsu)"
if: