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 readyToParse: boolean; override;
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 readyToParse: boolean; override;

Determine whether or not the parser is ready to parse.

This method builds on the behavior inherited from ASymbolParser.readyToParse. It calls the inherited routine and, if that routine returns True to indicate all is well, it checks to determine whether Self.Output is Nil, indicating that no output stream has been defined for the parser. If not, it attempts to borrow the reference from the parent, if it is available.

To parse successfully, an output stream must be provided to the parser before parsing begins. To set the output stream used by the parser, call ASourceParser.SetOutput. This method will return False if no output stream has been provided and it is unable to borrow the reference of a parent.

Returns

True if the parser is ready to parse; False if not.

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-06-25 11:12:03