Sha256: 0bab903ad7dbad977cdb8e551c6212598ac999a4ec05253144e354379f058349

Contents?: true

Size: 1.52 KB

Versions: 19

Compression:

Stored size: 1.52 KB

Contents

# frozen_string_literal: true

module RBS
  class Parser
    def self.parse_type(source, range: 0..., variables: [], require_eof: false)
      buf = buffer(source)
      _parse_type(buf, range.begin || 0, range.end || buf.last_position, variables, require_eof)
    end

    def self.parse_method_type(source, range: 0..., variables: [], require_eof: false)
      buf = buffer(source)
      _parse_method_type(buf, range.begin || 0, range.end || buf.last_position, variables, require_eof)
    end

    def self.parse_signature(source)
      buf = buffer(source)
      dirs, decls = _parse_signature(buf, buf.last_position)

      [buf, dirs, decls]
    end

    def self.buffer(source)
      case source
      when String
        Buffer.new(content: source, name: "a.rbs")
      when Buffer
        source
      end
    end

    autoload :SyntaxError, "rbs/parser_compat/syntax_error"
    autoload :SemanticsError, "rbs/parser_compat/semantics_error"
    autoload :LexerError, "rbs/parser_compat/lexer_error"
    autoload :LocatedValue, "rbs/parser_compat/located_value"

    KEYWORDS = %w(
      bool
      bot
      class
      instance
      interface
      nil
      self
      singleton
      top
      void
      type
      unchecked
      in
      out
      end
      def
      include
      extend
      prepend
      alias
      module
      attr_reader
      attr_writer
      attr_accessor
      public
      private
      untyped
      true
      false
      ).each_with_object({}) do |keyword, hash|
        hash[keyword] = nil
      end
  end
end

Version data entries

19 entries across 19 versions & 1 rubygems

Version Path
rbs-3.4.4 lib/rbs/parser_aux.rb
rbs-3.4.3 lib/rbs/parser_aux.rb
rbs-3.4.2 lib/rbs/parser_aux.rb
rbs-3.4.1 lib/rbs/parser_aux.rb
rbs-3.4.0 lib/rbs/parser_aux.rb
rbs-3.4.0.pre.1 lib/rbs/parser_aux.rb
rbs-3.3.2 lib/rbs/parser_aux.rb
rbs-3.3.1 lib/rbs/parser_aux.rb
rbs-3.3.0 lib/rbs/parser_aux.rb
rbs-3.3.0.pre.2 lib/rbs/parser_aux.rb
rbs-3.3.0.pre.1 lib/rbs/parser_aux.rb
rbs-3.2.2 lib/rbs/parser_aux.rb
rbs-3.2.1 lib/rbs/parser_aux.rb
rbs-3.2.0 lib/rbs/parser_aux.rb
rbs-3.2.0.pre.1 lib/rbs/parser_aux.rb
rbs-3.1.3 lib/rbs/parser_aux.rb
rbs-3.1.2 lib/rbs/parser_aux.rb
rbs-3.1.1 lib/rbs/parser_aux.rb
rbs-3.1.0 lib/rbs/parser_aux.rb