aboutsummaryrefslogtreecommitdiff
path: root/tools/parse.nom
blob: 68be3a8bf1ebf8647b872d823a3810de15bc3422 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
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 ""