public virtual Token match(Token.TokenType expectedTokenType)
{
Token matchedToken = lookAhead(1);
if(lookAheadType(1) == expectedTokenType) {
#if WRITE_DEBUG_INFO
Console.WriteLine("MATCHED TOKEN " + lookAhead(1).getTokenString() + " (line " + lookAhead(1).LineNr + ")");
#endif
consumeCurrentToken();
} else {
#if WRITE_DEBUG_INFO
Console.WriteLine("FAILED TO MATCH TOKEN OF TYPE " + expectedTokenType.ToString() +
" ...FOUND " + lookAhead(1).getTokenString() + " (line " + lookAhead(1).LineNr + ")");
#endif
throw new Error(
"The code word '" + lookAhead(1).getTokenString() + "'" +
" does not compute. Expected " + expectedTokenType,
Error.ErrorType.SYNTAX,
lookAhead(1).LineNr,
lookAhead(1).LinePosition);
}
return matchedToken;
}