Skip to content

Commit 3a0480e

Browse files
michaelforneyfjl
authored andcommitted
core/asm: allow numbers in labels (#20362)
Numbers were already allowed when creating labels, just not when referencing them.
1 parent 5d21667 commit 3a0480e

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

core/asm/lex_test.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,14 @@ func TestLexer(t *testing.T) {
6060
input: "0123abc",
6161
tokens: []token{{typ: lineStart}, {typ: number, text: "0123"}, {typ: element, text: "abc"}, {typ: eof}},
6262
},
63+
{
64+
input: "@foo",
65+
tokens: []token{{typ: lineStart}, {typ: label, text: "foo"}, {typ: eof}},
66+
},
67+
{
68+
input: "@label123",
69+
tokens: []token{{typ: lineStart}, {typ: label, text: "label123"}, {typ: eof}},
70+
},
6371
}
6472

6573
for _, test := range tests {

core/asm/lexer.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,7 @@ func lexComment(l *lexer) stateFn {
234234
// the lex text state function to advance the parsing
235235
// process.
236236
func lexLabel(l *lexer) stateFn {
237-
l.acceptRun(Alpha + "_")
237+
l.acceptRun(Alpha + "_" + Numbers)
238238

239239
l.emit(label)
240240

0 commit comments

Comments
 (0)