_properly_ handle arb Lua block comments; now passes the embedded block comment test
This commit is contained in:
parent
f1bdccefd2
commit
f1b7c894f7
|
@ -29,7 +29,7 @@ end
|
|||
|
||||
function Lang:grab_block_comment(v,tok)
|
||||
v = v:gsub(self.block_comment,'')
|
||||
return tools.grab_block_comment(v,tok,self.end_block1,self.end_block2)
|
||||
return tools.grab_block_comment(v,tok,self.end_comment)
|
||||
end
|
||||
|
||||
function Lang:find_module(tok,t,v)
|
||||
|
@ -62,8 +62,6 @@ function Lua:_init()
|
|||
self.line_comment = '^%-%-+' -- used for stripping
|
||||
self.start_comment_ = '^%-%-%-+' -- used for doc comment line start
|
||||
self.block_comment = '^%-%-%[=*%[%-+' -- used for block doc comments
|
||||
self.end_block1 = ']'
|
||||
self.end_block2 = ']'
|
||||
self:finalize()
|
||||
end
|
||||
|
||||
|
@ -73,6 +71,13 @@ function Lua.lexer(fname)
|
|||
return lexer.lua(f,{}),f
|
||||
end
|
||||
|
||||
function Lua:grab_block_comment(v,tok)
|
||||
local equals = v:match('^%-%-%[(=*)%[')
|
||||
v = v:gsub(self.block_comment,'')
|
||||
return tools.grab_block_comment(v,tok,'%]'..equals..'%]')
|
||||
end
|
||||
|
||||
|
||||
function Lua:parse_module_call(tok,t,v)
|
||||
t,v = tnext(tok)
|
||||
if t == '(' then t,v = tnext(tok) end
|
||||
|
@ -167,6 +172,8 @@ function Lua:parse_extra (tags,tok)
|
|||
end
|
||||
end
|
||||
|
||||
-- note a difference here: we scan C/C++ code in full-text mode, not line by line.
|
||||
-- This is because we can't detect multiline comments in line mode
|
||||
|
||||
class.CC(Lang)
|
||||
|
||||
|
|
|
@ -327,11 +327,11 @@ end
|
|||
-- The PL Lua lexer does not do block comments
|
||||
-- when used in line-grabbing mode, so this function grabs each line
|
||||
-- until we meet the end of the comment
|
||||
function M.grab_block_comment (v,tok,end1,end2)
|
||||
function M.grab_block_comment (v,tok,patt)
|
||||
local res = {v}
|
||||
repeat
|
||||
v = lexer.getline(tok)
|
||||
if v:match '%]=*%]' then break end
|
||||
if v:match (patt) then break end
|
||||
append(res,v)
|
||||
append(res,'\n')
|
||||
until false
|
||||
|
|
Loading…
Reference in New Issue