Sha256: 2db8e51d8ab6aa66557b2e116186ef915854e1b419aa24537679319dc7229c26

Contents?: true

Size: 763 Bytes

Versions: 3

Compression:

Stored size: 763 Bytes

Contents

require 'ripper_ruby_parser/commenting_ripper_parser'
require 'ripper_ruby_parser/sexp_processor'

module RipperRubyParser
  # Main parser class. Brings together Ripper and our
  # RipperRubyParser::SexpProcessor.
  class Parser
    attr_accessor :extra_compatible

    def initialize processor = SexpProcessor.new
      @processor = processor
      @extra_compatible = false
    end

    def parse source, filename = '(string)', lineno = 1
      parser = CommentingRipperParser.new(source, filename, lineno)
      exp = parser.parse

      @processor.filename = filename
      @processor.extra_compatible = extra_compatible
      result = @processor.process exp

      if result == s(:void_stmt)
        nil
      else
        result
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
ripper_ruby_parser-1.1.2 lib/ripper_ruby_parser/parser.rb
ripper_ruby_parser-1.1.1 lib/ripper_ruby_parser/parser.rb
ripper_ruby_parser-1.1.0 lib/ripper_ruby_parser/parser.rb