Class ASourceScanner

DescriptionHierarchyFieldsMethodsProperties

Unit

Declaration

type ASourceScanner = class(AScanner)

Description

This class represents a scanner this used to return tokens from a source code stream.

Instances of ASourceScanner are designed to work on instances of ATextInputStream which contain raw source code to tokenize.

Hierarchy

Overview

Fields

Protected MyLanguage: AParsedLanguage;

Methods

Public constructor forSource(const ThisSource: ATextInputStream; const ThisLanguage: AParsedLanguage); overload; virtual;
Public function init: boolean; override;
Public procedure next; override;
Public function Peek: AToken; override;
Public function Language: AParsedLanguage;

Description

Fields

Protected MyLanguage: AParsedLanguage;

Refers to the language used to tokenize the source

Methods

Public constructor forSource(const ThisSource: ATextInputStream; const ThisLanguage: AParsedLanguage); overload; virtual;

Construct a new instance of ASourceScanner that will iterate over the source in ThisSource using ThisLanguage to tokenize the source.

This method differs from the constructor for instances of AScanner in that it expects the source stream to be an instance of ATextInputStream rather than an intermediate code stream, and it requires a language definition to use in order to tokenize the source.

Public function init: boolean; override;

Initializer

Public procedure next; override;

Retrieve the next token from the source.

This method overrides the behavior inherited from AScanner: where that method constructs and returns instances of AToken exclusively, this method will construct and return instances of ATokenFromSource for the most part.

This method always succeeds; however, if the end of the source has been reached, the token created will be an instance of AStreamEndingToken. If AScanner.CurrentToken already refers to such an instance, then this routine does nothing.

Public function Peek: AToken; override;

Peek at the next token from the source without advancing the scanner.

This method reads a token from the source and returns it, then rewinds the source position so that the token will be read again.

The caller should free the token reference returned by this routine when it is no longer needed. The scanner does NOT free the reference.

Public function Language: AParsedLanguage;

Retrieve a reference to the language definition used to tokenize the source.

The caller should NOT free this reference without first freeing the scanner; the reference is required in order to properly tokenize the source (it is passed to ATokenFromSource.using.)


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