Class AMiniParser
Unit
classwork
Declaration
type AMiniParser = class(ANode)
Description
This class represents a miniature parser. The purpose of the class is to provide a quick way to parse custom formatting strings.
The parser creates an instance of AMiniScanner which is used to scan the string in question. The scanner returns tokens which the parser will act upon by calling one of three callback routines. These callback routines can be set by the calling routine. This behavior allows the caller to customize the parser's response to a token without the need to define a custom descendant of this class (though, of course, that is also possible).
The three callback routines defined by this class are:
Hierarchy
Overview
Fields
Methods
Description
Fields
|
MyScanner: AMiniScanner; |
Refers to the scanner used to scan for tokens
|
|
myRecognizedTokenCallback: AMiniParserCallback; |
Refers to the callback used when a recognized token is found
|
|
myNumericTokenCallback: AMiniParserCallback; |
Refers to the callback used when a numeric token is found
|
|
myUnrecognizedTokenCallback: AMiniParserCallback; |
Refers to the callback used when an unrecognized token is found
|
Methods
|
function init: boolean; override; |
Initializer
|
|
destructor destroy; override; |
Destructor
|
|
procedure nextToken; virtual; |
Retrieve the next token from the source.
|
|
function previousToken: PMiniToken; virtual; |
Retrieve the previous token read from the source.
|
|
function currentToken: PMiniToken; virtual; |
Retrieve the most recent token read from the source.
|
|
function parse: int64; virtual; |
Parse the source.
|
|
function Scanner: AMiniScanner; virtual; |
Retrieve a reference to the scanner used to obtain tokens.
The caller should NOT attempt to free the reference returned by this routine.
|
|
function RecognizedTokens: AStringTree; virtual; |
Retrieve a reference to the list of recognized tokens.
This function is a pass-through function and returns the value returned by a call to Self.Scanner.RecognizedTokens.
The caller should NOT attempt to free the reference returned by this routine.
|
|
function recognizedTokenCallback: AMiniParserCallback; virtual; |
Retrieve a reference to the recognized token callback. This is the method called when a token is found that matches a value in Self.RecognizedTokens.
|
|
function numericTokenCallback: AMiniParserCallback; virtual; |
Retrieve a reference to the numeric token callback. This is the method called when an integer or floating-point token is encountered.
|
|
function setNumericTokenCallback(const newCallback: AMiniParserCallback): AMiniParserCallback; virtual; |
Set the numeric token callback. This is the method that will be called when an integer or floating-point token is encountered.
Returns
The previous value of AMiniParser.numericTokenCallback. The caller can save this reference in order to "chain up" to the previous handler. |
|
function unrecognizedTokenCallback: AMiniParserCallback; virtual; |
Retrieve a reference to the unrecognized token callback. This is the method that will be called when an unrecognized token is encountered.
|
|
function setUnrecognizedTokenCallback(const newCallback: AMiniParserCallback): AMiniParserCallback; virtual; |
Set the unrecognized token callback. This is the method that will be called when an unrecognized token is encountered.
Returns
The previous value of AMiniParser.unrecognizedTokenCallback. The caller can save this reference in order to "chain up" to the previous handler. |
Generated by PasDoc 0.13.0 on 2015-06-23 19:40:11
|