Class: Journey::NFA::Simulator

### Home Classes Methods

### In Files

- lib/journey/nfa/simulator.rb

### Parent

Object

### Methods

- ::new
- #=~
- #match
- #simulate

### 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::Simulator

### Attributes

tt[R]

### Public Class Methods

new(transition_table) click to toggle source

    # File lib/journey/nfa/simulator.rb, line 16
    def initialize transition_table
      @tt = transition_table
    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
    def simulate string
      input = StringScanner.new string
      state = tt.eclosure 0
      until input.eos?
        sym   = input.scan(/[\/\.\?]|[^\/\.\?]+/)

        # FIXME: tt.eclosure is not needed for the GTG
        state = tt.eclosure tt.move(state, sym)
      end

      acceptance_states = state.find_all { |s|
        tt.accepting? tt.eclosure(s).sort.last
      }

      return if acceptance_states.empty?

      memos = acceptance_states.map { |x| tt.memo x }.flatten.compact

      MatchData.new memos
    end

Also aliased as: =~, match

[Validate]

Generated with the Darkfish Rdoc Generator 2.