From af9dc0702568dc45b8809523dde760bb99aafbcb Mon Sep 17 00:00:00 2001 From: Bruce Hill Date: Wed, 16 May 2018 15:44:07 -0700 Subject: 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. --- nomsu.moon | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) (limited to 'nomsu.moon') 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) -- cgit v1.2.3