mirror of
https://github.com/robertkrimen/otto
synced 2025-10-26 20:28:49 +08:00
Parse float literals of the kind ".01", ".0..." properly
This commit is contained in:
parent
b5e40f8a85
commit
a6d6f26c01
4
lexer.go
4
lexer.go
|
|
@ -396,10 +396,8 @@ func (self *_lexer) scanNumericLiteral() _token {
|
||||||
|
|
||||||
isHex, isOctal := false, false
|
isHex, isOctal := false, false
|
||||||
{
|
{
|
||||||
self.accept(".")
|
|
||||||
|
|
||||||
acceptable := "0123456789"
|
acceptable := "0123456789"
|
||||||
if self.accept("0") {
|
if !self.accept(".") && self.accept("0") {
|
||||||
if self.accept("xX") {
|
if self.accept("xX") {
|
||||||
acceptable = "0123456789abcdefABCDEF"
|
acceptable = "0123456789abcdefABCDEF"
|
||||||
isHex = true
|
isHex = true
|
||||||
|
|
|
||||||
|
|
@ -288,4 +288,12 @@ Second line \
|
||||||
"number 0",
|
"number 0",
|
||||||
)
|
)
|
||||||
|
|
||||||
|
test(`.01`,
|
||||||
|
"number .01",
|
||||||
|
)
|
||||||
|
|
||||||
|
test(`.01e+2`,
|
||||||
|
"number .01e+2",
|
||||||
|
)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user