-
-
Notifications
You must be signed in to change notification settings - Fork 177
Disable EQUS
expansion for raw symbols (by lexing them as strings)
#1649
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -1104,7 +1104,9 @@ Additionally, label names can contain up to a single dot | |||||||||||||
.Ql \&. , | ||||||||||||||
which may not be the first character. | ||||||||||||||
.Pp | ||||||||||||||
A symbol cannot have the same name as a reserved keyword, unless it is prefixed by a hash | ||||||||||||||
A symbol cannot have the same name as a reserved keyword, unless it is a | ||||||||||||||
.Dq raw symbol | ||||||||||||||
prefixed by a hash | ||||||||||||||
.Sq # . | ||||||||||||||
For example, | ||||||||||||||
.Ql #load | ||||||||||||||
|
@@ -1387,6 +1389,8 @@ This expansion is disabled in a few contexts: | |||||||||||||
and | ||||||||||||||
.Ql MACRO name | ||||||||||||||
will not expand string constants in their names. | ||||||||||||||
Expansion is also disabled for raw string constant symbols (string constant symbols prefixed by a hash | ||||||||||||||
.Sq # ) . | ||||||||||||||
Comment on lines
+1392
to
+1393
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In the vein of my previous comment:
Suggested change
|
||||||||||||||
.Bd -literal -offset indent | ||||||||||||||
DEF COUNTREG EQUS "[hl+]" | ||||||||||||||
ld a, COUNTREG | ||||||||||||||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
error: def-scoped.asm(10): | ||
syntax error, unexpected local label, expecting symbol | ||
syntax error, unexpected local label, expecting symbol or string symbol | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hmm... this sounds confusing. “Why is it expecting a symbol or a symbol?” There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah, this is one reason why I prefer #1648 as well. |
||
error: def-scoped.asm(13): | ||
syntax error, unexpected local label, expecting symbol | ||
syntax error, unexpected local label, expecting symbol or string symbol | ||
error: def-scoped.asm(16): | ||
syntax error, unexpected local label, expecting symbol | ||
syntax error, unexpected local label, expecting symbol or string symbol | ||
error: Assembly aborted (3 errors)! |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
def n equ 42 | ||
def s equs "hello" | ||
macro m | ||
endm | ||
|
||
assert (#n) == 42 | ||
assert (#s) == $656c6c6f | ||
assert (#m) == 0 | ||
assert (#u) == 0 | ||
|
||
assert strlen(#n) == 0 | ||
assert strlen(#s) == 5 | ||
assert strlen(#m) == 0 | ||
assert strlen(#u) == 0 | ||
|
||
def d_n = (#n) | ||
def d_s = (#s) | ||
def d_m = (#m) | ||
def d_u = (#u) | ||
|
||
def s_n equs #n | ||
def s_s equs #s | ||
def s_m equs #m | ||
def s_u equs #u | ||
|
||
purge #s | ||
purge #s | ||
assert (#s) == 0 | ||
assert strlen(#s) == 0 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
warning: raw-string-symbol-errors.asm(7): [-Wobsolete] | ||
Treating multi-unit strings as numbers is deprecated | ||
error: raw-string-symbol-errors.asm(8): | ||
'm' is not a numeric symbol | ||
error: raw-string-symbol-errors.asm(11): | ||
syntax error, unexpected symbol | ||
error: raw-string-symbol-errors.asm(13): | ||
syntax error, unexpected symbol | ||
error: raw-string-symbol-errors.asm(14): | ||
syntax error, unexpected symbol | ||
warning: raw-string-symbol-errors.asm(17): [-Wobsolete] | ||
Treating multi-unit strings as numbers is deprecated | ||
error: raw-string-symbol-errors.asm(18): | ||
'm' is not a numeric symbol | ||
error: raw-string-symbol-errors.asm(19): | ||
Expected constant expression: 'u' is not constant at assembly time | ||
error: raw-string-symbol-errors.asm(21): | ||
syntax error, unexpected symbol | ||
error: raw-string-symbol-errors.asm(23): | ||
syntax error, unexpected symbol | ||
error: raw-string-symbol-errors.asm(24): | ||
syntax error, unexpected symbol | ||
error: raw-string-symbol-errors.asm(27): | ||
's' was already purged | ||
error: raw-string-symbol-errors.asm(29): | ||
syntax error, unexpected symbol | ||
error: Assembly aborted (11 errors)! |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
opt Wno-unmapped-char | ||
|
||
def hello equs "world" | ||
def name equs "hello" | ||
println "{name}" | ||
println #name | ||
assert !strcmp(strsub(#name, 1, 4), "hell") | ||
assert strlen(#hello) == charlen(#hello) | ||
assert strlen("{hello}") == 5 | ||
|
||
def multi equs """the quick | ||
brown fox""" | ||
println #multi | ||
|
||
def char equs "A" | ||
def n = #char | ||
println n | ||
def n = (#char) | ||
println n | ||
def n = 1 + #char | ||
println n | ||
assert #char == $41 | ||
|
||
def fmt equs "%s %s %d" | ||
println strfmt(#fmt, #name, #hello, (#char)) | ||
|
||
purge #name | ||
assert !def(name) && !def(#name) && def(hello) | ||
|
||
section "test", rom0 | ||
#label: | ||
db #hello | ||
dw #hello | ||
dw BANK(#label), #label |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
hello | ||
hello | ||
the quick | ||
brown fox | ||
$41 | ||
$41 | ||
$42 | ||
hello world 65 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
error: syntax-error-lexer-mode.asm(7): | ||
syntax error, unexpected af | ||
error: syntax-error-lexer-mode.asm(11): | ||
syntax error, unexpected af, expecting symbol | ||
syntax error, unexpected af, expecting symbol or string symbol | ||
error: Assembly aborted (2 errors)! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this should be more explicit that “raw symbol” means “prefixed with a hash”.
I'm also realising that “raw identifier” is a better name, since it might not be referring to a symbol yet? (And identifiers are names for symbols. I'd be fine with calling those “raw names”, if that sounds better than “identifier”.)