public Execute ( Lexer lexer, ICharStream input, int startIndex ) : void | ||
lexer | Lexer | The lexer instance. |
input | ICharStream |
/// The input stream which is the source for the current token.
/// When this method is called, the current
/// |
startIndex | int |
/// The token start index. This value may be passed to
/// |
return | void |
public virtual void Execute(Lexer lexer, ICharStream input, int startIndex)
{
bool requiresSeek = false;
int stopIndex = input.Index;
try
{
foreach (ILexerAction lexerAction in lexerActions)
{
ILexerAction action = lexerAction;
if (action is LexerIndexedCustomAction)
{
int offset = ((LexerIndexedCustomAction)action).Offset;
input.Seek(startIndex + offset);
action = ((LexerIndexedCustomAction)action).Action;
requiresSeek = (startIndex + offset) != stopIndex;
}
else
{
if (action.IsPositionDependent)
{
input.Seek(stopIndex);
requiresSeek = false;
}
}
action.Execute(lexer);
}
}
finally
{
if (requiresSeek)
{
input.Seek(stopIndex);
}
}
}
protected internal virtual void Accept(ICharStream input, LexerActionExecutor lexerActionExecutor, int startIndex, int index, int line, int charPos) { // seek to after last char in token input.Seek(index); this._line = line; this.charPositionInLine = charPos; if (lexerActionExecutor != null && recog != null) { lexerActionExecutor.Execute(recog, input, startIndex); } }