Class ASymbol

DescriptionHierarchyFieldsMethodsProperties

Unit

Declaration

type ASymbol = class(AStringLeaf)

Description

This class represents a basic symbol, which may be an identifier (such as a variable or function name), a numeric constant, or a string literal. It indicates the symbol scope (the symbol table to which the symbol belongs), as well as the name of the source and line number where the symbol was declared.

You will likely not directly instantiate this class, as it is meant to serve as a template for more specific symbol types that may be required by a parser.

Hierarchy

Overview

Fields

Protected myScope: TSymbolScope;
Protected myCategory: longword;

Methods

Public function init: boolean; override;
Public function reference: TSymbolReference; virtual;
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 scope: TSymbolScope; virtual;
Public function category: longword; virtual;

Description

Fields

Protected myScope: TSymbolScope;

Refers to the symbol table to which the symbol belongs

Protected myCategory: longword;

Indicates how the symbol was defined

Methods

Public function init: boolean; override;

Initializer

Public function reference: TSymbolReference; virtual;

Retrieve a reference to the symbol, which contains the scope and index of the symbol.

The reference returned by this routine can be used to locate the symbol after it has been retrieved from an intermediate code stream. In a manner of speaking, this reference is the absolute address of the symbol, at which it can always be found (unless the source is modified).

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

Construct a shallow copy of the other object.

This method builds upon the behavior inherited from AStringLeaf.shallowCopyFrom. It calls that method, then checks to see whether Other is an instance of ASymbol. If so, it copies the values of

from Other to Self, overwriting the values in Self.

Note that this method does NOT copy the left and right subtree of Other and so does not place Self inside the same symbol table as Other, if any.

Public function selfStreamingLength: TStreamIOSize; override;

Calculate the number of bytes required to stream the symbol.

This method builds upon the behavior inherited from AStringLeaf.selfStreamingLength: it calls the inherited routine first, then adds the number of bytes required to write the symbol category and symbol scope.

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

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

This method builds upon the behavior inherited from AStringLeaf.writeSelfTo. It calls that method, then writes the values of ASymbol.category and ASymbol.scope.

Returns

The total number of bytes written to the stream.

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

Read the symbol from the specified stream.

This method builds upon the behavior inherited from AStringLeaf.readFrom. It calls that routine, then reads the values of ASymbol.scope and ASymbol.category from Source.

Returns

The total number of bytes read from Source.

Public function toString: AnsiString; override;

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

This method overrides the behavior inherited from AStringLeaf. It returns a quoted form of the symbol name, as obtained by a call to Charstring.quote when applied to AStringLeaf.name. This behavior is designed to make it easy to output a symbol as part of a syntax error message, hint, or warning.

Public function scope: TSymbolScope; virtual;

Retrieve the symbol's scope, which indicates the symbol table to which it belongs.

Public function category: longword; virtual;

Get the symbol category, which indicates how it was defined.

The value returned by this routine will be one of the SYMCAT_ constants, such as SYMCAT_VARIABLE.


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