Class ASymbolicToken

DescriptionHierarchyFieldsMethodsProperties

Unit

Declaration

type ASymbolicToken = class(AToken)

Description

This class represents a symbol that is entered into a symbol table. These will usually be identifiers, numeric constants, or string literals. The actual value of the symbol is stored in a separate symbol table, to which the token makes reference by means of ASymbolicToken.symbol.

Hierarchy

Overview

Fields

Protected mySymbol: TSymbolReference;

Methods

Public function init: boolean; override;
Public procedure returnTo(const Source: AStream); override;
Public function shallowCopyFrom(const Other: AnObject): boolean; override;
Public function selfStreamingLength: TStreamIOSize; override;
Public function writeSelfTo(const Dest: AStream): TStreamIOSize; override;
Public function readFrom(const Source: AStream): TStreamIOSize; override;
Public function toString: AnsiString; override;
Public function symbol: TSymbolReference;

Description

Fields

Protected mySymbol: TSymbolReference;

Stores the scope and index of the symbol represented by the token.

Methods

Public function init: boolean; override;

Initializer

Public procedure returnTo(const Source: AStream); override;

Return the token to its source. The token will be read again the next time the source is queried for a token.

This method overrides the behavior inherited from AToken. It rewinds Source by the size of its index and opcode, then calls the inherited routine.

This method is defined to provide a way for a scanner to "peek" at the next token in the source stream without actually having to process it.

Public function shallowCopyFrom(const Other: AnObject): boolean; override;

Construct a shallow copy of the other object.

This method extends the behavior inherited from AToken.shallowCopyFrom: it calls that method, then checks to see whether Other is an instance of ASymbolicToken. If so, it copies the value of ASymbolicToken.symbol from Other to Self, overwriting the values in Self.

Note that this method does NOT copy any sibling or child nodes and so cannot be used to create a full copy of any descendant of ANode. The copy will NOT be automatically placed in the list to which Other belongs, if any, but the caller is free to do so.

Public function selfStreamingLength: TStreamIOSize; override;

Calculate the number of bytes required to stream the token.

This method builds upon the behavior inherited from AToken.selfStreamingLength: it calls that routine, then adds the number of bytes required to stream the value of ASymbolicToken.symbol.

Public function writeSelfTo(const Dest: AStream): TStreamIOSize; override;

Write the token, and just the token, to the specified stream.

This method builds upon the behavior inherited from AToken. It calls the inherited routine, then writes the value of ASymbolicToken.symbol to Dest.

Returns

The total number of bytes written to Dest.

Public function readFrom(const Source: AStream): TStreamIOSize; override;

Read the token from the specified intermediate code stream.

This method builds upon the behavior inherited from AToken. It calls the inherited routine, then reads the value of ASymbolicToken.symbol.

Returns

The total number of bytes read from Source.

Public function toString: AnsiString; override;

Construct a string representation of the token, suitable for printing to a text-based device, such as a console.

This method overrides the behavior inherited from AToken. It constructs a string that contains the display name of the class and the value of ASymbolicToken.symbol. The format of this string is controlled by the value of smtkStringRepresentation.

Public function symbol: TSymbolReference;

Retrieve the token scope, which refers to the symbol list to which the symbol belongs. A given source program may have one or more symbol lists, which are indexed within an instance of ASymbolVectorVector.

General practice is to define a few global symbol lists: one for all string literals, one for all numeric constants, and one for all types; as well as one or more local scopes for each routine within the source program. The value returned by this method is the index of the appropriate instance of ASymbolVector within that list.


Generated by PasDoc 0.13.0 on 2015-01-10 17:13:18