core/asm: fix the bug of "00" prefix number (#22883)

This commit is contained in:
Evolution404 2021-05-18 16:22:58 +08:00 committed by GitHub
parent bb9f9ccf4f
commit b7a91663ab
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 1 deletions

View File

@ -60,6 +60,10 @@ func TestLexer(t *testing.T) {
input: "0123abc",
tokens: []token{{typ: lineStart}, {typ: number, text: "0123"}, {typ: element, text: "abc"}, {typ: eof}},
},
{
input: "00123abc",
tokens: []token{{typ: lineStart}, {typ: number, text: "00123"}, {typ: element, text: "abc"}, {typ: eof}},
},
{
input: "@foo",
tokens: []token{{typ: lineStart}, {typ: label, text: "foo"}, {typ: eof}},

View File

@ -254,7 +254,7 @@ func lexInsideString(l *lexer) stateFn {
func lexNumber(l *lexer) stateFn {
acceptance := Numbers
if l.accept("0") || l.accept("xX") {
if l.accept("xX") {
acceptance = HexadecimalNumbers
}
l.acceptRun(acceptance)