Documentation ¶
Index ¶
Constants ¶
View Source
const ( Bit Unit = 1 Hex = 4 Octett = 8 )
View Source
const ( UNKNOWN ObjectType = "unknown" UNDEFINED = "undefined" RUNTIME_ERROR = "runtime error" RETURN_VALUE = "return value" INTEGER = "integer" FLOAT = "float" BOOL = "boolean" STRING = "string" BITSTRING = "bitstring" FUNCTION = "function" LIST = "list" BUILTIN_OBJ = "builtin function" VERDICT = "verdict" )
Variables ¶
View Source
var Builtins = map[string]*Builtin{ "lengthof": {Fn: func(args ...Object) Object { if len(args) != 1 { return Errorf("wrong number of arguments. got=%d, want=1", len(args)) } switch arg := args[0].(type) { case *String: return Int{Int: big.NewInt(int64(len(arg.Value)))} case *Bitstring: return Int{Int: big.NewInt(int64(arg.Value.BitLen() / int(arg.Unit)))} } return Errorf("%s arguments not supported", args[0].Type()) }}, }
View Source
var ErrSyntax = errors.New("invalid syntax")
View Source
var (
Undefined = &undefined{}
)
Functions ¶
Types ¶
type Bitstring ¶ added in v0.9.5
func NewBitstring ¶ added in v0.9.5
func (*Bitstring) Type ¶ added in v0.9.5
func (b *Bitstring) Type() ObjectType
type Builtin ¶ added in v0.9.5
func (*Builtin) Type ¶ added in v0.9.5
func (b *Builtin) Type() ObjectType
type Error ¶
type Error struct {
Message string
}
func (*Error) Type ¶
func (e *Error) Type() ObjectType
type Function ¶
type Function struct { Params *ast.FormalPars Body *ast.BlockStmt Env *Env }
func (*Function) Type ¶
func (f *Function) Type() ObjectType
type List ¶ added in v0.9.5
type List struct {
Elements []Object
}
func (*List) Type ¶ added in v0.9.5
func (l *List) Type() ObjectType
type Object ¶
type Object interface { Inspect() string Type() ObjectType }
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
Click to show internal directories.
Click to hide internal directories.