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.
18 19 20 |
# File 'lib/rley/parser/parse_state_tracker.rb', line 18 def initialize(aStateSetIndex) self.state_set_index = aStateSetIndex end |
Instance Attribute Details
#parse_state ⇒ Object
The current parse state
12 13 14 |
# File 'lib/rley/parser/parse_state_tracker.rb', line 12 def parse_state @parse_state end |
#processed_states ⇒ Object (readonly)
The already processed states from current state set
15 16 17 |
# File 'lib/rley/parser/parse_state_tracker.rb', line 15 def processed_states @processed_states end |
#state_set_index ⇒ Object
The index of the current state set
9 10 11 |
# File 'lib/rley/parser/parse_state_tracker.rb', line 9 def state_set_index @state_set_index end |
Instance Method Details
#curr_dotted_item ⇒ Object
The dotted item for the current parse state.
43 44 45 |
# File 'lib/rley/parser/parse_state_tracker.rb', line 43 def curr_dotted_item() parse_state.dotted_rule end |
#select_state(theStates) ⇒ Object
Take the first provided state that wasn't processed yet.
37 38 39 40 |
# File 'lib/rley/parser/parse_state_tracker.rb', line 37 def select_state(theStates) a_state = theStates.find { |st| !processed_states.include?(st) } self.parse_state = a_state end |
#symbol_on_left ⇒ Object
47 48 49 |
# File 'lib/rley/parser/parse_state_tracker.rb', line 47 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
52 53 54 |
# File 'lib/rley/parser/parse_state_tracker.rb', line 52 def to_prev_state_set() self.state_set_index = state_set_index - 1 end |