Fixes/upgrades.

This commit is contained in:
Bruce Hill 2018-11-08 16:59:10 -08:00
parent 652c29bdef
commit ba96cdfa07
2 changed files with 14 additions and 14 deletions

View File

@ -328,4 +328,4 @@ say (best of [2, -3, 4, -8] according to ((% squared)'s meaning))
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
say (best of [2, -3, 4, -8] where %x has score (%x * %x)) say (best of [2, -3, 4, -8] where %x has score (%x * %x))

View File

@ -1,4 +1,4 @@
#!/usr/bin/env nomsu -V4.8.10 #!/usr/bin/env nomsu -V4.10.12.7
# #
Find an action by its stub. Usage: 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 ...
@ -14,24 +14,24 @@ say "Looking for stub: \%stub..."
%files = ((command line args).% for % in 2 to (size of (command line args))) %files = ((command line args).% for % in 2 to (size of (command line args)))
for %path in %files: for %path in %files:
for file %filename in %path: for file %filename in %path:
unless (%filename::matches "%.nom$") (do next %filename) unless (%filename::matches "%.nom$"): do next %filename
%file = (read file %filename) %file = (read file %filename)
%code = (%NomsuCode (%Source %filename 1 (size of %file)) %file)
try: try:
%tree = (parse %file from %filename) %tree = (%code parsed)
..and if it barfs: ..and if it barfs %msg:
say (red "\%filename failed to parse") say (red "\%filename failed to parse:\n\%msg")
%tree = (nil) %tree = (nil)
unless %tree: do next %filename unless %tree: do next %filename
%results = [] %results = []
for %t in recursive %tree: for %t in recursive %tree:
if (%t is "Action" syntax tree): if ((%t is "Action" syntax tree) and (%t.stub is %stub)):
if (%t.stub is %stub): %line_num = (line number of %t.source.start in %file)
%line_num = (line number of %t.source.start in %file) %results::add {..}
%results::add {..} line: %line_num
line: %line_num text: "\
text: "\ ..\(blue "\%filename:\%line_num:")
..\(blue "\%filename:\%line_num:") \(yellow (source lines of %t))"
\(yellow (source lines of %t))"
if (%t is syntax tree): if (%t is syntax tree):
for %sub in %t: recurse %t on %sub for %sub in %t: recurse %t on %sub