Lex - Lexical analyser


Section contents


Overview

Defined in

cdescriptor.oxh

Class Lex
Construction NewLex
NewLex2
NewLex3
NewLex4
DeleteLex
Methods Assign
AssignDes
Get
Inc
Mark
MarkedToken
MarkedTokenStr
NextToken
NextTokenStr
Offset
Peek
Remainder
RemainderStr
RemainderFromMark
RemainderFromMarkStr
SkipAndMark
SkipCharacters
SkipSpace
SkipSpaceAndMark
TokenLength
UnGet
UnGetToMark
Val
ValFloat
ValRadix
ValRadixLimit

Construction / destruction


NewLex - Constructor

Usage

this& = NewLex&:

Description

Creates a lexical analyser object and returns a handle which allows the object to be manipulated.

Return Value
this& An value which represents the created lexical analyser object
Error Handling

If the object could not be created then an error is generated which should be trapped by an ONERR handler.

Example
  LOCAL this&

  this& = NewLex&:
  DeleteLex:(this&) 

NewLex2 - Constructor

Usage

this& = NewLex2&:(str$)

Description

Creates a lexical analyser object and returns a handle which allows the object to be manipulated.

Arguments
str$ A string to initialise the analyser
Return Value
this& An value which represents the created lexical analyser object
Error Handling

If the object could not be created then an error is generated which should be trapped by an ONERR handler.

Example
  LOCAL this&

  this& = NewLex2&:("a line to analyse")
  DeleteLex:(this&) 

NewLex3 - Constructor

Usage

this& = NewLex3&:(des&)

Description

Creates a lexical analyser object and returns a handle which allows the object to be manipulated.

Arguments
des& A handle to a descriptor object
Return Value
this& An value which represents the created lexical analyser object
Error Handling

If the object could not be created then an error is generated which should be trapped by an ONERR handler.

Example
  LOCAL this&,des&

  des& = NewDesAlloc(20)
  DesCopyStr:(des&,"a line to analyser")
  this& = NewLex3&:(des&)
  DeleteDes(des&)
  DeleteLex:(this&) 

NewLex4 - Constructor

Usage

this& = NewLex4&:(lex&)

Description

Creates a lexical analyser object and returns a handle which allows the object to be manipulated.

Arguments
lex& A handle to a lexical analyser object
Return Value
this& An value which represents the created lexical analyser object
Error Handling

If the object could not be created then an error is generated which should be trapped by an ONERR handler.

Example
  LOCAL this&,lex&

  lex& = NewLex2&:("this is a line")
  this& = NewLex4&:(lex&)
  DeleteLex:(this&)
  DeleteLex:(lex&) 

DeleteLex - Destructor

Usage

DeleteLex:(BYREF this&)

Description

Destroys the lexical analyser object.

Arguments
BYREF this& A handle to a lexical analyser object
Example
  LOCAL this&

  this& = NewLex&:
  DeleteLex:(this&) 

Methods provided


LexAssign

Usage

LexAssign:(this&,lex&)

Description

Assigns the constents of the lexical analyser object lex& to the lexical analyser object this&..

Arguments
this& A handle to a lexical analyser object
lex& A handle to a lexical analyser object

LexAssignDes

Usage

LexAssignDes:(this&,des&)

Description

Assigns the contents of the descriptor des& to the lexical analyser object this&..

Arguments
this& A handle to a lexical analyser object
des& A handle to a descriptor object

LexAssignStr

Usage

LexAssignStr:(this&,str$)

Description

Assigns the contents of the string str$ to the lexical analyser object this&..

Arguments
this& A handle to a lexical analyser object
str$ A string

LexEos

Usage

result% = LexEos%:(this&)

Description

Returns the True (-1) if the current character position is at the end of the lexical analyser's buffer contents, otherwise it returns False (0)..

Arguments
this& A handle to a lexical analyser object
Return value
result% True(-1) if and the end of the string, other False (0)

LexGet

Usage

char% = LexGet%:(this&)

Description

Returns the next character from the input string and advances the character position one place.

Arguments
this& A handle to a lexical analyser object
Return value
char% The next character or 0 if at the end of the input string

LexInc

Usage

LexInc:(this&,number&)

Description

Advances the character position by number& positions.

Arguments
this& A handle to a lexical analyser object
number& The number of character positions to increment

LexMark

Usage

LexMark:(this&,make&)

Description

<TBS>

Arguments
this& A handle to a lexical analyser object
mark& A handle to a lexical markt, or 0 for the default mark

LexMarkedOffset

Usage

offset& = LexMarkedOffset&:(this&,mar&)

Description

Returns the offset of the marked token from the start of the buffer.

Arguments
this& A handle to a lexical analyser object
mark& A handle to a lexical markt, or 0 for the default mark
Return value
offset& The offset of the default maked token

LexMarkedToken

Usage

des& = LexMarkedToken&:(this&)

Description

Returns the marked token as a descriptor.

Arguments
this& A handle to a lexical analyser object
Return value
des& The current token as a descriptor object
Error Handling

If the des& object cannot be created then an error is generated which should be trapped by an ONERR handler.


LexMarkedTokenStr

Usage

token$ = LexMarkedTokenStr$:(this&)

Description

Returns the marked token as a string.

Arguments
this& A handle to a lexical analyser object
Return value
token$ The current token
Error Handling

If the token$ string cannot be created then an error is generated which should be trapped by an ONERR handler.


LexNextToken

Usage

des& = LexNextToken&:(this&)

Description

Skips white space and returns the next token as a descriptor object.

Arguments
this& A handle to a lexical analyser object
Return value
des& The next token as a descriptor object
Error Handling

If the des& object cannot be created then an error is generated which should be trapped by an ONERR handler.


LexNextTokenStr

Usage

token$ = LexNextTokenStr$:(this&)

Description

Skips white space and returns the next token as a string.

Arguments
this& A handle to a lexical analyser object
Return value
token$ The next token
Error Handling

If the token$ string cannot be created then an error is generated which should be trapped by an ONERR handler.


LexOffset

Usage

offset& = LexOffset&:(this&)

Description

Returns the offset of the current character position from the start of the string.

Arguments
this& A handle to a lexical analyser object
Return value
offset& The offset of the current character position from the start of the string

LexPeek

Usage

char% = LexPeek%:(this&)

Description

Returns the next character that would be retirn by LexGet:

Arguments
this& A handle to a lexical analyser object
Return value
char% The next character or 0 if at the end of the input string

LexRemainder

Usage

des& = LexRemainder&:(this&)

Description

Returns the remainder of the string in the lexical buffer from the current position to the end of the string.

Arguments
this& A handle to a lexical analyser object
Return value
des& The remainder of the string from the current position to the end of the string returned as a descriptor object
Error Handling

If the des& object cannot be created then an error is generated which should be trapped by an ONERR handler.


LexRemainderStr

Usage

str$ = LexRemainderStr&:(this&)

Description

Returns the remainder of the string in the lexical buffer from the current position to the end of the string.

Arguments
this& A handle to a lexical analyser object
Return value
str$ The remainder of the string from the current position to the end of the string
Error Handling

If the str$ string cannot be created then an error is generated which should be trapped by an ONERR handler.


LexRemainderFromMark

Usage

des& = LexRemainderFromMask&:(this&,mark&)

Description

Returns the remainder of the string in the lexical buffer from the mark& to the end of the string as a descriptor object.

Arguments
this& A handle to a lexical analyser object
mark& A handle to a lexical mark, or 0 for the default mark
Return value
des& The remainder of the string from the mark& to the end of the string returned as a descriptor object
Error Handling

If the des& object cannot be created then an error is generated which should be trapped by an ONERR handler.


LexRemainderFromMarkStr

Usage

str$ = LexRemainderFromMaskStr$:(this&,mark)

Description

Returns the remainder of the string in the lexical buffer from the mark& to the end of the string.

Arguments
this& A handle to a lexical analyser object
mark& A handle to a lexical mark, or 0 for the default mark
Return value
str$ The remainder of the string from the mark& to the end of the string
Error Handling

If the str$ string cannot be created then an error is generated which should be trapped by an ONERR handler.


LexSkipAndMark

Usage

LexSkipAndMark:(this&,number&,mark&)

Description

Advances the character position number& character positions, or to the end of the string. The current position is set into the default mark.

Arguments
this& A handle to a lexical analyser object
number& The number of character position to skip
mark& A handle to a lexical mark, or 0 for the default mark

LexSkipCharacters

Usage

LexSkipCharacters:(this&)

Description

Advances the character position until the first whitespace character is encountered, or to the end of the string.

Arguments
this& A handle to a lexical analyser object

LexSkipSpace

Usage

LexSkipSpace:(this&)

Description

Advances the character position until the first non-whitespace character is encountered, or to the end of the string.

Arguments
this& A handle to a lexical analyser object

LexSkipSpaceAndMark

Usage

LexSkipSpaceandMark:(this&,mark&)

Description

Advances the character position until the first non-whitespace character is encountered, or to the end of the string. The current position is set into the default mark.

Arguments
this& A handle to a lexical analyser object
mark& A handle to a lexical mark, or 0 for the default mark

LexTokenLength

Usage

len& = LexTokenLength&:(this&,mark&)

Description

Returns the difference between the current character position and the default mark.

Arguments
this& A handle to a lexical analyser object
mark& A handle to a lexical mark, or 0 for the default mark
Return value
len& The length of the token

LexUnget

Usage

LexUnget:(this&)

Description

Decrements the current character position by one place.

Arguments
this& A handle to a lexical analyser object

LexUnGetToMark

Usage

LexUnGetToMark:(this&,mark&)

Description

Sets the current character position to the position of the current mark..

Arguments
this& A handle to a lexical analyser object
mark& A handle to a lexical mark, or 0 for the default mark

LexVal

Usage

result% = LexVal%:(this&,BYREF value&)

Description

<TBS>

Arguments
this& A handle to a lexical analyser object
BYREF value& Where the extracted signed integer value is placed
Return value
err% The error status of the conversion operation

LexValFloat

Usage

result% = LexValFloat%:(this&,BYREF value,point%)

Description

<TBS>

Arguments
this& A handle to a lexical analyser object
BYREF value Where the extracted floating point value is placed
point% The character to use for the decimal point
Return value
err% The error status of the conversion operation

LexValRadix

Usage

result% = LexValRadix%:(this&,BYREF value&,radix&)

Description

<TBS>

Arguments
this& A handle to a lexical analyser object
BYREF value& Where the extracted signed integer value is placed
radix& The radix to use in the conversion operation
Return value
err% The error status of the conversion operation

LexValRadixLimit

Usage

result% = LexValRadixLimit%:(this&,BYREF value&,radix&,limit&)

Description

<TBS>

Arguments
this& A handle to a lexical analyser object
BYREF value& Where the extracted signed integer value is placed
radix& The radix to use in the conversion operation
limit& The maximum value allowed
Return value
err% The error status of the conversion operation