Add support for special float values (inf and nan) (#210)

This commit is contained in:
Jelte Fennema
2018-01-18 23:10:55 +01:00
committed by Thomas Pelletier
parent a1e8a8d702
commit 778c285afa
6 changed files with 79 additions and 2 deletions
+8
View File
@@ -5,6 +5,7 @@ package toml
import (
"errors"
"fmt"
"math"
"reflect"
"regexp"
"strconv"
@@ -243,6 +244,13 @@ func (p *tomlParser) parseRvalue() interface{} {
return true
case tokenFalse:
return false
case tokenInf:
if tok.val[0] == '-' {
return math.Inf(-1)
}
return math.Inf(1)
case tokenNan:
return math.NaN()
case tokenInteger:
cleanedVal := cleanupNumberToken(tok.val)
var err error