Skip to content

Commit

Permalink
Fix lexer for floats
Browse files Browse the repository at this point in the history
  • Loading branch information
antonmedv committed Feb 26, 2020
1 parent 3e7d20e commit 79ed70d
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 7 deletions.
8 changes: 2 additions & 6 deletions parser/lexer/lexer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,12 @@ type lexTest struct {
tokens []Token
}

type lexErrorTest struct {
input string
err string
}

var lexTests = []lexTest{
{
".5 1 02 1e3 0xFF 1.2e-4 1_000_000 _42 -.5",
".5 0.025 1 02 1e3 0xFF 1.2e-4 1_000_000 _42 -.5",
[]Token{
{Kind: Number, Value: ".5"},
{Kind: Number, Value: "0.025"},
{Kind: Number, Value: "1"},
{Kind: Number, Value: "02"},
{Kind: Number, Value: "1e3"},
Expand Down
2 changes: 1 addition & 1 deletion parser/lexer/state.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ func (l *lexer) scanNumber() bool {
l.backup()
return true
}
l.accept(digits)
l.acceptRun(digits)
}
if l.accept("eE") {
l.accept("+-")
Expand Down

0 comments on commit 79ed70d

Please sign in to comment.