Class: Ibex::Runtime::ParseSessionState

Inherits:
Object
  • Object
show all
Defined in:
lib/ibex/runtime/parse_session_state.rb

Overview

Mutable stack storage for one parser invocation.

The parser keeps local aliases to these arrays in its hot paths. The object owns their lifetime and replacement so recovery and push-session reset cannot accidentally leave one stack behind.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeParseSessionState

Returns a new instance of ParseSessionState.



17
18
19
# File 'lib/ibex/runtime/parse_session_state.rb', line 17

def initialize
  reset!
end

Instance Attribute Details

#location_stackObject (readonly)

: Array?



14
15
16
# File 'lib/ibex/runtime/parse_session_state.rb', line 14

def location_stack
  @location_stack
end

#state_stackObject (readonly)

: Array



12
13
14
# File 'lib/ibex/runtime/parse_session_state.rb', line 12

def state_stack
  @state_stack
end

#value_stackObject (readonly)

: Array



13
14
15
# File 'lib/ibex/runtime/parse_session_state.rb', line 13

def value_stack
  @value_stack
end

Instance Method Details

#replace!(state_stack, value_stack, location_stack) ⇒ Object



29
30
31
32
33
# File 'lib/ibex/runtime/parse_session_state.rb', line 29

def replace!(state_stack, value_stack, location_stack)
  @state_stack = state_stack
  @value_stack = value_stack
  @location_stack = location_stack
end

#replace_location_stack!(location_stack) ⇒ Object



41
42
43
# File 'lib/ibex/runtime/parse_session_state.rb', line 41

def replace_location_stack!(location_stack)
  @location_stack = location_stack
end

#replace_value_stack!(value_stack) ⇒ Object



36
37
38
# File 'lib/ibex/runtime/parse_session_state.rb', line 36

def replace_value_stack!(value_stack)
  @value_stack = value_stack
end

#reset!Object



22
23
24
25
26
# File 'lib/ibex/runtime/parse_session_state.rb', line 22

def reset!
  @state_stack = []
  @value_stack = []
  @location_stack = nil
end