diff options
| author | Bruce Hill <bruce@bruce-hill.com> | 2018-11-08 15:23:22 -0800 |
|---|---|---|
| committer | Bruce Hill <bruce@bruce-hill.com> | 2018-11-08 15:24:15 -0800 |
| commit | 652c29bdef1f0991cc13bef59d6dc78b657ae9a4 (patch) | |
| tree | 8e335399e77b1893657b9fa985db0738034daac3 /nomnom/decompile.nom | |
| parent | 1f3660f393c1a17988a15b89f18686b28e51a9e7 (diff) | |
Major overhaul, splitting nomsu_compiler into nomsu_environment,
nomsu_compiler, and nomsu_decompiler. Also added comprehensions.
Diffstat (limited to 'nomnom/decompile.nom')
| -rw-r--r-- | nomnom/decompile.nom | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/nomnom/decompile.nom b/nomnom/decompile.nom index 11ec233..c958280 100644 --- a/nomnom/decompile.nom +++ b/nomnom/decompile.nom @@ -3,6 +3,8 @@ use "nomnom/code_obj.nom" use "nomnom/parser.nom" +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + # TODO: maybe re-implement the fancy coroutine checker that aborts early if nomsu gets too long externally (%tree decompiled inline) means: assume (%tree is a "Syntax Tree") @@ -175,10 +177,10 @@ externally (%tree decompiled) means: "FileChunks": (%1 and %2 should clump) means: if ((%1.type == "Action") and (%2.type == "Action")): - if (%1.stub == "use 1"): - return (%2.stub == "use 1") - if (%1.stub == "test 1"): return (yes) - if (%2.stub == "test 1"): return (no) + if (%1.stub == "use"): + return (%2.stub == "use") + if (%1.stub == "test"): return (yes) + if (%2.stub == "test"): return (no) return (not ((recurse on %1)::is multi-line)) @@ -199,14 +201,12 @@ externally (%tree decompiled) means: return %nomsu "Action": - %pos = %tree.source.start %next_space = "" if %tree.target: %target_nomsu = (recurse on %tree.target) if ((%tree.target.type == "Action") and (%target_nomsu::is one line)): %target_nomsu::parenthesize %nomsu::add %target_nomsu - %pos = %tree.target.source.stop %next_space = ("\n..::" if (%target_nomsu::is multi-line) else "::") for %bit in %tree at %i: @@ -290,8 +290,9 @@ externally (%tree decompiled) means: "Var": if ((%tree.(%i+1) is text) and (not (%tree.(%i+1)::matches "^[ \n\t,.:#(){}[%]]"))): %interp_nomsu::parenthesize - "List" "Dict": + do nothing + else: %interp_nomsu::parenthesize %nomsu::add %interp_nomsu |
