From e2136d60b2db6c714a0c7c84f38bbcad5c519b71 Mon Sep 17 00:00:00 2001 From: Eldred Habert Date: Mon, 3 Oct 2022 16:50:32 +0200 Subject: [PATCH] Print a more user-friendly error message for leftover diff marks (#1089) --- src/asm/parser.y | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/src/asm/parser.y b/src/asm/parser.y index ee9bb9de..21d6a536 100644 --- a/src/asm/parser.y +++ b/src/asm/parser.y @@ -690,17 +690,19 @@ asmfile : lines ; lines : %empty - | lines line + | lines opt_diff_mark line ; endofline : T_NEWLINE | T_EOB ; -plain_directive : label - | label cpu_command - | label macro - | label directive - | assignment_directive +opt_diff_mark : %empty // OK + | T_OP_ADD { + error("syntax error, unexpected + at the beginning of the line (is it a leftover diff mark?)\n"); + } + | T_OP_SUB { + error("syntax error, unexpected - at the beginning of the line (is it a leftover diff mark?)\n"); + } ; line : plain_directive endofline @@ -786,6 +788,13 @@ else : T_POP_ELSE T_NEWLINE { } ; +plain_directive : label + | label cpu_command + | label macro + | label directive + | assignment_directive +; + endc : T_POP_ENDC { lexer_DecIFDepth(); }