Skip to content

Commit

Permalink
Warn about leftover merge conflict markers
Browse files Browse the repository at this point in the history
  • Loading branch information
Rangi42 committed Oct 22, 2024
1 parent f048cbb commit c6e6b46
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 1 deletion.
19 changes: 19 additions & 0 deletions src/asm/parser.y
Original file line number Diff line number Diff line change
Expand Up @@ -420,10 +420,29 @@ diff_mark:
}
;

merge_conflict:
OP_SHL OP_SHL OP_SHL OP_LOGICLT {
::error(
"syntax error, unexpected <<<<<<< line (is it a leftover merge conflict mark?)\n"
);
}
| OP_USHR OP_USHR OP_LOGICGT {
::error(
"syntax error, unexpected >>>>>>> line (is it a leftover merge conflict mark?)\n"
);
}
| OP_LOGICEQU OP_LOGICEQU OP_LOGICEQU POP_EQUAL {
::error(
"syntax error, unexpected ======= line (is it a leftover merge conflict mark?)\n"
);
}
;

// Lines and line directives.

line:
plain_directive endofline
| merge_conflict endofline
| line_directive // Directives that manage newlines themselves
// Continue parsing the next line on a syntax error
| error {
Expand Down
7 changes: 7 additions & 0 deletions test/asm/diff-marks.asm
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
SECTION "test", ROM0
- ld a, 0
+ xor a
<<<<<<<
ld a, 0
=======
xor a
>>>>>>>
+<<<<<<<
->>>>>>>
16 changes: 15 additions & 1 deletion test/asm/diff-marks.err
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,18 @@ error: diff-marks.asm(2):
syntax error, unexpected - at the beginning of the line (is it a leftover diff mark?)
error: diff-marks.asm(3):
syntax error, unexpected + at the beginning of the line (is it a leftover diff mark?)
error: Assembly aborted (2 errors)!
error: diff-marks.asm(4):
syntax error, unexpected <<<<<<< line (is it a leftover merge conflict mark?)
error: diff-marks.asm(6):
syntax error, unexpected ======= line (is it a leftover merge conflict mark?)
error: diff-marks.asm(8):
syntax error, unexpected >>>>>>> line (is it a leftover merge conflict mark?)
error: diff-marks.asm(9):
syntax error, unexpected + at the beginning of the line (is it a leftover diff mark?)
error: diff-marks.asm(9):
syntax error, unexpected <<<<<<< line (is it a leftover merge conflict mark?)
error: diff-marks.asm(10):
syntax error, unexpected - at the beginning of the line (is it a leftover diff mark?)
error: diff-marks.asm(10):
syntax error, unexpected >>>>>>> line (is it a leftover merge conflict mark?)
error: Assembly aborted (9 errors)!

0 comments on commit c6e6b46

Please sign in to comment.