Class TTokenizer

Unit

Declaration

type TTokenizer = class(TObject)

Description

Converts an input TStream to a sequence of TToken objects.

Source: source/component/PasDoc_Tokenizer.pas (line 325).

Hierarchy

Overview

Fields

Protected FOnMessage: TPasDocMessageEvent;
Protected FVerbosity: Cardinal;
Protected BufferedChar: Char;
Protected EOS: Boolean;
Protected IsCharBuffered: Boolean;
Protected Line: Integer;
Protected Stream: TStream;
Protected FStreamName: string;
Protected FStreamAbsoluteFileName: string;

Methods

Protected procedure DoError(const AMessage: string; const AArguments: array of const);
Protected procedure DoMessage(const AVerbosity: Cardinal; const MessageType: TPasDocMessageType; const AMessage: string; const AArguments: array of const);
Protected procedure CheckForDirective(const t: TToken);
Protected procedure ConsumeChar;
Protected function CreateSymbolToken(const st: TSymbolType; const s: string): TToken; overload;
Protected function CreateSymbolToken(const st: TSymbolType): TToken; overload;
Protected function GetChar(out c: AnsiChar): Integer;
Protected function PeekChar(out c: Char): Boolean;
Protected function ReadCommentType1: TToken;
Protected function ReadCommentType2: TToken;
Protected function ReadCommentType3: TToken;
Protected function ReadAttAssemblerRegister: TToken;
Protected function ReadLiteralString(var t: TToken): Boolean;
Protected function ReadToken(c: Char; const s: TCharSet; const TT: TTokenType; var t: TToken): Boolean;
Public constructor Create( const AStream: TStream; const OnMessageEvent: TPasDocMessageEvent; const VerbosityLevel: Cardinal; const AStreamName, AStreamAbsoluteFileName: string);
Public destructor Destroy; override;
Public function HasData: Boolean;
Public function GetStreamInfo: string;
Public function GetToken(const NilOnEnd: Boolean = false; const NilOnInvalidContent: Boolean = false): TToken;
Public procedure UnGetToken(var T: TToken);
Public function SkipUntilCompilerDirective: TToken;

Properties

Public property OnMessage: TPasDocMessageEvent read FOnMessage write FOnMessage;
Public property Verbosity: Cardinal read FVerbosity write FVerbosity;
Public property StreamName: string read FStreamName;
Public property StreamAbsoluteFileName: string read FStreamAbsoluteFileName;

Description

Fields

Protected FOnMessage: TPasDocMessageEvent;

This item has no description.

Source: source/component/PasDoc_Tokenizer.pas (line 331).

Protected FVerbosity: Cardinal;

This item has no description.

Source: source/component/PasDoc_Tokenizer.pas (line 332).

Protected BufferedChar: Char;

if IsCharBuffered is true, this field contains the buffered character

Source: source/component/PasDoc_Tokenizer.pas (line 335).

Protected EOS: Boolean;

true if end of stream Stream has been reached, false otherwise

Source: source/component/PasDoc_Tokenizer.pas (line 337).

Protected IsCharBuffered: Boolean;

if this is true, BufferedChar contains a buffered character; the next call to GetChar or PeekChar will return this character, not the next in the associated stream Stream

Source: source/component/PasDoc_Tokenizer.pas (line 341).

Protected Line: Integer;

current line number in stream Stream; useful when giving error messages

Source: source/component/PasDoc_Tokenizer.pas (line 343).

Protected Stream: TStream;

the input stream this tokenizer is working on

Source: source/component/PasDoc_Tokenizer.pas (line 345).

Protected FStreamName: string;

This item has no description.

Source: source/component/PasDoc_Tokenizer.pas (line 346).

Protected FStreamAbsoluteFileName: string;

This item has no description.

Source: source/component/PasDoc_Tokenizer.pas (line 347).

Methods

Protected procedure DoError(const AMessage: string; const AArguments: array of const);

This item has no description.

Source: source/component/PasDoc_Tokenizer.pas (line 349).

Protected procedure DoMessage(const AVerbosity: Cardinal; const MessageType: TPasDocMessageType; const AMessage: string; const AArguments: array of const);

This item has no description.

Source: source/component/PasDoc_Tokenizer.pas (line 350).

Protected procedure CheckForDirective(const t: TToken);

This item has no description.

Source: source/component/PasDoc_Tokenizer.pas (line 353).

Protected procedure ConsumeChar;

This item has no description.

Source: source/component/PasDoc_Tokenizer.pas (line 354).

Protected function CreateSymbolToken(const st: TSymbolType; const s: string): TToken; overload;

This item has no description.

Source: source/component/PasDoc_Tokenizer.pas (line 356).

Protected function CreateSymbolToken(const st: TSymbolType): TToken; overload;

Uses default symbol representation, from SymbolNames[st]

Source: source/component/PasDoc_Tokenizer.pas (line 360).

Protected function GetChar(out c: AnsiChar): Integer;

Returns 1 on success or 0 on failure

Source: source/component/PasDoc_Tokenizer.pas (line 368).

Protected function PeekChar(out c: Char): Boolean;

This item has no description.

Source: source/component/PasDoc_Tokenizer.pas (line 370).

Protected function ReadCommentType1: TToken;

This item has no description.

Source: source/component/PasDoc_Tokenizer.pas (line 371).

Protected function ReadCommentType2: TToken;

This item has no description.

Source: source/component/PasDoc_Tokenizer.pas (line 372).

Protected function ReadCommentType3: TToken;

This item has no description.

Source: source/component/PasDoc_Tokenizer.pas (line 373).

Protected function ReadAttAssemblerRegister: TToken;

This item has no description.

Source: source/component/PasDoc_Tokenizer.pas (line 374).

Protected function ReadLiteralString(var t: TToken): Boolean;

This item has no description.

Source: source/component/PasDoc_Tokenizer.pas (line 375).

Protected function ReadToken(c: Char; const s: TCharSet; const TT: TTokenType; var t: TToken): Boolean;

This item has no description.

Source: source/component/PasDoc_Tokenizer.pas (line 376).

Public constructor Create( const AStream: TStream; const OnMessageEvent: TPasDocMessageEvent; const VerbosityLevel: Cardinal; const AStreamName, AStreamAbsoluteFileName: string);

Creates a TTokenizer and associates it with given input TStream. Note that AStream will be freed when this object will be freed.

Source: source/component/PasDoc_Tokenizer.pas (line 382).

Public destructor Destroy; override;

Releases all dynamically allocated memory.

Source: source/component/PasDoc_Tokenizer.pas (line 388).

Public function HasData: Boolean;

This item has no description.

Source: source/component/PasDoc_Tokenizer.pas (line 389).

Public function GetStreamInfo: string;

This item has no description.

Source: source/component/PasDoc_Tokenizer.pas (line 390).

Public function GetToken(const NilOnEnd: Boolean = false; const NilOnInvalidContent: Boolean = false): TToken;

Get next token from stream.

Parameters
NilOnEnd
If True, return Nil once stream ends. Otherwise we make exception about it.
NilOnInvalidContent
If True, return Nil on some invalid content, like "!" which is not Pascal token at all. This parameter is independent from NilOnEnd. The "invalid content" affected by this parameter is still something that "we can read to advance our position within the stream".

Source: source/component/PasDoc_Tokenizer.pas (line 402).

Public procedure UnGetToken(var T: TToken);

Makes the token T next to be returned by GetToken. Also sets T to Nil, to prevent you from freeing it accidentally.

You cannot have more than one "unget" token. If you only call UnGetToken after some GetToken, you are safe.

Source: source/component/PasDoc_Tokenizer.pas (line 410).

Public function SkipUntilCompilerDirective: TToken;

Skip all chars until it encounters some compiler directive, like $ELSE or $ENDIF. Returns either Nil or a token with MyType = TOK_DIRECTIVE.

Source: source/component/PasDoc_Tokenizer.pas (line 415).

Properties

Public property OnMessage: TPasDocMessageEvent read FOnMessage write FOnMessage;

This item has no description.

Source: source/component/PasDoc_Tokenizer.pas (line 417).

Public property Verbosity: Cardinal read FVerbosity write FVerbosity;

This item has no description.

Source: source/component/PasDoc_Tokenizer.pas (line 418).

Public property StreamName: string read FStreamName;

Informative to user name of the stream from which this token was read. This can be a filename (relative or absolute, however user specified it), but it also can be something arbitrary like "$if / $elseif condition".

So don't treat it like a reliable filename, for this use StreamAbsoluteFileName.

Source: source/component/PasDoc_Tokenizer.pas (line 426).

Public property StreamAbsoluteFileName: string read FStreamAbsoluteFileName;

Filename, always absolute, of the underlying file of this stream. Empty ('') if this is not a file stream.

Source: source/component/PasDoc_Tokenizer.pas (line 430).


Generated by PasDoc 0.17.0.snapshot.