From 79ed70d5a38712acbbfe8fdbb11bfcc3e38a6c92 Mon Sep 17 00:00:00 2001 From: Anton Medvedev Date: Wed, 26 Feb 2020 12:13:59 +0300 Subject: [PATCH] Fix lexer for floats --- parser/lexer/lexer_test.go | 8 ++------ parser/lexer/state.go | 2 +- 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/parser/lexer/lexer_test.go b/parser/lexer/lexer_test.go index 7b1434d68..68065993a 100644 --- a/parser/lexer/lexer_test.go +++ b/parser/lexer/lexer_test.go @@ -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"}, diff --git a/parser/lexer/state.go b/parser/lexer/state.go index 7d1097368..81ac76713 100644 --- a/parser/lexer/state.go +++ b/parser/lexer/state.go @@ -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("+-")