-
-
Notifications
You must be signed in to change notification settings - Fork 172
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Don't treat labels and macros differently in column 1
Fixes #1512
- Loading branch information
Showing
7 changed files
with
69 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
MACRO mac | ||
println "got {d:_NARG} args: \#" | ||
ENDM | ||
|
||
; indented, these were always macro invocations | ||
mac | ||
mac ro | ||
mac : ld a, 1 | ||
|
||
; in column 1, we historically treated these as labels | ||
mac | ||
mac ro | ||
mac : ld b, 2 | ||
|
||
SECTION "test", ROM0 | ||
|
||
; a colon makes these into labels | ||
Label1: ld c, 3 | ||
Label2: ld d, 4 | ||
|
||
; a macro invocation when already defined as a label | ||
Label1 args | ||
; and a label definition when already defined as a macro | ||
mac: ld e, 5 | ||
|
||
; the space before the colon matters! | ||
undef : | ||
undef : |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
error: lexer-hack.asm(22): | ||
"Label1" is not a macro | ||
error: lexer-hack.asm(24): | ||
'mac' already defined at lexer-hack.asm(1) | ||
error: lexer-hack.asm(27): | ||
Macro "undef" not defined | ||
error: lexer-hack.asm(28): | ||
Macro "undef" not defined | ||
error: Assembly aborted (4 errors)! |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
got 0 args: | ||
got 1 args: ro | ||
got 2 args: : ld a,1 | ||
got 0 args: | ||
got 1 args: ro | ||
got 2 args: : ld b,2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,11 @@ | ||
MACRO mac | ||
println "got {d:_NARG} args" | ||
ENDM | ||
mac | ||
mac 42 | ||
notmac | ||
mac | ||
mac 42 | ||
mac:: | ||
mac :: | ||
def x = 1 ; so far so good... | ||
def n equ 2 + * / ^ 3 ; oops | ||
def s equs "no closing quote, lol | ||
section "test", rom0 ; good again | ||
ld a, 42 ; keep going... | ||
ld xor, ret ; oh no :( | ||
label1: ; yes... | ||
label2:: ; yes... | ||
label3::: ; no! | ||
halt stop abort ; please | ||
println "finally!" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,11 @@ | ||
error: syntax-error-after-syntax-error.asm(2): | ||
syntax error, unexpected * | ||
error: syntax-error-after-syntax-error.asm(3): | ||
Unterminated string | ||
error: syntax-error-after-syntax-error.asm(6): | ||
syntax error, unexpected newline, expecting : or :: | ||
error: syntax-error-after-syntax-error.asm(7): | ||
syntax error, unexpected newline, expecting : or :: | ||
To invoke `mac` as a macro it must be indented | ||
error: syntax-error-after-syntax-error.asm(8): | ||
syntax error, unexpected number, expecting : or :: | ||
To invoke `mac` as a macro it must be indented | ||
syntax error, unexpected xor | ||
error: syntax-error-after-syntax-error.asm(9): | ||
'mac' already defined at syntax-error-after-syntax-error.asm(1) | ||
syntax error, unexpected : | ||
error: syntax-error-after-syntax-error.asm(10): | ||
'mac' already defined at syntax-error-after-syntax-error.asm(1) | ||
syntax error, unexpected stop, expecting newline or end of buffer or :: | ||
error: Assembly aborted (5 errors)! |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1 @@ | ||
got 0 args | ||
got 1 args | ||
finally! |