diff options
| author | Bruce Hill <bruce@bruce-hill.com> | 2019-02-02 19:49:26 -0800 |
|---|---|---|
| committer | Bruce Hill <bruce@bruce-hill.com> | 2019-02-02 19:49:26 -0800 |
| commit | 0e90d68efabf613e79eb85b7349d6270901e007a (patch) | |
| tree | c19aeb4b8598fc30b249c0d95780504d3d9aa417 /lib/tools | |
| parent | 891fa6b3624e63c87c2b15007eed822e20e39a38 (diff) | |
Added XML format outputter
Diffstat (limited to 'lib/tools')
| -rwxr-xr-x | lib/tools/parse.nom | 22 |
1 files changed, 21 insertions, 1 deletions
diff --git a/lib/tools/parse.nom b/lib/tools/parse.nom index a7e306e..f0c35a3 100755 --- a/lib/tools/parse.nom +++ b/lib/tools/parse.nom @@ -37,6 +37,23 @@ use "commandline" else: say "\$indent \(quote $arg)" +($ as xml) means: + when (type of $) is: + "a Syntax Tree": + $body = ([: for $bit in $: add ($bit as xml)], joined with " ") + if ($.type == "Action"): + return (" + <Action name="\(($, get stub) as xml)">\$body</Action> + ") + ..else: + return (" + <\($.type)>\$body</\($.type)> + ") + "Text": + return ($, with "&" -> "&", with "\"" -> """, with "'" -> "'", with "<" -> "<", with ">" -> ">") + else: + return "\$" + command line program with $args: for $filename in $args.extras: $file = (read file $filename) @@ -44,4 +61,7 @@ command line program with $args: fail "File does not exist: \$filename" $nomsu = (NomsuCode from (Source $filename 1 (size of $file)) $file) $tree = ($nomsu parsed) - print tree $tree at indent "" + if ($args.x or $args.xml): + say ($tree as xml) + ..else: + print tree $tree at indent "" |
