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

PerCederberg.Grammatica.Parser.RE
Class CharacterSetElement

ICloneable
   |
   +--Element
         |
         +--CharacterSetElement

   in CharacterSetElement.cs

class CharacterSetElement
extends Element

A regular expression character set element. This element matches a single character inside (or outside) a character set. The character set is user defined and may contain ranges of characters. The set may also be inverted, meaning that only characters not inside the set will be considered to match.


Inner Classes, Typedefs, and Enums
class CharacterSetElement.Range
          A character range class.
 
Field Summary
 static CharacterSetElement DIGIT
          The digit character set.
 static CharacterSetElement DOT
          The dot ('.') character set.
 static CharacterSetElement NON_DIGIT
          The non-digit character set.
 static CharacterSetElement NON_WHITESPACE
          The non-whitespace character set.
 static CharacterSetElement NON_WORD
          The non-word character set.
 static CharacterSetElement WHITESPACE
          The whitespace character set.
 static CharacterSetElement WORD
          The word character set.
 
Constructor Summary
CharacterSetElement( bool inverted )
          Creates a new character set element.
 
Method Summary
 void AddCharacter( char c )
          Adds a single character to this character set.
 void AddCharacters( string str )
          Adds multiple characters to this character set.
 void AddCharacters( StringElement elem )
          Adds multiple characters to this character set.
 void AddCharacterSet( CharacterSetElement elem )
          Adds a character subset to this character set.
 void AddRange( char min, char max )
          Adds a character range to this character set.
 override object Clone()
          Returns this element as the character set shouldn't be modified after creation.
 override int Match( Matcher m, string str, int start, int skip )
          Returns the length of a matching string starting at the specified position.
 override void PrintTo( TextWriter output, string indent )
          Prints this element to the specified output stream.
 override string ToString()
          Returns a string description of this character set.
   
Methods inherited from class Element
Clone, Match, PrintTo
 

Field Detail

DIGIT

public static CharacterSetElement DIGIT;
The digit character set. This element matches a single numeric character.

DOT

public static CharacterSetElement DOT;
The dot ('.') character set. This element matches a single character that is not equal to a newline character.

NON_DIGIT

public static CharacterSetElement NON_DIGIT;
The non-digit character set. This element matches a single non-numeric character.

NON_WHITESPACE

public static CharacterSetElement NON_WHITESPACE;
The non-whitespace character set. This element matches a single non-whitespace character.

NON_WORD

public static CharacterSetElement NON_WORD;
The non-word character set. This element matches a single non-word character.

WHITESPACE

public static CharacterSetElement WHITESPACE;
The whitespace character set. This element matches a single whitespace character.

WORD

public static CharacterSetElement WORD;
The word character set. This element matches a single word character.


Constructor Detail

CharacterSetElement

public CharacterSetElement( bool inverted );
Creates a new character set element. If the inverted character set flag is set, only characters NOT in the set will match.
Parameters:
inverted - the inverted character set flag


Method Detail

AddCharacter

public void AddCharacter( char c );
Adds a single character to this character set.
Parameters:
c - the character to add

AddCharacters

public void AddCharacters( string str );
Adds multiple characters to this character set.
Parameters:
str - the string with characters to add

AddCharacters

public void AddCharacters( StringElement elem );
Adds multiple characters to this character set.
Parameters:
elem - the string element with characters to add

AddCharacterSet

public void AddCharacterSet( CharacterSetElement elem );
Adds a character subset to this character set.
Parameters:
elem - the character set to add

AddRange

public void AddRange( char min, char max );
Adds a character range to this character set.
Parameters:
min - the minimum character value
max - the maximum character value

Clone

public override object Clone();
Returns this element as the character set shouldn't be modified after creation. This partially breaks the contract of clone(), but as new characters are not added to the character set after creation, this will work correctly.
Returns:
this character set element

Match

public override int Match( Matcher m, string str, int start, int skip );
Returns the length of a matching string starting at the specified position. The number of matches to skip can also be specified, but numbers higher than zero (0) cause a failed match for any element that doesn't attempt to combine other elements.
Parameters:
m - the matcher being used
str - the string to match
start - the starting position
skip - the number of matches to skip
Returns:
the length of the matching string, or -1 if no match was found

PrintTo

public override void PrintTo( TextWriter output, string indent );
Prints this element to the specified output stream.
Parameters:
output - the output stream to use
indent - the current indentation

ToString

public override string ToString();
Returns a string description of this character set.
Returns:
a string description of this character set

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