1
0
mirror of https://github.com/cc65/cc65.git synced 2024-06-09 06:29:38 +00:00

Added better error recovery

git-svn-id: svn://svn.cc65.org/cc65/trunk@2013 b7a2c559-68d2-44c3-8de9-860c34a00d81
This commit is contained in:
cuz 2003-03-13 12:35:54 +00:00
parent 467d8ad9c5
commit c8d76046cb

View File

@ -74,22 +74,40 @@ static void CheckTok (token_t Tok, const char* Msg, int* PendingToken)
*/
{
if (CurTok.Tok != Tok) {
Error (Msg);
Error (Msg);
} else if (PendingToken) {
*PendingToken = 1;
*PendingToken = 1;
} else {
NextToken ();
NextToken ();
}
}
static void CheckSemi (int* PendingToken)
/* Helper function for Statement. Will call CheckTok with the parameters
* for a semicolon.
/* Helper function for Statement. Will check for a semicolon and print an
* error message if not found (plus some error recovery). If PendingToken is
* NULL, it will the skip the token, otherwise it will store one to
* PendingToken.
* This function is a special version of CheckTok with the addition of the
* error recovery.
*/
{
CheckTok (TOK_SEMI, "`;' expected", PendingToken);
int HaveToken = (CurTok.Tok == TOK_SEMI);
if (!HaveToken) {
Error ("`;' expected");
/* Try to be smart about errors */
if (CurTok.Tok == TOK_COLON || CurTok.Tok == TOK_COMMA) {
HaveToken = 1;
}
}
if (HaveToken) {
if (PendingToken) {
*PendingToken = 1;
} else {
NextToken ();
}
}
}