aboutsummaryrefslogtreecommitdiff
path: root/nomsu.moon
diff options
context:
space:
mode:
authorBruce Hill <bitbucket@bruce-hill.com>2018-05-16 15:44:07 -0700
committerBruce Hill <bitbucket@bruce-hill.com>2018-05-16 15:45:59 -0700
commitaf9dc0702568dc45b8809523dde760bb99aafbcb (patch)
tree8334bab3a859aaa12ae5cb9f78b92f2eea5477b4 /nomsu.moon
parent3ffeaf1f5dbf3e225dc536066d0fedda3f38ac70 (diff)
Converted DictEntry to be an actual tree, instead of a pseudo-tree, made 'parse % as %'
generate lua code with already-substituted tree literals instead of reparsing and substituting at parse time, and made some general optimizations.
Diffstat (limited to 'nomsu.moon')
-rwxr-xr-xnomsu.moon16
1 files changed, 5 insertions, 11 deletions
diff --git a/nomsu.moon b/nomsu.moon
index ce0e8d6..db196fc 100755
--- a/nomsu.moon
+++ b/nomsu.moon
@@ -131,7 +131,6 @@ NOMSU_DEFS = with {}
-- Newline supports either windows-style CR+LF or unix-style LF
.Tuple = (values)->
return Tuple(unpack(values))
- .DictEntry = (k,v) -> Types.DictEntry(k,v)
.nl = P("\r")^-1 * P("\n")
.ws = S(" \t")
.tonumber = tonumber
@@ -429,16 +428,11 @@ class NomsuCompiler
walk_tree: (tree, depth=0)=>
coroutine.yield(tree, depth)
return unless Types.is_node(tree)
- switch tree.type
- when "List", "Block", "Action", "Text", "IndexChain"
- for v in *tree.value
- @walk_tree(v, depth+1)
- when "Dict"
- for e in *tree.value
- @walk_tree(e.key, depth+1)
- @walk_tree(e.value, depth+1)
- else @walk_tree(tree.value, depth+1)
- return nil
+ if Tuple\is_instance(tree.value)
+ for v in *tree.value
+ @walk_tree(v, depth+1)
+ else
+ @walk_tree(v, depth+1)
tree_with_replacements: (tree, replacements)=>
return tree unless next(replacements)