Codebase list lua-ldoc / f1b7c89
_properly_ handle arb Lua block comments; now passes the embedded block comment test steve donovan 12 years ago
2 changed file(s) with 12 addition(s) and 5 deletion(s). Raw diff Collapse all Expand all
2828
2929 function Lang:grab_block_comment(v,tok)
3030 v = v:gsub(self.block_comment,'')
31 return tools.grab_block_comment(v,tok,self.end_block1,self.end_block2)
31 return tools.grab_block_comment(v,tok,self.end_comment)
3232 end
3333
3434 function Lang:find_module(tok,t,v)
6161 self.line_comment = '^%-%-+' -- used for stripping
6262 self.start_comment_ = '^%-%-%-+' -- used for doc comment line start
6363 self.block_comment = '^%-%-%[=*%[%-+' -- used for block doc comments
64 self.end_block1 = ']'
65 self.end_block2 = ']'
6664 self:finalize()
6765 end
6866
7169 if not f then quit(e) end
7270 return lexer.lua(f,{}),f
7371 end
72
73 function Lua:grab_block_comment(v,tok)
74 local equals = v:match('^%-%-%[(=*)%[')
75 v = v:gsub(self.block_comment,'')
76 return tools.grab_block_comment(v,tok,'%]'..equals..'%]')
77 end
78
7479
7580 function Lua:parse_module_call(tok,t,v)
7681 t,v = tnext(tok)
166171 end
167172 end
168173
174 -- note a difference here: we scan C/C++ code in full-text mode, not line by line.
175 -- This is because we can't detect multiline comments in line mode
169176
170177 class.CC(Lang)
171178
326326 -- The PL Lua lexer does not do block comments
327327 -- when used in line-grabbing mode, so this function grabs each line
328328 -- until we meet the end of the comment
329 function M.grab_block_comment (v,tok,end1,end2)
329 function M.grab_block_comment (v,tok,patt)
330330 local res = {v}
331331 repeat
332332 v = lexer.getline(tok)
333 if v:match '%]=*%]' then break end
333 if v:match (patt) then break end
334334 append(res,v)
335335 append(res,'\n')
336336 until false