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

PerCederberg.Grammatica.Runtime
Class TokenMatcher

System.Object
   |
   +--TokenMatcher

   in Tokenizer.cs
Direct Known Subclasses:
NFAMatcher, RegExpMatcher, StringDFAMatcher

internal abstract class TokenMatcher
extends System.Object

A token pattern matcher. This class is the base class for the various types of token matchers that exist. The token matcher checks for matches with the tokenizer buffer, and maintains the state of the last match.


Field Summary
protected bool ignoreCase
          The ignore character case flag.
protected TokenPattern[] patterns
          The array of token patterns.
 
Constructor Summary
TokenMatcher( bool ignoreCase )
          Creates a new token matcher.
 
Method Summary
 virtual void AddPattern( TokenPattern pattern )
          Adds a string token pattern to this matcher.
 TokenPattern GetPattern( int id )
          Returns the token pattern with the specified id.
 abstract void Match( ReaderBuffer buffer, TokenMatch match )
          Searches for matching token patterns at the start of the input stream.
 override string ToString()
          Returns a string representation of this matcher.
 

Field Detail

ignoreCase

protected bool ignoreCase;
The ignore character case flag.

patterns

protected TokenPattern[] patterns;
The array of token patterns.


Constructor Detail

TokenMatcher

public TokenMatcher( bool ignoreCase );
Creates a new token matcher.
Parameters:
ignoreCase - the character case ignore flag


Method Detail

AddPattern

public virtual void AddPattern( TokenPattern pattern );
Adds a string token pattern to this matcher.
Parameters:
pattern - the pattern to add
Throws:
Exception - if the pattern couldn't be added to the matcher

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

Match

public abstract void Match( ReaderBuffer buffer, TokenMatch match );
Searches for matching token patterns at the start of the input stream. If a match is found, the token match object is updated.
Parameters:
buffer - the input buffer to check
match - the token match to update
Throws:
IOException - if an I/O error occurred

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.5 Documentation
FRAMES    NO FRAMES
SUMMARY:  INNER | FIELD | CONSTR | METHOD