
Hi Team (Using: V2017.1 Build 0651),
I have a question about fixing ambiguity between 2 of my production rules using CanMatch Callbacks.
In the following CanMatch callback I have the issue that I cannot Advance the TokenReader to the end of the "non-terminal", I can only advance from token to token but I can never know when my complex variableExpression "non-terminal" finishes.
Yet, the call to "variableExpression.CanMatch(state)" actualy goes through the token reader until the end without a problem but does not return any info about the end offset or the token located at the end of the "non-terminal". This info is critical for me as I need it so that I may continue my tokenReader advancements to the correct Token.
private bool CanMatchAssignmentStatement(IParserState state)
{
state.TokenReader.Push();
try
{
// My variableExpression is a non-terminal
if (variableExpression.CanMatch(state))
{
// This only advances to the next token within the varaibelExpression non-terminal.
// What I need is to advance to the last token at the end of the "variableExpression"
// matched non-terminal.
state.TokenReader.Advance();
if (state.TokenReader.LookAheadToken.Id == StTokenId.EqualityOperatorEqual)
{
state.TokenReader.Advance();
if (expression.CanMatch(state))
{
return true;
}
}
}
return false;
}
finally
{
state.TokenReader.Pop();
}
}
Ideally what I am looking for is a "state.TokenReader.Advance("non-terminal");" Basically saying to advance the token reader to last Token at the end of the matching non-terminal.
*Note: Just to let you know variableExpression is way to complex for me to breakup into TokenIDs and perform advance on those, so please don't propose me to advance by searching TokenIds
Thank you
Nassim F.
[Modified 6 years ago]