1
0
Fork 0

Optimize numbers

This commit is contained in:
Gregory Eremin 2015-02-17 23:58:49 +07:00
parent 0d2df2c6e5
commit bfdb311495
1 changed files with 2 additions and 7 deletions

View File

@ -218,20 +218,15 @@ func lexBool(l *Lexer) stateFn {
} }
func lexNumber(l *Lexer) stateFn { func lexNumber(l *Lexer) stateFn {
var ( numDots := 0
last rune
numDots = 0
)
for { for {
switch r := l.next(); r { switch r := l.next(); r {
case '1', '2', '3', '4', '5', '6', '7', '8', '9', '0': case '1', '2', '3', '4', '5', '6', '7', '8', '9', '0':
last = r
case '.': case '.':
numDots++ numDots++
last = r
default: default:
l.backup() l.backup()
if numDots > 1 || last == '.' { if numDots > 1 || r == '.' {
return l.errorf("Invalid number: %q", l.val()) return l.errorf("Invalid number: %q", l.val())
} }
l.emit(Number) l.emit(Number)