Class: Rley::Parser::ParseEntryTracker

Inherits:
Object
  • Object
show all
Defined in:
lib/rley/parser/parse_entry_tracker.rb

Overview

Helper class that keeps track of the parse entries used while a Parsing instance is constructing a parse forest.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(aEntrySetIndex) ⇒ ParseEntryTracker

Constructor.



18
19
20
# File 'lib/rley/parser/parse_entry_tracker.rb', line 18

def initialize(aEntrySetIndex)
  self.entry_set_index = aEntrySetIndex
end

Instance Attribute Details

#entry_set_indexObject

The index of the current entry set



9
10
11
# File 'lib/rley/parser/parse_entry_tracker.rb', line 9

def entry_set_index
  @entry_set_index
end

#parse_entryObject

The current parse entry



12
13
14
# File 'lib/rley/parser/parse_entry_tracker.rb', line 12

def parse_entry
  @parse_entry
end

#processed_entriesObject (readonly)

The already processed entries from current entry set



15
16
17
# File 'lib/rley/parser/parse_entry_tracker.rb', line 15

def processed_entries
  @processed_entries
end

Instance Method Details

#curr_dotted_itemObject

The dotted item for the current parse entry.



43
44
45
# File 'lib/rley/parser/parse_entry_tracker.rb', line 43

def curr_dotted_item
  parse_entry.dotted_rule
end

#select_entry(theEntrys) ⇒ Object

Take the first provided entry that wasn't processed yet.



37
38
39
40
# File 'lib/rley/parser/parse_entry_tracker.rb', line 37

def select_entry(theEntrys)
  a_entry = theEntrys.find { |st| !processed_entries.include?(st) }
  self.parse_entry = a_entry
end

#symbol_on_leftObject



47
48
49
# File 'lib/rley/parser/parse_entry_tracker.rb', line 47

def symbol_on_left
  curr_dotted_item.prev_symbol
end

#to_prev_entry_setObject

Notification that one begins with the previous entry set



52
53
54
# File 'lib/rley/parser/parse_entry_tracker.rb', line 52

def to_prev_entry_set
  self.entry_set_index = entry_set_index - 1
end