Class: Lrama::Tracer::State

Inherits:
Object
  • Object
show all
Defined in:
lib/lrama/tracer/state.rb

Instance Method Summary collapse

Constructor Details

#initialize(io, automaton: false, closure: false, **_) ⇒ State

Returns a new instance of State.



8
9
10
11
# File 'lib/lrama/tracer/state.rb', line 8

def initialize(io, automaton: false, closure: false, **_)
  @io = io
  @state = automaton || closure
end

Instance Method Details

#trace(state) ⇒ Object



14
15
16
17
18
19
20
21
# File 'lib/lrama/tracer/state.rb', line 14

def trace(state)
  return unless @state

  # Bison 3.8.2 renders "(reached by "end-of-input")" for State 0 but
  # I think it is not correct...
  previous = state.kernels.first.previous_sym
  @io << "Processing state #{state.id} (reached by #{previous.display_name})" << "\n"
end

#trace_list_append(state_count, state) ⇒ Object



24
25
26
27
28
29
30
# File 'lib/lrama/tracer/state.rb', line 24

def trace_list_append(state_count, state)
  return unless @state

  previous = state.kernels.first.previous_sym
  @io << sprintf("state_list_append (state = %d, symbol = %d (%s))",
                  state_count, previous.number, previous.display_name) << "\n"
end