ITokenReader Interface
Provides the base requirements for an object that can provide tokens to a ILLParser in a forward-only direction.
public interface ITokenReader
Properties
IsAtEnd
Gets whether the current IToken is at the end of the text buffer.
bool IsAtEnd { get; }
Property Value
IsParserInErrorState
Gets or sets whether the parser is currently recovering from an error state.
bool IsParserInErrorState { get; set; }
Property Value
- bool:
true
if the parser is currently recovering from an error state; otherwise,false
.
LookAheadToken
Returns the IToken that is immediately after the current token.
IToken LookAheadToken { get; }
Property Value
Offset
Gets the current offset, which is offset after the last Token that was read.
int Offset { get; }
Property Value
StackLevel
Token
Gets the current IToken.
Methods
Advance()
Advances to the next IToken.
void Advance()
AdvanceTo(int)
Advances to the next IToken with the specified ID, such that the LookAheadToken property will be pointing to the matched token, if any.
bool AdvanceTo(int tokenId)
Parameter | Type | Description |
---|---|---|
tokenId | int | The ID of IToken for which to search. |
Returns
Remarks
If this method is successful, the LookAheadToken will be the IToken that was located.
AdvanceTo(params int[])
Advances to the next IToken with one of the specified IDs, such that the LookAheadToken property will be pointing to the matched token, if any.
bool AdvanceTo(params int[] tokenIds)
Parameter | Type | Description |
---|---|---|
tokenIds | int[] | The array of IToken IDs for which to search. |
Returns
Remarks
If this method is successful, the LookAheadToken will be the IToken that was located.
AreNext(params int[])
Returns whether the next look-ahead tokens match the specified sequence of token IDs.
bool AreNext(params int[] tokenIds)
Parameter | Type | Description |
---|---|---|
tokenIds | int[] | The sequence of token IDs for which to search. |
Returns
- bool:
true
if the next look-ahead tokens match the specified sequence of token IDs; otherwise,false
.
Remarks
This method is very useful within can-match callbacks that require two or more token look-aheads.
GetLookAheadToken(int)
Returns the IToken that is the specified number of positions past the current token.
IToken GetLookAheadToken(int count)
Parameter | Type | Description |
---|---|---|
count | int | The number of positions past the current token to examine. |
Returns
Remarks
A parameter value of 1
will return the value of the LookAheadToken method without actually seeking past the next token.
GetTokenText(IToken)
string GetTokenText(IToken targetToken)
Parameter | Type | Description |
---|---|---|
targetToken | IToken | The IToken to examine. |
Returns
Initialize()
Initializes the token reader, which will be called by a ILLParser before the token reader is used.
void Initialize()
OffsetToPosition(int)
Returns the TextPosition that represents the specified offset within the text lines.
TextPosition OffsetToPosition(int offset)
Parameter | Type | Description |
---|---|---|
offset | int | The offset of a character within the snapshot. |
Returns
- TextPosition:
The TextPosition that represents the specified offset within the text lines.
Pop()
Pops the top token reader state from the stack and restores the token reader to that state.
Push()
Pushes the token reader state onto a stack for later restoration, generally to begin a multiple token look-ahead operation.