Class ALineEndingToken

DescriptionHierarchyFieldsMethodsProperties

Unit

Declaration

type ALineEndingToken = class(AToken)

Description

This class represents the end of a source line. Some parsers may process these tokens out of the source and place them in an intermediate code stream as a way to mark the end of a statement.

Hierarchy

Overview

Fields

Protected myLineCount: longword;

Methods

Public function init: boolean; 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 lineCount: longword; virtual;

Description

Fields

Protected myLineCount: longword;

Stores the number of line endings represented by the token

Methods

Public function init: boolean; override;

Initializer

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

Construct a shallow copy of the other object.

This method extends the behavior inherited from AnObject.shallowCopyFrom: it calls that method, then checks to see whether Other is an instance of AToken. If so, it copies the value of ALineEndingToken.lineCount from Other to Self, overwriting the value 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 ALineEndingToken.lineCount.

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

Write the token, and just the token, to the given stream. This method builds upon the behavior inherited from AToken. It calls the inherited routine, then writes the number of line endings that are represented by the token.

Returns

The total number of bytes written to Dest.

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

Read the token from the given stream.

This method builds upon the behavior inherited from AToken. It calls the inherited routine, then reads the number of line endings that are represented by the token.

Returns

The total number of bytes read from Source.

Public function toString: AnsiString; override;

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

This method overrides the behavior inherited from AToken; it simply returns the value defined by letkStringRepresentation.

Public function lineCount: longword; virtual;

Retrieve the number of line endings represented by the token.

This value is usually set when an instance of ALineEndingTokenFromSource has written itself to an intermediate code stream. The value will be at least one (1), but may be more depending upon whether or not multiple line endings in the original source were consolidated into one token.


Generated by PasDoc 0.13.0 on 2015-06-25 11:12:03