Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
G
Geth-Modification
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
张蕾
Geth-Modification
Commits
53f3460a
Commit
53f3460a
authored
Jul 31, 2017
by
njupt-moon
Committed by
Felix Lange
Jul 31, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
core/asm: fix hex number lexing (#14861)
parent
bdf98b4f
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
41 additions
and
6 deletions
+41
-6
lex_test.go
core/asm/lex_test.go
+40
-5
lexer.go
core/asm/lexer.go
+1
-1
No files found.
core/asm/lex_test.go
View file @
53f3460a
...
...
@@ -16,7 +16,10 @@
package
asm
import
"testing"
import
(
"reflect"
"testing"
)
func
lexAll
(
src
string
)
[]
token
{
ch
:=
Lex
(
"test.asm"
,
[]
byte
(
src
),
false
)
...
...
@@ -28,9 +31,41 @@ func lexAll(src string) []token {
return
tokens
}
func
TestComment
(
t
*
testing
.
T
)
{
tokens
:=
lexAll
(
";; this is a comment"
)
if
len
(
tokens
)
!=
2
{
// {new line, EOF}
t
.
Error
(
"expected no tokens"
)
func
TestLexer
(
t
*
testing
.
T
)
{
tests
:=
[]
struct
{
input
string
tokens
[]
token
}{
{
input
:
";; this is a comment"
,
tokens
:
[]
token
{{
typ
:
lineStart
},
{
typ
:
eof
}},
},
{
input
:
"0x12345678"
,
tokens
:
[]
token
{{
typ
:
lineStart
},
{
typ
:
number
,
text
:
"0x12345678"
},
{
typ
:
eof
}},
},
{
input
:
"0x123ggg"
,
tokens
:
[]
token
{{
typ
:
lineStart
},
{
typ
:
number
,
text
:
"0x123"
},
{
typ
:
element
,
text
:
"ggg"
},
{
typ
:
eof
}},
},
{
input
:
"12345678"
,
tokens
:
[]
token
{{
typ
:
lineStart
},
{
typ
:
number
,
text
:
"12345678"
},
{
typ
:
eof
}},
},
{
input
:
"123abc"
,
tokens
:
[]
token
{{
typ
:
lineStart
},
{
typ
:
number
,
text
:
"123"
},
{
typ
:
element
,
text
:
"abc"
},
{
typ
:
eof
}},
},
{
input
:
"0123abc"
,
tokens
:
[]
token
{{
typ
:
lineStart
},
{
typ
:
number
,
text
:
"0123"
},
{
typ
:
element
,
text
:
"abc"
},
{
typ
:
eof
}},
},
}
for
_
,
test
:=
range
tests
{
tokens
:=
lexAll
(
test
.
input
)
if
!
reflect
.
DeepEqual
(
tokens
,
test
.
tokens
)
{
t
.
Errorf
(
"input %q
\n
got: %+v
\n
want: %+v"
,
test
.
input
,
tokens
,
test
.
tokens
)
}
}
}
core/asm/lexer.go
View file @
53f3460a
...
...
@@ -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
(
"0"
)
||
l
.
accept
(
"xX"
)
{
acceptance
=
HexadecimalNumbers
}
l
.
acceptRun
(
acceptance
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment