method
parse_statements
v2_1_10 -
Show latest stable
- Class:
RDoc::Parser::Ruby
parse_statements(container, single = NORMAL, current_method = nil, comment = new_comment(''))public
The core of the Ruby parser.
# File lib/rdoc/parser/ruby.rb, line 1608
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
# Look for RDoc in a comment about to be thrown away
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 # leading spaces
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
# Until and While can have a 'do', which shouldn't increase the nesting.
# We can't solve the general case, but we can handle most occurrences by
# ignoring a do at the end of a line.
when TkUNTIL, TkWHILE then
nest += 1
skip_optional_do_after_expression
# 'for' is trickier
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 Related methods
- Instance methods
- collect_first_comment
- consume_trailing_spaces
- create_attr
- create_module_alias
- error
- get_bool
- get_class_or_module
- get_class_specification
- get_constant
- get_constant_with_optional_parens
- get_end_token
- get_method_container
- get_symbol_or_name
- get_tkread_clean
- get_visibility_information
- look_for_directives_in
- make_message
- new_comment
- parse_alias
- parse_attr
- parse_attr_accessor
- parse_call_parameters
- parse_class
- parse_class_regular
- parse_class_singleton
- parse_comment
- parse_comment_attr
- parse_comment_ghost
- parse_comment_tomdoc
- parse_constant
- parse_constant_body
- parse_extend_or_include
- parse_identifier
- parse_meta_attr
- parse_meta_method
- parse_meta_method_name
- parse_meta_method_params
- parse_method
- parse_method_dummy
- parse_method_name
- parse_method_name_regular
- parse_method_name_singleton
- parse_method_or_yield_parameters
- parse_method_parameters
- parse_method_params_and_body
- parse_module
- parse_require
- parse_rescue
- parse_statements
- parse_symbol_arg
- parse_symbol_arg_paren
- parse_symbol_arg_space
- parse_symbol_in_arg
- parse_top_level_statements
- parse_visibility
- parse_yield
- read_directive
- read_documentation_modifiers
- record_location
- remove_private_comments
- scan
- skip_for_variable
- skip_method
- skip_optional_do_after_expression
- skip_tkspace_comment
- stop_at_EXPR_END
- suppress_parents
- update_visibility
- warn
- Class methods
- new