From 3a0480e07d4eca0adcc9e2e989e969f14aaf917c Mon Sep 17 00:00:00 2001 From: Michael Forney Date: Sat, 23 Nov 2019 03:52:17 -0800 Subject: [PATCH] core/asm: allow numbers in labels (#20362) Numbers were already allowed when creating labels, just not when referencing them. --- core/asm/lex_test.go | 8 ++++++++ core/asm/lexer.go | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/core/asm/lex_test.go b/core/asm/lex_test.go index 16e0ad458..6b8bd3d74 100644 --- a/core/asm/lex_test.go +++ b/core/asm/lex_test.go @@ -60,6 +60,14 @@ func TestLexer(t *testing.T) { input: "0123abc", tokens: []token{{typ: lineStart}, {typ: number, text: "0123"}, {typ: element, text: "abc"}, {typ: eof}}, }, + { + input: "@foo", + tokens: []token{{typ: lineStart}, {typ: label, text: "foo"}, {typ: eof}}, + }, + { + input: "@label123", + tokens: []token{{typ: lineStart}, {typ: label, text: "label123"}, {typ: eof}}, + }, } for _, test := range tests { diff --git a/core/asm/lexer.go b/core/asm/lexer.go index 00526242e..9eb8f914a 100644 --- a/core/asm/lexer.go +++ b/core/asm/lexer.go @@ -234,7 +234,7 @@ func lexComment(l *lexer) stateFn { // the lex text state function to advance the parsing // process. func lexLabel(l *lexer) stateFn { - l.acceptRun(Alpha + "_") + l.acceptRun(Alpha + "_" + Numbers) l.emit(label)