Fixed comments in nomsu codegen.
This commit is contained in:
parent
626b6cab79
commit
7112af7cb6
@ -1078,7 +1078,7 @@ do
|
|||||||
comments = _accum_0
|
comments = _accum_0
|
||||||
end
|
end
|
||||||
table.sort(comments, function(a, b)
|
table.sort(comments, function(a, b)
|
||||||
return (a.pos > b.pos)
|
return (a.source.start > b.source.start)
|
||||||
end)
|
end)
|
||||||
pop_comments = function(pos, prefix, suffix)
|
pop_comments = function(pos, prefix, suffix)
|
||||||
if prefix == nil then
|
if prefix == nil then
|
||||||
@ -1089,11 +1089,11 @@ do
|
|||||||
end
|
end
|
||||||
local nomsu = NomsuCode(tree.source)
|
local nomsu = NomsuCode(tree.source)
|
||||||
for i = #comments, 1, -1 do
|
for i = #comments, 1, -1 do
|
||||||
if comments[i].pos > pos then
|
if comments[i].source.start > pos then
|
||||||
break
|
break
|
||||||
end
|
end
|
||||||
local comment
|
local comment
|
||||||
comment, comments[i] = comments[i].comment, nil
|
comment, comments[i] = comments[i][1], nil
|
||||||
nomsu:append("#" .. (gsub(comment, "\n", "\n ")) .. "\n")
|
nomsu:append("#" .. (gsub(comment, "\n", "\n ")) .. "\n")
|
||||||
if comment:match("^\n.") then
|
if comment:match("^\n.") then
|
||||||
nomsu:append("\n")
|
nomsu:append("\n")
|
||||||
|
@ -672,13 +672,13 @@ with NomsuCompiler
|
|||||||
find_comments(tree)
|
find_comments(tree)
|
||||||
-- Sort in reversed order so they can be easily popped
|
-- Sort in reversed order so they can be easily popped
|
||||||
comments = [c for c in pairs comment_set]
|
comments = [c for c in pairs comment_set]
|
||||||
table.sort(comments, (a,b)->(a.pos > b.pos))
|
table.sort(comments, (a,b)->(a.source.start > b.source.start))
|
||||||
|
|
||||||
pop_comments = (pos, prefix='', suffix='')->
|
pop_comments = (pos, prefix='', suffix='')->
|
||||||
nomsu = NomsuCode(tree.source)
|
nomsu = NomsuCode(tree.source)
|
||||||
for i=#comments,1,-1
|
for i=#comments,1,-1
|
||||||
break if comments[i].pos > pos
|
break if comments[i].source.start > pos
|
||||||
comment, comments[i] = comments[i].comment, nil
|
comment, comments[i] = comments[i][1], nil
|
||||||
nomsu\append("#"..(gsub(comment, "\n", "\n ")).."\n")
|
nomsu\append("#"..(gsub(comment, "\n", "\n ")).."\n")
|
||||||
if comment\match("^\n.") then nomsu\append("\n") -- for aesthetics
|
if comment\match("^\n.") then nomsu\append("\n") -- for aesthetics
|
||||||
return '' if #nomsu.bits == 0
|
return '' if #nomsu.bits == 0
|
||||||
|
Loading…
Reference in New Issue
Block a user