class Pegasus::Nfa::Nfa

Overview

A nondeterministic finite automaton, to be created from regular expressions.

Defined in:

pegasus/nfa.cr
pegasus/nfa_to_dfa.cr
pegasus/regex.cr

Constant Summary

ESCAPES = {'\'' => 39_u8, '"' => 34_u8, '?' => 63_u8, '\\' => 92_u8, 'a' => 7_u8, 'b' => 8_u8, 'f' => 12_u8, 'n' => 10_u8, 'r' => 13_u8, 't' => 9_u8, 'v' => 11_u8, '*' => 42_u8, '+' => 43_u8, '-' => 45_u8, '|' => 124_u8, '[' => 91_u8, ']' => 93_u8, '(' => 40_u8, ')' => 41_u8, '.' => 46_u8, '/' => 47_u8}

Constructors

Instance Method Summary

Instance methods inherited from class Pegasus::Automata::Automaton(Int64?, Pegasus::Nfa::Transition)

last_id : Int64 last_id, start : State(V?, T) | Nil start, start=(start : State(V?, T) | Nil) start=, state_for(*, data : V?) state_for, states : Set(State(V?, T)) states

Constructor methods inherited from class Pegasus::Automata::Automaton(Int64?, Pegasus::Nfa::Transition)

new new

Constructor Detail

def self.new #

Creates a new Nfa with a start state.


[View source]

Instance Method Detail

def add_regex(str, id) #

Adds a regular expression branch to this Nfa.


[View source]
def dfa #

Creates a Pegasus::Dfa::Dfa for this Nfa.


[View source]
def find_lambda_states(s : Set(NState)) #

Finds the lambda states connected to any of the states of the given set.


[View source]
def state #

Creates a new state for no value (aka, a set with nil as the value)


[View source]