Sha256: 97926818717169fc5ac51b8e65f72fc52ebb11872814b366ba98fbb899b4d6ea
Contents?: true
Size: 814 Bytes
Versions: 1
Compression:
Stored size: 814 Bytes
Contents
module Stamina class Automaton # # Checks if this automaton is complete # def complete? alph = alphabet states.find{|s| !(alphabet - s.out_symbols).empty?}.nil? end # # Returns a completed copy of this automaton # def complete self.dup.complete! end # # Completes this automaton. # def complete!(sink_data = {:initial => false, :accepting => false, :error => false}) alph = alphabet sink = add_state(sink_data) each_state do |s| out_symbols = s.out_symbols (alph-out_symbols).each do |symbol| connect(s, sink, symbol) end end adj = sink.adjacent_states drop_state(sink) if adj.empty? or adj == [sink] self end end # class Automaton end # module Stamina
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
stamina-core-0.6.1 | lib/stamina-core/stamina/automaton/complete.rb |