shithub: rgbds

Download patch

ref: e2136d60b2db6c714a0c7c84f38bbcad5c519b71
parent: 74e40654e64f321399f3e2bb04019f83c96ce6fa
author: Eldred Habert <eldredhabert0@gmail.com>
date: Mon Oct 3 12:50:32 EDT 2022

Print a more user-friendly error message for leftover diff marks (#1089)

--- a/src/asm/parser.y
+++ b/src/asm/parser.y
@@ -690,17 +690,19 @@
 ;
 
 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
@@ -784,6 +786,13 @@
 				lexer_ReachELSEBlock();
 			}
 		}
+;
+
+plain_directive	: label
+		| label cpu_command
+		| label macro
+		| label directive
+		| assignment_directive
 ;
 
 endc		: T_POP_ENDC {