Sha256: f2f86b9bbdcdc04a396180232bbf392e8ffd575021747c3868b29cd21a5a27e6

Contents?: true

Size: 990 Bytes

Versions: 11

Compression:

Stored size: 990 Bytes

Contents

# frozen_string_literal: true

require "parser/rubynext"

module RubyNext
  module Language
    class Builder < ::Parser::Builders::Default
      modernize
    end

    class << self
      def parser
        ::Parser::RubyNext.new(Builder.new).tap do |prs|
          prs.diagnostics.tap do |diagnostics|
            diagnostics.all_errors_are_fatal = true
          end
        end
      end

      def parse(source, file = "(string)")
        buffer = ::Parser::Source::Buffer.new(file).tap do |buffer|
          buffer.source = source
        end

        parser.parse(buffer)
      rescue ::Parser::SyntaxError => e
        raise ::SyntaxError, e.message
      end

      def parse_with_comments(source, file = "(string)")
        buffer = ::Parser::Source::Buffer.new(file).tap do |buffer|
          buffer.source = source
        end

        parser.parse_with_comments(buffer)
      rescue ::Parser::SyntaxError => e
        raise ::SyntaxError, e.message
      end
    end
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
ruby-next-core-0.10.5 lib/ruby-next/language/parser.rb
ruby-next-core-0.10.4 lib/ruby-next/language/parser.rb
ruby-next-core-0.10.3 lib/ruby-next/language/parser.rb
ruby-next-core-0.10.2 lib/ruby-next/language/parser.rb
ruby-next-core-0.10.1 lib/ruby-next/language/parser.rb
ruby-next-core-0.10.0 lib/ruby-next/language/parser.rb
ruby-next-core-0.9.1 lib/ruby-next/language/parser.rb
ruby-next-core-0.9.0 lib/ruby-next/language/parser.rb
ruby-next-core-0.9.0.pre lib/ruby-next/language/parser.rb
ruby-next-core-0.8.0 lib/ruby-next/language/parser.rb
ruby-next-core-0.7.0 lib/ruby-next/language/parser.rb