Remove column 1 restriction for labels with colons (#635)

Partial fix for #457
This commit is contained in:
Eldred Habert
2021-02-23 20:42:24 +01:00
committed by GitHub
parent 929e2a4490
commit dafef5a953
5 changed files with 37 additions and 7 deletions

View File

@@ -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 T_LABEL;
return tokenType; return tokenType;

30
test/asm/label-indent.asm Normal file
View File

@@ -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

View File

View File

View File

@@ -2,7 +2,7 @@ SECTION "All instructions", ROM0[0]
; 8-bit Arithmetic and Logic Instructions ; 8-bit Arithmetic and Logic Instructions
alu_instruction_list : MACRO alu_instruction_list: MACRO
\1 a,a \1 a,a
\1 a,b \1 a,b
\1 a,c \1 a,c
@@ -23,7 +23,7 @@ ENDM
alu_instruction_list sub alu_instruction_list sub
alu_instruction_list xor alu_instruction_list xor
incdec_8bit_instruction_list : MACRO incdec_8bit_instruction_list: MACRO
\1 a \1 a
\1 b \1 b
\1 c \1 c
@@ -56,7 +56,7 @@ ENDM
; Bit Operations Instructions ; Bit Operations Instructions
bitop_u3_instruction_list : MACRO bitop_u3_instruction_list: MACRO
NBIT SET 0 NBIT SET 0
REPT 8 REPT 8
\1 NBIT,a \1 NBIT,a
@@ -75,7 +75,7 @@ ENDM
bitop_u3_instruction_list res bitop_u3_instruction_list res
bitop_u3_instruction_list set bitop_u3_instruction_list set
bitop_noarg_instruction_list : MACRO bitop_noarg_instruction_list: MACRO
\1 a \1 a
\1 b \1 b
\1 c \1 c
@@ -105,7 +105,7 @@ ENDM
; Load Instructions ; Load Instructions
ld_r8_x_instruction_list : MACRO ld_r8_x_instruction_list: MACRO
ld \1,a ld \1,a
ld \1,b ld \1,b
ld \1,c ld \1,c
@@ -125,7 +125,7 @@ ENDM
ld_r8_x_instruction_list [hl] ld_r8_x_instruction_list [hl]
ld_r8_x_instruction_list l ld_r8_x_instruction_list l
ld_x_r8_instruction_list : MACRO ld_x_r8_instruction_list: MACRO
ld a,\1 ld a,\1
ld b,\1 ld b,\1
ld c,\1 ld c,\1