Sha256: eb2177e895d0bb9ef03db6855f6164c2b669e05e43c17545cfab823e42d06820

Contents?: true

Size: 901 Bytes

Versions: 61

Compression:

Stored size: 901 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(name, value, 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

61 entries across 61 versions & 1 rubygems

Version Path
graphql-1.12.24 lib/graphql/language/token.rb
graphql-1.12.23 lib/graphql/language/token.rb
graphql-1.12.22 lib/graphql/language/token.rb
graphql-1.12.21 lib/graphql/language/token.rb
graphql-1.12.20 lib/graphql/language/token.rb
graphql-1.12.19 lib/graphql/language/token.rb
graphql-1.11.10 lib/graphql/language/token.rb
graphql-1.12.18 lib/graphql/language/token.rb
graphql-1.11.9 lib/graphql/language/token.rb
graphql-1.12.17 lib/graphql/language/token.rb
graphql-1.12.16 lib/graphql/language/token.rb
graphql-1.12.15 lib/graphql/language/token.rb
graphql-1.12.14 lib/graphql/language/token.rb
graphql-1.12.13 lib/graphql/language/token.rb
graphql-1.12.12 lib/graphql/language/token.rb
graphql-1.12.11 lib/graphql/language/token.rb
graphql-1.12.10 lib/graphql/language/token.rb
graphql-1.12.9 lib/graphql/language/token.rb
graphql-1.12.8 lib/graphql/language/token.rb
graphql-1.12.7 lib/graphql/language/token.rb