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

PerCederberg.Grammatica.Runtime.RE
Class Matcher

System.Object
   |
   +--Matcher

   in Matcher.cs

public class Matcher
extends System.Object

A regular expression string matcher. This class handles the matching of a specific string with a specific regular expression. It contains state information about the matching process, as for example the position of the latest match, and a number of flags that were set. This class is not thread-safe.


Constructor Summary
internal Matcher( Element e, ReaderBuffer buffer, bool ignoreCase )
          Creates a new matcher with the specified element.
 
Method Summary
 int End()
          Returns the end position of the latest match.
 bool HasReadEndOfString()
          Checks if the end of the string was encountered during the last match attempt.
 bool IsCaseInsensitive()
          Checks if this matcher compares in case-insensitive mode.
 int Length()
          Returns the length of the latest match.
 bool MatchFrom( int pos )
          Attempts to find a match starting at the specified position in the string.
 bool MatchFromBeginning()
          Attempts to find a match starting at the beginning of the string.
 void Reset()
          Resets the information about the last match.
 void Reset( string str )
          Resets the matcher for use with a new input string.
 void Reset( ReaderBuffer buffer )
          Resets the matcher for use with a new look-ahead character input stream.
 internal void SetReadEndOfString()
          Sets the end of string encountered flag.
 int Start()
          Returns the start position of the latest match.
 override string ToString()
          Returns the latest matched string.
 

Constructor Detail

Matcher

 internal Matcher( Element e, ReaderBuffer buffer, bool ignoreCase );
Creates a new matcher with the specified element.
Parameters:
e - the base regular expression element
buffer - the input character buffer to work with
ignoreCase - the character case ignore flag


Method Detail

End

public int End();
Returns the end position of the latest match. This is one character after the match end, i.e. the first character after the match. If no match has been encountered, this method returns the same value as start().
Returns:
the end position of the latest match

HasReadEndOfString

public bool HasReadEndOfString();
Checks if the end of the string was encountered during the last match attempt. This flag signals that more input may be needed in order to get a match (or a longer match).
Returns:
true if the end of string was encountered, or false otherwise

IsCaseInsensitive

public bool IsCaseInsensitive();
Checks if this matcher compares in case-insensitive mode.
Returns:
true if the matching is case-insensitive, or false otherwise
Since:
1.5

Length

public int Length();
Returns the length of the latest match.
Returns:
the length of the latest match, or -1 if no match was found

MatchFrom

public bool MatchFrom( int pos );
Attempts to find a match starting at the specified position in the string.
Parameters:
pos - the starting position of the match
Returns:
true if a match was found, or false otherwise
Throws:
IOException - if an I/O error occurred while reading an input stream

MatchFromBeginning

public bool MatchFromBeginning();
Attempts to find a match starting at the beginning of the string.
Returns:
true if a match was found, or false otherwise
Throws:
IOException - if an I/O error occurred while reading an input stream

Reset

public void Reset();
Resets the information about the last match. This will clear all flags and set the match length to a negative value. This method is automatically called before starting a new match.

Reset

public void Reset( string str );
Resets the matcher for use with a new input string. This will clear all flags and set the match length to a negative value.
Parameters:
str - the new string to work with
Since:
1.5

Reset

public void Reset( ReaderBuffer buffer );
Resets the matcher for use with a new look-ahead character input stream. This will clear all flags and set the match length to a negative value.
Parameters:
buffer - the character input buffer
Since:
1.5

SetReadEndOfString

 internal void SetReadEndOfString();
Sets the end of string encountered flag. This method is called by the various elements analyzing the string.

Start

public int Start();
Returns the start position of the latest match. If no match has been encountered, this method returns zero (0).
Returns:
the start position of the latest match

ToString

public override string ToString();
Returns the latest matched string. If no string has been matched, an empty string will be returned.
Returns:
the latest matched string

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