Class: Rley::Parser::ParseStateTracker

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

Overview

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(aStateSetIndex) ⇒ ParseStateTracker

Constructor. Refined variant of the inherited constructor.



16
17
18
# File 'lib/rley/parser/parse_state_tracker.rb', line 16

def initialize(aStateSetIndex)
  self.state_set_index = aStateSetIndex
end

Instance Attribute Details

#parse_stateObject

The current parse state



10
11
12
# File 'lib/rley/parser/parse_state_tracker.rb', line 10

def parse_state
  @parse_state
end

#processed_statesObject (readonly)

The already processed states from current state set



13
14
15
# File 'lib/rley/parser/parse_state_tracker.rb', line 13

def processed_states
  @processed_states
end

#state_set_indexObject

The index of the current state set



7
8
9
# File 'lib/rley/parser/parse_state_tracker.rb', line 7

def state_set_index
  @state_set_index
end

Instance Method Details

#curr_dotted_itemObject

The dotted item for the current parse state.



40
41
42
# File 'lib/rley/parser/parse_state_tracker.rb', line 40

def curr_dotted_item()
  parse_state.dotted_rule
end

#select_state(theStates) ⇒ Object

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



34
35
36
37
# File 'lib/rley/parser/parse_state_tracker.rb', line 34

def select_state(theStates)
  a_state = theStates.find { |st| !processed_states.include?(st) }
  self.parse_state = a_state
end

#symbol_on_leftObject



44
45
46
# File 'lib/rley/parser/parse_state_tracker.rb', line 44

def symbol_on_left()
  return curr_dotted_item.prev_symbol
end

#to_prev_state_setObject

Notification that one begins with the previous state set



49
50
51
# File 'lib/rley/parser/parse_state_tracker.rb', line 49

def to_prev_state_set()
  self.state_set_index = state_set_index - 1
end