Documentation ¶
Index ¶
- Constants
- Variables
- func IsError(obj Object) bool
- type BaseVector
- func (bv *BaseVector) Append(vals ...Object) Object
- func (bv *BaseVector) ElementType() ObjectType
- func (bv *BaseVector) Head(n int) []Object
- func (bv *BaseVector) Infix(f func(Object, Object) Object, other IVector) Object
- func (bv *BaseVector) Inspect() string
- func (bv *BaseVector) Length() int
- func (bv *BaseVector) Print(dtype string) string
- func (bv *BaseVector) Replace(start int, end int, replacement IVector, t ObjectType) Object
- func (bv *BaseVector) Set(index int, val Object, t ObjectType) Object
- func (bv *BaseVector) Slice(start int, end int) Object
- func (bv *BaseVector) Tail(n int) []Object
- func (bv *BaseVector) Type() ObjectType
- func (bv *BaseVector) Values(n int) []Object
- type Boolean
- type Builtin
- type BuiltinFunction
- type CharacterVector
- func (cv *CharacterVector) Append(objects ...Object) Object
- func (bv *CharacterVector) ElementType() ObjectType
- func (cv *CharacterVector) Head(n int) Object
- func (cv *CharacterVector) Infix(f func(Object, Object) Object, other IVector) Object
- func (cv *CharacterVector) Inspect() string
- func (cv *CharacterVector) Length() int
- func (cv *CharacterVector) New(elements []Object) IVector
- func (cv *CharacterVector) Print() string
- func (cv *CharacterVector) Replace(start int, end int, replacement IVector) Object
- func (cv *CharacterVector) Set(index int, val Object) Object
- func (cv *CharacterVector) Slice(start int, end int) Object
- func (cv *CharacterVector) Tail(n int) Object
- func (cv *CharacterVector) Type() ObjectType
- func (cv *CharacterVector) Values() []Object
- type Dict
- type DictKey
- type DictPair
- type Env
- type Error
- type Function
- type Hashable
- type IVector
- type Integer
- type LogicalVector
- func (lv *LogicalVector) Append(objects ...Object) Object
- func (bv *LogicalVector) ElementType() ObjectType
- func (lv *LogicalVector) Head(n int) Object
- func (lv *LogicalVector) Infix(f func(Object, Object) Object, other IVector) Object
- func (lv *LogicalVector) Inspect() string
- func (lv *LogicalVector) Length() int
- func (lv *LogicalVector) New(elements []Object) IVector
- func (lv *LogicalVector) Print() string
- func (lv *LogicalVector) Replace(start int, end int, replacement IVector) Object
- func (lv *LogicalVector) Set(index int, val Object) Object
- func (lv *LogicalVector) Slice(start int, end int) Object
- func (lv *LogicalVector) Tail(n int) Object
- func (lv *LogicalVector) Type() ObjectType
- func (lv *LogicalVector) Values() []Object
- type Null
- type Number
- type NumericVector
- func (nv *NumericVector) Append(objects ...Object) Object
- func (bv *NumericVector) ElementType() ObjectType
- func (nv *NumericVector) Head(n int) Object
- func (nv *NumericVector) Infix(f func(Object, Object) Object, other IVector) Object
- func (nv *NumericVector) Inspect() string
- func (nv *NumericVector) Length() int
- func (nv *NumericVector) New(elements []Object) IVector
- func (nv *NumericVector) Print() string
- func (nv *NumericVector) Replace(start int, end int, replacement IVector) Object
- func (nv *NumericVector) Set(index int, val Object) Object
- func (nv *NumericVector) Slice(start int, end int) Object
- func (nv *NumericVector) Tail(n int) Object
- func (nv *NumericVector) Type() ObjectType
- func (nv *NumericVector) Values() []Object
- type Object
- type ObjectType
- type Range
- type ReturnValue
- type String
- type Vector
- func (v *Vector) Append(objects ...Object) Object
- func (bv *Vector) ElementType() ObjectType
- func (v *Vector) Head(n int) Object
- func (v *Vector) Infix(f func(Object, Object) Object, other IVector) Object
- func (v *Vector) Inspect() string
- func (v *Vector) Length() int
- func (v *Vector) Print() string
- func (v *Vector) Replace(start int, end int, replacement IVector) Object
- func (v *Vector) Set(index int, val Object) Object
- func (v *Vector) Slice(start int, end int) Object
- func (v *Vector) Tail(n int) Object
- func (v *Vector) Type() ObjectType
- func (v *Vector) Values() []Object
Constants ¶
View Source
const ( NUMBER_OBJ = "NUMBER" STRING_OBJ = "STRING" BOOLEAN_OBJ = "BOOLEAN" NULL_OBJ = "NULL" RETURN_OBJ = "RETURN" FUNCTION_OBJ = "FUNCTION" BUILTIN_OBJ = "BUILTIN" ERROR_OBJ = "ERROR" RANGE_OBJ = "RANGE" // vector VECTOR_OBJ = "VECTOR" // dict DICT_OBJ = "DICT" // colors COLOR_BLUE = "\033[34m" COLOR_RESET = "\033[0m" )
Variables ¶
View Source
var FALSE = &Boolean{Value: false}
View Source
var NULL = &Null{}
only need one "constant" object for true, false and null
View Source
var TRUE = &Boolean{Value: true}
Functions ¶
Types ¶
type BaseVector ¶
type BaseVector struct {
Elements []Object
}
the inner element for all vectors, provides implementation for methods in IVector (doesn't have to be of IVector itself)
func (*BaseVector) Append ¶
func (bv *BaseVector) Append(vals ...Object) Object
append objects to vector, flattening if necessary
func (*BaseVector) ElementType ¶
func (bv *BaseVector) ElementType() ObjectType
func (*BaseVector) Head ¶
func (bv *BaseVector) Head(n int) []Object
func (*BaseVector) Inspect ¶
func (bv *BaseVector) Inspect() string
func (*BaseVector) Length ¶
func (bv *BaseVector) Length() int
func (*BaseVector) Print ¶
func (bv *BaseVector) Print(dtype string) string
func (*BaseVector) Replace ¶
func (bv *BaseVector) Replace(start int, end int, replacement IVector, t ObjectType) Object
func (*BaseVector) Set ¶
func (bv *BaseVector) Set(index int, val Object, t ObjectType) Object
func (*BaseVector) Tail ¶
func (bv *BaseVector) Tail(n int) []Object
func (*BaseVector) Type ¶
func (bv *BaseVector) Type() ObjectType
func (*BaseVector) Values ¶
func (bv *BaseVector) Values(n int) []Object
type Boolean ¶
type Boolean struct {
Value bool
}
func (*Boolean) Type ¶
func (b *Boolean) Type() ObjectType
type Builtin ¶
type Builtin struct { RequiredParametersNum int Fn BuiltinFunction }
func (*Builtin) Type ¶
func (b *Builtin) Type() ObjectType
type BuiltinFunction ¶
type CharacterVector ¶
type CharacterVector struct {
BaseVector
}
vectors with object.String
func (*CharacterVector) Append ¶
func (cv *CharacterVector) Append(objects ...Object) Object
func (*CharacterVector) ElementType ¶
func (bv *CharacterVector) ElementType() ObjectType
func (*CharacterVector) Head ¶
func (cv *CharacterVector) Head(n int) Object
func (*CharacterVector) Inspect ¶
func (cv *CharacterVector) Inspect() string
func (*CharacterVector) Length ¶
func (cv *CharacterVector) Length() int
func (*CharacterVector) New ¶
func (cv *CharacterVector) New(elements []Object) IVector
func (*CharacterVector) Print ¶
func (cv *CharacterVector) Print() string
func (*CharacterVector) Replace ¶
func (cv *CharacterVector) Replace(start int, end int, replacement IVector) Object
func (*CharacterVector) Tail ¶
func (cv *CharacterVector) Tail(n int) Object
func (*CharacterVector) Type ¶
func (cv *CharacterVector) Type() ObjectType
func (*CharacterVector) Values ¶
func (cv *CharacterVector) Values() []Object
type Dict ¶
{"a": 1} => &Dict{Pairs: {"a".Hash(): {"a": 1}}}
func (*Dict) Type ¶
func (d *Dict) Type() ObjectType
type DictKey ¶
type DictKey struct { Type ObjectType // the type of the origional key in DictLiteral, one of String, Integer, or Boolean Value uint64 }
type Env ¶
type Env struct {
// contains filtered or unexported fields
}
func NewEnclosedEnvironment ¶
func (*Env) GetAllEnvs ¶
func (*Env) GetOuterEnv ¶
type Error ¶
type Error struct {
Message string
}
func (*Error) Type ¶
func (e *Error) Type() ObjectType
type Function ¶
type Function struct { Parameters []*ast.Identifier Defaults map[string]ast.Expression RequiredParametersNum int Body *ast.BlockStatement Env *Env }
func (*Function) Type ¶
func (f *Function) Type() ObjectType
type IVector ¶
type IVector interface { Type() ObjectType Inspect() string Print() string ElementType() ObjectType Length() int Head(n int) Object Tail(n int) Object Values() []Object Slice(start int, end int) Object Append(objects ...Object) Object Set(start int, val Object) Object Replace(start int, end int, replacement IVector) Object Infix(func(Object, Object) Object, IVector) Object }
interface for all vectors
type Integer ¶
type Integer struct {
Value int64
}
not used, all numbers are stored as float64
func (*Integer) Type ¶
func (n *Integer) Type() ObjectType
type LogicalVector ¶
type LogicalVector struct {
BaseVector
}
vectors with object.Boolean
func (*LogicalVector) Append ¶
func (lv *LogicalVector) Append(objects ...Object) Object
func (*LogicalVector) ElementType ¶
func (bv *LogicalVector) ElementType() ObjectType
func (*LogicalVector) Head ¶
func (lv *LogicalVector) Head(n int) Object
func (*LogicalVector) Inspect ¶
func (lv *LogicalVector) Inspect() string
func (*LogicalVector) Length ¶
func (lv *LogicalVector) Length() int
func (*LogicalVector) New ¶
func (lv *LogicalVector) New(elements []Object) IVector
func (*LogicalVector) Print ¶
func (lv *LogicalVector) Print() string
func (*LogicalVector) Replace ¶
func (lv *LogicalVector) Replace(start int, end int, replacement IVector) Object
func (*LogicalVector) Tail ¶
func (lv *LogicalVector) Tail(n int) Object
func (*LogicalVector) Type ¶
func (lv *LogicalVector) Type() ObjectType
func (*LogicalVector) Values ¶
func (lv *LogicalVector) Values() []Object
type Number ¶
type Number struct {
Value float64
}
func (*Number) Type ¶
func (n *Number) Type() ObjectType
type NumericVector ¶
type NumericVector struct {
BaseVector
}
vectors with object.Number
func (*NumericVector) Append ¶
func (nv *NumericVector) Append(objects ...Object) Object
func (*NumericVector) ElementType ¶
func (bv *NumericVector) ElementType() ObjectType
func (*NumericVector) Head ¶
func (nv *NumericVector) Head(n int) Object
func (*NumericVector) Inspect ¶
func (nv *NumericVector) Inspect() string
func (*NumericVector) Length ¶
func (nv *NumericVector) Length() int
func (*NumericVector) New ¶
func (nv *NumericVector) New(elements []Object) IVector
func (*NumericVector) Print ¶
func (nv *NumericVector) Print() string
func (*NumericVector) Replace ¶
func (nv *NumericVector) Replace(start int, end int, replacement IVector) Object
func (*NumericVector) Tail ¶
func (nv *NumericVector) Tail(n int) Object
func (*NumericVector) Type ¶
func (nv *NumericVector) Type() ObjectType
func (*NumericVector) Values ¶
func (nv *NumericVector) Values() []Object
type Object ¶
type Object interface { Type() ObjectType Inspect() string }
type ObjectType ¶
type ObjectType string
type ReturnValue ¶
type ReturnValue struct {
Value Object
}
func (*ReturnValue) Inspect ¶
func (r *ReturnValue) Inspect() string
func (*ReturnValue) Type ¶
func (r *ReturnValue) Type() ObjectType
type String ¶
type String struct {
Value string
}
func (*String) Type ¶
func (s *String) Type() ObjectType
type Vector ¶
type Vector struct {
BaseVector
}
vector with mixed types
func (*Vector) ElementType ¶
func (bv *Vector) ElementType() ObjectType
func (*Vector) Type ¶
func (v *Vector) Type() ObjectType
Click to show internal directories.
Click to hide internal directories.