diff options
Diffstat (limited to 'tools/find_action.nom')
| -rwxr-xr-x | tools/find_action.nom | 60 |
1 files changed, 28 insertions, 32 deletions
diff --git a/tools/find_action.nom b/tools/find_action.nom index c6cbe36..6b85ad3 100755 --- a/tools/find_action.nom +++ b/tools/find_action.nom @@ -9,37 +9,33 @@ use "lib/consolecolor.nom" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -%stub = (command line args).1 +%stub = (command line args).extra_args.1 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" - - 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: - %tree = (%code parsed) - ..and if it barfs %msg: - say (red "\%filename failed to parse:\n\%msg") - %tree = (nil) - - unless %tree: - do next %filename +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) + + 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 |
