Parent

Journey::NFA::Visitor

Public Class Methods

new(tt) click to toggle source
    # File lib/journey/nfa/builder.rb, line 7
 7:       def initialize tt
 8:         @tt = tt
 9:         @i  = 1
10:       end

Public Instance Methods

terminal(node) click to toggle source
    # File lib/journey/nfa/builder.rb, line 50
50:       def terminal node
51:         from_i = @i += 1 # new state
52:         to_i   = @i += 1 # new state
53: 
54:         @tt[from_i, to_i] = node
55:         @tt.accepting = to_i
56:         @tt.add_memo to_i, node.memo
57: 
58:         [from_i, to_i]
59:       end
visit_CAT(node) click to toggle source
    # File lib/journey/nfa/builder.rb, line 12
12:       def visit_CAT node
13:         left  = visit node.left
14:         right = visit node.right
15: 
16:         @tt.merge left.last, right.first
17: 
18:         [left.first, right.last]
19:       end
visit_GROUP(node) click to toggle source
    # File lib/journey/nfa/builder.rb, line 21
21:       def visit_GROUP node
22:         from  = @i += 1
23:         left  = visit node.left
24:         to    = @i += 1
25: 
26:         @tt.accepting = to
27: 
28:         @tt[from, left.first] = nil
29:         @tt[left.last, to] = nil
30:         @tt[from, to] = nil
31: 
32:         [from, to]
33:       end
visit_OR(node) click to toggle source
    # File lib/journey/nfa/builder.rb, line 35
35:       def visit_OR node
36:         from  = @i += 1
37:         children = node.children.map { |c| visit c }
38:         to    = @i += 1
39: 
40:         children.each do |child|
41:           @tt[from, child.first]  = nil
42:           @tt[child.last, to]     = nil
43:         end
44: 
45:         @tt.accepting = to
46: 
47:         [from, to]
48:       end

Disabled; run with --debug to generate this.

[Validate]

Generated with the Darkfish Rdoc Generator 1.1.6.