parsing.ppIntroduction Units Class Hierarchy Classes, Interfaces, Objects and Records Types Variables Constants Functions and Procedures Identifiers Classes hierarchy graph
|
Class ASymbol
Unit
parsing
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.
Symbols derived from a type make use of the Parent property to refer to the symbol that defines the type. If a symbol has no parent, then it typically represents a top-level type.
Hierarchy
Overview
Fields
Methods
Description
Fields
|
myScope: TSymbolScope; |
Refers to the symbol table to which the symbol belongs
|
|
myCategory: longword; |
Indicates how the symbol was defined
|
Methods
|
function init: boolean; override; |
Initializer
|
|
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).
|
|
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.
|
|
function canAssignFrom(const OtherSymbol: ASymbol): boolean; virtual; |
Determine whether or not the value represented by OtherSymbol can be assigned to Self .
This method first checks to see whether Self and OtherSymbol are derived from the same symbol type by calling TObject.inheritsFrom on Self and passing OtherSymbol.classType . If so, it returns True , since symbols that inherit from the same immediate parent symbol type should be compatible with each.
If the two symbols do not inherit from the same immediate parent, this method then checks to see whether a type has been defined for both symbols by calling ASymbol.Parent on Self and OtherSymbol . If the calls return values which are not Nil , the method calls itself using Self.Parent as the value of Self and OtherSymbol.Parent as the value of OtherSymbol .
Returns
True if this type is compatible with OtherType ; False if not.
|
|
function canCompareWith(const OtherSymbol: ASymbol): boolean; virtual; |
Determine whether or not the value represented by OtherSymbol can be compared with that represented by Self .
This method first checks to see whether Self and OtherSymbol are derived from the same symbol type by calling TObject.inheritsFrom on Self and passing OtherSymbol.classType . If so, it returns True , since symbols that inherit from the same immediate parent symbol type should be compatible with each.
If the two symbols do not inherit from the same immediate parent, this method then checks to see whether a type has been defined for both symbols by calling ASymbol.Parent on Self and OtherSymbol . If the calls return values which are not Nil , the method calls itself using Self.Parent as the value of Self and OtherSymbol.Parent as the value of OtherSymbol .
Returns
True if this type is compatible with OtherType ; False if not.
|
|
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.
|
|
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. |
|
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 . |
|
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.
|
|
function scope: TSymbolScope; virtual; |
Retrieve the symbol's scope, which indicates the symbol table to which it belongs.
|
|
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-06-25 11:12:03
|