Class: Journey::NFA::Visitor

### Home Classes Methods

### In Files

- lib/journey/nfa/builder.rb

### Parent

Visitors::Visitor

### Methods

- ::new
- #terminal
- #visit_CAT
- #visit_GROUP
- #visit_OR

### Files

- CHANGELOG.rdoc
- Manifest.txt
- README.rdoc

### Class/Module Index

Quicksearch

- Journey
- Journey::Formatter
- Journey::GTG
- Journey::GTG::Builder
- Journey::GTG::MatchData
- Journey::GTG::Simulator
- Journey::GTG::TransitionTable
- Journey::NFA
- Journey::NFA::Builder
- Journey::NFA::MatchData
- Journey::NFA::Simulator
- Journey::NFA::TransitionTable
- Journey::NFA::Visitor
- Journey::Nodes
- Journey::Nodes::Binary
- Journey::Nodes::Cat
- Journey::Nodes::Dummy
- Journey::Nodes::Group
- Journey::Nodes::Literal
- Journey::Nodes::Or
- Journey::Nodes::Star
- Journey::Nodes::Symbol
- Journey::Nodes::Terminal
- Journey::Nodes::Unary
- Journey::Parser
- Journey::Path
- Journey::Path::Pattern
- Journey::Path::Pattern::MatchData
- Journey::Route
- Journey::Router
- Journey::Router::RoutingError
- Journey::Router::Strexp
- Journey::Router::Utils
- Journey::Router::Utils::UriEscape
- Journey::Routes
- Journey::Scanner
- Rack

No matching classes.

# Journey::NFA::Visitor

### Public Class Methods

new(tt) click to toggle source

    # File lib/journey/nfa/builder.rb, line 7
    def initialize tt
      @tt = tt
      @i  = -1
    end

### Public Instance Methods

terminal(node) click to toggle source

    # File lib/journey/nfa/builder.rb, line 50
    def terminal node
      from_i = @i += 1 # new state
      to_i   = @i += 1 # new state

      @tt[from_i, to_i] = node
      @tt.accepting = to_i
      @tt.add_memo to_i, node.memo

      [from_i, to_i]
    end

visit_CAT(node) click to toggle source

    # File lib/journey/nfa/builder.rb, line 12
    def visit_CAT node
      left  = visit node.left
      right = visit node.right

      @tt.merge left.last, right.first

      [left.first, right.last]
    end

visit_GROUP(node) click to toggle source

    # File lib/journey/nfa/builder.rb, line 21
    def visit_GROUP node
      from  = @i += 1
      left  = visit node.left
      to    = @i += 1

      @tt.accepting = to

      @tt[from, left.first] = nil
      @tt[left.last, to] = nil
      @tt[from, to] = nil

      [from, to]
    end

visit_OR(node) click to toggle source

    # File lib/journey/nfa/builder.rb, line 35
    def visit_OR node
      from  = @i += 1
      children = node.children.map { |c| visit c }
      to    = @i += 1

      children.each do |child|
        @tt[from, child.first]  = nil
        @tt[child.last, to]     = nil
      end

      @tt.accepting = to

      [from, to]
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.