Class: RipperRubyParser::CommentingRipperParser Private

Inherits:
Ripper::SexpBuilder
  • Object
show all
Defined in:
lib/ripper_ruby_parser/commenting_ripper_parser.rb

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Variant of Ripper’s SexpBuilder parser class that inserts comments as Sexps into the built parse tree.

rubocop: disable Metrics/ClassLength

Instance Method Summary collapse

Constructor Details

#initialize(*args) ⇒ CommentingRipperParser

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of CommentingRipperParser.



14
15
16
17
18
19
20
21
22
# File 'lib/ripper_ruby_parser/commenting_ripper_parser.rb', line 14

def initialize(*args)
  super
  @comment = ""
  @comment_stack = []
  @delimiter_stack = []
  @space_before = false
  @seen_space = false
  @in_symbol = false
end

Instance Method Details

#parseObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



24
25
26
27
28
29
# File 'lib/ripper_ruby_parser/commenting_ripper_parser.rb', line 24

def parse
  result = super
  raise "Ripper parse failed." unless result

  Sexp.from_array(result)
end