From af62e3e8bf2794048e7c20fc16fabd8c4726961e Mon Sep 17 00:00:00 2001 From: Bruce Hill Date: Thu, 12 Jul 2018 21:24:08 -0700 Subject: All tests passing. --- parser.moon | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) (limited to 'parser.moon') diff --git a/parser.moon b/parser.moon index 7786650..5e37a59 100644 --- a/parser.moon +++ b/parser.moon @@ -58,15 +58,24 @@ setmetatable(NOMSU_DEFS, {__index:(key)=> if userdata.source with userdata.source value.source = Source(.filename, .start + start-1, .start + stop-1) - if key == "Comment" - value = value[1] - else - comments = {} + while true + found = false for i=#value,1,-1 - if type(value[i]) == 'table' and value[i].type == "Comment" - insert comments, remove(value, i) - if #comments > 0 - value.comments = comments + continue unless type(value[i]) == 'table' + if value[i].is_halfblock + found = true + hb = remove(value, i) + for v in *hb + insert value, i, v + i += 1 + break unless found + comments = {} + for i=#value,1,-1 + continue unless type(value[i]) == 'table' + if value[i].type == "Comment" + insert comments, remove(value, i) + if #comments > 0 + value.comments = comments setmetatable(value, AST[key]) if value.__init then value\__init! return value -- cgit v1.2.3