mirror of
https://github.com/cc65/cc65.git
synced 2025-01-03 16:33:19 +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:
parent
467d8ad9c5
commit
c8d76046cb
@ -74,22 +74,40 @@ static void CheckTok (token_t Tok, const char* Msg, int* PendingToken)
|
|||||||
*/
|
*/
|
||||||
{
|
{
|
||||||
if (CurTok.Tok != Tok) {
|
if (CurTok.Tok != Tok) {
|
||||||
Error (Msg);
|
Error (Msg);
|
||||||
} else if (PendingToken) {
|
} else if (PendingToken) {
|
||||||
*PendingToken = 1;
|
*PendingToken = 1;
|
||||||
} else {
|
} else {
|
||||||
NextToken ();
|
NextToken ();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
static void CheckSemi (int* PendingToken)
|
static void CheckSemi (int* PendingToken)
|
||||||
/* Helper function for Statement. Will call CheckTok with the parameters
|
/* Helper function for Statement. Will check for a semicolon and print an
|
||||||
* for a semicolon.
|
* 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 ();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user