Parent

Journey::NFA::Simulator

Attributes

tt[R]

Public Class Methods

new(transition_table) click to toggle source
    # File lib/journey/nfa/simulator.rb, line 16
16:       def initialize transition_table
17:         @tt = transition_table
18:       end

Public Instance Methods

=~(string) click to toggle source
Alias for: simulate
match(string) click to toggle source
Alias for: simulate
simulate(string) click to toggle source
    # File lib/journey/nfa/simulator.rb, line 20
20:       def simulate string
21:         input = StringScanner.new string
22:         state = tt.eclosure 0
23:         until input.eos?
24:           sym   = input.scan(/[\/\.\?]|[^\/\.\?]+/)
25: 
26:           # FIXME: tt.eclosure is not needed for the GTG
27:           state = tt.eclosure tt.move(state, sym)
28:         end
29: 
30:         acceptance_states = state.find_all { |s|
31:           tt.accepting? tt.eclosure(s).sort.last
32:         }
33: 
34:         return if acceptance_states.empty?
35: 
36:         memos = acceptance_states.map { |x| tt.memo x }.flatten.compact
37: 
38:         MatchData.new memos
39:       end
Also aliased as: =~, match

Disabled; run with --debug to generate this.

[Validate]

Generated with the Darkfish Rdoc Generator 1.1.6.