Documentation ¶
Index ¶
- Variables
- func AddPrimitive(name string, value Call)
- func AsBool(o any, def bool) bool
- func AsFloat(o any, def float64) float64
- func AsInt(o any, def int64) int64
- func AsString(o any, def string) string
- func CallLambda(l Lambda, env *Env, args []any) (ret any)
- func Eval(env *Env, v any) any
- func Primitives() (l []string)
- type Boolean
- type Call
- type CanBool
- type CanCompare
- type CanFloat
- type CanInt
- type Cond
- type Env
- type Error
- type Float
- type Integer
- func (o Integer) Bool() bool
- func (o Integer) Eq(v any) bool
- func (o Integer) Float() float64
- func (o Integer) Geq(v any) bool
- func (o Integer) Gt(v any) bool
- func (o Integer) Int() int64
- func (o Integer) Leq(v any) bool
- func (o Integer) Lt(v any) bool
- func (o Integer) String() string
- func (o Integer) Value() any
- type Lambda
- type List
- type Object
- type Op
- type Parser
- type Quoted
- type String
- type Symbol
Constants ¶
This section is empty.
Variables ¶
var ( ErrEOF = Error{/* contains filtered or unexported fields */} ErrInvalid = Error{/* contains filtered or unexported fields */} ErrInvalidType = Error{/* contains filtered or unexported fields */} ErrMissing = Error{/* contains filtered or unexported fields */} Verbose = false True = Boolean{/* contains filtered or unexported fields */} Nil = Boolean{/* contains filtered or unexported fields */} )
Functions ¶
func AddPrimitive ¶
AddPrimitive adds a new built-in/primitive method. Note that it can override existing primitives
func AsBool ¶
AsBool converts the input object to a boolean, if possible or return the default value.
func AsFloat ¶
AsFloat converts the input object to a float, if possible or return the default value.
func AsInt ¶
AsInt converts the input object to an integer, if possible or return the default value.
func CallLambda ¶
CallLambda call a lambda function, passing the local enviroment and some input parameters
func Primitives ¶
func Primitives() (l []string)
Primitives returns a list of primivives (names) Note that this doesn't return the math and conditional operators.
Types ¶
type Boolean ¶
type Boolean struct {
// contains filtered or unexported fields
}
Boolean is the boolean primitive object
type CanBool ¶
type CanBool interface {
Bool() bool
}
CanBool is for objects that can cast to a boolean (true/false)
type CanCompare ¶
type CanCompare interface { Eq(v any) bool Lt(v any) bool Leq(v any) bool Gt(v any) bool Geq(v any) bool }
CanCompare is for objects that can compare with other objects (=, <, <=, >, >=)
type CanFloat ¶
type CanFloat interface {
Float() float64
}
CanFloat is for objects that can cast to a float (float64) value
type CanInt ¶
type CanInt interface {
Int() int64
}
CanInt is for objects that can cast to an integer (int64) value
type Cond ¶
type Cond struct {
// contains filtered or unexported fields
}
Cond is for conditional operators ( =, <, <=, >, >= )
type Env ¶
type Env struct {
// contains filtered or unexported fields
}
Env stores the current environments (collection of variables)
func NewEnv ¶
NewEnv creates a new enviroment. The root environment should have prev=nil, local environment will link to the previous (parent) one.
func (*Env) GetValues ¶
GetValues returns the primitive value for the input variables or evaluated objects.
type Error ¶
type Error struct {
// contains filtered or unexported fields
}
Error is a primitive object that maps errors
type Float ¶
type Float struct {
// contains filtered or unexported fields
}
Float is the floating point primitive type (float64)
type Integer ¶
type Integer struct {
// contains filtered or unexported fields
}
Integer is the integer primitive type (int64)
type Lambda ¶
type Lambda struct {
// contains filtered or unexported fields
}
Lambda is the anonymous function type
type List ¶
type List struct {
// contains filtered or unexported fields
}
List is the list type
type Op ¶
type Op struct {
// contains filtered or unexported fields
}
Op is for math operators ( +, -, *, / )
type Parser ¶
type Parser struct {
// contains filtered or unexported fields
}
Parser can parse a gisp object or program
func (*Parser) Parse ¶
Parse parses the input from the Reader until EOF and returns a list of objects
type Quoted ¶
type Quoted struct {
// contains filtered or unexported fields
}
Quoted is for quoted symbols