From 5f38d73004f0fcf259acfa12d46feff4c6170273 Mon Sep 17 00:00:00 2001 From: Bruce Hill Date: Sun, 11 Nov 2018 15:25:25 -0800 Subject: Now preserving hex numbers with "0xF00" -> parse -> decompile -> "0xF00", fix for (compile error at ...) --- nomsu_decompiler.moon | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'nomsu_decompiler.moon') diff --git a/nomsu_decompiler.moon b/nomsu_decompiler.moon index 99dce3e..5b72823 100644 --- a/nomsu_decompiler.moon +++ b/nomsu_decompiler.moon @@ -4,7 +4,7 @@ re = require 're' MAX_LINE = 80 -GOLDEN_RATIO = ((1+math.sqrt(5))/2) +GOLDEN_RATIO = ((math.sqrt(5)-1)/2) -- Parsing helper functions utf8_char_patt = ( @@ -130,7 +130,12 @@ tree_to_inline_nomsu = (tree)-> return nomsu when "Number" - return NomsuCode\from(tree.source, tostring(tree[1])) + s = if tree.hex and tree[1] < 0 + ("-0x%X")\format(-tree[1]) + elseif tree.hex + ("0x%X")\format(tree[1]) + else tostring(tree[1]) + return NomsuCode\from(tree.source, s) when "Var" return NomsuCode\from(tree.source, "%", tree[1]) -- cgit v1.2.3