Class: Rley::Parser::ParseStateTracker
- Inherits:
-
Object
- Object
- Rley::Parser::ParseStateTracker
- 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
-
#parse_state ⇒ Object
The current parse state.
-
#processed_states ⇒ Object
readonly
The already processed states from current state set.
-
#state_set_index ⇒ Object
The index of the current state set.
Instance Method Summary collapse
-
#curr_dotted_item ⇒ Object
The dotted item for the current parse state.
-
#initialize(aStateSetIndex) ⇒ ParseStateTracker
constructor
Constructor.
-
#select_state(theStates) ⇒ Object
Take the first provided state that wasn't processed yet.
- #symbol_on_left ⇒ Object
-
#to_prev_state_set ⇒ Object
Notification that one begins with the previous state set.
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_state ⇒ Object
The current parse state
10 11 12 |
# File 'lib/rley/parser/parse_state_tracker.rb', line 10 def parse_state @parse_state end |
#processed_states ⇒ Object (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_index ⇒ Object
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_item ⇒ Object
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_left ⇒ Object
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_set ⇒ Object
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 |