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

PerCederberg.Grammatica.Parser
Class TokenPattern

System.Object
   |
   +--TokenPattern

   in TokenPattern.cs

class TokenPattern
extends System.Object

A token pattern. This class contains the definition of a token (i.e. it's pattern), and allows testing a string against this pattern. A token pattern is uniquely identified by an integer id, that must be provided upon creation.


Inner Classes, Typedefs, and Enums
enum TokenPattern.PatternType
          The pattern type enumeration.
 
Constructor Summary
TokenPattern( int id, string name, TokenPattern.PatternType type, string pattern )
          Creates a new token pattern.
 
Method Summary
 string GetErrorMessage()
          Returns the token error message if the pattern corresponds to an error token.
 int GetId()
          Returns the unique token pattern identity value.
 string GetIgnoreMessage()
          Returns the token ignore message if the pattern corresponds to an ignored token.
 string GetName()
          Returns the token pattern name.
 string GetPattern()
          Returns te token pattern.
 TokenPattern.PatternType GetPatternType()
          Returns the token pattern type.
 bool IsError()
          Checks if the pattern corresponds to an error token.
 bool IsIgnore()
          Checks if the pattern corresponds to an ignored token.
 void SetError()
          Sets the token error flag and assigns a default error message.
 void SetError( string message )
          Sets the token error flag and assigns the specified error message.
 void SetIgnore()
          Sets the token ignore flag and clears the ignore message.
 void SetIgnore( string message )
          Sets the token ignore flag and assigns the specified ignore message.
 string ToShortString()
          Returns a short string representation of this object.
 override string ToString()
          Returns a string representation of this object.
 

Constructor Detail

TokenPattern

public TokenPattern( int id, string name, TokenPattern.PatternType type, string pattern );
Creates a new token pattern.
Parameters:
id - the token pattern id
name - the token pattern name
type - the token pattern type
pattern - the token pattern


Method Detail

GetErrorMessage

public string GetErrorMessage();
Returns the token error message if the pattern corresponds to an error token.
Returns:
the token error message

GetId

public int GetId();
Returns the unique token pattern identity value.
Returns:
the token pattern id

GetIgnoreMessage

public string GetIgnoreMessage();
Returns the token ignore message if the pattern corresponds to an ignored token.
Returns:
the token ignore message

GetName

public string GetName();
Returns the token pattern name.
Returns:
the token pattern name

GetPattern

public string GetPattern();
Returns te token pattern.
Returns:
the token pattern

GetPatternType

public TokenPattern.PatternType GetPatternType();
Returns the token pattern type.
Returns:
the token pattern type

IsError

public bool IsError();
Checks if the pattern corresponds to an error token. If this is true, it means that an error should be reported if a matching token is found.
Returns:
true if the pattern maps to an error token, or false otherwise

IsIgnore

public bool IsIgnore();
Checks if the pattern corresponds to an ignored token. If this is true, it means that the token should be ignored if found.
Returns:
true if the pattern maps to an ignored token, or false otherwise

SetError

public void SetError();
Sets the token error flag and assigns a default error message.

SetError

public void SetError( string message );
Sets the token error flag and assigns the specified error message.
Parameters:
message - the error message to display

SetIgnore

public void SetIgnore();
Sets the token ignore flag and clears the ignore message.

SetIgnore

public void SetIgnore( string message );
Sets the token ignore flag and assigns the specified ignore message.
Parameters:
message - the ignore message to display

ToShortString

public string ToShortString();
Returns a short string representation of this object.
Returns:
a short string representation of this object

ToString

public override string ToString();
Returns a string representation of this object.
Returns:
a token pattern string representation

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