Make failed macro arg expansions non-fatal

Expanding empty strings is valid but pointless;
macro args already skipped doing so, now other
`beginExpansion` calls do too.

This also fixes failed interpolations (which were
already non-fatal) to continue reading characters,
not evaluate to their initial '{' character.
This commit is contained in:
Rangi
2021-04-20 11:51:01 -04:00
committed by Eldred Habert
parent 1aeaca2af6
commit e596dbfc80
13 changed files with 84 additions and 50 deletions

View File

@@ -5,5 +5,8 @@ ERROR: interpolation-overflow.asm(4):
warning: interpolation-overflow.asm(4): [-Wlarge-constant]
Precision of fixed-point constant is too large
while expanding symbol "0.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"
FATAL: interpolation-overflow.asm(4):
ERROR: interpolation-overflow.asm(4):
Macro argument '\1' not defined
ERROR: interpolation-overflow.asm(4):
syntax error, unexpected number
error: Assembly aborted (4 errors)!

View File

@@ -1,2 +1,3 @@
FATAL: invalid-empty-macro-arg.asm(1):
ERROR: invalid-empty-macro-arg.asm(1):
Empty bracketed macro argument
error: Assembly aborted (1 error)!

View File

@@ -1,2 +1,5 @@
FATAL: invalid-macro-arg-character.asm(1):
ERROR: invalid-macro-arg-character.asm(1):
Invalid character in bracketed macro argument '!'
ERROR: invalid-macro-arg-character.asm(1):
syntax error, unexpected >
error: Assembly aborted (2 errors)!

View File

@@ -1,2 +1,3 @@
FATAL: invalid-macro-arg-symbol.asm(1):
ERROR: invalid-macro-arg-symbol.asm(1):
Bracketed symbol "foo" does not exist
error: Assembly aborted (1 error)!

View File

@@ -9,7 +9,7 @@ m: macro
SHIFT
SHIFT
SHIFT 256
PRINTLN "\1"
PRINTLN "\1?"
endm
m This, used, not, to, work

View File

@@ -2,5 +2,6 @@ warning: rept-shift.asm(15) -> rept-shift.asm::m(10): [-Wmacro-shift]
Cannot shift macro arguments past their end
warning: rept-shift.asm(15) -> rept-shift.asm::m(11): [-Wmacro-shift]
Cannot shift macro arguments past their end
FATAL: rept-shift.asm(15) -> rept-shift.asm::m(12):
ERROR: rept-shift.asm(15) -> rept-shift.asm::m(12):
Macro argument '\1' not defined
error: Assembly aborted (1 error)!

View File

@@ -1 +1,2 @@
This works!
?

View File

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

View File

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

View File

@@ -0,0 +1 @@
$A

View File

@@ -1,4 +1,4 @@
warn_unique EQUS "WARN \"\\@\""
warn_unique EQUS "WARN \"\\@!\""
m: macro
warn_unique

View File

@@ -1,27 +1,31 @@
warning: unique-id.asm(12) -> unique-id.asm::m(4): [-Wuser]
_u1
_u1!
while expanding symbol "warn_unique"
warning: unique-id.asm(12) -> unique-id.asm::m(5) -> unique-id.asm::m::REPT~1(6): [-Wuser]
_u2
_u2!
while expanding symbol "warn_unique"
warning: unique-id.asm(12) -> unique-id.asm::m(5) -> unique-id.asm::m::REPT~2(6): [-Wuser]
_u3
_u3!
while expanding symbol "warn_unique"
warning: unique-id.asm(12) -> unique-id.asm::m(8): [-Wuser]
_u1
_u1!
while expanding symbol "warn_unique"
warning: unique-id.asm(14) -> unique-id.asm::m(4): [-Wuser]
_u4
_u4!
while expanding symbol "warn_unique"
warning: unique-id.asm(14) -> unique-id.asm::m(5) -> unique-id.asm::m::REPT~1(6): [-Wuser]
_u5
_u5!
while expanding symbol "warn_unique"
warning: unique-id.asm(14) -> unique-id.asm::m(5) -> unique-id.asm::m::REPT~2(6): [-Wuser]
_u6
_u6!
while expanding symbol "warn_unique"
warning: unique-id.asm(14) -> unique-id.asm::m(8): [-Wuser]
_u4
_u4!
while expanding symbol "warn_unique"
FATAL: unique-id.asm(15):
ERROR: unique-id.asm(15):
Macro argument '\@' not defined
while expanding symbol "warn_unique"
warning: unique-id.asm(15): [-Wuser]
!
while expanding symbol "warn_unique"
error: Assembly aborted (1 error)!