Nfa class

A nondeterministic finite automaton (NFA) for executing regular expression patterns.

Implements RegexpPattern to match strings according to Thompson's construction.

For example:

final nfa = Nfa.fromString('a*b+');
print(nfa.matchAsPrefix('aaabb')?.group(0)); // 'aaabb'
Inheritance

Constructors

Nfa({required NfaState start, required NfaState end})
Creates an NFA with given start and end states.
Nfa.fromString(String regexp)
Compiles a regular expression string into an Nfa.
factory

Properties

end → NfaState
The accepting terminal state of the NFA.
final
hashCode → int
The hash code for this object.
no setterinherited
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited
start → NfaState
The entry state of the NFA.
final

Methods

allMatches(String input, [int start = 0]) → Iterable<Match>
Matches this pattern against the string repeatedly.
inherited
matchAsPrefix(String input, [int start = 0]) → Match?
Matches this pattern against the start of string.
inherited
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() → String
A string representation of this object.
inherited
tryMatch(String input, int start, int end) → int
Returns the end index (exclusive) of the longest prefix of input matched by this pattern, or -1 if no prefix of input matches.

Operators

operator ==(Object other) → bool
The equality operator.
inherited