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

A token node. More...

Inheritance diagram for PerCederberg.Grammatica.Runtime.Token:
PerCederberg.Grammatica.Runtime.Node

Public Member Functions

 Token (TokenPattern pattern, string image, int line, int col)
 Creates a new token. More...
 
string GetImage ()
 Returns the token image. More...
 
Token GetPreviousToken ()
 Returns the previous token. More...
 
Token GetNextToken ()
 Returns the next token. More...
 
override string ToString ()
 Returns a string representation of this token. More...
 
string ToShortString ()
 Returns a short string representation of this token. More...
 
- Public Member Functions inherited from PerCederberg.Grammatica.Runtime.Node
virtual int GetId ()
 Returns the node type id. More...
 
virtual string GetName ()
 Returns the node name. More...
 
virtual int GetStartLine ()
 The line number of the first character in this node. More...
 
virtual int GetStartColumn ()
 The column number of the first character in this node. More...
 
virtual int GetEndLine ()
 The line number of the last character in this node. More...
 
virtual int GetEndColumn ()
 The column number of the last character in this node. More...
 
Node GetParent ()
 Returns the parent node. More...
 
virtual int GetChildCount ()
 Returns the number of child nodes. More...
 
int GetDescendantCount ()
 Returns the number of descendant nodes. More...
 
virtual Node GetChildAt (int index)
 Returns the child node with the specified index. More...
 
int GetValueCount ()
 Returns the number of computed values associated with this node. More...
 
object GetValue (int pos)
 Returns a computed value of this node, if previously set. More...
 
ArrayList GetAllValues ()
 Returns the list with all the computed values for this node. More...
 
void AddValue (object value)
 Adds a computed value to this node. More...
 
void AddValues (ArrayList values)
 Adds a set of computed values to this node. More...
 
void RemoveAllValues ()
 Removes all computed values stored in this node. More...
 
void PrintTo (TextWriter output)
 Prints this node and all subnodes to the specified output stream. More...
 

Properties

override int Id [get]
 The node type id property (read-only). More...
 
override string Name [get]
 The node name property (read-only). More...
 
override int StartLine [get]
 The line number property of the first character in this node (read-only). More...
 
override int StartColumn [get]
 The column number property of the first character in this node (read-only). More...
 
override int EndLine [get]
 The line number property of the last character in this node (read-only). More...
 
override int EndColumn [get]
 The column number property of the last character in this node (read-only). More...
 
string Image [get]
 The token image property (read-only). More...
 
Token Previous [get, set]
 The previous token property. More...
 
Token Next [get, set]
 The next token property. More...
 
- Properties inherited from PerCederberg.Grammatica.Runtime.Node
abstract int Id [get]
 The node type id property (read-only). More...
 
abstract string Name [get]
 The node name property (read-only). More...
 
virtual int StartLine [get]
 The line number property of the first character in this node (read-only). More...
 
virtual int StartColumn [get]
 The column number property of the first character in this node (read-only). More...
 
virtual int EndLine [get]
 The line number property of the last character in this node (read-only). More...
 
virtual int EndColumn [get]
 The column number property of the last character in this node (read-only). More...
 
Node Parent [get]
 The parent node property (read-only). More...
 
virtual int Count [get]
 The child node count property (read-only). More...
 
virtual Node this[int index] [get]
 The child node index (read-only). More...
 
ArrayList Values [get, set]
 The node values property. More...
 

Detailed Description

A token node.

This class represents a token (i.e. a set of adjacent characters) in a parse tree. The tokens are created by a tokenizer, that groups characters together into tokens according to a set of token patterns.

Author
Per Cederberg
Version
1.5

Constructor & Destructor Documentation

PerCederberg.Grammatica.Runtime.Token.Token ( TokenPattern  pattern,
string  image,
int  line,
int  col 
)
inline

Creates a new token.

Parameters
patternthe token pattern
imagethe token image (i.e. characters)
linethe line number of the first character
colthe column number of the first character

Member Function Documentation

string PerCederberg.Grammatica.Runtime.Token.GetImage ( )
inline

Returns the token image.

The token image consists of the input characters matched to form this token.

Returns
the token image
See also
Image
Deprecated:
Use the Image property instead.
Token PerCederberg.Grammatica.Runtime.Token.GetNextToken ( )
inline

Returns the next token.

The next token may be a token that has been ignored in the parsing. Note that if the token list feature hasn't been used in the tokenizer, this method will always return null. By default the token list feature is not used.

Returns
the next token, or null if no such token is available
See also
Next
GetPreviousToken
Tokenizer::UseTokenList
Since
1.4
Deprecated:
Use the Next property instead.
Token PerCederberg.Grammatica.Runtime.Token.GetPreviousToken ( )
inline

Returns the previous token.

The previous token may be a token that has been ignored in the parsing. Note that if the token list feature hasn't been used in the tokenizer, this method will always return null. By default the token list feature is not used.

Returns
the previous token, or null if no such token is available
See also
Previous
GetNextToken
Tokenizer::UseTokenList
Since
1.4
Deprecated:
Use the Previous property instead.
string PerCederberg.Grammatica.Runtime.Token.ToShortString ( )
inline

Returns a short string representation of this token.

The string will only contain the token image and possibly the token pattern name.

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

Returns a string representation of this token.

Returns
a string representation of this token

Property Documentation

override int PerCederberg.Grammatica.Runtime.Token.EndColumn
get

The column number property of the last character in this node (read-only).

If the node has child elements, this value will be fetched from the last child.

Since
1.5
override int PerCederberg.Grammatica.Runtime.Token.EndLine
get

The line number property of the last character in this node (read-only).

If the node has child elements, this value will be fetched from the last child.

Since
1.5
override int PerCederberg.Grammatica.Runtime.Token.Id
get

The node type id property (read-only).

This value is set as a unique identifier for each type of node, in order to simplify later identification.

Since
1.5
string PerCederberg.Grammatica.Runtime.Token.Image
get

The token image property (read-only).

The token image consists of the input characters matched to form this token.

Since
1.5
override string PerCederberg.Grammatica.Runtime.Token.Name
get

The node name property (read-only).

Since
1.5
Token PerCederberg.Grammatica.Runtime.Token.Next
getset

The next token property.

If the token list feature is used in the tokenizer, all tokens found will be chained together in a double-linked list. The next token may be a token that was ignored during the parsing, due to it's ignore flag being set. If there is no next token or if the token list feature wasn't used in the tokenizer (the default), the next token will always be null.

See also
Previous
Tokenizer::UseTokenList
Since
1.5
Token PerCederberg.Grammatica.Runtime.Token.Previous
getset

The previous token property.

If the token list feature is used in the tokenizer, all tokens found will be chained together in a double-linked list. The previous token may be a token that was ignored during the parsing, due to it's ignore flag being set. If there is no previous token or if the token list feature wasn't used in the tokenizer (the default), the previous token will always be null.

See also
Next
Tokenizer::UseTokenList
Since
1.5
override int PerCederberg.Grammatica.Runtime.Token.StartColumn
get

The column number property of the first character in this node (read-only).

If the node has child elements, this value will be fetched from the first child.

Since
1.5
override int PerCederberg.Grammatica.Runtime.Token.StartLine
get

The line number property of the first character in this node (read-only).

If the node has child elements, this value will be fetched from the first child.

Since
1.5

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