Skip to content

Commit

Permalink
Remove column 1 restriction for labels with colons
Browse files Browse the repository at this point in the history
Partial fix for #457
  • Loading branch information
ISSOtm committed Feb 21, 2021
1 parent a6d844a commit 43dcd01
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/asm/lexer.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
30 changes: 30 additions & 0 deletions test/asm/label-indent.asm
Original file line number Diff line number Diff line change
@@ -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
Empty file added test/asm/label-indent.err
Empty file.
Empty file added test/asm/label-indent.out
Empty file.
12 changes: 6 additions & 6 deletions test/link/all-instructions.asm
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down

0 comments on commit 43dcd01

Please sign in to comment.