diff --git a/src/asm/lexer.c b/src/asm/lexer.c index 138471ce..3d2bcf49 100644 --- a/src/asm/lexer.c +++ b/src/asm/lexer.c @@ -2026,7 +2026,7 @@ static int yylex_NORMAL(void) } } - if (tokenType == T_ID && lexerState->atLineStart) + if (tokenType == T_ID && (lexerState->atLineStart || peek(0) == ':')) return T_LABEL; return tokenType; diff --git a/test/asm/label-indent.asm b/test/asm/label-indent.asm new file mode 100644 index 00000000..2369196e --- /dev/null +++ b/test/asm/label-indent.asm @@ -0,0 +1,30 @@ + +SECTION "Label testing", WRAMX + + Lab: + .loc + Lab.loc2 + +; X = 0 +; ; Should not believe X is a label! +; IF X == 1 +; FAIL "Wrong!" +; ENDC +; X \ +; = 1 +; IF X != 1 +; FAIL "Wrong!" +; ENDC +; +; Y equ 42 +; PRINTT "Y={Y}\n" +; PURGE Y +; +; Y equs "mac" +; mac: MACRO +; PRINTT "\1\n" +; ENDM +; ; Should invoke macro Y, and not match "equ" due to the "a" behind it +; Y equates 69 +; Y equsquisite (isn't that English?) +; Y eq diff --git a/test/asm/label-indent.err b/test/asm/label-indent.err new file mode 100644 index 00000000..e69de29b diff --git a/test/asm/label-indent.out b/test/asm/label-indent.out new file mode 100644 index 00000000..e69de29b diff --git a/test/link/all-instructions.asm b/test/link/all-instructions.asm index 09cd3d53..4e321ffc 100644 --- a/test/link/all-instructions.asm +++ b/test/link/all-instructions.asm @@ -2,7 +2,7 @@ SECTION "All instructions", ROM0[0] ; 8-bit Arithmetic and Logic Instructions -alu_instruction_list : MACRO +alu_instruction_list: MACRO \1 a,a \1 a,b \1 a,c @@ -23,7 +23,7 @@ ENDM alu_instruction_list sub alu_instruction_list xor -incdec_8bit_instruction_list : MACRO +incdec_8bit_instruction_list: MACRO \1 a \1 b \1 c @@ -56,7 +56,7 @@ ENDM ; Bit Operations Instructions -bitop_u3_instruction_list : MACRO +bitop_u3_instruction_list: MACRO NBIT SET 0 REPT 8 \1 NBIT,a @@ -75,7 +75,7 @@ ENDM bitop_u3_instruction_list res bitop_u3_instruction_list set -bitop_noarg_instruction_list : MACRO +bitop_noarg_instruction_list: MACRO \1 a \1 b \1 c @@ -105,7 +105,7 @@ ENDM ; Load Instructions -ld_r8_x_instruction_list : MACRO +ld_r8_x_instruction_list: MACRO ld \1,a ld \1,b ld \1,c @@ -125,7 +125,7 @@ ENDM ld_r8_x_instruction_list [hl] ld_r8_x_instruction_list l -ld_x_r8_instruction_list : MACRO +ld_x_r8_instruction_list: MACRO ld a,\1 ld b,\1 ld c,\1