Class ASourceParser

DescriptionHierarchyFieldsMethodsProperties

Unit

Declaration

type ASourceParser = class(ASymbolParser)

Description

This class represents a parser that uses a language definition to parse an arbitrary source stream into intermediate code. Symbols (identifiers and constants) that are encountered by the parser are destined to be entered into its symbol tables.

You will likely not create a direct instance of this class, as calling its parse method does not do much that is useful. Instead, you will derive a custom class from this one.

Hierarchy

Overview

Fields

Protected MyOutput: AStream;

Methods

Public function init: boolean; override;
Public function parse: int64; override;
Public function parseInto(const Dest: AStream): int64; virtual;
Public function Output: AStream; virtual;
Public function SetOutput(const Dest: AStream): AStream; virtual;

Description

Fields

Protected MyOutput: AStream;

Refers to the stream used by the parser for output.

Methods

Public function init: boolean; override;

Initializer

Public function parse: int64; override;

Execute the parser.

This method builds on the behavior inherited from ASymbolParser.parse: it first calls the inherited routine, then checks to ensure that ASourceParser.Output is valid (not Nil). If ASourceParser.Output is Nil, then this method returns -1; otherwise, it returns zero (0).

You will want to override this method when deriving from ASourceParser so that it does actual work.

Public function parseInto(const Dest: AStream): int64; virtual;

Set the parser's output stream and execute the parser.

This method sets the value of ASourceParser.Output to Dest and then calls ASourceParser.parse. The result of that call is returned to the caller.

If Dest is invalid (Nil), then this routine does nothing and returns -1.

Returns

Zero (0) on success. A negative value means an error occurred that prevented parsing from completing successfully; a positive value indicates the number of syntax errors that were encountered while parsing.

Public function Output: AStream; virtual;

Retrieve a reference to the output stream used by the parser.

This is the stream to which syntax-checked code is written and will most likely represent an intermediate code stream of some kind.

The caller should NOT free the reference returned by this routine.

Public function SetOutput(const Dest: AStream): AStream; virtual;

Set the output stream used by the parser.

In most cases, Dest will refer to a binary stream which is used to capture raw tokens as they are sucessfully parsed from a source stream.

Returns

The previous value of ASourceParser.Output.


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