From 692fae5416ce1f2702b599ffb27b2e3d2235eba7 Mon Sep 17 00:00:00 2001 From: Bruce Hill Date: Wed, 26 Sep 2018 12:45:08 -0700 Subject: Incremental fixes and more nomnom ports. --- tools/find_action.nom | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'tools') diff --git a/tools/find_action.nom b/tools/find_action.nom index e6fe90a..8381855 100755 --- a/tools/find_action.nom +++ b/tools/find_action.nom @@ -15,12 +15,19 @@ for %path in %files: unless (%filename::matches "%.nom$") (do next %filename) %file = (read file %filename) %tree = (parse %file from %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 -- cgit v1.2.3 From 23abab4f809e8d4b825746580082292db700036b Mon Sep 17 00:00:00 2001 From: Bruce Hill Date: Mon, 29 Oct 2018 13:00:08 -0700 Subject: Some cleanups and fixes, made the parser more permissive of prematurely terminated files. --- tools/find_action.nom | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'tools') diff --git a/tools/find_action.nom b/tools/find_action.nom index 8381855..e30f155 100755 --- a/tools/find_action.nom +++ b/tools/find_action.nom @@ -23,8 +23,8 @@ for %path in %files: %results::add {..} line: %line_num text: "\ - ..\(blue "\%filename:\%line_num:") - \(yellow (source lines of %t))" + ..\(blue "\%filename:\%line_num:") + \(yellow (source lines of %t))" if (%t is syntax tree): for %sub in %t: recurse %t on %sub -- cgit v1.2.3 From e7e84c9eda38c930f5475301de4a449dcf59e8b6 Mon Sep 17 00:00:00 2001 From: Bruce Hill Date: Tue, 30 Oct 2018 20:32:14 -0700 Subject: Fix for compiler not parenthesizing method targets, fix for parser not recognizing \ line continuation, and improvements to upgrade tool API. --- tools/upgrade.nom | 27 +++++++++++++++++---------- 1 file changed, 17 insertions(+), 10 deletions(-) (limited to 'tools') diff --git a/tools/upgrade.nom b/tools/upgrade.nom index cd3fbbb..4e03945 100755 --- a/tools/upgrade.nom +++ b/tools/upgrade.nom @@ -10,22 +10,29 @@ 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 +%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 + 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 to %version) %text = "\ - ..#!/usr/bin/env nomsu -V\(Nomsu version) + ..#!/usr/bin/env nomsu -V\%version \(%uptree as nomsu)" if: -- cgit v1.2.3 From ea3197aaffba00318920ed5e1e33ca5f2a5e6c5c Mon Sep 17 00:00:00 2001 From: Bruce Hill Date: Tue, 30 Oct 2018 23:42:04 -0700 Subject: Fully working version of (action [foo]: baz) -> ((foo) means: baz) refactor and misc other changes. --- tools/upgrade.nom | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tools') diff --git a/tools/upgrade.nom b/tools/upgrade.nom index 4e03945..7d36793 100755 --- a/tools/upgrade.nom +++ b/tools/upgrade.nom @@ -1,4 +1,4 @@ -#!/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 ... -- cgit v1.2.3 From 7a35e38d8778670fe0662f203e82638355db3bba Mon Sep 17 00:00:00 2001 From: Bruce Hill Date: Wed, 31 Oct 2018 15:05:17 -0700 Subject: Renamed (action %) -> (%'s meaning) --- tools/autoformat.nom | 4 ++-- tools/find_action.nom | 8 ++++---- tools/parse.nom | 6 +++--- tools/replace.nom | 4 ++-- tools/test.nom | 5 ++--- tools/upgrade.nom | 14 ++++++++++++-- 6 files changed, 25 insertions(+), 16 deletions(-) (limited to 'tools') 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 e30f155..e7e3f49 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" @@ -28,6 +28,6 @@ for %path in %files: if (%t is syntax tree): for %sub in %t: recurse %t on %sub + sort %results by % -> %.line - for % in %results: - say %.text + 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 7d36793..575646e 100755 --- a/tools/upgrade.nom +++ b/tools/upgrade.nom @@ -1,7 +1,7 @@ #!/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,27 +10,37 @@ use "lib/os.nom" %args = (command line args) %inplace = (no) +%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 to %version) + %uptree = (..) + %tree upgraded from (%start_version or (%tree.version or (Nomsu version))) to %version %text = "\ ..#!/usr/bin/env nomsu -V\%version \(%uptree as nomsu)" -- cgit v1.2.3 From 307dea18815ba4a06a3098edb170d7ad90708815 Mon Sep 17 00:00:00 2001 From: Bruce Hill Date: Fri, 2 Nov 2018 14:38:24 -0700 Subject: Changed stub convention to (foo 1 baz 2) -> foo_1_baz instead of foo_1_baz_2, removed "smext", made some cleanup changes. --- tools/find_action.nom | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'tools') diff --git a/tools/find_action.nom b/tools/find_action.nom index e7e3f49..02abdbc 100755 --- a/tools/find_action.nom +++ b/tools/find_action.nom @@ -14,7 +14,12 @@ 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): -- cgit v1.2.3