Implement . string constant for the current label scope (#1499)

This commit is contained in:
Sylvie
2024-09-13 15:20:01 -04:00
committed by GitHub
parent bfb96b038d
commit 122ef95d9c
15 changed files with 133 additions and 23 deletions

View File

@@ -11,5 +11,23 @@ REDEF _NARG = 78
DEF _NARG EQUS "hello"
REDEF _NARG EQUS "world"
SECTION "test", ROM0
SECTION "_NARG", ROM0
_NARG:
ENDSECTION
ASSERT !DEF(.)
PURGE .
DEF . EQU 12
REDEF . EQU 34
DEF . = 56
REDEF . = 78
DEF . EQUS "hello"
REDEF . EQUS "world"
SECTION ".", ROM0
.:
ENDSECTION

View File

@@ -14,4 +14,20 @@ error: builtin-reserved.asm(12):
'_NARG' is reserved for a built-in symbol
error: builtin-reserved.asm(15):
'_NARG' is reserved for a built-in symbol
error: Assembly aborted (8 errors)!
error: builtin-reserved.asm(20):
'.' not defined
error: builtin-reserved.asm(22):
'.' is reserved for a built-in symbol
error: builtin-reserved.asm(23):
'.' is reserved for a built-in symbol
error: builtin-reserved.asm(25):
'.' is reserved for a built-in symbol
error: builtin-reserved.asm(26):
'.' is reserved for a built-in symbol
error: builtin-reserved.asm(28):
'.' is reserved for a built-in symbol
error: builtin-reserved.asm(29):
'.' is reserved for a built-in symbol
error: builtin-reserved.asm(32):
"." has no value outside of a label scope
error: Assembly aborted (16 errors)!

12
test/asm/label-scope.asm Normal file
View File

@@ -0,0 +1,12 @@
ASSERT !DEF(@) && !DEF(.)
PURGE @, .
SECTION "test", ROM0[42]
Foobar:
PURGE @, .
ASSERT DEF(@) && DEF(.) && DEF(Foobar)
PRINTLN "PC: {#05X:@}; label scope: \"{.}\"; {.}: {#05X:{.}}"

9
test/asm/label-scope.err Normal file
View File

@@ -0,0 +1,9 @@
error: label-scope.asm(3):
'@' not defined
error: label-scope.asm(3):
'.' not defined
error: label-scope.asm(8):
Built-in symbol '@' cannot be purged
error: label-scope.asm(8):
Built-in symbol '.' cannot be purged
error: Assembly aborted (4 errors)!

1
test/asm/label-scope.out Normal file
View File

@@ -0,0 +1 @@
PC: $002A; label scope: "Foobar"; Foobar: $002A

View File

@@ -2,4 +2,5 @@ section "period", rom0
global1: db 1
.local db 2
. db 3
. db 3 ; this...
global1 db 4 ; ...expands to this

View File

@@ -1,3 +1,5 @@
error: period.asm(5):
syntax error, unexpected .
error: Assembly aborted (1 error)!
syntax error, unexpected DB, expecting : or ::
error: period.asm(6):
syntax error, unexpected DB, expecting : or ::
error: Assembly aborted (2 errors)!

View File

@@ -3,6 +3,11 @@ assert !DEF(@)
println @
println "{@}?"
; not inside a label scope
assert !DEF(.)
println .
println "{.}?"
; not inside a macro
assert !DEF(_NARG)
println _NARG
@@ -13,6 +18,11 @@ assert DEF(@)
println @
println "{@}!"
LabelScope:
assert DEF(.)
println .
println "{.}!"
MACRO m
assert DEF(_NARG)
println _NARG

View File

@@ -3,7 +3,11 @@ error: undefined-builtins.asm(3):
error: undefined-builtins.asm(4):
Interpolated symbol "@" does not exist
error: undefined-builtins.asm(8):
_NARG has no value outside of a macro
"." has no value outside of a label scope
error: undefined-builtins.asm(9):
Interpolated symbol "." does not exist
error: undefined-builtins.asm(13):
_NARG has no value outside of a macro
error: undefined-builtins.asm(14):
Interpolated symbol "_NARG" does not exist
error: Assembly aborted (4 errors)!
error: Assembly aborted (6 errors)!

View File

@@ -1,8 +1,12 @@
$0
?
?
$0
?
$42
$42!
$42
LabelScope!
$3
$3!