class Racc::LocationPointer


because pointer points right edge of the final symbol when reducing.
Note that the number of pointers is more than rule’s RHS array,
A set of rule and position in it’s RHS.

def before(len)

def before(len)
  @rule.ptrs[@index - len] or ptr_bug!
end

def eql?(ot)

def eql?(ot)
  @hash == ot.hash
end

def head?

def head?
  @index == 0
end

def initialize(rule, i, sym)

def initialize(rule, i, sym)
  @rule   = rule
  @index  = i
  @symbol = sym
  @ident  = @rule.hash + i
  @reduce = sym.nil?
end

def next

def next
  @rule.ptrs[@index + 1] or ptr_bug!
end

def ptr_bug!

def ptr_bug!
  raise "racc: fatal: pointer not exist: self: #{to_s}"
end

def to_s

def to_s
  sprintf('(%d,%d %s)',
          @rule.ident, @index, (reduce?() ? '#' : @symbol.to_s))
end