method
parse_statements
v1_9_3_392 -
Show latest stable
-
0 notes -
Class: Ruby
- 1_8_6_287
- 1_8_7_72
- 1_8_7_330
- 1_9_1_378 (0)
- 1_9_2_180 (38)
- 1_9_3_125 (0)
- 1_9_3_392 (0)
- 2_1_10 (0)
- 2_2_9 (0)
- 2_4_6
- 2_5_5
- 2_6_3
- What's this?
Related methods
- Class methods (1)
- new
- Instance methods (82)
- add_token_listener (<= v1_9_1_378)
- collect_first_comment
- consume_trailing_spaces (>= v2_1_10)
- create_attr (>= v2_1_10)
- create_module_alias (>= v2_1_10)
- error
- extract_call_seq
- get_bool
- get_class_or_module
- get_class_specification
- get_constant
- get_constant_with_optional_...
- get_end_token (>= v2_1_10)
- get_method_container (>= v2_1_10)
- get_symbol_or_name
- get_tk (<= v1_9_1_378)
- get_tkread (<= v1_9_1_378)
- get_tkread_clean (>= v2_1_10)
- get_visibility_information (>= v2_1_10)
- look_for_directives_in
- make_message
- new_comment (>= v2_1_10)
- parse_alias
- parse_attr
- parse_attr_accessor
- parse_call_parameters
- parse_class
- parse_class_regular (>= v2_1_10)
- parse_class_singleton (>= v2_1_10)
- parse_comment
- parse_comment_attr (>= v2_1_10)
- parse_comment_ghost (>= v2_1_10)
- parse_comment_tomdoc (>= v2_1_10)
- parse_constant
- parse_constant_body (>= v2_1_10)
- parse_extend_or_include (>= v2_1_10)
- parse_identifier (>= v2_1_10)
- parse_include
- parse_meta_attr
- parse_meta_method
- parse_meta_method_name (>= v2_1_10)
- parse_meta_method_params (>= v2_1_10)
- parse_method
- parse_method_dummy (>= v2_1_10)
- parse_method_name (>= v2_1_10)
- parse_method_name_regular (>= v2_1_10)
- parse_method_name_singleton (>= v2_1_10)
- parse_method_or_yield_param...
- parse_method_parameters
- parse_method_params_and_body (>= v2_1_10)
- parse_module
- parse_require
- parse_rescue (>= v2_1_10)
- parse_statements
- parse_symbol_arg
- parse_symbol_arg_paren (>= v2_1_10)
- parse_symbol_arg_space (>= v2_1_10)
- parse_symbol_in_arg
- parse_top_level_statements
- parse_toplevel_statements (<= v1_9_1_378)
- parse_visibility
- parse_yield
- parse_yield_parameters (<= v1_9_1_378)
- peek_read (<= v1_9_1_378)
- peek_tk (<= v1_9_1_378)
- read_directive
- read_documentation_modifiers
- record_location (>= v2_1_10)
- remove_private_comments
- remove_token_listener (<= v1_9_1_378)
- reset (<= v1_9_1_378)
- scan
- skip_for_variable
- skip_method
- skip_optional_do_after_expr...
- skip_tkspace (<= v1_9_1_378)
- skip_tkspace_comment
- stop_at_EXPR_END (>= v2_1_10)
- suppress_parents (>= v2_1_10)
- unget_tk (<= v1_9_1_378)
- update_visibility (>= v2_1_10)
- warn
= private
= protected
parse_statements(container, single = NORMAL, current_method = nil, comment = '')
public
The core of the ruby parser.
Show source
# File lib/rdoc/parser/ruby.rb, line 1255 def parse_statements(container, single = NORMAL, current_method = nil, 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 unless comment.empty? then look_for_directives_in container, comment if container.done_documenting then container.ongoing_visibility = save_visibility end end keep_comment = true else non_comment_seen = true end unget_tk tk # TODO peek instead of get then unget keep_comment = true when TkCLASS then parse_class container, single, tk, comment when TkMODULE then if container.document_children then parse_module container, single, tk, comment else nest += 1 end when TkDEF then parse_method container, single, tk, comment when TkCONSTANT then unless parse_constant container, tk, comment 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 TkIDENTIFIER then if nest == 1 and current_method.nil? then case tk.name when 'private', 'protected', 'public', 'private_class_method', 'public_class_method', 'module_function' then parse_visibility container, single, tk keep_comment = true when 'attr' then parse_attr container, single, tk, comment when /^attr_(reader|writer|accessor)$/ then parse_attr_accessor container, single, tk, comment when 'alias_method' then parse_alias container, single, tk, comment when 'require', 'include' then # ignore else if comment =~ /\A#\#$/ then case comment when /^# +:?attr(_reader|_writer|_accessor)?:/ then parse_meta_attr container, single, tk, comment else parse_meta_method container, single, tk, comment end end end end case tk.name when "require" then parse_require container, comment when "include" then parse_include 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 = '' comment.force_encoding @encoding if @encoding end begin get_tkread skip_tkspace false end while peek_tk == TkNL end end