Arena
1.0
A content management system
|
A generic token. More...
Public Member Functions | |
def | __init__ |
Constructor. More... | |
def | init |
Initializer. | |
def | rewind |
Return the token to the input stream. More... | |
def | toString |
Return a string representation of the token. More... | |
def | readFrom |
Read the token from the specified stream. More... | |
def | writeTo |
Write the token to the specified stream. More... | |
def | code |
Retrieve the token code. | |
def | literal |
Retrieve the token literal. | |
def | Language |
Retrieve the language used to parse the token. More... | |
Public Member Functions inherited from Library.Base.Classwork.AnObject | |
def | init |
Initialize a new object instance. More... | |
def | __init__ |
Construct and initialize a new instance of AnObject. More... | |
def | __del__ |
Destroy the object instance. More... | |
def | displayName |
Construct a "pretty" display name for the class instance, based on the name of its class. More... | |
def | implements |
Determine whether the class instance is related to the specified class. More... | |
def | toString |
Return a string representation of the class, suitable for output to a console or text-based device. More... | |
def | __str__ |
Return a string representation of the class. More... | |
def | classname |
Return the name of the class from which the instance was created. More... | |
def | name |
Return the name of the class. More... | |
Public Member Functions inherited from Library.String.Utilities.IsPrintable | |
def | toString |
Return a string representation of the class conveniently. More... | |
def | __str__ |
Return a string representation of the class. More... | |
def | printTo |
Print a string representation of the class to the specified stream. More... | |
Public Member Functions inherited from Library.IO.Streams.IsStreamable | |
def | writeTo |
Write class instance data to the specified stream. More... | |
def | readFrom |
Read class instance data from the specified stream. More... | |
Static Public Member Functions | |
def | fromSource |
Construct a new token based on the next character read from the specified stream. More... | |
A generic token.
This class serves as the base for all other token types that can be parsed from a stream. It provides methods for reading the token from a given input stream and for writing it to another stream. It also provides a class method that can be called to construct and return the appropriate token type depending on the current character retrieved from a given input stream.
def Library.Parse.Scan.Tokens.AToken.__init__ | ( | Self, | |
ThisLanguage | |||
) |
Constructor.
ThisLanguage
is a reference to an instance of AComputerLanguage, which will be used to match specific characters and identifiers to keywords and operators.
|
static |
Construct a new token based on the next character read from the specified stream.
ThisSource
should be a reference to the input stream from which tokens will be parsed.
ThisLanguage
should be a reference to an instance of AComputerLanguage, which will be used to determine the type of the character read from the input stream.
def Library.Parse.Scan.Tokens.AToken.Language | ( | Self | ) |
Retrieve the language used to parse the token.
def Library.Parse.Scan.Tokens.AToken.readFrom | ( | Self, | |
Source | |||
) |
Read the token from the specified stream.
This routine should be implemented by descendant classes.
def Library.Parse.Scan.Tokens.AToken.rewind | ( | Self, | |
ThisSource | |||
) |
Return the token to the input stream.
This methods allows a form of token "peeking", in which a parser can retrieve a token from the stream to see if matches a predefined list of tokens, and then return it to the stream so that it can be read again.
The base implementation of this method simply calls AStream.rewindBy() on ThisSource
to rewind the stream by the length of the token literal string.
def Library.Parse.Scan.Tokens.AToken.toString | ( | Self | ) |
Return a string representation of the token.
This representation will be a quoted form of the token text, unless the token text is already quoted.
def Library.Parse.Scan.Tokens.AToken.writeTo | ( | Self, | |
Dest | |||
) |
Write the token to the specified stream.
In the base implementation, this routine simply writes the token code to the stream. Descendant classes may override this routine in order to output additional information.