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.



788
789
790
791
# File 'lib/racc/state.rb', line 788

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

Instance Attribute Details

#laObject (readonly)

Returns the value of attribute la.



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

def la
  @la
end

#ruleObject (readonly)

Returns the value of attribute rule.



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

def rule
  @rule
end

Instance Method Details

#each_la(tbl) ⇒ Object



796
797
798
799
800
801
802
803
804
805
# File 'lib/racc/state.rb', line 796

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