value

package
v0.0.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 26, 2022 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var FormatToString = map[NumberFormat]string{
	DEC: "dec",
	HEX: "hex",
	OCT: "oct",
	BIN: "bin",
	RAT: "rat",
	SCI: "sci",
}
View Source
var StringToFormat = map[string]NumberFormat{}

Functions

This section is empty.

Types

type IntOperationError

type IntOperationError struct {
	// contains filtered or unexported fields
}

func (IntOperationError) Error

func (x IntOperationError) Error() string

type Number

type Number struct {
	Num *big.Rat
	Fmt NumberFormat
}

func Float64

func Float64(x float64) Number

func Int64

func Int64(x int64) Number

func (Number) BinOP

func (a Number) BinOP(op token.Token, b Value) (Value, error)

func (Number) Format

func (a Number) Format(tsep string, prec int) string

func (Number) In

func (a Number) In(fmt string) (Value, error)

func (Number) String

func (a Number) String() string

func (Number) UnOP

func (a Number) UnOP(op token.Token) (Value, error)

type NumberFormat

type NumberFormat int
const (
	DEC NumberFormat = iota
	HEX
	OCT
	BIN
	RAT
	SCI
)

func (NumberFormat) String

func (n NumberFormat) String() string

type Time

type Time struct {
	// contains filtered or unexported fields
}

func GetNamedTime

func GetNamedTime(name string) *Time

func NewTime

func NewTime(t time.Time) Time

func (Time) BinOP

func (a Time) BinOP(op token.Token, b Value) (Value, error)

func (Time) In

func (t Time) In(fmt string) (Value, error)

func (Time) String

func (t Time) String() string

func (Time) UnOP

func (t Time) UnOP(op token.Token) (Value, error)

type Unit

type Unit struct {
	Num   *big.Rat
	Fmt   NumberFormat
	Units unit.Units
}

func (Unit) BinOP

func (a Unit) BinOP(op token.Token, b Value) (Value, error)

func (Unit) Format

func (a Unit) Format(tsep string, prec int) string

func (Unit) In

func (a Unit) In(fmt string) (Value, error)

func (Unit) String

func (a Unit) String() string

func (Unit) UnOP

func (a Unit) UnOP(op token.Token) (Value, error)

type UnsupportedBinOP

type UnsupportedBinOP struct {
	// contains filtered or unexported fields
}

func (UnsupportedBinOP) Error

func (err UnsupportedBinOP) Error() string

type Value

type Value interface {
	BinOP(token.Token, Value) (Value, error)
	UnOP(token.Token) (Value, error)
	In(string) (Value, error)
	String() string
}

type ValueType

type ValueType int
const (
	TYPE_UNKNOWN ValueType = iota
	TYPE_NUMBER
	TYPE_UNIT
	TYPE_TIME
)

func Type

func Type(x Value) ValueType

func (ValueType) String

func (t ValueType) String() string

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
JackTT - Gopher 🇻🇳