Libraries.Language.Compile.Parsing.TokenIterator Documentation

This class iterates over a token stream and provides helper operations in doing so.

Inherits from: Libraries.Language.Object, Libraries.Containers.Iterator

Actions Documentation

Compare(Libraries.Language.Object object)

This action compares two object hash codes and returns an integer. The result is larger if this hash code is larger than the object passed as a parameter, smaller, or equal. In this case, -1 means smaller, 0 means equal, and 1 means larger. This action was changed in Quorum 7 to return an integer, instead of a CompareResult object, because the previous implementation was causing efficiency issues.

Parameters

Return

integer: The Compare result, Smaller, Equal, or Larger.

Example

Object o
Object t
integer result = o:Compare(t) //1 (larger), 0 (equal), or -1 (smaller)

Copy()

This action copies the iterator. This copy is shallow, meaning it does not copy the tokens involved and instead is used to provide more complex lookahead situations where we want to preserve the original iterator.

Return

Libraries.Language.Compile.Parsing.TokenIterator:

Equals(Libraries.Language.Object object)

This action determines if two objects are equal based on their hash code values.

Parameters

Return

boolean: True if the hash codes are equal and false if they are not equal.

Example

use Libraries.Language.Object
use Libraries.Language.Types.Text
Object o
Text t
boolean result = o:Equals(t)

FindRecentDocumentation()

This action finds the most recent documentation token.

Return

Libraries.Language.Compile.Parsing.Token:

GetChannelToRead()

This gets which channel we are going to work on.

Return

integer:

GetCurrent()

This action gets the current item and does not move onto the next item to be iterated over.

Return

Libraries.Language.Object: Returns the object.

GetHashCode()

This action gets the hash code for an object.

Return

integer: The integer hash code of the object.

Example

Object o
integer hash = o:GetHashCode()

GetLexer()

This returns the lexer we are working on.

Return

Libraries.Language.Compile.Parsing.Lexer:

HasNext()

This action determines if there is a next item in the iteration.

Return

boolean: true if there is a next item and false if there is not.

IsReadingAllChannels()

This determines whether or not we are counting all tokens as part of the source stream or skipping.

Return

boolean:

IsRecentDocumentationFirstTokenOnly()

This is a deprecated helper action that was used for testing comparisons to Antlr.

Return

boolean:

IsValid()

Returns whether the current token has a valid index.

Return

boolean: true if the current token is at a valid index.

Look(integer bump)

This action looks ahead or behind in the token stream and returns a token if one is found. The token returned is the one on the same channel currently being read.

Parameters

  • integer bump

Return

Libraries.Language.Object:

LookAhead(integer bump)

This action looks ahead in the token stream and returns a token if one is found. The token returned is the one on the same channel currently being read.

Parameters

  • integer bump

Return

Libraries.Language.Object:

Next()

This action gets the next item in the iteration and continues the iteration.

Return

Libraries.Language.Object: Returns the object if it is valid and undefined otherwise.

Rewind()

This action starts the iteration over from the beginning.

SetChannelToRead(integer channelToRead)

This sets which channel we are going to work on.

Parameters

  • integer channelToRead

SetLexer(Libraries.Language.Compile.Parsing.Lexer lexer)

This sets the lexer we are working on.

Parameters

SetReadingAllChannels(boolean readAllChannels)

This sets whether or not we are counting all tokens as part of the source stream or skipping.

Parameters

  • boolean readAllChannels