diff options
| author | Bruce Hill <bitbucket@bruce-hill.com> | 2018-05-16 15:44:07 -0700 |
|---|---|---|
| committer | Bruce Hill <bitbucket@bruce-hill.com> | 2018-05-16 15:45:59 -0700 |
| commit | af9dc0702568dc45b8809523dde760bb99aafbcb (patch) | |
| tree | 8334bab3a859aaa12ae5cb9f78b92f2eea5477b4 /nomsu.moon | |
| parent | 3ffeaf1f5dbf3e225dc536066d0fedda3f38ac70 (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-x | nomsu.moon | 16 |
1 files changed, 5 insertions, 11 deletions
@@ -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) |
