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) ⇒ Recognizer::EItem
Add an Earley item to the set if not yet present.
-
#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) ⇒ Recognizer::EItem
Add an Earley item to the set if not yet present.
21 22 23 24 25 26 27 |
# File 'lib/dendroid/recognizer/item_set.rb', line 21 def add_item(anItem) idx = items.find_index anItem return items[idx] if idx @items << anItem anItem end |
#items_expecting(aSymbol) ⇒ void
This method returns an undefined value.
Find the items that expect a given grammar symbol
32 33 34 |
# File 'lib/dendroid/recognizer/item_set.rb', line 32 def items_expecting(aSymbol) items.select { |itm| itm.expecting?(aSymbol) } end |
#to_s ⇒ String
Return a text representation of the item set
38 39 40 |
# File 'lib/dendroid/recognizer/item_set.rb', line 38 def to_s items.join("\n") end |