in types.go [559:601]
func parseValue(p *cfgPrimitive, opts *options, str string, parseCfg parse.Config) (value, error) {
if opts.noParse {
return nil, raiseNoParse(p.ctx, p.meta())
}
// only set IgnoreCommas if the default has been changed.
if opts.ignoreCommas {
parseCfg.IgnoreCommas = opts.ignoreCommas
}
ifc, err := parse.ValueWithConfig(str, parseCfg)
if err != nil {
return nil, err
}
if ifc == nil {
if strings.TrimSpace(str) == "" {
return newString(p.ctx, p.meta(), str), nil
}
return &cfgNil{cfgPrimitive{ctx: p.ctx, metadata: p.meta()}}, nil
}
switch v := ifc.(type) {
case bool:
return newBool(p.ctx, p.meta(), v), nil
case int64:
return newInt(p.ctx, p.meta(), v), nil
case uint64:
return newUint(p.ctx, p.meta(), v), nil
case float64:
return newFloat(p.ctx, p.meta(), v), nil
case string:
return newString(p.ctx, p.meta(), v), nil
}
sub, err := normalize(opts, ifc)
if err != nil {
return nil, err
}
sub.ctx = p.ctx
sub.metadata = p.metadata
return cfgSub{sub}, nil
}