From dfd39f0b14794b360fd6c961c65ab45d229e00b1 Mon Sep 17 00:00:00 2001 From: Bruce Hill Date: Sun, 22 Jul 2018 13:59:08 -0700 Subject: Shifting further towards having inline tests. Also added a helper function for directly extracting source lines from a Source or AST. --- tools/parse.nom | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100755 tools/parse.nom (limited to 'tools/parse.nom') diff --git a/tools/parse.nom b/tools/parse.nom new file mode 100755 index 0000000..68be3a8 --- /dev/null +++ b/tools/parse.nom @@ -0,0 +1,27 @@ +#!/usr/bin/env nomsu -V2.4.4.3 +use "core" +use "lib/os.nom" +action [print tree %t at indent %indent]: + 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 " + "Number": + say "\(%indent)\(%t.1)" + "Var": + say "\(%indent)%\(%t.1)" + else: + say "\(%indent)\(%t.type):" + for %arg in %t: + if: + (%arg is syntax tree): + print tree %arg at indent "\%indent " + else: + say "\%indent \(quote %arg)" + +for %path in (=lua "arg"): + for file %filename in %path: + unless (%filename matches "%.nom$"): do next %filename + print tree (parse (read file %filename) from %filename) at indent "" -- cgit v1.2.3