From af3274ca9237a08093009e87955e30ab5f473f12 Mon Sep 17 00:00:00 2001 From: Bruce Hill Date: Sun, 24 Sep 2017 20:20:27 -0700 Subject: massive overhaul, compiler kinda works. --- utils.moon | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'utils.moon') diff --git a/utils.moon b/utils.moon index f267c7d..471b28e 100644 --- a/utils.moon +++ b/utils.moon @@ -7,6 +7,10 @@ utils = { i += 1 return true + size: (t)-> + with n = 0 + for _ in pairs(t) do n += 1 + repr: (x)-> switch type(x) when 'table' @@ -18,7 +22,9 @@ utils = { else "{#{table.concat(["[#{utils.repr(k)}]= #{utils.repr(v)}" for k,v in pairs x], ", ")}}" when 'string' - if not x\find[["]] and not x\find"\n" and not x\find"\\" + if x == "\n" + return "'\\n'" + elseif not x\find[["]] and not x\find"\n" and not x\find"\\" "\""..x.."\"" elseif not x\find[[']] and not x\find"\n" and not x\find"\\" "\'"..x.."\'" -- cgit v1.2.3