Class: Racc::Item

Inherits:
Object show all
Defined in:
lib/racc/state.rb

Overview

LALR item. A set of rule and its lookahead tokens.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(rule, la) ⇒ Item

Returns a new instance of Item.



792
793
794
795
# File 'lib/racc/state.rb', line 792

def initialize(rule, la)
  @rule = rule
  @la  = la
end

Instance Attribute Details

#laObject (readonly)

Returns the value of attribute la.



798
799
800
# File 'lib/racc/state.rb', line 798

def la
  @la
end

#ruleObject (readonly)

Returns the value of attribute rule.



797
798
799
# File 'lib/racc/state.rb', line 797

def rule
  @rule
end

Instance Method Details

#each_la(tbl) ⇒ Object



800
801
802
803
804
805
806
807
808
809
# File 'lib/racc/state.rb', line 800

def each_la(tbl)
  la = @la
  0.upto(la.size - 1) do |i|
    (0..7).each do |ii|
      if la[idx = i * 8 + ii] == 1
        yield tbl[idx]
      end
    end
  end
end