Class ALineEndingTokenFromSource

DescriptionHierarchyFieldsMethodsProperties

Unit

Declaration

type ALineEndingTokenFromSource = class(ASpaceToken)

Description

This class represents the end of a source line. Certain parsers may process such tokens; others may discard them.

Hierarchy

Overview

Fields

Protected myLineCount: longword;

Methods

Public function init: boolean; override;
Public function shallowCopyFrom(const Other: AnObject): boolean; override;
Public function writeSelfTo(const Dest: AStream): TStreamIOSize; override;
Public function readFrom(const Source: AStream): TStreamIOSize; override;
Public function lineCount: longword; virtual;

Description

Fields

Protected myLineCount: longword;

Stores the number of line endings encountered while tokenizing

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 ASpaceToken.shallowCopyFrom: it calls that method, then checks to see whether Other is an instance of ALineEndingTokenFromSource. If so, it copies the value of ALineEndingTokenFromSource.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 writeSelfTo(const Dest: AStream): TStreamIOSize; override;

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

This method builds on the behavior inherited from ATokenFromSource. It calls the inherited routine, then writes the value of ALineEndingTokenFromSource.lineCount to the stream.

Returns

The total number of bytes written to Dest.

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

Read the token from the given source stream.

This method reads up to two characters from the source, depending on the style of line ending encountered. The method is written to handle Apple-style, Unix-style, and Windows-style line endings.

This method is written with the assumption that Source represents an instance of ATextInputStream. To read non-symbolic tokens from an intermediate code stream, an instance of AToken should be used instead.

Returns

The total number of bytes read from Source.

Public function lineCount: longword; virtual;

Retrieve the number of line endings encountered while tokenizing the source.

This function is most useful when ALineEndingTokenFromSource.consolidation is True but you still want to know how many line endings have been consolidated into one token.


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