Class ALinearCParser

DescriptionHierarchyFieldsMethodsProperties

Unit

Declaration

type ALinearCParser = class(AParsedLanguageParser)

Description

This class represents a parser for the LinearC language. It descends from AParsedLanguageParser because the parser does not output to an intermediate code stream, and though it still makes use of a symbol table representative of the options that can be set on the command line by the user, it needs only one of those.

The parser automatically constructs an instance of TheLinearCLanguage to manage the tokens it parses. This language specification will be freed when the parser is freed.

To use the parser, simply pass an instance of AStringStream that contains a string with all command-line options on it to the constructor, then call ALinearCParser.parse.

Hierarchy

  • ALinearCParser

Overview

Fields

Protected MyOptions: ACommandLineOptionDictionary;

Methods

Protected function readyToParse: boolean; override;
Public constructor forSource(const ThisSource: AStream; const takeOwnershipOfSource: boolean; const TheseOptions: ACommandLineOptionDictionary; const ThisLog: ALog); overload; virtual;
Public constructor forSource(const ThisParent: AParser); override;
Public function init: boolean; override;
Public destructor destroy; override;
Public function parse: int64; override;
Public function Options: ACommandLineOptionDictionary; virtual;

Description

Fields

Protected MyOptions: ACommandLineOptionDictionary;

Refers to the options that are parsed

Methods

Protected function readyToParse: boolean; override;

Initialize the parser prior to parsing the source.

This method builds on the behavior inherited from AParsedLanguageParser.readyToParse. It calls the inherited routine and, if that routine returns True to indicate all is well, it checks to see whether Self.Scanner is Nil, indicating that a descendant class has not yet assigned a scanner to the parser. If not, the method constructs an instance of ASourceScanner.

The method also checks to see whether Self.Options is Nil, indicating that a descendant class has not yet assigned a list of options to the parser. If not, the method attempts to borrow the reference from its parent parser, if one is available.

The method returns True only if the inherited routine returns true and if both Self.Scanner and Self.Options are not Nil.

Returns

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

Public constructor forSource(const ThisSource: AStream; const takeOwnershipOfSource: boolean; const TheseOptions: ACommandLineOptionDictionary; const ThisLog: ALog); overload; virtual;

Construct a new instance of ALinearCParser that will parse the command line represented by ThisSource using the options specified by TheseOptions, and outputting error and status information to ThisLog.

This method constructs a new instance of ATextInputStream around ThisSource. That instance will be freed when the parser is freed. takeOwnershipOfSource is passed to ATextInputStream.around.

Public constructor forSource(const ThisParent: AParser); override;

Construct a new parser that will inherit the properties of its parent parser.

The new parser will inherit the values of ThisParent's Scanner, Source, Log, and Options.

Public function init: boolean; override;

Initializer

Public destructor destroy; override;

Destroy the parser.

This method frees the instance of ATextInputStream that was constructed by ALinearCParser.forSource and then calls the inherited routine.

Public function parse: int64; override;

Parse the command line.

This method builds on the behavior inherited from AParsedLanguageParser.parse; it calls that routine, then constructs an instance of ALinearCStatementBlock to parse the entire command line.

If ALinearCParser.Options returns Nil, indicating that no instance of ACommandLineOptionDictionary was passed to the constructor when the parser was created, then this routine will do nothing and will return -1.

Public function Options: ACommandLineOptionDictionary; virtual;

Retrieve a reference to the dictionary of command-line options that may be set by the user.

The caller should NOT attempt to free this reference before freeing the parser.


Generated by PasDoc 0.13.0 on 2015-06-25 11:07:51