separate number into float and integer

This commit is contained in:
Neemek 2026-07-07 23:24:44 +02:00
parent 10f55313b0
commit daab50d54c
Signed by: neemek
GPG key ID: 84FFE4D7D40AB25E
22 changed files with 848 additions and 428 deletions

View file

@ -2,6 +2,7 @@ package core
import (
"fmt"
"math/big"
"strconv"
"strings"
)
@ -21,7 +22,8 @@ type Boundary interface {
const (
StringNodeType NodeType = iota
NumberNodeType
FloatNodeType
IntegerNodeType
ReferenceNodeType
BooleanNodeType
NilNodeType
@ -43,8 +45,10 @@ func (n NodeType) String() string {
switch n {
case StringNodeType:
return "String"
case NumberNodeType:
return "Number"
case FloatNodeType:
return "Float"
case IntegerNodeType:
return "Integer"
case ReferenceNodeType:
return "Reference"
case BinaryNodeType:
@ -120,22 +124,41 @@ func (n StringNode) Bounds() (Pos, Pos) {
return n.start, n.end
}
type NumberNode struct {
type FloatNode struct {
value float64
start Pos
end Pos
}
func (n NumberNode) Type() NodeType {
return NumberNodeType
func (n FloatNode) Type() NodeType {
return FloatNodeType
}
func (n NumberNode) String() string {
return strconv.FormatFloat(n.value, 'g', -1, NumberSize)
func (n FloatNode) String() string {
return strconv.FormatFloat(n.value, 'g', -1, FloatSize)
}
func (n NumberNode) Bounds() (Pos, Pos) {
func (n FloatNode) Bounds() (Pos, Pos) {
return n.start, n.end
}
type IntegerNode struct {
value *big.Int
start Pos
end Pos
}
func (n IntegerNode) Type() NodeType {
return IntegerNodeType
}
func (n IntegerNode) String() string {
return n.value.String()
}
func (n IntegerNode) Bounds() (Pos, Pos) {
return n.start, n.end
}