From 500b86f1e2cee70737dd5917810dee0a295db8d4 Mon Sep 17 00:00:00 2001 From: Kugel Fuhr <98353208+kugelfuhr@users.noreply.github.com> Date: Fri, 4 Jul 2025 14:56:20 +0200 Subject: [PATCH] Improve error recovery. --- src/ca65/main.c | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/src/ca65/main.c b/src/ca65/main.c index cb06ca631..60f342567 100644 --- a/src/ca65/main.c +++ b/src/ca65/main.c @@ -853,26 +853,23 @@ static void OneLine (void) Seg = ActiveSeg; PC = GetPC (); - /* Define the label */ - SymDef (Sym, GenCurrentPC (), ADDR_SIZE_DEFAULT, SF_LABEL); - /* Skip the colon. If NoColonLabels is enabled, allow labels ** without a colon if there is no whitespace before the ** identifier. */ if (CurTok.Tok != TOK_COLON) { if (HadWS || !NoColonLabels) { - Error ("Expected ':' after identifier to form a label"); - /* Try some smart error recovery */ - if (CurTok.Tok == TOK_NAMESPACE) { - NextTok (); - } + ErrorSkip ("Expected ':' after identifier to form a label"); + goto Done; } } else { /* Skip the colon */ NextTok (); } + /* Define the label */ + SymDef (Sym, GenCurrentPC (), ADDR_SIZE_DEFAULT, SF_LABEL); + /* If we come here, a new identifier may be waiting, which may ** be a macro or instruction. */ @@ -907,8 +904,8 @@ static void OneLine (void) } else if (PCAssignment && (CurTok.Tok == TOK_STAR || CurTok.Tok == TOK_PC)) { NextTok (); if (CurTok.Tok != TOK_EQ) { - Error ("'=' expected"); - SkipUntilSep (); + ErrorSkip ("'=' expected"); + goto Done; } else { /* Skip the equal sign */ NextTok (); @@ -938,6 +935,7 @@ static void OneLine (void) } } +Done: /* Line separator must come here */ ConsumeSep (); }