Class: RipperRubyParser::Parser
- Inherits:
-
Object
- Object
- RipperRubyParser::Parser
- Defined in:
- lib/ripper_ruby_parser/parser.rb
Overview
Main parser class. Brings together Ripper and our RipperRubyParser::SexpProcessor.
Instance Attribute Summary collapse
-
#extra_compatible ⇒ Object
Returns the value of attribute extra_compatible.
Instance Method Summary collapse
-
#initialize ⇒ Parser
constructor
A new instance of Parser.
- #parse(source, filename = "(string)", lineno = 1) ⇒ Object
Constructor Details
#initialize ⇒ Parser
Returns a new instance of Parser.
12 13 14 |
# File 'lib/ripper_ruby_parser/parser.rb', line 12 def initialize @extra_compatible = false end |
Instance Attribute Details
#extra_compatible ⇒ Object
Returns the value of attribute extra_compatible.
10 11 12 |
# File 'lib/ripper_ruby_parser/parser.rb', line 10 def extra_compatible @extra_compatible end |
Instance Method Details
#parse(source, filename = "(string)", lineno = 1) ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/ripper_ruby_parser/parser.rb', line 16 def parse(source, filename = "(string)", lineno = 1) parser = CommentingRipperParser.new(source, filename, lineno) exp = parser.parse processor = SexpProcessor.new(filename: filename, extra_compatible: extra_compatible) result = processor.process exp result = result[1] if result.sexp_type == :begin if result.sexp_type == :void_stmt nil else trickle_up_line_numbers result trickle_down_line_numbers result result end end |