Allow NUL characters in strings (#1405)

This commit is contained in:
Sylvie
2024-06-18 14:26:18 -04:00
committed by GitHub
parent 9cc595b2cc
commit 623c3f662c
15 changed files with 91 additions and 37 deletions

View File

@@ -0,0 +1,12 @@
MACRO echo
print "\#"
ENDM
; '\0' can be printed like any other character
print "hello\0world\0"
echo left\0right\0
SECTION "test", ROM0
; '\0' can be included in ROM like any other character
db "foo\0bar", 0
charmap "a\0b", $42
db "a\0b\0"

View File

@@ -0,0 +1,2 @@
warning: null-character.asm(12): [-Wunmapped-char]
Unmapped character '\0'

BIN
test/asm/null-character.out Normal file

Binary file not shown.

Binary file not shown.

View File

@@ -1,3 +1,3 @@
error: null-in-macro.asm(4) -> null-in-macro.asm::foo(2):
Unknown character 0x00
Unknown character '\0'
error: Assembly aborted (1 error)!

View File

@@ -0,0 +1,7 @@
SECTION "test", ROM0
; '\0' is not special here; it's lexed as a line continuation...
DEF foo\0bar EQU 42
db foo\0bar
; ...just like any other non-whitespace character
DEF spam\Xeggs EQU 69
db spam\Xeggs

View File

@@ -0,0 +1,17 @@
error: null-outside-string.asm(3):
Begun line continuation, but encountered character '0'
error: null-outside-string.asm(3):
syntax error, unexpected number
error: null-outside-string.asm(4):
Begun line continuation, but encountered character '0'
error: null-outside-string.asm(4):
syntax error, unexpected number
error: null-outside-string.asm(6):
Begun line continuation, but encountered character 'X'
error: null-outside-string.asm(6):
syntax error, unexpected identifier
error: null-outside-string.asm(7):
Begun line continuation, but encountered character 'X'
error: null-outside-string.asm(7):
syntax error, unexpected identifier
error: Assembly aborted (8 errors)!

View File

@@ -1,2 +1,2 @@
def x\0 = 10
def x\<0> = 10
println x

View File

@@ -1,3 +1,3 @@
error: symbol-invalid-macro-arg.asm(1):
Invalid macro argument '\0'
Invalid bracketed macro argument '\<0>'
error: Assembly aborted (1 error)!