Declaration¶
Source position: classesh.inc line 2303
type
TParser = class(TObject)
public
constructor Create;
destructor Destroy;
procedure CheckToken;
procedure CheckTokenSymbol;
procedure Error;
procedure ErrorFmt;
procedure ErrorStr;
procedure HexToBinary;
function NextToken : AnsiChar;
function SourcePos : LongInt;
function TokenComponentIdent : string;
function TokenFloat : Extended;
function TokenInt : Int64;
function TokenString : string;
function TokenWideString : WideString;
function TokenSymbolIs : Boolean;
property FloatType: AnsiChar; {r}
property SourceLine: Integer; {r}
property Token: AnsiChar; {r}
end;
Description¶
This class breaks a stream of text data in tokens. Its primary use is to help reading the contents of a form file (usually a file with dfm, xfm or lfm extension), and for this reason it isn't suitable to be used as a general parser.
The parser is always positioned on a certain token, whose type is stored in the Token property. Various methods are provided to obtain the token value in the desired format.
To advance to the next token, invoke NextToken method.
Properties¶
| Member | Visibility | Description |
|---|---|---|
| FloatType read only | public | The type of a float token. |
| SourceLine read only | public | Current source line number. |
| Token read only | public | The type of the current token. |
Methods¶
| Member | Visibility | Description |
|---|---|---|
| CheckToken | public | Checks whether the token if of the given type. |
| CheckTokenSymbol | public | Checks whether the token equals the given symbol. |
| Create | public | Creates a new parser instance. |
| Destroy | public | Destroys the parser instance. |
| Error | public | Raises an EParserError exception with the given message. |
| ErrorFmt | public | Raises an EParserError exception and formats the message. |
| ErrorStr | public | Raises an EParserError exception with the given message. |
| HexToBinary | public | Writes hexadecimal data to a stream. |
| NextToken | public | Reads the next token and returns its type. |
| SourcePos | public | Returns the current position in the stream. |
| TokenComponentIdent | public | Returns the path of a subcomponent starting from the current token. |
| TokenFloat | public | Returns the current token as a float. |
| TokenInt | public | Returns the current token as an integer. |
| TokenString | public | Returns the current token as a string. |
| TokenSymbolIs | public | Returns True if the token equals the given symbol. |
| TokenWideString | public | Returns the current token as a widestring. |
See also¶
| Name | Description |
|---|---|
| TParser.Token | The type of the current token. |
| TParser.NextToken | Reads the next token and returns its type. |