diff options
| author | Bruce Hill <bruce@bruce-hill.com> | 2018-12-31 01:36:48 -0800 |
|---|---|---|
| committer | Bruce Hill <bruce@bruce-hill.com> | 2018-12-31 01:37:21 -0800 |
| commit | 7762c8c45b6f0349d769682b26349fb25a7a8657 (patch) | |
| tree | fdcac310b37753312bb9cc010db67d92c854810d /nomsu_decompiler.moon | |
| parent | d8f9b15fd9da8c9ae29ee0b63c4302e5efbde387 (diff) | |
Added the ": for $ in $: ..." shorthand for indented comprehensions.
Diffstat (limited to 'nomsu_decompiler.moon')
| -rw-r--r-- | nomsu_decompiler.moon | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/nomsu_decompiler.moon b/nomsu_decompiler.moon index 3c20f76..3deaabc 100644 --- a/nomsu_decompiler.moon +++ b/nomsu_decompiler.moon @@ -427,6 +427,11 @@ tree_to_nomsu = (tree)-> elseif item.type == 'Comment' item_nomsu = tree_to_nomsu(item) sep = '\n' if i > 1 + elseif item.type == 'Block' and #item == 1 + -- Comprehensions use the more concise ": for $ in $: ..." form + item_nomsu = tree_to_nomsu(item[1]) + item_nomsu\prepend ": " + sep = '\n' if i > 1 else item_nomsu = tree_to_inline_nomsu(item) if #item_nomsu\text! > MAX_LINE @@ -434,7 +439,8 @@ tree_to_nomsu = (tree)-> item_nomsu = tree_to_nomsu(item) nomsu\add sep nomsu\add item_nomsu - if item_nomsu\is_multiline! or item.type == 'Comment' or nomsu\trailing_line_len! + #tostring(item_nomsu) >= MAX_LINE + if item_nomsu\is_multiline! or item.type == 'Comment' or item.type == "Block" or + nomsu\trailing_line_len! + #tostring(item_nomsu) >= MAX_LINE sep = '\n' else sep = ', ' |
