Sha256: 4fa86090af127454bd805197c430bdbfc1eadc61cff4aa65785b0ee69417ac97

Contents?: true

Size: 617 Bytes

Versions: 4

Compression:

Stored size: 617 Bytes

Contents

module Rly
  class LRItem
    attr_accessor :lr_after, :lr_before, :lr_next
    attr_reader :prod, :name, :usyms, :lr_index, :length, :lookaheads, :index

    def initialize(p, n)
      @name = p.name
      @prod = p.prod.dup
      @index = p.index
      @lr_index = n
      @lookaheads = {}
      @prod.insert(n, :'.')
      @length = @prod.length
      @usyms = p.usyms

      @lr_items = []
      @lr_next = nil
    end
    
    def to_s
      if @prod
        "#{@name} -> #{@prod.join(' ')}"
      else
        "#{@name} -> <empty>"
      end
    end

    def inspect
      "#<LRItem #{to_s}>"
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
rly-0.2.3 lib/rly/parse/lr_item.rb
rly-0.2.2 lib/rly/parse/lr_item.rb
rly-0.2.1 lib/rly/parse/lr_item.rb
rly-0.2.0 lib/rly/parse/lr_item.rb