Unit Lexer

DescriptionusesClasses, Interfaces, Objects and RecordsFunctions and ProceduresTypesConstantsVariables

Description

Unit defining a lexer class (TLexer) which is a modified version of the class TParser included in the Delphi IDE software. It also implements utility procedures that can be used for parsing definition files (similar to Delphi *.dfm files).

uses

Classes, Interfaces, Objects and Records

NameDescription
Class EParseError Error class used during parsing.
record TTokenRec Record for holding the information about a token stored during the parsing of the stream.
Class EParserError Exception class used for errors generated by the parser itself.
Class TLexer Class that provides the basic functionality for parsing a stream into tokens (hence the name TLexer).

Functions and Procedures

Overview

function GetLabelIndex(token_list: TList; id: string; idx, max_idx: integer): integer;
procedure ParseFile(S: TStream; var token_list: TList);

Description

function GetLabelIndex(token_list: TList; id: string; idx, max_idx: integer): integer;

Utility procedure that returns the index of a token (in a list of tokens) based on an identifier. The list of tokens should consist of PTokenRecs and GetLabelIndex returns a non-negative value if the argument id matches the the string in the member TTokenRec.Token. GetLabelIndex is not case sensitive.

parameters
token_list
is the list of tokens.
id
is the string to search for.
idx
is the current index (or starting index).
max_idx
is the upper bound of the index search.
returns

-1 if no matching token was found in the range [idx, max_idx], otherwise the index of the matching token is returned.

procedure ParseFile(S: TStream; var token_list: TList);

Parses a stream and generates tokens (stored in a list).

parameters
S
is the stream to be parsed.
token_list
is the list that will store the PTokenRecs generated during the parsing of the stream.

Types

NameDescription
PTokenRec = ˆTTokenRec;

Pointer to TTokenRec.

Constants

NameDescription
toBoolean = Char(6);

Boolean token identifier (token object). See TTokenRec.TokenType.


Generated by PasDoc 0.8.8.3 on 2005-05-28 08:13:49