fix(format): never peel a stacked label that names a macro
Peeling a stacked label whose name is a macro moves it onto a line of its own, where its expansion decides the line's shape: an empty body leaves a bare colon behind, a line the parser rejects. The peel loops now hold such labels back with the rest of the line, and the crashing input joins the corpus. Assisted-by: GLM 5.3
This commit is contained in:
1 parent
b54d2b4520
commit
f932c5811c
3 files changed
+18
-3
No files matched your search
+6
-3
@@ -70,10 +70,11 @@ func Source(src string) string {
|
||||
// instruction after the last one is rendered at the
|
||||
// function's alignment width, so its mnemonic counts here,
|
||||
// unless it names a macro and never reaches a line of its
|
||||
// own.
|
||||
// own. A stacked label naming a macro is never peeled
|
||||
// either: its expansion decides what the line becomes.
|
||||
rest := line[2:]
|
||||
for len(rest) >= 2 && rest[0].Kind == token.Ident && rest[1].Kind == token.Colon &&
|
||||
!isDirective(rest[0].Text) {
|
||||
!isDirective(rest[0].Text) && !macros[rest[0].Text] {
|
||||
rest = rest[2:]
|
||||
}
|
||||
if len(rest) > 0 && rest[0].Kind == token.Ident && !isDirective(rest[0].Text) &&
|
||||
@@ -146,8 +147,10 @@ func Source(src string) string {
|
||||
// honest about what it is looking at.
|
||||
outs = append(outs, outLine{kind: kLabel, text: line[0].Text + ":"})
|
||||
rest := line[2:]
|
||||
// A stacked label naming a macro is never peeled: its expansion
|
||||
// decides what the line becomes, exactly as the first label's.
|
||||
for len(rest) >= 2 && rest[0].Kind == token.Ident && rest[1].Kind == token.Colon &&
|
||||
!isDirective(rest[0].Text) {
|
||||
!isDirective(rest[0].Text) && !macros[rest[0].Text] {
|
||||
outs = append(outs, outLine{kind: kLabel, text: rest[0].Text + ":"})
|
||||
rest = rest[2:]
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user