Skip to content

Commit

Permalink
core/asm: allow numbers in labels (ethereum#20362)
Browse files Browse the repository at this point in the history
Numbers were already allowed when creating labels, just not when
referencing them.
  • Loading branch information
michaelforney authored and enriquefynn committed Feb 15, 2021
1 parent 7a774d8 commit 5b089a5
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
8 changes: 8 additions & 0 deletions core/asm/lex_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion core/asm/lexer.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down

0 comments on commit 5b089a5

Please sign in to comment.