good morning!!!!
Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
E
Erigon
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container registry
Harbor Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
a
Erigon
Commits
53f3460a
Commit
53f3460a
authored
Jul 31, 2017
by
njupt-moon
Committed by
Felix Lange
Jul 31, 2017
Browse files
Options
Downloads
Patches
Plain Diff
core/asm: fix hex number lexing (#14861)
parent
bdf98b4f
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
core/asm/lex_test.go
+40
-5
40 additions, 5 deletions
core/asm/lex_test.go
core/asm/lexer.go
+1
-1
1 addition, 1 deletion
core/asm/lexer.go
with
41 additions
and
6 deletions
core/asm/lex_test.go
+
40
−
5
View file @
53f3460a
...
@@ -16,7 +16,10 @@
...
@@ -16,7 +16,10 @@
package
asm
package
asm
import
"testing"
import
(
"reflect"
"testing"
)
func
lexAll
(
src
string
)
[]
token
{
func
lexAll
(
src
string
)
[]
token
{
ch
:=
Lex
(
"test.asm"
,
[]
byte
(
src
),
false
)
ch
:=
Lex
(
"test.asm"
,
[]
byte
(
src
),
false
)
...
@@ -28,9 +31,41 @@ func lexAll(src string) []token {
...
@@ -28,9 +31,41 @@ func lexAll(src string) []token {
return
tokens
return
tokens
}
}
func
TestComment
(
t
*
testing
.
T
)
{
func
TestLexer
(
t
*
testing
.
T
)
{
tokens
:=
lexAll
(
";; this is a comment"
)
tests
:=
[]
struct
{
if
len
(
tokens
)
!=
2
{
// {new line, EOF}
input
string
t
.
Error
(
"expected no tokens"
)
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
)
}
}
}
}
}
This diff is collapsed.
Click to expand it.
core/asm/lexer.go
+
1
−
1
View file @
53f3460a
...
@@ -254,7 +254,7 @@ func lexInsideString(l *lexer) stateFn {
...
@@ -254,7 +254,7 @@ func lexInsideString(l *lexer) stateFn {
func
lexNumber
(
l
*
lexer
)
stateFn
{
func
lexNumber
(
l
*
lexer
)
stateFn
{
acceptance
:=
Numbers
acceptance
:=
Numbers
if
l
.
accept
(
"0"
)
&&
l
.
accept
(
"xX"
)
{
if
l
.
accept
(
"0"
)
||
l
.
accept
(
"xX"
)
{
acceptance
=
HexadecimalNumbers
acceptance
=
HexadecimalNumbers
}
}
l
.
acceptRun
(
acceptance
)
l
.
acceptRun
(
acceptance
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment