aboutsummaryrefslogtreecommitdiff
path: root/lib/tools
diff options
context:
space:
mode:
Diffstat (limited to 'lib/tools')
-rwxr-xr-xlib/tools/parse.nom22
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 "&" -> "&amp;", with "\"" -> "&quot;", with "'" -> "&apos;", with "<" -> "&lt;", with ">" -> "&gt;")
+ 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 ""