def parse_statements(container, single = NORMAL, current_method = nil,
comment = new_comment(''))
raise 'no' unless RDoc::Comment === comment
comment.force_encoding @encoding if @encoding
nest = 1
save_visibility = container.visibility
non_comment_seen = true
while tk = get_tk do
keep_comment = false
try_parse_comment = false
non_comment_seen = true unless TkCOMMENT === tk
case tk
when TkNL then
skip_tkspace
tk = get_tk
if TkCOMMENT === tk then
if non_comment_seen then
non_comment_seen = parse_comment container, tk, comment unless
comment.empty?
comment = ''
comment.force_encoding @encoding if @encoding
end
while TkCOMMENT === tk do
comment << tk.text << "\n"
tk = get_tk
if TkNL === tk then
skip_tkspace false
tk = get_tk
end
end
comment = new_comment comment
unless comment.empty? then
look_for_directives_in container, comment
if container.done_documenting then
throw :eof if RDoc::TopLevel === container
container.ongoing_visibility = save_visibility
end
end
keep_comment = true
else
non_comment_seen = true
end
unget_tk tk
keep_comment = true
when TkCLASS then
parse_class container, single, tk, comment
when TkMODULE then
parse_module container, single, tk, comment
when TkDEF then
parse_method container, single, tk, comment
when TkCONSTANT then
unless parse_constant container, tk, comment, current_method then
try_parse_comment = true
end
when TkALIAS then
parse_alias container, single, tk, comment unless current_method
when TkYIELD then
if current_method.nil? then
warn "Warning: yield outside of method" if container.document_self
else
parse_yield container, single, tk, current_method
end
when TkUNTIL, TkWHILE then
nest += 1
skip_optional_do_after_expression
when TkFOR then
nest += 1
skip_for_variable
skip_optional_do_after_expression
when TkCASE, TkDO, TkIF, TkUNLESS, TkBEGIN then
nest += 1
when TkSUPER then
current_method.calls_super = true if current_method
when TkRESCUE then
parse_rescue
when TkIDENTIFIER then
if nest == 1 and current_method.nil? then
keep_comment = parse_identifier container, single, tk, comment
end
case tk.name
when "require" then
parse_require container, comment
when "include" then
parse_extend_or_include RDoc::Include, container, comment
when "extend" then
parse_extend_or_include RDoc::Extend, container, comment
end
when TkEND then
nest -= 1
if nest == 0 then
read_documentation_modifiers container, RDoc::CLASS_MODIFIERS
container.ongoing_visibility = save_visibility
parse_comment container, tk, comment unless comment.empty?
return
end
else
try_parse_comment = nest == 1
end
if try_parse_comment then
non_comment_seen = parse_comment container, tk, comment unless
comment.empty?
keep_comment = false
end
unless keep_comment then
comment = new_comment ''
comment.force_encoding @encoding if @encoding
container.params = nil
container.block_params = nil
end
consume_trailing_spaces
end
container.params = nil
container.block_params = nil
end