Sha256: cce562bb694522c1abad5ace0ec8973fe11ff234dceca28ea2d5038954eb9386

Contents?: true

Size: 813 Bytes

Versions: 5

Compression:

Stored size: 813 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
      # @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

5 entries across 5 versions & 1 rubygems

Version Path
graphql-1.8.0.pre4 lib/graphql/language/token.rb
graphql-1.8.0.pre3 lib/graphql/language/token.rb
graphql-1.7.8 lib/graphql/language/token.rb
graphql-1.8.0.pre2 lib/graphql/language/token.rb
graphql-1.7.7 lib/graphql/language/token.rb