aboutsummaryrefslogtreecommitdiff
path: root/nomnom/decompile.nom
diff options
context:
space:
mode:
authorBruce Hill <bruce@bruce-hill.com>2018-09-26 13:05:28 -0700
committerBruce Hill <bruce@bruce-hill.com>2018-09-26 13:05:47 -0700
commitb43432e647fbb3bb76aa2836e3899d5e407c50f9 (patch)
tree640aee09e7dafbcca53c4792d3446c7f6265e004 /nomnom/decompile.nom
parent692fae5416ce1f2702b599ffb27b2e3d2235eba7 (diff)
Fixed all syntax errors, got original (non-nomnom) tests passing.
Diffstat (limited to 'nomnom/decompile.nom')
-rw-r--r--nomnom/decompile.nom21
1 files changed, 11 insertions, 10 deletions
diff --git a/nomnom/decompile.nom b/nomnom/decompile.nom
index 27ef406..0d8d4d2 100644
--- a/nomnom/decompile.nom
+++ b/nomnom/decompile.nom
@@ -45,9 +45,10 @@ action [decompile %tree inline]:
"Block":
%nomsu = (Nomsu Code from %tree [":"])
- for i,line in ipairs tree
- %nomsu::add(i == 1 and " " or "; ")
- %nomsu::add recurse(line, nomsu, i == 1 or i < #tree)
+ for %line in %tree at %i:
+ %nomsu::add [..]
+ " " if (%i == 1) else "; "
+ decompile %line inline
return %nomsu
"Text":
@@ -100,12 +101,12 @@ action [decompile %tree inline]:
"IndexChain":
%nomsu = (Nomsu Code from %tree)
for %bit in %tree at %i:
- if (%i > 1): nomsu::add "."
+ if (%i > 1): %nomsu::add "."
if (..)
all of [..]
%i > 1, %bit.type == "Text", (size of %bit) == 1, %bit.1 is text,
%bit.1::is a nomsu identifier
- %nomsu::add %bit.1
+ ..:%nomsu::add %bit.1
..else:
%bit_nomsu = (decompile %bit inline)
if (..)
@@ -261,7 +262,7 @@ action [decompile %tree]:
%bit = (escape text %bit)
for %line in (%bit::lines) at %j:
if:
- (%j > 1): nomsu::add "\n"
+ (%j > 1): %nomsu::add "\n"
(((size of %line) > 10) and ((%nomsu::trailing line length) > %max_line)):
%nomsu::add "\\\n.."
@@ -304,14 +305,14 @@ action [decompile %tree]:
%item_nomsu = (recurse on %item_nomsu)
%nomsu::add %item_nomsu
if (%i < (size of %tree)):
- if (..)
- (%item_nomsu::is multi-line) or (..)
- (%nomsu::trailing line length) + (size of "\%item_nomsu")) >= %MAX_LINE
+ if any of [..]
+ %item_nomsu::is multi-line
+ ((%nomsu::trailing line length) + (size of "\%item_nomsu")) >= %MAX_LINE
..: %nomsu::add "\n"
..else: %nomsu::add ", "
return (..)
Nomsu Code from %tree [..]
- "[..]\n " if tree.type == "List" else "{..}\n "
+ "[..]\n " if (%tree.type == "List") else "{..}\n "
%nomsu
"DictEntry":