Grammatica
Public Types | Public Member Functions | Properties | List of all members
PerCederberg.Grammatica.Runtime.TokenPattern Class Reference

A token pattern. More...

Public Types

enum  PatternType { PatternType.STRING, PatternType.REGEXP }
 The pattern type enumeration. More...
 

Public Member Functions

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

Properties

int Id [get]
 The token pattern identity property (read-only). More...
 
string Name [get]
 The token pattern name property (read-only). More...
 
PatternType Type [get]
 The token pattern type property (read-only). More...
 
string Pattern [get]
 The token pattern property (read-only). More...
 
bool Error [get, set]
 The error flag property. More...
 
string ErrorMessage [get, set]
 The token error message property. More...
 
bool Ignore [get, set]
 The ignore flag property. More...
 
string IgnoreMessage [get, set]
 The token ignore message property. More...
 
string DebugInfo [get, set]
 The token debug info message property. More...
 

Detailed Description

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.

Author
Per Cederberg
Version
1.5

Member Enumeration Documentation

The pattern type enumeration.

Enumerator
STRING 

The string pattern type is used for tokens that only match an exact string.

REGEXP 

The regular expression pattern type is used for tokens that match a regular expression.

Constructor & Destructor Documentation

PerCederberg.Grammatica.Runtime.TokenPattern.TokenPattern ( int  id,
string  name,
PatternType  type,
string  pattern 
)
inline

Creates a new token pattern.

Parameters
idthe token pattern id
namethe token pattern name
typethe token pattern type
patternthe token pattern

Member Function Documentation

string PerCederberg.Grammatica.Runtime.TokenPattern.GetErrorMessage ( )
inline

Returns the token error message if the pattern corresponds to an error token.

Returns
the token error message
See also
ErrorMessage
Deprecated:
Use the ErrorMessage property instead.
int PerCederberg.Grammatica.Runtime.TokenPattern.GetId ( )
inline

Returns the unique token pattern identity value.

Returns
the token pattern id
See also
Id
Deprecated:
Use the Id property instead.
string PerCederberg.Grammatica.Runtime.TokenPattern.GetIgnoreMessage ( )
inline

Returns the token ignore message if the pattern corresponds to an ignored token.

Returns
the token ignore message
See also
IgnoreMessage
Deprecated:
Use the IgnoreMessage property instead.
string PerCederberg.Grammatica.Runtime.TokenPattern.GetName ( )
inline

Returns the token pattern name.

Returns
the token pattern name
See also
Name
Deprecated:
Use the Name property instead.
string PerCederberg.Grammatica.Runtime.TokenPattern.GetPattern ( )
inline

Returns te token pattern.

Returns
the token pattern
See also
Pattern
Deprecated:
Use the Pattern property instead.
PatternType PerCederberg.Grammatica.Runtime.TokenPattern.GetPatternType ( )
inline

Returns the token pattern type.

Returns
the token pattern type
See also
Type
Deprecated:
Use the Type property instead.
bool PerCederberg.Grammatica.Runtime.TokenPattern.IsError ( )
inline

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
See also
Error
Deprecated:
Use the Error property instead.
bool PerCederberg.Grammatica.Runtime.TokenPattern.IsIgnore ( )
inline

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
See also
Ignore
Deprecated:
Use the Ignore property instead.
void PerCederberg.Grammatica.Runtime.TokenPattern.SetError ( )
inline

Sets the token error flag and assigns a default error message.

See also
Error
Deprecated:
Use the Error property instead.
void PerCederberg.Grammatica.Runtime.TokenPattern.SetError ( string  message)
inline

Sets the token error flag and assigns the specified error message.

Parameters
messagethe error message to display
See also
ErrorMessage
Deprecated:
Use the ErrorMessage property instead.
void PerCederberg.Grammatica.Runtime.TokenPattern.SetIgnore ( )
inline

Sets the token ignore flag and clears the ignore message.

See also
Ignore
Deprecated:
Use the Ignore property instead.
void PerCederberg.Grammatica.Runtime.TokenPattern.SetIgnore ( string  message)
inline

Sets the token ignore flag and assigns the specified ignore message.

Parameters
messagethe ignore message to display
See also
IgnoreMessage
Deprecated:
Use the IgnoreMessage property instead.
string PerCederberg.Grammatica.Runtime.TokenPattern.ToShortString ( )
inline

Returns a short string representation of this object.

Returns
a short string representation of this object
override string PerCederberg.Grammatica.Runtime.TokenPattern.ToString ( )
inline

Returns a string representation of this object.

Returns
a token pattern string representation

Property Documentation

string PerCederberg.Grammatica.Runtime.TokenPattern.DebugInfo
getset

The token debug info message property.

This is normally be set when the token pattern is analyzed by the tokenizer.

Since
1.5
bool PerCederberg.Grammatica.Runtime.TokenPattern.Error
getset

The error flag property.

If this property is true, the token pattern corresponds to an error token and an error should be reported if a match is found. When setting this property to true, a default error message is created if none was previously set.

Since
1.5
string PerCederberg.Grammatica.Runtime.TokenPattern.ErrorMessage
getset

The token error message property.

The error message is printed whenever the token is matched. Setting the error message property also sets the error flag to true.

See also
Error
Since
1.5
int PerCederberg.Grammatica.Runtime.TokenPattern.Id
get

The token pattern identity property (read-only).

This property contains the unique token pattern identity value.

Since
1.5
bool PerCederberg.Grammatica.Runtime.TokenPattern.Ignore
getset

The ignore flag property.

If this property is true, the token pattern corresponds to an ignore token and should be skipped if a match is found.

Since
1.5
string PerCederberg.Grammatica.Runtime.TokenPattern.IgnoreMessage
getset

The token ignore message property.

The ignore message is printed whenever the token is matched. Setting the ignore message property also sets the ignore flag to true.

See also
Ignore
Since
1.5
string PerCederberg.Grammatica.Runtime.TokenPattern.Name
get

The token pattern name property (read-only).

Since
1.5
string PerCederberg.Grammatica.Runtime.TokenPattern.Pattern
get

The token pattern property (read-only).

This property contains the actual pattern (string or regexp) which have to be matched.

Since
1.5
PatternType PerCederberg.Grammatica.Runtime.TokenPattern.Type
get

The token pattern type property (read-only).

Since
1.5

The documentation for this class was generated from the following file: