aboutsummaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorBruce Hill <bruce@bruce-hill.com>2018-12-14 20:21:03 -0800
committerBruce Hill <bruce@bruce-hill.com>2018-12-14 20:21:03 -0800
commit4fe63f253f58f87ab986fea38902d95f2a5ea338 (patch)
tree12094f1c69b8ab375eb17507c959c43f9295c6c2 /tools
parent6abec65843f0f37f7fc6032ac5db0fff3db71815 (diff)
Auto-updated to version 5
Diffstat (limited to 'tools')
-rwxr-xr-xtools/autoformat.nom28
-rwxr-xr-xtools/find_action.nom54
-rwxr-xr-xtools/parse.nom50
-rw-r--r--tools/repl.nom42
-rwxr-xr-xtools/test.nom36
-rwxr-xr-xtools/upgrade.nom50
6 files changed, 130 insertions, 130 deletions
diff --git a/tools/autoformat.nom b/tools/autoformat.nom
index 44d91e3..76d1d27 100755
--- a/tools/autoformat.nom
+++ b/tools/autoformat.nom
@@ -1,4 +1,4 @@
-#!/usr/bin/env nomsu -V4.12.12.8
+#!/usr/bin/env nomsu -V5.12.12.8
#
Auto-format Nomsu code. Usage:
nomsu tools/autoformat.nom [-i] file1 file2 directory1 ...
@@ -9,18 +9,18 @@ use "lib/os.nom"
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-%args = (command line args)
-for %filename in %args.extra_args:
- %file = (read file %filename)
- unless %file:
- barf "File does not exist: \%filename"
- %leading_indent = (%file::matching "[\n]*([ ]*)")
- %code = (NomsuCode from (%Source %filename 1 (size of %file)) %file)
- %tree = (%code parsed)
- %formatted = "\
- ..\%leading_indent\(((%tree as nomsu)::text)::with "\n" -> "\n\%leading_indent")"
+$args = (command line args)
+for $filename in $args.extra_args:
+ $file = (read file $filename)
+ unless $file:
+ barf "File does not exist: \$filename"
+ $leading_indent = ($file|matching "[\n]*([ ]*)")
+ $code = (NomsuCode from ($Source $filename 1 (size of $file)) $file)
+ $tree = ($code parsed)
+ $formatted = "
+ \$leading_indent\((($tree as nomsu)|text)|with "\n" -> "\n\$leading_indent")"
- if %args."-i":
- write %formatted to file %filename
+ if $args."-i":
+ write $formatted to file $filename
..else:
- say %formatted inline
+ say $formatted inline
diff --git a/tools/find_action.nom b/tools/find_action.nom
index bcc80ac..49ac71e 100755
--- a/tools/find_action.nom
+++ b/tools/find_action.nom
@@ -1,4 +1,4 @@
-#!/usr/bin/env nomsu -V4.12.12.8
+#!/usr/bin/env nomsu -V5.12.12.8
#
Find an action by its stub. Usage:
nomsu tools/find_action.nom "foo %" file1 file2 directory1 ...
@@ -9,33 +9,33 @@ use "lib/consolecolor.nom"
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-%stub = (command line args).extra_args.1
-say "Looking for stub: \%stub..."
-for % in 2 to (size of (command line args).extra_args):
- %filename = (command line args).extra_args.%
- %file = (read file %filename)
- unless %file:
- barf "File does not exist: \%filename"
- %code = (NomsuCode from (%Source %filename 1 (size of %file)) %file)
+$stub = (command line args).extra_args.1
+say "Looking for stub: \$stub..."
+for $ in 2 to (size of (command line args).extra_args):
+ $filename = (command line args).extra_args.$
+ $file = (read file $filename)
+ unless $file:
+ barf "File does not exist: \$filename"
+ $code = (NomsuCode from ($Source $filename 1 (size of $file)) $file)
try:
- %tree = (%code parsed)
- ..and if it barfs %msg:
- say (red "\%filename failed to parse:\n\%msg")
- %tree = (nil)
+ $tree = ($code parsed)
+ ..and if it barfs $msg:
+ say (red "\$filename failed to parse:\n\$msg")
+ $tree = (nil)
- unless %tree:
- do next %filename
+ unless $tree:
+ do next $filename
- %results = []
- for %t in recursive %tree:
- if ((%t is "Action" syntax tree) and (%t.stub is %stub)):
- %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))"
+ $results = []
+ for $t in recursive $tree:
+ if (($t is "Action" syntax tree) and ($t.stub is $stub)):
+ $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))"}
- if (%t is syntax tree):
- for %sub in %t:
- recurse %t on %sub
- sort %results by % -> %.line
- for % in %results:
- say %.text
+ 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 0745847..e6768a6 100755
--- a/tools/parse.nom
+++ b/tools/parse.nom
@@ -1,4 +1,4 @@
-#!/usr/bin/env nomsu -V4.12.12.8
+#!/usr/bin/env nomsu -V5.12.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 ...
@@ -7,39 +7,39 @@ use "lib/os.nom"
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-externally (print tree %t at indent %indent) means:
- if %t.type is:
+externally (print tree $t at indent $indent) means:
+ if $t.type is:
"Action":
- say "\(%indent)Action (\(%t.stub)):"
- for %arg in %t:
- if (%arg is syntax tree):
- print tree %arg at indent "\%indent "
-
+ say "\($indent)Action (\($t.stub)):"
+ for $arg in $t:
+ if ($arg is syntax tree):
+ print tree $arg at indent "\$indent "
+
"MethodCall":
- say "\(%indent)MethodCall on:"
- print tree %t.1 at indent "\%indent "
- print tree %t.2 at indent "\%indent "
+ say "\($indent)MethodCall on:"
+ print tree $t.1 at indent "\$indent "
+ print tree $t.2 at indent "\$indent "
"Number":
- say "\%indent\(%t.1)"
+ say "\$indent\($t.1)"
"Var":
- say "\(%indent)%\(%t.1)"
+ say "\($indent)%\($t.1)"
else:
- say "\%indent\(%t.type):"
- for %arg in %t:
+ say "\$indent\($t.type):"
+ for $arg in $t:
when:
- (%arg is syntax tree):
- print tree %arg at indent "\%indent "
+ ($arg is syntax tree):
+ print tree $arg at indent "\$indent "
else:
- say "\%indent \(quote %arg)"
+ say "\$indent \(quote $arg)"
-for %filename in (command line args).extra_args:
- %file = (read file %filename)
- unless %file:
- barf "File does not exist: \%filename"
- %nomsu = (NomsuCode from (Source %filename 1 (size of %file)) %file)
- %tree = (%nomsu parsed)
- print tree %tree at indent ""
+for $filename in (command line args).extra_args:
+ $file = (read file $filename)
+ unless $file:
+ barf "File does not exist: \$filename"
+ $nomsu = (NomsuCode from (Source $filename 1 (size of $file)) $file)
+ $tree = ($nomsu parsed)
+ print tree $tree at indent ""
diff --git a/tools/repl.nom b/tools/repl.nom
index 8f9d013..3f1eff3 100644
--- a/tools/repl.nom
+++ b/tools/repl.nom
@@ -1,4 +1,4 @@
-#!/usr/bin/env nomsu -V4.12.12.8
+#!/usr/bin/env nomsu -V5.12.12.8
#
This file defines a Read-Evaluate-Print-Loop (REPL) for Nomsu
@@ -9,53 +9,53 @@ use "lib/os.nom"
externally [quit, exit] all mean: lua> "os.exit(0)"
externally (help) means:
- say "\
- ..This is the Nomsu v\(Nomsu version) interactive console.
+ 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."
-say "\
- ..
+say "
+
\(bright)\(underscore)Welcome to the Nomsu v\(Nomsu version) interactive console!\(reset color)
press 'enter' twice to run a command
"
repeat:
say (bright (yellow ">> ")) inline
- %buff = []
+ $buff = []
repeat:
say (bright) inline
- %line = (%io.read "*L")
+ $line = ($io.read "*L")
say (reset color) inline
- if ((%line == "\n") or (not %line)):
- if ((size of %buff) > 0):
+ if (($line == "\n") or (not $line)):
+ if ((size of $buff) > 0):
# clear the line
say "\027[1A\027[2K" inline
go to (run buffer)
- %buff::add (%line::with "\t" -> " ")
+ $buff|add ($line|with "\t" -> " ")
say (dim (yellow ".. ")) inline
--- (run buffer) ---
- if ((size of %buff) == 0): stop
- %buff = (%buff::joined)
+ if ((size of $buff) == 0): stop
+ $buff = ($buff|joined)
# TODO: support local variables
- spoof file %buff
+ spoof file $buff
try:
- %ret = (run %buff)
- ..and if it barfs %err: say %err
+ $ret = (run $buff)
+ ..and if it barfs $err: say $err
..or if it succeeds:
- if (type of %ret) is:
+ if (type of $ret) is:
"nil":
do nothing
"boolean":
- say "= \("yes" if %ret else "no")"
+ say "= \("yes" if $ret else "no")"
"table":
- if %ret.as_nomsu:
- say "= \(%ret::as nomsu)"
+ if $ret.as_nomsu:
+ say "= \($ret|as nomsu)"
..else:
- say "= \%ret"
+ say "= \$ret"
else:
- say "= \%ret"
+ say "= \$ret"
diff --git a/tools/test.nom b/tools/test.nom
index bcbd289..5b36010 100755
--- a/tools/test.nom
+++ b/tools/test.nom
@@ -1,4 +1,4 @@
-#!/usr/bin/env nomsu -V4.12.12.8
+#!/usr/bin/env nomsu -V5.12.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 ...
@@ -9,26 +9,26 @@ use "lib/consolecolor.nom"
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Make sure all the files get run
-for %filename in (command line args).extra_args: use %filename
-%tests = {: for %s = %t in (tests): add (=lua "Source:from_string(\%s)") = %t}
-for %filename in (command line args).extra_args:
- %file = (read file %filename)
- %version = (%file::matching "#![^\n]* nomsu %-V[ ]*([^\n]*)")
- %file_tests = []
- for %src = %test in %tests:
- if (%src.filename == %filename):
- if %version:
- %test = "#!/usr/bin/env nomsu -V\%version\n\%test"
- %file_tests::add {test: %test, source: %src}
+for $filename in (command line args).extra_args: use $filename
+$tests = {: for $s = $t in (tests): add (=lua "Source:from_string(\$s)") = $t}
+for $filename in (command line args).extra_args:
+ $file = (read file $filename)
+ $version = ($file|matching "#![^\n]* nomsu %-V[ ]*([^\n]*)")
+ $file_tests = []
+ for $src = $test in $tests:
+ if ($src.filename == $filename):
+ if $version:
+ $test = "#!/usr/bin/env nomsu -V\$version\n\$test"
+ $file_tests|add {test: $test, source: $src}
- unless (%file_tests is empty):
- sort %file_tests by % -> %.source
- lua> "io.write('[ .. ] ', \%filename); io.flush()"
+ unless ($file_tests is empty):
+ sort $file_tests by $ -> $.source
+ lua> "io.write('[ .. ] ', \$filename); io.flush()"
if (command line args)."-v": say ""
- for % in %file_tests:
+ for $ in $file_tests:
if (command line args)."-v":
- say " \(yellow (%.test::with "\n" -> "\n "))"
- run %.test
+ say " \(yellow ($.test|with "\n" -> "\n "))"
+ run $.test
if (command line args)."-v":
say (green "PASS")
diff --git a/tools/upgrade.nom b/tools/upgrade.nom
index 0512134..48f1811 100755
--- a/tools/upgrade.nom
+++ b/tools/upgrade.nom
@@ -1,4 +1,4 @@
-#!/usr/bin/env nomsu -V4.12.12.8
+#!/usr/bin/env nomsu -V5.12.12.8
#
Tool to automatically update code from old versions of Nomsu. Usage:
nomsu tools/upgrade.nom [-i] file1 file2 directory1 ...
@@ -11,32 +11,32 @@ use "lib/consolecolor.nom"
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-%args = (command line args)
-%inplace = (%args."-i" or %args."--inplace")
-%start_version = %args."--upgrade-from"
-%version = (%args."--upgrade-to" or (Nomsu version))
-%test = (%args."-t" or %args."--test")
-for %filename in %args.extra_args:
- %file = (read file %filename)
- unless %file:
- barf "File does not exist: \%filename"
- %leading_indent = (%file::matching "[\n]*([ ]*)")
- %code = (NomsuCode from (Source %filename 1 (size of %file)) %file)
- %tree = (%code parsed)
- %uptree = (..)
- %tree upgraded from (%start_version or (%tree.version or (Nomsu version))) to \
- ..%version
- %text = "\%leading_indent\(((%uptree as nomsu)::text)::with "\n" -> "\n\%leading_indent")"
+$args = (command line args)
+$inplace = ($args."-i" or $args."--inplace")
+$start_version = $args."--upgrade-from"
+$version = ($args."--upgrade-to" or (Nomsu version))
+$test = ($args."-t" or $args."--test")
+for $filename in $args.extra_args:
+ $file = (read file $filename)
+ unless $file:
+ barf "File does not exist: \$filename"
+ $leading_indent = ($file|matching "[\n]*([ ]*)")
+ $code = (NomsuCode from (Source $filename 1 (size of $file)) $file)
+ $tree = ($code parsed)
+ $uptree = (..)
+ $tree upgraded from ($start_version or ($tree.version or (Nomsu version))) to \
+ ..$version
+ $text = "\$leading_indent\((($uptree as nomsu)|text)|with "\n" -> "\n\$leading_indent")"
when:
- %inplace:
- say "Upgraded \%filename"
- write %text to file %filename
+ $inplace:
+ say "Upgraded \$filename"
+ write $text to file $filename
- %test:
- if (%uptree == %tree):
- say (dim "\%filename will not be changed")
+ $test:
+ if ($uptree == $tree):
+ say (dim "\$filename will not be changed")
..else:
- say (bright "\%filename will be changed")
+ say (bright "\$filename will be changed")
else:
- say %text inline
+ say $text inline