Sha256: d35e14750a27cc42efcf07122fdda83910e0eb8a662268024981d74133e4b034

Contents?: true

Size: 786 Bytes

Versions: 2

Compression:

Stored size: 786 Bytes

Contents

module Rly
  class Production
    attr_reader :index, :name, :prod, :precedence, :block, :usyms, :line
    attr_accessor :lr_items, :lr_next, :lr0_added, :reduced

    # FIXME line!!!
    def initialize(index, name, prod, precedence=[:right, 0], block=nil)
      @index = index
      @name = name
      @prod = prod
      @precedence = precedence
      @block = block

      @usyms = []
      prod.each { |sym| @usyms << sym unless @usyms.include?(sym) }
    end

    def to_s
      "#{name} -> #{@prod.map { |s| s.to_s }.join(' ')}"
    end

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

    def length
      @prod.length
    end

    def line
      @line ||= 0
    end

    def lr0_added
      @lr0_added ||= 0
    end

    def reduced
      @reduced ||= 0
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
rly-0.2.3 lib/rly/parse/production.rb
rly-0.2.2 lib/rly/parse/production.rb