aboutsummaryrefslogtreecommitdiff
path: root/parser.moon
diff options
context:
space:
mode:
authorBruce Hill <bitbucket@bruce-hill.com>2018-07-12 21:24:08 -0700
committerBruce Hill <bitbucket@bruce-hill.com>2018-07-12 21:24:13 -0700
commitaf62e3e8bf2794048e7c20fc16fabd8c4726961e (patch)
tree71230e6b87b41ac7d0ce0d38cdabcf183317e25c /parser.moon
parentf908bb49b30dcead0c5123a513a1ee9e70dac412 (diff)
All tests passing.
Diffstat (limited to 'parser.moon')
-rw-r--r--parser.moon25
1 files changed, 17 insertions, 8 deletions
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