Overview   Project   Class   Tree   Deprecated   Index 
Grammatica 1.4 Documentation
FRAMES    NO FRAMES
SUMMARY:  INNER | FIELD | CONSTR | METHOD

PerCederberg.Grammatica.Parser
Class StringTokenMatcher

System.Object
   |
   +--TokenMatcher
         |
         +--StringTokenMatcher

   in Tokenizer.cs

class StringTokenMatcher
extends TokenMatcher

A string token pattern matcher. This class is used to match a set of strings with the tokenizer buffer. This class internally uses a DFA for maximum performance. It also maintains the state of the last match.


Constructor Summary
StringTokenMatcher()
          Creates a new string token matcher.
 
Method Summary
 void AddPattern( TokenPattern pattern )
          Adds a string token pattern to this matcher.
 override int GetMatchedLength()
          Returns the length of the latest match.
 override TokenPattern GetMatchedPattern()
          Returns the latest matched token pattern.
 TokenPattern GetPattern( int id )
          Returns the token pattern with the specified id.
 override bool HasReadEndOfString()
          Checks if the end of string was encountered during the last match.
 bool MatchFrom( string str, int pos )
          Checks if the token pattern matches the tokenizer buffer from the specified position.
 void Reset()
          Resets the matcher state.
 void SetReadEndOfString()
          Sets the end of string encountered flag.
 override string ToString()
          Returns a string representation of this matcher.
   
Methods inherited from class TokenMatcher
GetMatchedPattern, GetMatchedLength, HasReadEndOfString
 

Constructor Detail

StringTokenMatcher

public StringTokenMatcher();
Creates a new string token matcher.


Method Detail

AddPattern

public void AddPattern( TokenPattern pattern );
Adds a string token pattern to this matcher.
Parameters:
pattern - the pattern to add

GetMatchedLength

public override int GetMatchedLength();
Returns the length of the latest match.
Returns:
the length of the latest match, or zero (0) if no match found

GetMatchedPattern

public override TokenPattern GetMatchedPattern();
Returns the latest matched token pattern.
Returns:
the latest matched token pattern, or null if no match found

GetPattern

public TokenPattern GetPattern( int id );
Returns the token pattern with the specified id. Only token patterns handled by this matcher can be returned.
Parameters:
id - the token pattern id
Returns:
the token pattern found, or null if not found

HasReadEndOfString

public override bool HasReadEndOfString();
Checks if the end of string was encountered during the last match.
Returns:
true if the end of string was reached, or false otherwise

MatchFrom

public bool MatchFrom( string str, int pos );
Checks if the token pattern matches the tokenizer buffer from the specified position. This method will also reset all flags in this matcher.
Parameters:
str - the string to match
pos - the starting position
Returns:
true if a match was found, or false otherwise

Reset

public void Reset();
Resets the matcher state. This will clear the results of the last match.

SetReadEndOfString

public void SetReadEndOfString();
Sets the end of string encountered flag.

ToString

public override string ToString();
Returns a string representation of this matcher. This will contain all the token patterns.
Returns:
a detailed string representation of this matcher

 Overview   Project   Class   Tree   Deprecated   Index 
Grammatica 1.4 Documentation
FRAMES    NO FRAMES
SUMMARY:  INNER | FIELD | CONSTR | METHOD