PerCederberg.Grammatica.Runtime
Class TokenStringDFA
System.Object
|
+--TokenStringDFA
in TokenStringDFA.cs
- internal class TokenStringDFA
- extends System.Object
A deterministic finite state automaton for matching exact strings.
It uses a sorted binary tree representation of the state
transitions in order to enable quick matches with a minimal memory
footprint. It only supports a single character transition between
states, but may be run in an all case-insensitive mode.
- Since:
- 1.5
|
Constructor Summary |
TokenStringDFA()
Creates a new empty string automaton. |
|
Method Summary |
void |
AddMatch( string str, bool caseInsensitive, TokenPattern value )
Adds a string match to this automaton. |
TokenPattern |
Match( ReaderBuffer buffer, bool caseInsensitive )
Checks if the automaton matches an input stream. |
override string |
ToString()
Returns a detailed string representation of this automaton. |
TokenStringDFA
public TokenStringDFA();
- Creates a new empty string automaton.
AddMatch
public void AddMatch( string str, bool caseInsensitive, TokenPattern value );
- Adds a string match to this automaton. New states and
transitions will be added to extend this automaton to
support the specified string.
- Parameters:
str - the string to match
caseInsensitive - the case-insensitive flag
value - the match value
Match
public TokenPattern Match( ReaderBuffer buffer, bool caseInsensitive );
- Checks if the automaton matches an input stream. The
matching will be performed from a specified position. This
method will not read any characters from the stream, just
peek ahead. The comparison can be done either in
case-sensitive or case-insensitive mode.
- Parameters:
input - the input stream to check
pos - the starting position
caseInsensitive - the case-insensitive flag
- Returns:
- the match value, or
null if no match was found
- Throws:
IOException - if an I/O error occurred
ToString
public override string ToString();
- Returns a detailed string representation of this automaton.
- Returns:
- a detailed string representation of this automaton