aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBruce Hill <bruce@bruce-hill.com>2018-12-14 20:53:00 -0800
committerBruce Hill <bruce@bruce-hill.com>2018-12-14 20:54:18 -0800
commitd3905474c9c84da4a789f6dc40aa1ae7d0bfaf2a (patch)
treefcf0e2361b7a877ca2ddb0112bfb14a7e1ea1cfa
parentd30f6a397d274b0b942bdd2e2648b42538f1cbe2 (diff)
Removed EOL comments
-rw-r--r--core/operators.nom3
-rw-r--r--lib/consolecolor.nom6
-rw-r--r--nomsu.5.peg6
-rw-r--r--nomsu_decompiler.lua4
-rw-r--r--nomsu_decompiler.moon3
-rwxr-xr-xtools/find_action.nom2
6 files changed, 14 insertions, 10 deletions
diff --git a/core/operators.nom b/core/operators.nom
index bc658b1..91a09ab 100644
--- a/core/operators.nom
+++ b/core/operators.nom
@@ -220,7 +220,8 @@ test:
(not $) compiles to "(not \($ as lua expr))"
test:
assume ((size of [1, 2, 3]) == 3)
-(size of $list) compiles to "(#\($list as lua expr))"
+ assume ((# [1, 2, 3]) == 3)
+[# $list, size of $list] all compile to "(#\($list as lua expr))"
($list is empty) compiles to "(#\($list as lua expr) == 0)"
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
diff --git a/lib/consolecolor.nom b/lib/consolecolor.nom
index 092105b..55feade 100644
--- a/lib/consolecolor.nom
+++ b/lib/consolecolor.nom
@@ -8,16 +8,14 @@ test:
$colors = {..}
normal: 0, "reset color": 0, bright: 1, bold: 1, dim: 2, italic: 3, underscore: 4
"slow blink": 5, "fast blink": 6, reverse: 7, inverse: 7, inverted: 7
- hidden: 8, # There's some other codes, but they're not currently implemented
+ hidden: 8
+ # There's some other codes, but they're not currently implemented
black: 30, red: 31, green: 32, yellow: 33, blue: 34, magenta: 35, cyan: 36
white: 37, "on black": 40, "on red": 41, "on green": 42, "on yellow": 43
"on blue": 44, "on magenta": 45, "on cyan": 46, "on white": 47
for $name = $colornum in $colors:
$colornum = "\$colornum"
-
- #(=lua "COMPILE_ACTIONS").%name = (..)
- [%nomsu, %tree] -> (Lua "'\\027[\(%colornum)m'")
$compile.action.$name = (..)
for ($compile $text):
if $text:
diff --git a/nomsu.5.peg b/nomsu.5.peg
index e51f72d..ae87f71 100644
--- a/nomsu.5.peg
+++ b/nomsu.5.peg
@@ -31,15 +31,13 @@ empty_block (Block):
nodent: (unexpected_indent [^%nl]* / =curr_indent)
indent: {~ =curr_indent (ws / (%tab -> ' '))+ ~}
blank_lines: %nl ((nodent comment / ws*) %nl)*
-eol: ws* eol_comment? (!. / &%nl)
+eol: ws* (!. / &%nl)
nl_nodent: blank_lines nodent
nl_indent: blank_lines tab_error? {:curr_indent: indent :} (comment nl_nodent)*
comment (Comment):
"#" {~ [^%nl]* (%nl+ (indent -> '') [^%nl]*)* (%nl &%nl)* ~}
-eol_comment (Comment):
- "#" {[^%nl]*}
unexpected_code: ws* _unexpected_code
_unexpected_code (Error):
@@ -236,7 +234,7 @@ inline_dict_entry:
dict_key:
text_word / inline_expression
-operator_char: ['`~@^&*+=|<>?/%!-]
+operator_char: [#'`~@^&*+=|<>?/%!-]
ident_char: [a-zA-Z0-9_] / %utf8_char
ws: " "
diff --git a/nomsu_decompiler.lua b/nomsu_decompiler.lua
index 1d445c9..c3b7cb2 100644
--- a/nomsu_decompiler.lua
+++ b/nomsu_decompiler.lua
@@ -227,6 +227,9 @@ tree_to_nomsu = function(tree)
for subtree in coroutine.wrap(function()
return (t:map(coroutine.yield) and nil)
end) do
+ if subtree.type == "Comment" then
+ try_inline = false
+ end
if subtree.type == "Block" then
if #subtree > 1 then
try_inline = false
@@ -456,6 +459,7 @@ tree_to_nomsu = function(tree)
item_nomsu = recurse(item)
end
if item.type == 'Comment' then
+ sep = '\n'
item_nomsu = tree_to_nomsu(item)
end
nomsu:add(sep)
diff --git a/nomsu_decompiler.moon b/nomsu_decompiler.moon
index 9cb9ae8..f8c2aa3 100644
--- a/nomsu_decompiler.moon
+++ b/nomsu_decompiler.moon
@@ -173,6 +173,8 @@ tree_to_nomsu = (tree)->
space = MAX_LINE - nomsu\trailing_line_len!
try_inline = true
for subtree in coroutine.wrap(-> (t\map(coroutine.yield) and nil))
+ if subtree.type == "Comment"
+ try_inline = false
if subtree.type == "Block"
if #subtree > 1
try_inline = false
@@ -356,6 +358,7 @@ tree_to_nomsu = (tree)->
if #item_nomsu\text! > MAX_LINE
item_nomsu = recurse(item)
if item.type == 'Comment'
+ sep = '\n'
item_nomsu = tree_to_nomsu(item)
nomsu\add sep
nomsu\add item_nomsu
diff --git a/tools/find_action.nom b/tools/find_action.nom
index 49ac71e..50621f1 100755
--- a/tools/find_action.nom
+++ b/tools/find_action.nom
@@ -24,7 +24,7 @@ for $ in 2 to (size of (command line args).extra_args):
$tree = (nil)
unless $tree:
- do next $filename
+ do next $
$results = []
for $t in recursive $tree: