MC
API
     
Subsystem
list
     
Top
level

The LEXer Class

This page describes a Lexical Analyzer for use with the Symbol Table class.

A Lexical Analyzer, or Lexer for short, reads an input stream and breaks it up into meaningful syntactic units called "tokens". The input stream is normally an ASCII file; the stream is a stream of characters.

Defined in: Shared/Lexer.inc

Data Types

LEXtoken - a token type

Methods

void PushFile (string sFileName)
void PushStrings (list of string lsTheInput)
void ClearInputs ()
string GetFileName ()
LEXtoken GetToken (out anytype aValue optional, out anytype tType optional)
void UnGet ()
string ErrorInfo (out string sFileName, out integer iLine, out string sInput, out integer iInputPosition)


LEXtoken

This is a data type whose value represents a lexical token type.

Declaration

type LEXtoken is enum { /* see below */ }

Values

eLEX_NAME A symbolic name consisting of 'A'-'Z', 'a'-'Z', '_' (underscore), and '0'-'9'. It may not start with a digit.
eLEX_BOOLEAN "TRUE", "true", "FALSE", or "false"
eLEX_STRING A sequence of characters beginning or ending with a single or double quote. The ending quote must be the same character as the beginning quote.
eLEX_NUMBER An integer or floating point number, optionally preceded by a minus sign.
eLEX_EQUALS
eLEX_SEMICOLON
eLEX_OPEN_CURLY
eLEX_CLOSE_CURLY
eLEX_COMMA
eLEX_END_OF_INPUT


PushFile

Pushes a file onto the input stack.

Declaration

void PushFile (string sFileName)

Inputs

sFileName
The name of the file.

Outputs

None.

Exceptions

X_LEX_INPUT_STACK
The named file is already in the input stack.


PushStrings

Pushes a list of strings onto the input stack.

Declaration

void PushStrings (list of string lsTheInput)

Inputs

lsTheInput
A list of strings.

Outputs

None.


ClearInputs

Clears out the input stack so that it is empty.

Declaration

void ClearInputs ()

Inputs

None.

Outputs

None.


GetFileName

Returns the name of the current input file, or an empty string if the current input source is not a file.

Declaration

string GetFileName()

Inputs

None.

Outputs

Returns
The name of the file, or an empty string.


GetToken

Reads the next token from the input stack, and returns it.

Declaration

LEXtoken GetToken (out anytype aValue optional, out anytype tType optional)

Inputs

None.

Outputs

Returns
The type of token.
aValue
The value of the token (if any).
tType
The 4Test data type of the token.

Exceptions

X_LEX_SYNTAX_ERROR
Indicates a syntax error in the input stream. Use ErrorInfo to get more information about the error.


UnGet

Un-gets the most recently lexed token, so that it will be returned by the next call to UnGet. You can only unget one token at a time.

Declaration

void LEXunGet ()

Inputs

None.

Outputs

None.


ErrorInfo

Returns a string describing the most recent error, and information about where the error occurred. If the error did not occur in a file, sFileName // is empty, and iLine is 0.

Declaration

string ErrorInfo (out string sFileName, out integer iLine, out string sInput, out integer iInputPosition)

Inputs

None.

Outputs

Returns
A string describing the most recent error.
sFileName
The name of the file in which the error occurred, or an empty string if the input source was not a file.
iLine
The number of the line in which the error occurred, or 0 if the input source was not a file.
sInput
A copy of the input line in which the error occurred.
iInputPosition
The position (character offset) in the input line at which the error was discovered.



This page is maintained by (REMOVED).

Last updated 9 April 1998.