Skip to content

Commit

Permalink
Fix exponent parse error
Browse files Browse the repository at this point in the history
  • Loading branch information
antonmedv committed Mar 2, 2020
1 parent 2482543 commit 9217dda
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
2 changes: 1 addition & 1 deletion parser/parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ func (p *parser) parsePrimaryExpression() Node {
case Number:
p.next()
value := strings.Replace(token.Value, "_", "", -1)
if strings.Contains(value, ".") {
if strings.ContainsAny(value, ".eE") {
number, err := strconv.ParseFloat(value, 64)
if err != nil {
p.error("invalid float literal: %v", err)
Expand Down
4 changes: 4 additions & 0 deletions parser/parser_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@ func TestParse(t *testing.T) {
"2.5",
&ast.FloatNode{Value: 2.5},
},
{
"1e9",
&ast.FloatNode{Value: 1e9},
},
{
"true",
&ast.BoolNode{Value: true},
Expand Down

0 comments on commit 9217dda

Please sign in to comment.