Class: Lrama::Tracer::Closure

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

Instance Method Summary collapse

Constructor Details

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

Returns a new instance of Closure.



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

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

Instance Method Details

#trace(state) ⇒ Object



14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/lrama/tracer/closure.rb', line 14

def trace(state)
  return unless @closure

  @io << "Closure: input" << "\n"
  state.kernels.each do |item|
    @io << "  #{item.display_rest}" << "\n"
  end
  @io << "\n\n"
  @io << "Closure: output" << "\n"
  state.items.each do |item|
    @io << "  #{item.display_rest}" << "\n"
  end
  @io << "\n\n"
end