MCPcopy Create free account
hub / github.com/araddon/qlbridge / load

Method load

expr/node.go:687–714  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

685}
686
687func (n *NumberNode) load() error {
688 // Do integer test first so we get 0x123 etc.
689 iv, err := strconv.ParseInt(n.Text, 0, 64) // will fail for -0.
690 if err == nil {
691 n.IsInt = true
692 n.Int64 = iv
693 }
694 // If an integer extraction succeeded, promote the float.
695 if n.IsInt {
696 n.IsFloat = true
697 n.Float64 = float64(n.Int64)
698 } else {
699 f, err := strconv.ParseFloat(n.Text, 64)
700 if err == nil {
701 n.IsFloat = true
702 n.Float64 = f
703 // If a floating-point extraction succeeded, extract the int if needed.
704 if !n.IsInt && float64(int64(f)) == f {
705 n.IsInt = true
706 n.Int64 = int64(f)
707 }
708 }
709 }
710 if !n.IsInt && !n.IsFloat {
711 return fmt.Errorf("illegal number syntax: %q", n.Text)
712 }
713 return nil
714}
715func (m *NumberNode) NodeType() string { return "Number" }
716func (n *NumberNode) String() string { return n.Text }
717func (m *NumberNode) WriteDialect(w DialectWriter) { w.WriteNumber(m.Text) }

Callers 3

NewNumberStrFunction · 0.95
FromPBMethod · 0.95
FromExprMethod · 0.95

Calls 1

ErrorfMethod · 0.80

Tested by

no test coverage detected