diff options
| author | Bruce Hill <bruce@bruce-hill.com> | 2019-03-20 14:15:43 -0700 |
|---|---|---|
| committer | Bruce Hill <bruce@bruce-hill.com> | 2019-03-20 14:15:43 -0700 |
| commit | 606fd090002f3d545cbd58440e96624907846f45 (patch) | |
| tree | adf9a810c326508522c2529e4a7b05f21cb5f090 /lib | |
| parent | 12db69cdd64e95a917824643d31a712618a6d014 (diff) | |
Added lisp-y output
Diffstat (limited to 'lib')
| -rwxr-xr-x | lib/tools/parse.nom | 43 |
1 files changed, 31 insertions, 12 deletions
diff --git a/lib/tools/parse.nom b/lib/tools/parse.nom index f0c35a3..89af6f6 100755 --- a/lib/tools/parse.nom +++ b/lib/tools/parse.nom @@ -42,15 +42,29 @@ use "commandline" "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> - ") + return "<Action name=\"\(($, get stub) as xml)\">\$body</Action>" ..else: - return (" - <\($.type)>\$body</\($.type)> - ") + return "<\($.type)>\$body</\($.type)>" + + "Text": + return + ( + ($, with "&" -> "&", with "\"" -> """, with "'" -> "'"), + with "<" -> "<" + ), with ">" -> ">" + + else: + return "\$" + +($ as lisp) means: + when (type of $) is: + "a Syntax Tree": + $body = ([$.type, : for $bit in $: add ($bit as lisp)], joined with " ") + return "(\$body)" + "Text": - return ($, with "&" -> "&", with "\"" -> """, with "'" -> "'", with "<" -> "<", with ">" -> ">") + return "\"\($, with "\\" -> "\\\\", with "\"" -> "\\\"", with "\n" -> "\\n")\"" + else: return "\$" @@ -59,9 +73,14 @@ command line program with $args: $file = (read file $filename) unless $file: fail "File does not exist: \$filename" - $nomsu = (NomsuCode from (Source $filename 1 (size of $file)) $file) + $nomsu = (NomsuCode from (Source $filename 1 (#$file)) $file) $tree = ($nomsu parsed) - if ($args.x or $args.xml): - say ($tree as xml) - ..else: - print tree $tree at indent "" + when: + ($args.x or $args.xml): + say ($tree as xml) + + ($args.l or $args.lisp): + say ($tree as lisp) + + else: + print tree $tree at indent ""
\ No newline at end of file |
