Class: Dendroid::Recognizer::ItemSet
- Inherits:
-
Object
- Object
- Dendroid::Recognizer::ItemSet
- Extended by:
- Forwardable
- Defined in:
- lib/dendroid/recognizer/item_set.rb
Overview
Holds the EItem identified by the recognizer when processing at token at given rank.
Instance Attribute Summary collapse
- #items ⇒ Recognizer::EItem readonly
Instance Method Summary collapse
-
#add_item(anItem) ⇒ Object
Add an Early item to the set.
-
#initialize ⇒ ItemSet
constructor
A new instance of ItemSet.
-
#items_expecting(aSymbol) ⇒ void
Find the items that expect a given grammar symbol.
-
#to_s ⇒ String
Return a text representation of the item set.
Constructor Details
#initialize ⇒ ItemSet
Returns a new instance of ItemSet.
14 15 16 |
# File 'lib/dendroid/recognizer/item_set.rb', line 14 def initialize @items = [] end |
Instance Attribute Details
#items ⇒ Recognizer::EItem (readonly)
10 11 12 |
# File 'lib/dendroid/recognizer/item_set.rb', line 10 def items @items end |
Instance Method Details
#add_item(anItem) ⇒ Object
Add an Early item to the set
20 21 22 |
# File 'lib/dendroid/recognizer/item_set.rb', line 20 def add_item(anItem) @items << anItem unless items.include? anItem end |
#items_expecting(aSymbol) ⇒ void
This method returns an undefined value.
Find the items that expect a given grammar symbol
27 28 29 |
# File 'lib/dendroid/recognizer/item_set.rb', line 27 def items_expecting(aSymbol) items.select { |itm| itm.expecting?(aSymbol) } end |
#to_s ⇒ String
Return a text representation of the item set
33 34 35 |
# File 'lib/dendroid/recognizer/item_set.rb', line 33 def to_s items.join("\n") end |