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

PerCederberg.Grammatica.Parser
Class RegExpTokenMatcher

System.Object
   |
   +--TokenMatcher
         |
         +--RegExpTokenMatcher

   in Tokenizer.cs

class RegExpTokenMatcher
extends TokenMatcher

A regular expression token pattern matcher. This class is used to match a single regular expression with the tokenizer buffer. This class also maintains the state of the last match.


Constructor Summary
RegExpTokenMatcher( TokenPattern pattern )
          Creates a new regular expression token matcher.
 
Method Summary
 override int GetMatchedLength()
          Returns the length of the latest match.
 override TokenPattern GetMatchedPattern()
          Returns the latest matched token pattern.
 TokenPattern GetPattern()
          Returns the token pattern.
 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.
 int Start()
          Returns the start position of the latest match.
 override string ToString()
          Returns a string representation of this token matcher.
   
Methods inherited from class TokenMatcher
GetMatchedPattern, GetMatchedLength, HasReadEndOfString
 

Constructor Detail

RegExpTokenMatcher

public RegExpTokenMatcher( TokenPattern pattern );
Creates a new regular expression token matcher.
Parameters:
pattern - the pattern to match
Throws:
RegExpException - if the regular expression couldn't be created properly


Method Detail

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();
Returns the token pattern.
Returns:
the token pattern

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

Start

public int Start();
Returns the start position of the latest match.
Returns:
the start position of the last match, or zero (0) if none found

ToString

public override string ToString();
Returns a string representation of this token matcher.
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