Sha256: 718112eb9e6d307dea380c0de0f22cd993d27d9719165f89ed3f3826af671784

Contents?: true

Size: 700 Bytes

Versions: 2

Compression:

Stored size: 700 Bytes

Contents

module Attentive
  class Token
    attr_reader :pos

    def initialize(pos=nil)
      @pos = pos
    end

    def ==(other)
      self.class == other.class
    end

    def ambiguous?
      false
    end

    def entity?
      false
    end

    def whitespace?
      false
    end

    def skippable?
      false
    end

    def matches?(cursor)
      self == cursor.peek
    end

  end



  class StringToken < Token
    attr_reader :string

    def initialize(string, pos=nil)
      @string = string
      super pos
    end

    def to_str
      to_s
    end

    def to_s
      string
    end

    def ==(other)
      self.class == other.class && self.string == other.string
    end

  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
attentive-0.1.1 lib/attentive/token.rb
attentive-0.1.0 lib/attentive/token.rb