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.



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

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

Instance Attribute Details

#laObject (readonly)

Returns the value of attribute la.



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

def la
  @la
end

#ruleObject (readonly)

Returns the value of attribute rule.



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

def rule
  @rule
end

Instance Method Details

#each_la(tbl) ⇒ Object



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

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