diff options
| author | Bruce Hill <bitbucket@bruce-hill.com> | 2018-07-12 21:24:08 -0700 |
|---|---|---|
| committer | Bruce Hill <bitbucket@bruce-hill.com> | 2018-07-12 21:24:13 -0700 |
| commit | af62e3e8bf2794048e7c20fc16fabd8c4726961e (patch) | |
| tree | 71230e6b87b41ac7d0ce0d38cdabcf183317e25c /parser.lua | |
| parent | f908bb49b30dcead0c5123a513a1ee9e70dac412 (diff) | |
All tests passing.
Diffstat (limited to 'parser.lua')
| -rw-r--r-- | parser.lua | 51 |
1 files changed, 43 insertions, 8 deletions
@@ -91,19 +91,54 @@ setmetatable(NOMSU_DEFS, { value.source = Source(_with_0.filename, _with_0.start + start - 1, _with_0.start + stop - 1) end end - if key == "Comment" then - value = value[1] - else - local comments = { } + while true do + local found = false for i = #value, 1, -1 do - if type(value[i]) == 'table' and value[i].type == "Comment" then - insert(comments, remove(value, i)) + local _continue_0 = false + repeat + if not (type(value[i]) == 'table') then + _continue_0 = true + break + end + if value[i].is_halfblock then + found = true + local hb = remove(value, i) + for _index_0 = 1, #hb do + local v = hb[_index_0] + insert(value, i, v) + i = i + 1 + end + end + _continue_0 = true + until true + if not _continue_0 then + break end end - if #comments > 0 then - value.comments = comments + if not (found) then + break end end + local comments = { } + for i = #value, 1, -1 do + local _continue_0 = false + repeat + if not (type(value[i]) == 'table') then + _continue_0 = true + break + end + if value[i].type == "Comment" then + insert(comments, remove(value, i)) + end + _continue_0 = true + until true + if not _continue_0 then + break + end + end + if #comments > 0 then + value.comments = comments + end setmetatable(value, AST[key]) if value.__init then value:__init() |
