Sha256: c7717c18091838e4ed4ba26c1e17686875440a446c797ffa78a3501cd2dd0963

Contents?: true

Size: 906 Bytes

Versions: 10

Compression:

Stored size: 906 Bytes

Contents

# frozen_string_literal: true
module GraphQL
  module Language
    # Emitted by the lexer and passed to the parser.
    # Contains type, value and position data.
    class Token
      if !String.method_defined?(:-@)
        using GraphQL::StringDedupBackport
      end

      # @return [Symbol] The kind of token this is
      attr_reader :name
      # @return [String] The text of this token
      attr_reader :value
      attr_reader :prev_token, :line, :col

      def initialize(value:, name:, line:, col:, prev_token:)
        @name = name
        @value = -value
        @line = line
        @col = col
        @prev_token = prev_token
      end

      alias to_s value
      def to_i; @value.to_i; end
      def to_f; @value.to_f; end

      def line_and_column
        [@line, @col]
      end

      def inspect
        "(#{@name} #{@value.inspect} [#{@line}:#{@col}])"
      end
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
graphql-1.9.14 lib/graphql/language/token.rb
graphql-1.10.0.pre1 lib/graphql/language/token.rb
graphql-1.9.13 lib/graphql/language/token.rb
graphql-1.9.12 lib/graphql/language/token.rb
graphql-1.9.11 lib/graphql/language/token.rb
graphql-1.9.10 lib/graphql/language/token.rb
graphql-1.9.9 lib/graphql/language/token.rb
graphql-1.9.8 lib/graphql/language/token.rb
graphql-1.9.7 lib/graphql/language/token.rb
graphql-1.9.6 lib/graphql/language/token.rb