zygo

package
v5.1.2+incompatible Latest Latest
Warning

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

Go to latest
Published: Dec 28, 2018 License: BSD-2-Clause Imports: 32 Imported by: 12

Documentation

Overview

This project does not use godoc. Instead there is extensive and detailed description of the language features maintained on the wiki. See the following link.

https://github.com/glycerine/zygomys/wiki

Index

Constants

View Source
const CallStackSize = 25
View Source
const DataStackSize = 100
View Source
const LoopStackSize = 5
View Source
const ScopeStackSize = 50
View Source
const SliceDefaultCap = 10
View Source
const StackStackSize = 5
View Source
const YesIamEmbeddedAbove = true

Variables

View Source
var (
	BoolRegex    = regexp.MustCompile("^(true|false)$")
	Uint64Regex  = regexp.MustCompile("^(0x|0o)?[0-9a-fA-F]+ULL$")
	DecimalRegex = regexp.MustCompile("^-?[0-9]+$")
	HexRegex     = regexp.MustCompile("^0x[0-9a-fA-F]+$")
	OctRegex     = regexp.MustCompile("^0o[0-7]+$")
	BinaryRegex  = regexp.MustCompile("^0b[01]+$")

	// SymbolRegex = regexp.MustCompile("^[^'#]+$")
	// (Sigil) symbols can begin with #, $, ?, but
	// sigils cannot appear later in any symbol.
	// Symbols cannot contain whitespace nor `~`, `@`, `(`, `)`, `[`, `]`,
	// `{`, `}`, `'`, `#`, `^`, `\`, `|`, `%`, `"`, `;`. They can optionally
	// end in `:`.
	// Nor, obviously, can symbols contain backticks, "`".
	// Symbols cannot start with a number. DotSymbols cannot have a number
	// as the first character after '.'
	SymbolRegex = regexp.MustCompile(`^[#$?]?[^#$?':;\\~@\[\]{}\^|"()%0-9,&][^'#:;\\~@\[\]{}\^|"()%,&*\-]*[:]?$`)
	// dot symbol examples: `.`, `.a`, `.a.b`, `.a.b.c`
	// dot symbol non-examples: `.a.`, `..`
	DotSymbolRegex = regexp.MustCompile(`^[.]$|^([.][^'#:;\\~@\[\]{}\^|"()%.0-9,][^'#:;\\~@\[\]{}\^|"()%.,*+\-]*)+$|^[^'#:;\\~@\[\]{}\^|"()%.0-9,][^'#:;\\~@\[\]{}\^|"()%.,*+\-]*([.][^'#:;\\~@\[\]{}\^|"()%.0-9,][^'#:;\\~@\[\]{}\^|"()%.,*+\-]*)+$`)
	DotPartsRegex  = regexp.MustCompile(`[.]?[^'#:;\\~@\[\]{}\^|"()%.0-9,][^'#:;\\~@\[\]{}\^|"()%.,]*`)
	CharRegex      = regexp.MustCompile("^'(\\\\?.|\n)'$")
	FloatRegex     = regexp.MustCompile("^-?([0-9]+\\.[0-9]*)$|-?(\\.[0-9]+)$|-?([0-9]+(\\.[0-9]*)?[eE]([-+]?[0-9]+))$")
	ComplexRegex   = regexp.MustCompile("^-?([0-9]+\\.[0-9]*)i?$|-?(\\.[0-9]+)i?$|-?([0-9]+(\\.[0-9]*)?[eE](-?[0-9]+))i?$")
	BuiltinOpRegex = regexp.MustCompile(`^(\+\+|\-\-|\+=|\-=|=|==|:=|\+|\-|\*|<|>|<=|>=|<-|->|\*=|/=|\*\*|!|!=|<!)$`)
)
View Source
var EndTk = Token{/* contains filtered or unexported fields */}
View Source
var ErrBadBreakLabel = fmt.Errorf("bad break label")
View Source
var ErrBadContinueLabel = fmt.Errorf("bad continue label")
View Source
var ErrBadLoopSyntax = fmt.Errorf("for loop: first argument must be a label or a vector of [init predicate advance]")
View Source
var ErrBadQuotedSym = fmt.Errorf("not a quoted symbol")
View Source
var ErrMoreInputNeeded = fmt.Errorf("parser needs more input")
View Source
var ErrShuttingDown error = fmt.Errorf("lexer shutting down")
View Source
var GITLASTCOMMIT string
View Source
var GITLASTTAG string

version information. See Makefile and gitcommit.go for update/init.

View Source
var KeyNotSymbol = fmt.Errorf("key is not a symbol")
View Source
var ListRegisteredTypes = []string{}

consistently ordered list of all registered types (created at init time).

View Source
var MethodNotFound = fmt.Errorf("method not found")
View Source
var MissingFunction = &SexpFunction{name: "__missing", user: true}
View Source
var NoAttachedGoStruct = fmt.Errorf("hash has no attach Go struct")
View Source
var NoExpressionsFound = fmt.Errorf("No expressions found")
View Source
var NotAList = errors.New("not a list")
View Source
var OutOfBounds error = errors.New("jump out of bounds")
View Source
var ParserHaltRequested = fmt.Errorf("parser halt requested")
View Source
var Q = func(quietly_ignored ...interface{}) {} // quiet
View Source
var ReservedWords = []string{"byte", "defbuild", "builder", "field", "and", "or", "cond", "quote", "def", "mdef", "fn", "defn", "begin", "let", "letseq", "assert", "defmac", "macexpand", "syntaxQuote", "include", "for", "set", "break", "continue", "newScope", "_ls", "int8", "int16", "int32", "int64", "uint8", "uint16", "uint32", "uint64", "float32", "float64", "complex64", "complex128", "bool", "string", "any", "break", "case", "chan", "const", "continue", "default", "else", "defer", "fallthrough", "for", "func", "go", "goto", "if", "import", "interface", "map", "package", "range", "return", "select", "struct", "switch", "type", "var", "append", "cap", "close", "complex", "copy", "delete", "imag", "len", "make", "new", "panic", "print", "println", "real", "recover", "null", "nil", "-", "+", "--", "++", "-=", "+=", ":=", "=", ">", "<", ">=", "<=", "send", "NaN", "nan"}
View Source
var ResetRequested = fmt.Errorf("parser reset requested")
View Source
var SexpEnd = &SexpSentinel{Val: 1}
View Source
var SexpFloatSize = 64
View Source
var SexpIntSize = 64
View Source
var SexpMarker = &SexpSentinel{Val: 2}
View Source
var SexpNull = &SexpSentinel{Val: 0}

these are values now so that they also have addresses.

View Source
var ShellCmd string = "/bin/bash"
View Source
var StackUnderFlowErr = fmt.Errorf("invalid stack access: underflow")
View Source
var SymNotFound = errors.New("symbol not found")
View Source
var UnexpectedEnd error = errors.New("Unexpected end of input")
View Source
var Verbose bool // set to true to debug
View Source
var Working bool // currently under investigation
View Source
var WrongNargs error = fmt.Errorf("wrong number of arguments")
View Source
var WrongType error = errors.New("operands have invalid type")

Functions

func AllBuiltinFunctions

func AllBuiltinFunctions() map[string]ZlispUserFunction

AllBuiltinFunctions returns all built in functions

func Blake2bUint64

func Blake2bUint64(raw []byte) uint64

Blake2bUint64 returns an 8 byte BLAKE2b cryptographic hash of the raw.

we're using the pure go: https://github.com/dchest/blake2b

but the C-wrapped refence may be helpful as well --

reference: https://godoc.org/github.com/codahale/blake2 reference: https://blake2.net/ reference: https://tools.ietf.org/html/rfc7693

func Chomp

func Chomp(by []byte) []byte

func ClosureToString

func ClosureToString(f *SexpFunction, env *Zlisp) string

func CoreFunctions

func CoreFunctions() map[string]ZlispUserFunction

CoreFunctions returns all of the core logic

func CountPostHook

func CountPostHook(env *Zlisp, name string, retval Sexp)

func CountPreHook

func CountPreHook(env *Zlisp, name string, args []Sexp)

func DecodeChar

func DecodeChar(atom string) (string, error)

func DirExists

func DirExists(name string) bool

func DumpFunction

func DumpFunction(fun ZlispFunction, pc int)

if pc is -1, don't show it.

func EncodingFunctions

func EncodingFunctions() map[string]ZlispUserFunction

func EscapeChar

func EscapeChar(char rune) (rune, error)

func FileExists

func FileExists(name string) bool

func GetEmbedPath

func GetEmbedPath(e []EmbedPath) string

func GoToJson

func GoToJson(iface interface{}) []byte

go -> json

func GoToMsgpack

func GoToMsgpack(iface interface{}) ([]byte, error)

func HashCountKeys

func HashCountKeys(hash *SexpHash) int

func HashExpression

func HashExpression(env *Zlisp, expr Sexp) (int, error)

func HashIsEmpty

func HashIsEmpty(hash *SexpHash) bool

func IsArray

func IsArray(expr Sexp) bool

func IsAssignmentList

func IsAssignmentList(expr Sexp, pos int) (bool, int)

func IsChar

func IsChar(expr Sexp) bool

func IsEmpty

func IsEmpty(expr Sexp) bool

func IsExactlyDoublePointer

func IsExactlyDoublePointer(target interface{}) bool

true if target is of type **T where T is a struct/string/int/other-non-pointer type.

func IsExactlySinglePointer

func IsExactlySinglePointer(target interface{}) bool

true if target is type *T where T is a struct/string/int/other-non-pointer type.

func IsExactlySinglePointerType

func IsExactlySinglePointerType(typ reflect.Type) bool

func IsFloat

func IsFloat(expr Sexp) bool

func IsFunc

func IsFunc(expr Sexp) bool

func IsHash

func IsHash(expr Sexp) bool

func IsInt

func IsInt(expr Sexp) bool

func IsList

func IsList(expr Sexp) bool

func IsNumber

func IsNumber(expr Sexp) bool

func IsString

func IsString(expr Sexp) bool

func IsSymbol

func IsSymbol(expr Sexp) bool

func IsTruthy

func IsTruthy(expr Sexp) bool

func IsZero

func IsZero(expr Sexp) bool

func JsonToGo

func JsonToGo(json []byte) (interface{}, error)

json -> go

func ListLen

func ListLen(expr Sexp) (int, error)

func MergeFuncMap

func MergeFuncMap(funcs ...map[string]ZlispUserFunction) map[string]ZlispUserFunction

MergeFuncMap returns the union of the two given maps

func MsgpackToGo

func MsgpackToGo(msgp []byte) (interface{}, error)

msgpack -> go

func MyWordCompleter

func MyWordCompleter(line string, pos int) (head string, c []string, tail string)

complete phrases that start with '('

func NilOrHoldsNil

func NilOrHoldsNil(iface interface{}) bool

detect if inteface is holding anything

func P

func P(format string, stuff ...interface{})

P is a shortcut for a call to fmt.Printf that implicitly starts and ends its message with a newline.

func PointerDepth

func PointerDepth(typ reflect.Type) int

func ReflectionFunctions

func ReflectionFunctions() map[string]ZlispUserFunction

func RegisterDemoStructs

func RegisterDemoStructs()

func RemoveCommasFilter

func RemoveCommasFilter(x Sexp) bool

detect SexpComma values and return false on them to filter them out.

func RemoveCommentsFilter

func RemoveCommentsFilter(x Sexp) bool

func RemoveEndsFilter

func RemoveEndsFilter(x Sexp) bool

detect SexpEnd values and return false on them to filter them out.

func Repl

func Repl(env *Zlisp, cfg *ZlispConfig)

func ReplMain

func ReplMain(cfg *ZlispConfig)

like main() for a standalone repl, now in library

func SandboxSafeFunctions

func SandboxSafeFunctions() map[string]ZlispUserFunction

SandboxSafeFuncs returns all functions that are safe to run in a sandbox

func SetHashKeyOrder

func SetHashKeyOrder(hash *SexpHash, keyOrd Sexp) error

func SetShellCmd

func SetShellCmd()

set ShellCmd as used by SystemFunction

func SexpToGo

func SexpToGo(sexp Sexp, env *Zlisp, dedup map[*SexpHash]interface{}) (result interface{})

translate an Sexpr to a go value that doesn't depend on any Sexp/Zlisp types. Zlisp maps will get turned into map[string]interface{}. This is mostly just an exercise in type conversion.

on first entry, dedup can be nil. We use it to write the

same pointer for a SexpHash used in more than one place.

func SexpToGoStructs

func SexpToGoStructs(
	sexp Sexp,
	target interface{},
	env *Zlisp,
	dedup map[*SexpHash]interface{},

) (result interface{}, err error)

try to convert to registered go structs if possible, filling in the structure of target (should be a pointer).

func SexpToJson

func SexpToJson(exp Sexp) string

sexp -> json

func SexpToMsgpack

func SexpToMsgpack(exp Sexp) ([]byte, interface{})

translate to sexp -> json -> go -> msgpack returns both the msgpack []bytes and the go intermediary

func StrFunctions

func StrFunctions() map[string]ZlispUserFunction

func StringToRunes

func StringToRunes(str string) []rune

func SystemFunctions

func SystemFunctions() map[string]ZlispUserFunction

func TSPrintf

func TSPrintf(format string, a ...interface{})

time-stamped printf

func VPrintf

func VPrintf(format string, a ...interface{})

func Version

func Version() string

func WPrintf

func WPrintf(format string, a ...interface{})

Types

type AddFuncScopeHelper

type AddFuncScopeHelper struct {
	MyFunction *SexpFunction
}

type AddFuncScopeInstr

type AddFuncScopeInstr struct {
	Name   string
	Helper *AddFuncScopeHelper // we need a pointer we can update later once we know MyFunction
}

func (AddFuncScopeInstr) Execute

func (a AddFuncScopeInstr) Execute(env *Zlisp) error

func (AddFuncScopeInstr) InstrString

func (a AddFuncScopeInstr) InstrString() string

type AddScopeInstr

type AddScopeInstr struct {
	Name string
}

func (AddScopeInstr) Execute

func (a AddScopeInstr) Execute(env *Zlisp) error

func (AddScopeInstr) InstrString

func (a AddScopeInstr) InstrString() string

type Address

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

func (Address) IsStackElem

func (a Address) IsStackElem()

type AssignInstr

type AssignInstr struct {
}

func (AssignInstr) Execute

func (a AssignInstr) Execute(env *Zlisp) error

func (AssignInstr) InstrString

func (a AssignInstr) InstrString() string

type BindlistInstr

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

bind these symbols to the SexpPair list found at datastack top.

func (BindlistInstr) Execute

func (b BindlistInstr) Execute(env *Zlisp) error

func (BindlistInstr) InstrString

func (b BindlistInstr) InstrString() string

type Booter

type Booter func(s interface{})

Booter provides for registering a callback for any new Go struct created by the ToGoFunction (togo).

type BranchInstr

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

func (BranchInstr) Execute

func (b BranchInstr) Execute(env *Zlisp) error

func (BranchInstr) InstrString

func (b BranchInstr) InstrString() string

type BreakInstr

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

func (*BreakInstr) Execute

func (s *BreakInstr) Execute(env *Zlisp) error

func (BreakInstr) InstrString

func (s BreakInstr) InstrString() string

type CallInstr

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

func (CallInstr) Execute

func (c CallInstr) Execute(env *Zlisp) error

func (CallInstr) InstrString

func (c CallInstr) InstrString() string

type ClearStackmarkInstr

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

erase everything up-to-and-including our mark

func (ClearStackmarkInstr) Execute

func (s ClearStackmarkInstr) Execute(env *Zlisp) error

func (ClearStackmarkInstr) InstrString

func (s ClearStackmarkInstr) InstrString() string

type Closing

type Closing struct {
	Stack *Stack
	Name  string
	// contains filtered or unexported fields
}

where we store our closure-supporing stack pointers

func NewClosing

func NewClosing(name string, env *Zlisp) *Closing

func NewEmptyClosing

func NewEmptyClosing(name string, env *Zlisp) *Closing

func (*Closing) IsStackElem

func (c *Closing) IsStackElem()

func (*Closing) LookupSymbol

func (c *Closing) LookupSymbol(sym *SexpSymbol, setVal *Sexp) (Sexp, error, *Scope)

func (*Closing) LookupSymbolUntilFunction

func (c *Closing) LookupSymbolUntilFunction(sym *SexpSymbol, setVal *Sexp, maximumFuncToSearch int, checkCaptures bool) (Sexp, error, *Scope)

func (*Closing) Show

func (c *Closing) Show(env *Zlisp, ps *PrintState, label string) (string, error)

func (*Closing) TopScope

func (c *Closing) TopScope() *Scope

type ContinueInstr

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

func (*ContinueInstr) Execute

func (s *ContinueInstr) Execute(env *Zlisp) error

func (ContinueInstr) InstrString

func (s ContinueInstr) InstrString() string

type CreateClosureInstr

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

when a defn or fn executes, capture the creation env.

func (CreateClosureInstr) Execute

func (a CreateClosureInstr) Execute(env *Zlisp) error

func (CreateClosureInstr) InstrString

func (a CreateClosureInstr) InstrString() string

type DataStackElem

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

func (DataStackElem) IsStackElem

func (d DataStackElem) IsStackElem()

type DebugInstr

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

func (DebugInstr) Execute

func (g DebugInstr) Execute(env *Zlisp) error

func (DebugInstr) InstrString

func (g DebugInstr) InstrString() string

type DispatchInstr

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

func (DispatchInstr) Execute

func (d DispatchInstr) Execute(env *Zlisp) error

func (DispatchInstr) InstrString

func (d DispatchInstr) InstrString() string

type DupInstr

type DupInstr int

func (DupInstr) Execute

func (d DupInstr) Execute(env *Zlisp) error

func (DupInstr) InstrString

func (d DupInstr) InstrString() string

type EmbedPath

type EmbedPath struct {
	ChildName     string
	ChildFieldNum int
}

type EnvToStackInstr

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

func (EnvToStackInstr) Execute

func (g EnvToStackInstr) Execute(env *Zlisp) error

func (EnvToStackInstr) InstrString

func (g EnvToStackInstr) InstrString() string

type Event

type Event struct {
	Id        int      `json:"id" msg:"id"`
	User      Person   `json:"user" msg:"user"`
	Flight    string   `json:"flight" msg:"flight"`
	Pilot     []string `json:"pilot" msg:"pilot"`
	Cancelled bool     `json:"cancelled" msg:"cancelled"`
}

func (*Event) DecodeMsg

func (z *Event) DecodeMsg(dc *msgp.Reader) (err error)

DecodeMsg implements msgp.Decodable

func (*Event) DisplayEvent

func (ev *Event) DisplayEvent(from string)

func (*Event) EncodeMsg

func (z *Event) EncodeMsg(en *msgp.Writer) (err error)

EncodeMsg implements msgp.Encodable

func (*Event) MarshalMsg

func (z *Event) MarshalMsg(b []byte) (o []byte, err error)

MarshalMsg implements msgp.Marshaler

func (*Event) Msgsize

func (z *Event) Msgsize() (s int)

Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message

func (*Event) UnmarshalMsg

func (z *Event) UnmarshalMsg(bts []byte) (o []byte, err error)

UnmarshalMsg implements msgp.Unmarshaler

type ExplodeInstr

type ExplodeInstr int

func (ExplodeInstr) Execute

func (e ExplodeInstr) Execute(env *Zlisp) error

func (ExplodeInstr) InstrString

func (e ExplodeInstr) InstrString() string

type Filter

type Filter func(x Sexp) bool

Filters return true to keep, false to drop.

type Flyer

type Flyer interface {
	Fly(w *Weather) (s string, err error)
}

type Generator

type Generator struct {
	Tail bool
	// contains filtered or unexported fields
}

func NewGenerator

func NewGenerator(env *Zlisp) *Generator

func (*Generator) AddInstruction

func (gen *Generator) AddInstruction(instr Instruction)

func (*Generator) AddInstructions

func (gen *Generator) AddInstructions(instr []Instruction)

func (*Generator) Generate

func (gen *Generator) Generate(expr Sexp) error

func (*Generator) GenerateAll

func (gen *Generator) GenerateAll(expressions []Sexp) error

func (*Generator) GenerateArray

func (gen *Generator) GenerateArray(arr *SexpArray) error

func (*Generator) GenerateAssert

func (gen *Generator) GenerateAssert(args []Sexp) error

func (*Generator) GenerateAssignment

func (gen *Generator) GenerateAssignment(expr *SexpPair, assignPos int) error

func (*Generator) GenerateBegin

func (gen *Generator) GenerateBegin(expressions []Sexp) error

func (*Generator) GenerateBreak

func (gen *Generator) GenerateBreak(args []Sexp) error

func (*Generator) GenerateBuilder

func (gen *Generator) GenerateBuilder(fun Sexp, args []Sexp) error

func (*Generator) GenerateCall

func (gen *Generator) GenerateCall(expr *SexpPair) error

func (*Generator) GenerateCallBySymbol

func (gen *Generator) GenerateCallBySymbol(sym *SexpSymbol, args []Sexp, orig Sexp) error

func (*Generator) GenerateCond

func (gen *Generator) GenerateCond(args []Sexp) error

func (*Generator) GenerateContinue

func (gen *Generator) GenerateContinue(args []Sexp) error

func (*Generator) GenerateDebug

func (gen *Generator) GenerateDebug(diag string) error

func (*Generator) GenerateDef

func (gen *Generator) GenerateDef(args []Sexp, opname string) error

func (*Generator) GenerateDefmac

func (gen *Generator) GenerateDefmac(args []Sexp, orig Sexp) error

func (*Generator) GenerateDefn

func (gen *Generator) GenerateDefn(args []Sexp, orig Sexp) error

func (*Generator) GenerateDispatch

func (gen *Generator) GenerateDispatch(fun Sexp, args []Sexp) error

func (*Generator) GenerateFn

func (gen *Generator) GenerateFn(args []Sexp, orig Sexp) error

func (*Generator) GenerateForLoop

func (gen *Generator) GenerateForLoop(args []Sexp) error

for loops: Just like in C.

(for {optional-label} [init predicate advance] (expr)*)

Each of init, predicate, and advance are expressions that are evaluated during the running of the for loop. The init expression is evaluated once at the top. The predicate is tested. If it is true then the body expressions are run. Then the advance expression is evaluated, and we return to the predicate test.

func (*Generator) GenerateInclude

func (gen *Generator) GenerateInclude(args []Sexp) error

func (*Generator) GenerateLet

func (gen *Generator) GenerateLet(name string, args []Sexp) error

func (*Generator) GenerateMacexpand

func (gen *Generator) GenerateMacexpand(args []Sexp) error

func (*Generator) GenerateMultiDef

func (gen *Generator) GenerateMultiDef(args []Sexp) error

(mdef a b c (list 1 2 3)) will bind a:1 b:2 c:3

func (*Generator) GenerateNewScope

func (gen *Generator) GenerateNewScope(expressions []Sexp) error

like begin, but puts its contents in a new scope

func (*Generator) GeneratePackage

func (gen *Generator) GeneratePackage(expressions []Sexp) error

func (*Generator) GenerateQuote

func (gen *Generator) GenerateQuote(args []Sexp) error

func (*Generator) GenerateReturn

func (gen *Generator) GenerateReturn(xs []Sexp) error

func (*Generator) GenerateShortCircuit

func (gen *Generator) GenerateShortCircuit(or bool, args []Sexp) error

func (*Generator) GenerateSyntaxQuote

func (gen *Generator) GenerateSyntaxQuote(args []Sexp) error

side-effect (or main effect) has to be pushing an expression on the top of the datastack that represents the expanded and substituted expression

func (*Generator) GetLHS

func (gen *Generator) GetLHS(arg Sexp, opname string) (*SexpSymbol, error)

func (*Generator) Reset

func (gen *Generator) Reset()

type GoStructRegistryType

type GoStructRegistryType struct {
	// comprehensive
	Registry map[string]*RegisteredType

	// only init-time builtins
	Builtin map[string]*RegisteredType

	// later, user-defined types
	Userdef map[string]*RegisteredType
}

the registry type

var GoStructRegistry GoStructRegistryType

The Go Type Registry ====================

simply decide upon a name, and add a maker function for that returns a pointer to your struct. The simply add to the init() function below.

The env parameter to your MakeGoStructFunc() function is there is case you want to initialize your struct differently depending on the content of its context, but this is not commonly needed. Also, the factory method *must* support the env parameter being nil and still return a sensible, usable value. The factory will be called with env = nil during init() time.

The repl will automatically do a (defmap record) for each record defined in the registry. e.g. for snoopy, hornet, hellcat, etc.

func (*GoStructRegistryType) GetOrCreatePointerType

func (gsr *GoStructRegistryType) GetOrCreatePointerType(pointedToType *RegisteredType) *RegisteredType

func (*GoStructRegistryType) GetOrCreateSliceType

func (gsr *GoStructRegistryType) GetOrCreateSliceType(rt *RegisteredType) *RegisteredType

func (*GoStructRegistryType) Lookup

func (r *GoStructRegistryType) Lookup(name string) *RegisteredType

func (*GoStructRegistryType) RegisterBuiltin

func (r *GoStructRegistryType) RegisterBuiltin(name string, e *RegisteredType)

func (*GoStructRegistryType) RegisterPointer

func (r *GoStructRegistryType) RegisterPointer(pointedToName string, pointedToType *RegisteredType) *RegisteredType

func (*GoStructRegistryType) RegisterUserdef

func (r *GoStructRegistryType) RegisterUserdef(
	e *RegisteredType,
	hasShadowStruct bool,
	names ...string)

type GotoInstr

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

func (GotoInstr) Execute

func (g GotoInstr) Execute(env *Zlisp) error

func (GotoInstr) InstrString

func (g GotoInstr) InstrString() string

type HashFieldDet

type HashFieldDet struct {
	FieldNum     int
	FieldType    reflect.Type
	StructField  reflect.StructField
	FieldName    string
	FieldJsonTag string
	EmbedPath    []EmbedPath // we are embedded if len(EmbedPath) > 0
}

type HashizeInstr

type HashizeInstr struct {
	HashLen  int
	TypeName string
}

func (HashizeInstr) Execute

func (s HashizeInstr) Execute(env *Zlisp) error

func (HashizeInstr) InstrString

func (s HashizeInstr) InstrString() string

type Hellcat

type Hellcat struct {
	Plane `json:"plane" msg:"plane"`
}

func (*Hellcat) Fly

func (b *Hellcat) Fly(w *Weather) (s string, err error)

type Hornet

type Hornet struct {
	Plane    `json:"plane" msg:"plane"`
	Mass     float64
	Nickname string
}

func (*Hornet) Fly

func (b *Hornet) Fly(w *Weather) (s string, err error)

type InfixOp

type InfixOp struct {
	Sym        *SexpSymbol
	Bp         int          // binding power, aka precedence level.
	MunchRight RightMuncher // aka nud
	MunchLeft  LeftMuncher  // aka led
	MunchStmt  StmtMuncher  // aka std. Used only at the beginning of a statement.
	IsAssign   bool
}

InfixOp lets us attach led (MunchLeft) and nud (MunchRight) Pratt parsing methods, along with a binding power, to a symbol.

type Instruction

type Instruction interface {
	InstrString() string
	Execute(env *Zlisp) error
}

type IntegerOp

type IntegerOp int
const (
	ShiftLeft IntegerOp = iota
	ShiftRightArith
	ShiftRightLog
	Modulo
	BitAnd
	BitOr
	BitXor
)

type JumpInstr

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

func (JumpInstr) Execute

func (j JumpInstr) Execute(env *Zlisp) error

func (JumpInstr) InstrString

func (j JumpInstr) InstrString() string

type KiSlice

type KiSlice []*mapsorter

func (KiSlice) Len

func (a KiSlice) Len() int

func (KiSlice) Less

func (a KiSlice) Less(i, j int) bool

func (KiSlice) Swap

func (a KiSlice) Swap(i, j int)

type LabelInstr

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

func (LabelInstr) Execute

func (s LabelInstr) Execute(env *Zlisp) error

func (LabelInstr) InstrString

func (s LabelInstr) InstrString() string

type LeftMuncher

type LeftMuncher func(env *Zlisp, pr *Pratt, left Sexp) (Sexp, error)

type Lexer

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

func NewLexer

func NewLexer(p *Parser) *Lexer

func (*Lexer) AddNextStream

func (lex *Lexer) AddNextStream(s io.RuneScanner)

func (*Lexer) AppendToken

func (lexer *Lexer) AppendToken(tok Token)

func (*Lexer) DecodeAtom

func (x *Lexer) DecodeAtom(atom string) (tk Token, err error)

func (*Lexer) DecodeBrace

func (x *Lexer) DecodeBrace(brace rune) Token

func (*Lexer) EmptyToken

func (lex *Lexer) EmptyToken() Token

func (*Lexer) GetNextToken

func (lexer *Lexer) GetNextToken() (tok Token, err error)

func (*Lexer) LexNextRune

func (lexer *Lexer) LexNextRune(r rune) error

func (*Lexer) Linenum

func (lexer *Lexer) Linenum() int

func (*Lexer) PeekNextToken

func (lexer *Lexer) PeekNextToken() (tok Token, err error)

func (*Lexer) PrependToken

func (lexer *Lexer) PrependToken(tok Token)

func (*Lexer) PromoteNextStream

func (lex *Lexer) PromoteNextStream() (ok bool)

func (*Lexer) Reset

func (lex *Lexer) Reset()

func (*Lexer) Token

func (lex *Lexer) Token(typ TokenType, str string) Token

type LexerState

type LexerState int
const (
	LexerNormal         LexerState = iota
	LexerCommentLine               //
	LexerStrLit                    //
	LexerStrEscaped                //
	LexerUnquote                   //
	LexerBacktickString            //
	LexerFreshAssignOrColon
	LexerFirstFwdSlash // could be start of // comment or /*
	LexerCommentBlock
	LexerCommentBlockAsterisk // could be end of block comment */
	LexerBuiltinOperator
	LexerRuneLit
	LexerRuneEscaped
)

type Loop

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

func (*Loop) IsStackElem

func (loop *Loop) IsStackElem()

type LoopStartInstr

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

func (LoopStartInstr) Execute

func (s LoopStartInstr) Execute(env *Zlisp) error

func (LoopStartInstr) InstrString

func (s LoopStartInstr) InstrString() string

type MakeGoStructFunc

type MakeGoStructFunc func(env *Zlisp, h *SexpHash) (interface{}, error)

type NestInner

type NestInner struct {
	Hello string `msg:"hello" json:"hello" zid:"0"`
}

func (*NestInner) DecodeMsg

func (z *NestInner) DecodeMsg(dc *msgp.Reader) (err error)

DecodeMsg implements msgp.Decodable

func (NestInner) EncodeMsg

func (z NestInner) EncodeMsg(en *msgp.Writer) (err error)

EncodeMsg implements msgp.Encodable

func (NestInner) MarshalMsg

func (z NestInner) MarshalMsg(b []byte) (o []byte, err error)

MarshalMsg implements msgp.Marshaler

func (NestInner) Msgsize

func (z NestInner) Msgsize() (s int)

Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message

func (*NestInner) UnmarshalMsg

func (z *NestInner) UnmarshalMsg(bts []byte) (o []byte, err error)

UnmarshalMsg implements msgp.Unmarshaler

type NestOuter

type NestOuter struct {
	Inner *NestInner `msg:"inner" json:"inner" zid:"0"`
}

the pointer wasn't getting followed.

func (*NestOuter) DecodeMsg

func (z *NestOuter) DecodeMsg(dc *msgp.Reader) (err error)

DecodeMsg implements msgp.Decodable

func (*NestOuter) EncodeMsg

func (z *NestOuter) EncodeMsg(en *msgp.Writer) (err error)

EncodeMsg implements msgp.Encodable

func (*NestOuter) MarshalMsg

func (z *NestOuter) MarshalMsg(b []byte) (o []byte, err error)

MarshalMsg implements msgp.Marshaler

func (*NestOuter) Msgsize

func (z *NestOuter) Msgsize() (s int)

Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message

func (*NestOuter) UnmarshalMsg

func (z *NestOuter) UnmarshalMsg(bts []byte) (o []byte, err error)

UnmarshalMsg implements msgp.Unmarshaler

type NumericOp

type NumericOp int
const (
	Add NumericOp = iota
	Sub
	Mult
	Div
	Pow
)

type Parser

type Parser struct {
	Done chan bool

	AddInput     chan io.RuneScanner
	ReqReset     chan io.RuneScanner
	ParsedOutput chan []ParserReply

	FlagSendNeedInput bool
	// contains filtered or unexported fields
}

func (*Parser) GetMoreInput

func (p *Parser) GetMoreInput(deliverThese []Sexp, errorToReport error) error

This function should *return* when it has more input for the parser/lexer, which will call it when they get wedged.

Listeners on p.ParsedOutput should know the Convention: sending a length 0 []ParserReply on p.ParsedOutput channel means: we need more input! They should send some in on p.AddInput channel; or request a reset and simultaneously give us new input with p.ReqReset channel.

func (*Parser) HaveStuffToSend

func (p *Parser) HaveStuffToSend() chan []ParserReply

func (*Parser) NewInput

func (p *Parser) NewInput(s io.RuneScanner)

func (*Parser) ParseArray

func (parser *Parser) ParseArray(depth int) (Sexp, error)

func (*Parser) ParseBacktickString

func (parser *Parser) ParseBacktickString(start *Token) (sx Sexp, err error)

func (*Parser) ParseBlockComment

func (parser *Parser) ParseBlockComment(start *Token) (sx Sexp, err error)

func (*Parser) ParseExpression

func (parser *Parser) ParseExpression(depth int) (res Sexp, err error)

func (*Parser) ParseInfix

func (parser *Parser) ParseInfix(depth int) (Sexp, error)

func (*Parser) ParseList

func (parser *Parser) ParseList(depth int) (sx Sexp, err error)

func (*Parser) ParseTokens

func (p *Parser) ParseTokens() ([]Sexp, error)

ParseTokens is the main service the Parser provides. Currently returns first error encountered, ignoring any expressions after that.

func (*Parser) Reset

func (p *Parser) Reset()

func (*Parser) ResetAddNewInput

func (p *Parser) ResetAddNewInput(s io.RuneScanner)

func (*Parser) Start

func (p *Parser) Start()

Starts launches a background goroutine that runs an infinite parsing loop.

func (*Parser) Stop

func (p *Parser) Stop() error

type ParserReply

type ParserReply struct {
	Expr []Sexp
	Err  error
}

type Person

type Person struct {
	First string `json:"first" msg:"first"`
	Last  string `json:"last" msg:"last"`
}

func (*Person) DecodeMsg

func (z *Person) DecodeMsg(dc *msgp.Reader) (err error)

DecodeMsg implements msgp.Decodable

func (Person) EncodeMsg

func (z Person) EncodeMsg(en *msgp.Writer) (err error)

EncodeMsg implements msgp.Encodable

func (Person) MarshalMsg

func (z Person) MarshalMsg(b []byte) (o []byte, err error)

MarshalMsg implements msgp.Marshaler

func (Person) Msgsize

func (z Person) Msgsize() (s int)

Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message

func (*Person) UnmarshalMsg

func (z *Person) UnmarshalMsg(bts []byte) (o []byte, err error)

UnmarshalMsg implements msgp.Unmarshaler

type Plane

type Plane struct {
	Wings

	ID      int     `json:"id" msg:"id"`
	Speed   int     `json:"speed" msg:"speed"`
	Chld    Flyer   `json:"chld" msg:"chld"`
	Friends []Flyer `json:"friends"`
}

the interface Flyer confounds the msgp msgpack code generator, so put the msgp:ignore Plane above

type PopInstr

type PopInstr int

func (PopInstr) Execute

func (p PopInstr) Execute(env *Zlisp) error

func (PopInstr) InstrString

func (p PopInstr) InstrString() string

type PopScopeTransferToDataStackInstr

type PopScopeTransferToDataStackInstr struct {
	PackageName string
}

PopScopeTransferToDataStackInstr is used to wrap up a package and put it on the data stack as a value.

func (PopScopeTransferToDataStackInstr) Execute

func (PopScopeTransferToDataStackInstr) InstrString

func (a PopScopeTransferToDataStackInstr) InstrString() string

type PopStackPutEnvInstr

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

func (PopStackPutEnvInstr) Execute

func (p PopStackPutEnvInstr) Execute(env *Zlisp) error

func (PopStackPutEnvInstr) InstrString

func (p PopStackPutEnvInstr) InstrString() string

type PopUntilStackmarkInstr

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

cleanup until our stackmark, but leave it in place

func (PopUntilStackmarkInstr) Execute

func (s PopUntilStackmarkInstr) Execute(env *Zlisp) error

func (PopUntilStackmarkInstr) InstrString

func (s PopUntilStackmarkInstr) InstrString() string

type PostHook

type PostHook func(*Zlisp, string, Sexp)

type Pratt

type Pratt struct {
	NextToken  Sexp
	CnodeStack []Sexp
	AccumTree  Sexp

	Pos    int
	Stream []Sexp
}

func NewPratt

func NewPratt(stream []Sexp) *Pratt

func (*Pratt) Advance

func (p *Pratt) Advance() error

Advance sets p.NextToken

func (*Pratt) Expression

func (p *Pratt) Expression(env *Zlisp, rbp int) (ret Sexp, err error)

func (*Pratt) IsEOF

func (p *Pratt) IsEOF() bool

func (*Pratt) ShowCnodeStack

func (p *Pratt) ShowCnodeStack()

type PreHook

type PreHook func(*Zlisp, string, []Sexp)

type PrintState

type PrintState struct {
	Indent int
	Seen   Seen
}

PrintState threads the state of display through SexpString() and Show() calls, to give pretty-printing indentation and to avoid infinite looping on cyclic data structures.

func NewPrintState

func NewPrintState() *PrintState

func NewPrintStateWithIndent

func NewPrintStateWithIndent(indent int) *PrintState

func (*PrintState) AddIndent

func (ps *PrintState) AddIndent(addme int) *PrintState

func (*PrintState) Clear

func (ps *PrintState) Clear()

func (*PrintState) Dump

func (ps *PrintState) Dump()

func (*PrintState) GetIndent

func (ps *PrintState) GetIndent() int

func (*PrintState) GetSeen

func (ps *PrintState) GetSeen(x interface{}) bool

func (*PrintState) SetSeen

func (ps *PrintState) SetSeen(x interface{}, name string)

type Prompter

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

func NewPrompter

func NewPrompter(prompt string) *Prompter

func (*Prompter) Close

func (p *Prompter) Close()

func (*Prompter) Getline

func (p *Prompter) Getline(prompt *string) (line string, err error)

type PushInstr

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

func (PushInstr) Execute

func (p PushInstr) Execute(env *Zlisp) error

func (PushInstr) InstrString

func (p PushInstr) InstrString() string

type PushStackmarkInstr

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

create a stack mark

func (PushStackmarkInstr) Execute

func (s PushStackmarkInstr) Execute(env *Zlisp) error

func (PushStackmarkInstr) InstrString

func (s PushStackmarkInstr) InstrString() string

type RecordDefn

type RecordDefn struct {
	Name      string
	Fields    []*SexpField
	FieldType map[string]*RegisteredType
}

func NewRecordDefn

func NewRecordDefn() *RecordDefn

func (*RecordDefn) SetFields

func (r *RecordDefn) SetFields(flds []*SexpField)

func (*RecordDefn) SetName

func (r *RecordDefn) SetName(name string)

func (*RecordDefn) SexpString

func (p *RecordDefn) SexpString(ps *PrintState) string

pretty print a struct

func (*RecordDefn) Type

func (p *RecordDefn) Type() *RegisteredType

type RegisteredType

type RegisteredType struct {
	Constructor    *SexpFunction
	RegisteredName string
	Factory        MakeGoStructFunc
	GenDefMap      bool
	ValueCache     reflect.Value
	TypeCache      reflect.Type
	PointerName    string
	ReflectName    string
	IsUser         bool
	Aliases        map[string]bool
	DisplayAs      string
	UserStructDefn *RecordDefn
	IsPointer      bool
	// contains filtered or unexported fields
}
var ArraySelectorRT *RegisteredType
var BoolRT *RegisteredType
var ClosureRT *RegisteredType
var ErrorRT *RegisteredType
var Float64RT *RegisteredType
var Int64RT *RegisteredType
var NullRT *RegisteredType
var PairRT *RegisteredType
var RawRT *RegisteredType
var ReflectRT *RegisteredType
var RuneRT *RegisteredType
var SentinelRT *RegisteredType

func NewRegisteredType

func NewRegisteredType(f MakeGoStructFunc) *RegisteredType

func (*RegisteredType) Init

func (e *RegisteredType) Init()

func (*RegisteredType) SexpString

func (p *RegisteredType) SexpString(ps *PrintState) string

func (*RegisteredType) ShortName

func (p *RegisteredType) ShortName() string

func (*RegisteredType) Type

func (r *RegisteredType) Type() *RegisteredType

func (*RegisteredType) TypeCheckRecord

func (p *RegisteredType) TypeCheckRecord(hash *SexpHash) error

type RemoveScopeInstr

type RemoveScopeInstr struct{}

func (RemoveScopeInstr) Execute

func (a RemoveScopeInstr) Execute(env *Zlisp) error

func (RemoveScopeInstr) InstrString

func (a RemoveScopeInstr) InstrString() string

type ReturnInstr

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

func (ReturnInstr) Execute

func (r ReturnInstr) Execute(env *Zlisp) error

func (ReturnInstr) InstrString

func (r ReturnInstr) InstrString() string

type RightMuncher

type RightMuncher func(env *Zlisp, pr *Pratt) (Sexp, error)

type Scope

type Scope struct {
	Map         map[int]Sexp
	IsGlobal    bool
	Name        string
	PackageName string
	Parent      *Scope
	IsFunction  bool          // if true, read-only.
	MyFunction  *SexpFunction // so we can query captured closure scopes.
	IsPackage   bool
	// contains filtered or unexported fields
}

Scopes map names to values. Scope nesting avoids variable name collisions and allows namespace maintainance. Most scopes (inside loops, inside functions) are implicitly created. Packages are scopes that the user can manipulate explicitly.

func (*Scope) CloneScope

func (s *Scope) CloneScope() *Scope

func (*Scope) DeleteSymbolInScope

func (scope *Scope) DeleteSymbolInScope(sym *SexpSymbol) error

func (Scope) IsStackElem

func (s Scope) IsStackElem()

func (*Scope) SexpString

func (s *Scope) SexpString(ps *PrintState) string

SexpString satisfies the Sexp interface, producing a string presentation of the value.

func (*Scope) Show

func (scop *Scope) Show(env *Zlisp, ps *PrintState, label string) (s string, err error)

func (*Scope) Type

func (s *Scope) Type() *RegisteredType

Type() satisfies the Sexp interface, returning the type of the value.

func (*Scope) UpdateSymbolInScope

func (scope *Scope) UpdateSymbolInScope(sym *SexpSymbol, expr Sexp) error

used to implement (set v 10)

type Seen

type Seen map[interface{}]struct{}

Seen tracks if a value has already been displayed, to detect and avoid cycles.

Q: How to do garbage-collection safe graph traversal in a graph of Go objects?

A: "Instead of converting the pointer to a uintptr, just store the pointer itself in a map[interface{}]bool. If you encounter the same pointer again, you will get the same map entry. The GC must guarantee that using pointers as map keys will work even if the pointers move."

- Ian Lance Taylor on golang-nuts (2016 June 20).

func NewSeen

func NewSeen() Seen

type Selector

type Selector interface {
	// RHS (right-hand-side) is used to dereference
	// the pointer-like Selector, yielding a value suitable for the
	// right-hand-side of an assignment statement.
	//
	RHS(env *Zlisp) (Sexp, error)

	// AssignToSelection sets the selection to rhs
	// The selected elements are the left-hand-side of the
	// assignment *lhs = rhs
	AssignToSelection(env *Zlisp, rhs Sexp) error
}

Selector stores indexing information that isn't yet materialized for getting or setting.

type SetOfPlanes

type SetOfPlanes struct {
	Flyers []Flyer `json:"flyers" msg:"flyers"`
}

type Sexp

type Sexp interface {
	// SexpString: produce a string from our value.
	// Single-line strings can ignore indent.
	// Only multiline strings should follow every
	// newline with at least indent worth of spaces.
	SexpString(ps *PrintState) string

	// Type returns the type of the value.
	Type() *RegisteredType
}

Sexp is the central interface for all S-expressions (Symbol expressions ala lisp).

func AddressOfFunction

func AddressOfFunction(env *Zlisp, name string, args []Sexp) (Sexp, error)

func AppendFunction

func AppendFunction(env *Zlisp, name string, args []Sexp) (Sexp, error)

func ApplyFunction

func ApplyFunction(env *Zlisp, name string, args []Sexp) (Sexp, error)

func ArrayAccessFunction

func ArrayAccessFunction(env *Zlisp, name string, args []Sexp) (Sexp, error)

func ArrayIndexFunction

func ArrayIndexFunction(env *Zlisp, name string, args []Sexp) (Sexp, error)

(arrayidx ar [0 1])

func ArrayOfFunction

func ArrayOfFunction(env *Zlisp, name string,
	args []Sexp) (Sexp, error)

generate fixed size array

func AsTmFunction

func AsTmFunction(env *Zlisp, name string,
	args []Sexp) (Sexp, error)

string -> time.Time

func AsUint64Function

func AsUint64Function(env *Zlisp, name string, args []Sexp) (Sexp, error)

coerce numbers to uint64

func AssignmentFunction

func AssignmentFunction(env *Zlisp, name string, args []Sexp) (Sexp, error)

the assignment function, =

func BaseTypeConstructorFunction

func BaseTypeConstructorFunction(env *Zlisp, name string, args []Sexp) (Sexp, error)

func BinaryIntFunction

func BinaryIntFunction(env *Zlisp, name string, args []Sexp) (Sexp, error)

func BitwiseFunction

func BitwiseFunction(env *Zlisp, name string, args []Sexp) (Sexp, error)

func CallGoMethodFunction

func CallGoMethodFunction(env *Zlisp, name string, args []Sexp) (Sexp, error)

Using reflection, invoke a Go method on a struct or interface. args[0] is a hash with an an attached GoStruct args[1] is a hash representing a method call on that struct. The returned Sexp is a hash that represents the result of that call.

func CallZMethodOnRecordFunction

func CallZMethodOnRecordFunction(env *Zlisp, name string, args []Sexp) (Sexp, error)

func ChanTxFunction

func ChanTxFunction(env *Zlisp, name string,
	args []Sexp) (Sexp, error)

func ColonAccessBuilder

func ColonAccessBuilder(env *Zlisp, name string, args []Sexp) (Sexp, error)

func CommaBuilder

func CommaBuilder(env *Zlisp, name string, args []Sexp) (Sexp, error)

CommaBuilder turns expressions on the LHS and RHS like {a,b,c = 1,2,3} into arrays (set [a b c] [1 2 3])

func CompareFunction

func CompareFunction(env *Zlisp, name string, args []Sexp) (Sexp, error)

func ComplementFunction

func ComplementFunction(env *Zlisp, name string, args []Sexp) (Sexp, error)

func ConcatArray

func ConcatArray(arr *SexpArray, rest []Sexp) (Sexp, error)

func ConcatFunction

func ConcatFunction(env *Zlisp, name string, args []Sexp) (Sexp, error)

func ConcatLists

func ConcatLists(a *SexpPair, bs []Sexp) (Sexp, error)

O(n^2) for n total nodes in all lists. So this is not super efficient. We have to find the tail of each list in turn by linear search. Avoid lists if possible in favor of arrays.

func ConcatTwoLists

func ConcatTwoLists(a *SexpPair, b Sexp) (Sexp, error)

func ConsFunction

func ConsFunction(env *Zlisp, name string, args []Sexp) (Sexp, error)

func ConstructorFunction

func ConstructorFunction(env *Zlisp, name string, args []Sexp) (Sexp, error)

func CreateGoroutineMacro

func CreateGoroutineMacro(env *Zlisp, name string,
	args []Sexp) (Sexp, error)

func DeclareMsgpackMapFunction

func DeclareMsgpackMapFunction(env *Zlisp, name string, args []Sexp) (Sexp, error)

func DefinedFunction

func DefinedFunction(env *Zlisp, name string, args []Sexp) (Sexp, error)

check is a symbol/string/value is defined

func DemoNestInnerOuterFunction

func DemoNestInnerOuterFunction(env *Zlisp, name string, args []Sexp) (Sexp, error)

constructor

func DerefFunction

func DerefFunction(env *Zlisp, name string, args []Sexp) (result Sexp, err error)

func DotFunction

func DotFunction(env *Zlisp, name string, args []Sexp) (Sexp, error)

"." dot operator

func DumpClosureEnvFunction

func DumpClosureEnvFunction(env *Zlisp, name string, args []Sexp) (Sexp, error)

_closdump : show the closed over env attached to an *SexpFunction

func EvalFunction

func EvalFunction(env *Zlisp, name string, args []Sexp) (Sexp, error)

EvalFunction: new version doesn't use a duplicated environment, allowing eval to create closures under the lexical scope and to allow proper scoping in a package.

func ExitFunction

func ExitFunction(env *Zlisp, name string, args []Sexp) (Sexp, error)

func ExpectErrorBuilder

func ExpectErrorBuilder(env *Zlisp, name string, args []Sexp) (Sexp, error)

func FirstFunction

func FirstFunction(env *Zlisp, name string, args []Sexp) (Sexp, error)

func FlattenToWordsFunction

func FlattenToWordsFunction(env *Zlisp, name string, args []Sexp) (Sexp, error)

given strings/lists of strings with possible whitespace flatten out to a array of SexpStr with no internal whitespace, suitable for passing along to (system) / exec.Command()

func FromGoFunction

func FromGoFunction(env *Zlisp, name string, args []Sexp) (Sexp, error)

func FuncBuilder

func FuncBuilder(env *Zlisp, name string,
	args []Sexp) (Sexp, error)

func GOOSFunction

func GOOSFunction(env *Zlisp, name string, args []Sexp) (Sexp, error)

func GenericAccessFunction

func GenericAccessFunction(env *Zlisp, name string, args []Sexp) (Sexp, error)

handles arrays or hashes

func GenericHpairFunction

func GenericHpairFunction(env *Zlisp, name string, args []Sexp) (Sexp, error)

works over hashes and arrays

func GensymFunction

func GensymFunction(env *Zlisp, name string, args []Sexp) (Sexp, error)

func GetEnvFunction

func GetEnvFunction(env *Zlisp, name string, args []Sexp) (Sexp, error)

func GoFieldListFunction

func GoFieldListFunction(env *Zlisp, name string, args []Sexp) (Sexp, error)

func GoMethodListFunction

func GoMethodListFunction(env *Zlisp, name string, args []Sexp) (Sexp, error)

func GoToSexp

func GoToSexp(iface interface{}, env *Zlisp) (Sexp, error)

convert iface, which will typically be map[string]interface{}, into an s-expression

func GobDecodeFunction

func GobDecodeFunction(env *Zlisp, name string, args []Sexp) (Sexp, error)

func GobEncodeFunction

func GobEncodeFunction(env *Zlisp, name string, args []Sexp) (Sexp, error)

func GoonDumpFunction

func GoonDumpFunction(env *Zlisp, name string, args []Sexp) (Sexp, error)

func HashAccessFunction

func HashAccessFunction(env *Zlisp, name string, args []Sexp) (Sexp, error)

func HashColonFunction

func HashColonFunction(env *Zlisp, name string, args []Sexp) (Sexp, error)

func HashIndexFunction

func HashIndexFunction(env *Zlisp, name string, args []Sexp) (Sexp, error)

(arrayidx ar [0 1]) refers here

func ImportPackageBuilder

func ImportPackageBuilder(env *Zlisp, name string, args []Sexp) (Sexp, error)

import a package, analagous to Golang.

func InfixBuilder

func InfixBuilder(env *Zlisp, name string, args []Sexp) (Sexp, error)

func IntegerDo

func IntegerDo(op IntegerOp, a, b Sexp) (Sexp, error)

func InterfaceBuilder

func InterfaceBuilder(env *Zlisp, name string,
	args []Sexp) (Sexp, error)

func IsNaNFunction

func IsNaNFunction(env *Zlisp, name string, args []Sexp) (Sexp, error)

func JoinSymFunction

func JoinSymFunction(env *Zlisp, name string, args []Sexp) (Sexp, error)

func JsonFunction

func JsonFunction(env *Zlisp, name string, args []Sexp) (Sexp, error)
Conversion map

Go map[string]interface{}  <--(1)--> lisp
  ^                                  ^ |
  |                                 /  |
 (2)   ------------ (4) -----------/  (5)
  |   /                                |
  V  V                                 V
msgpack <--(3)--> go struct, strongly typed

(1) we provide these herein; see jsonmsgp_test.go too.

(a) SexpToGo()
(b) GoToSexp()

(2) provided by ugorji/go/codec; see examples also herein

(a) MsgpackToGo() / JsonToGo()
(b) GoToMsgpack() / GoToJson()

(3) provided by tinylib/msgp, and by ugorji/go/codec

by using pre-compiled or just decoding into an instance
of the struct.

(4) see herein

(a) SexpToMsgpack() and SexpToJson()
(b) MsgpackToSexp(); uses (4) = (2) + (1)

(5) The SexpToGoStructs() and ToGoFunction() in this

file provide the capability of marshaling an
s-expression to a Go-struct that has been
registered to be associated with a named
hash map using (defmap). See repl/gotypereg.go
to add your Go-struct constructor. From
the prompt, the (togo) function instantiates
a 'shadow' Go-struct whose data matches
that configured in the record.

func JsonToSexp

func JsonToSexp(json []byte, env *Zlisp) (Sexp, error)

json -> sexp. env is needed to handle symbols correctly

func LenFunction

func LenFunction(env *Zlisp, name string, args []Sexp) (Sexp, error)

func ListToArray

func ListToArray(expr Sexp) ([]Sexp, error)

func MakeArrayFunction

func MakeArrayFunction(env *Zlisp, name string, args []Sexp) (Sexp, error)

func MakeChanFunction

func MakeChanFunction(env *Zlisp, name string,
	args []Sexp) (Sexp, error)

func MakeList

func MakeList(expressions []Sexp) Sexp

func MapArray

func MapArray(env *Zlisp, fun *SexpFunction, arr *SexpArray) (Sexp, error)

func MapFunction

func MapFunction(env *Zlisp, name string, args []Sexp) (Sexp, error)

func MapList

func MapList(env *Zlisp, fun *SexpFunction, expr Sexp) (Sexp, error)

func MillisFunction

func MillisFunction(env *Zlisp, name string,
	args []Sexp) (Sexp, error)

func MsgpackMapMacro

func MsgpackMapMacro(env *Zlisp, name string,
	args []Sexp) (Sexp, error)

declare a new record type

func MsgpackToSexp

func MsgpackToSexp(msgp []byte, env *Zlisp) (Sexp, error)

msgpack -> sexp

func NotFunction

func NotFunction(env *Zlisp, name string, args []Sexp) (Sexp, error)

func NowFunction

func NowFunction(env *Zlisp, name string,
	args []Sexp) (Sexp, error)

func NumericDo

func NumericDo(op NumericOp, a, b Sexp) (Sexp, error)

func NumericFloatDo

func NumericFloatDo(op NumericOp, a, b *SexpFloat) Sexp

func NumericFunction

func NumericFunction(env *Zlisp, name string, args []Sexp) (Sexp, error)

func NumericIntDo

func NumericIntDo(op NumericOp, a, b *SexpInt) Sexp

func NumericMatchChar

func NumericMatchChar(op NumericOp, a *SexpChar, b Sexp) (Sexp, error)

func NumericMatchFloat

func NumericMatchFloat(op NumericOp, a *SexpFloat, b Sexp) (Sexp, error)

func NumericMatchInt

func NumericMatchInt(op NumericOp, a *SexpInt, b Sexp) (Sexp, error)

func NumericMatchUint64

func NumericMatchUint64(op NumericOp, a *SexpUint64, b Sexp) (Sexp, error)

func NumericUint64Do

func NumericUint64Do(op NumericOp, a, b *SexpUint64) Sexp

func OldEvalFunction

func OldEvalFunction(env *Zlisp, name string, args []Sexp) (Sexp, error)

func PointerOrNumericFunction

func PointerOrNumericFunction(env *Zlisp, name string, args []Sexp) (Sexp, error)

func PointerToFunction

func PointerToFunction(env *Zlisp, name string,
	args []Sexp) (Sexp, error)

func PrintFunction

func PrintFunction(env *Zlisp, name string, args []Sexp) (Sexp, error)

func QuoteListFunction

func QuoteListFunction(env *Zlisp, name string, args []Sexp) (Sexp, error)

'(a b c) -> ('a 'b 'c)

func RandomFunction

func RandomFunction(env *Zlisp, name string,
	args []Sexp) (Sexp, error)

func RawToStringFunction

func RawToStringFunction(env *Zlisp, name string, args []Sexp) (Sexp, error)

func ReadFunction

func ReadFunction(env *Zlisp, name string, args []Sexp) (Sexp, error)

func ReadGreenpackFromFileFunction

func ReadGreenpackFromFileFunction(env *Zlisp, name string, args []Sexp) (Sexp, error)

func RegexpCompile

func RegexpCompile(env *Zlisp, name string,
	args []Sexp) (Sexp, error)

func RegexpFind

func RegexpFind(env *Zlisp, name string,
	args []Sexp) (Sexp, error)

func RemoveSymFunction

func RemoveSymFunction(env *Zlisp, name string, args []Sexp) (Sexp, error)

func RestFunction

func RestFunction(env *Zlisp, name string, args []Sexp) (Sexp, error)

func ScriptFacingRegisterDemoStructs

func ScriptFacingRegisterDemoStructs(env *Zlisp, name string, args []Sexp) (Sexp, error)

func SecondFunction

func SecondFunction(env *Zlisp, name string, args []Sexp) (Sexp, error)

func SetPrettyPrintFlag

func SetPrettyPrintFlag(env *Zlisp, name string, args []Sexp) (Sexp, error)

func SgetFunction

func SgetFunction(env *Zlisp, name string, args []Sexp) (Sexp, error)

func SimpleSourceFunction

func SimpleSourceFunction(env *Zlisp, name string, args []Sexp) (Sexp, error)

alternative. simpler, currently panics.

func SliceFunction

func SliceFunction(env *Zlisp, name string, args []Sexp) (Sexp, error)

func SliceOfFunction

func SliceOfFunction(env *Zlisp, name string,
	args []Sexp) (Sexp, error)

func SlurpfileFunction

func SlurpfileFunction(env *Zlisp, name string, args []Sexp) (Sexp, error)

read new-line delimited text from a file into an array (slurpf "path-to-file")

func SourceFileFunction

func SourceFileFunction(env *Zlisp, name string, args []Sexp) (Sexp, error)

func SplitStringFunction

func SplitStringFunction(env *Zlisp, name string, args []Sexp) (Sexp, error)

SplitStringFunction splits a string based on an arbitrary delimiter

func SplitStringOnNewlinesFunction

func SplitStringOnNewlinesFunction(env *Zlisp, name string, args []Sexp) (Sexp, error)

(nsplit "a\nb") -> ["a" "b"]

func StartGoroutineFunction

func StartGoroutineFunction(env *Zlisp, name string,
	args []Sexp) (Sexp, error)

func StopFunction

func StopFunction(env *Zlisp, name string, args []Sexp) (Sexp, error)

func Str2SymFunction

func Str2SymFunction(env *Zlisp, name string, args []Sexp) (Sexp, error)

func StringUtilFunction

func StringUtilFunction(env *Zlisp, name string, args []Sexp) (Sexp, error)

func StringifyFunction

func StringifyFunction(env *Zlisp, name string, args []Sexp) (Sexp, error)

func StructBuilder

func StructBuilder(env *Zlisp, name string,
	args []Sexp) (Sexp, error)

func StructConstructorFunction

func StructConstructorFunction(env *Zlisp, name string, args []Sexp) (Sexp, error)

func Sym2StrFunction

func Sym2StrFunction(env *Zlisp, name string, args []Sexp) (Sexp, error)

func SymnumFunction

func SymnumFunction(env *Zlisp, name string, args []Sexp) (Sexp, error)

func SystemBuilder

func SystemBuilder(env *Zlisp, name string, args []Sexp) (Sexp, error)

sys is a builder. shell out, return the combined output.

func SystemFunction

func SystemFunction(env *Zlisp, name string, args []Sexp) (Sexp, error)

func ThreadMapFunction

func ThreadMapFunction(env *Zlisp, name string, args []Sexp) (Sexp, error)

func TimeitFunction

func TimeitFunction(env *Zlisp, name string,
	args []Sexp) (Sexp, error)

func ToGoFunction

func ToGoFunction(env *Zlisp, name string, args []Sexp) (Sexp, error)

func TypeListFunction

func TypeListFunction(env *Zlisp, name string, args []Sexp) (Sexp, error)

func TypeQueryFunction

func TypeQueryFunction(env *Zlisp, name string, args []Sexp) (Sexp, error)

func UintegerDo

func UintegerDo(op IntegerOp, ia *SexpUint64, b Sexp) (Sexp, error)

func VarBuilder

func VarBuilder(env *Zlisp, name string,
	args []Sexp) (Sexp, error)

func WriteShadowGreenpackToFileFunction

func WriteShadowGreenpackToFileFunction(env *Zlisp, name string, args []Sexp) (Sexp, error)

(bsave value path) writes value as greenpack to file.

(greenpack value) writes value as greenpack to SexpRaw in memory.

bsave converts to binary with (togo) then saves the binary to file.

func WriteToFileFunction

func WriteToFileFunction(env *Zlisp, name string, args []Sexp) (Sexp, error)

(writef <content> path); (write path) is the macro version. (owritef <content> path): write an array of strings out to the named file, overwriting it in the process. (owrite) is the macro version. save is the same as write.

type SexpArray

type SexpArray struct {
	Val []Sexp

	Typ *RegisteredType

	IsFuncDeclTypeArray bool
	Infix               bool

	Env *Zlisp
}

func (*SexpArray) IndexBy

func (arr *SexpArray) IndexBy(idx *SexpArray) (Sexp, error)

IndexBy subsets one array (possibly multidimensional) by another. e.g. if arr is [a b c] and idx is [0], we'll return a.

func (*SexpArray) NumDim

func (arr *SexpArray) NumDim() int

func (*SexpArray) SexpString

func (arr *SexpArray) SexpString(ps *PrintState) string

func (*SexpArray) Type

func (r *SexpArray) Type() *RegisteredType

type SexpArraySelector

type SexpArraySelector struct {
	Select    *SexpArray
	Container *SexpArray
}

SexpSelector: select a subset of an array: can be multidimensional index/slice and hence know its container and its position(s), and thus be able to read and write that position as need be.

func (*SexpArraySelector) AssignToSelection

func (x *SexpArraySelector) AssignToSelection(env *Zlisp, rhs Sexp) error

func (*SexpArraySelector) RHS

func (x *SexpArraySelector) RHS(env *Zlisp) (Sexp, error)

RHS applies the selector to the contain and returns the value obtained.

func (*SexpArraySelector) SexpString

func (si *SexpArraySelector) SexpString(ps *PrintState) string

func (*SexpArraySelector) Type

func (si *SexpArraySelector) Type() *RegisteredType

Type returns the type of the value.

type SexpBool

type SexpBool struct {
	Val bool
	Typ *RegisteredType
}

func (*SexpBool) SexpString

func (b *SexpBool) SexpString(ps *PrintState) string

func (*SexpBool) Type

func (r *SexpBool) Type() *RegisteredType

type SexpChannel

type SexpChannel struct {
	Val chan Sexp
	Typ *RegisteredType
}

func (*SexpChannel) SexpString

func (ch *SexpChannel) SexpString(ps *PrintState) string

func (*SexpChannel) Type

func (ch *SexpChannel) Type() *RegisteredType

type SexpChar

type SexpChar struct {
	Val rune
	Typ *RegisteredType
}

func (*SexpChar) SexpString

func (c *SexpChar) SexpString(ps *PrintState) string

func (*SexpChar) Type

func (r *SexpChar) Type() *RegisteredType

type SexpClosureEnv

type SexpClosureEnv Scope

func (*SexpClosureEnv) SexpString

func (c *SexpClosureEnv) SexpString(ps *PrintState) string

func (*SexpClosureEnv) Type

func (r *SexpClosureEnv) Type() *RegisteredType

type SexpComma

type SexpComma struct{}

func (*SexpComma) SexpString

func (s *SexpComma) SexpString(ps *PrintState) string

func (*SexpComma) Type

func (r *SexpComma) Type() *RegisteredType

type SexpComment

type SexpComment struct {
	Comment string
	Block   bool
}

func (*SexpComment) SexpString

func (p *SexpComment) SexpString(ps *PrintState) string

func (*SexpComment) Type

func (p *SexpComment) Type() *RegisteredType

type SexpError

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

func (*SexpError) SexpString

func (e *SexpError) SexpString(ps *PrintState) string

func (*SexpError) Type

func (r *SexpError) Type() *RegisteredType

type SexpField

type SexpField SexpHash

func (*SexpField) AlignString

func (f *SexpField) AlignString(pad []int) string

func (*SexpField) FieldWidths

func (f *SexpField) FieldWidths() []int

compute key and value widths to assist alignment

func (*SexpField) SexpString

func (f *SexpField) SexpString(ps *PrintState) string

func (SexpField) Type

func (r SexpField) Type() *RegisteredType

type SexpFloat

type SexpFloat struct {
	Val        float64
	Typ        *RegisteredType
	Scientific bool
}

func (*SexpFloat) SexpString

func (f *SexpFloat) SexpString(ps *PrintState) string

func (*SexpFloat) Type

func (r *SexpFloat) Type() *RegisteredType

type SexpFunction

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

SexpFunction

func MakeBuilderFunction

func MakeBuilderFunction(name string, ufun ZlispUserFunction) *SexpFunction

func MakeUserFunction

func MakeUserFunction(name string, ufun ZlispUserFunction) *SexpFunction

func (*SexpFunction) ClosingLookupSymbol

func (sf *SexpFunction) ClosingLookupSymbol(sym *SexpSymbol, setVal *Sexp) (Sexp, error, *Scope)

func (*SexpFunction) ClosingLookupSymbolUntilFunc

func (sf *SexpFunction) ClosingLookupSymbolUntilFunc(sym *SexpSymbol, setVal *Sexp, maximumFuncToSearch int, checkCaptures bool) (Sexp, error, *Scope)

func (*SexpFunction) ClosingLookupSymbolUntilFunction

func (sf *SexpFunction) ClosingLookupSymbolUntilFunction(sym *SexpSymbol) (Sexp, error, *Scope)

func (*SexpFunction) Copy

func (sf *SexpFunction) Copy() *SexpFunction

func (*SexpFunction) LookupSymbolInParentChainOfClosures

func (sf *SexpFunction) LookupSymbolInParentChainOfClosures(sym *SexpSymbol, setVal *Sexp, env *Zlisp) (Sexp, error, *Scope)

chase parent pointers up the chain and check each of their immediate closures.

func (*SexpFunction) SetClosing

func (sf *SexpFunction) SetClosing(clos *Closing)

func (*SexpFunction) SexpString

func (sf *SexpFunction) SexpString(ps *PrintState) string

func (*SexpFunction) ShowClosing

func (sf *SexpFunction) ShowClosing(env *Zlisp, ps *PrintState, label string) (string, error)

func (*SexpFunction) Type

func (sf *SexpFunction) Type() *RegisteredType

type SexpGoroutine

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

func (*SexpGoroutine) SexpString

func (goro *SexpGoroutine) SexpString(ps *PrintState) string

func (*SexpGoroutine) Type

func (goro *SexpGoroutine) Type() *RegisteredType

type SexpHash

type SexpHash struct {
	TypeName         string
	Map              map[int][]*SexpPair
	KeyOrder         []Sexp
	GoStructFactory  *RegisteredType
	NumKeys          int
	GoMethods        []reflect.Method
	GoFields         []reflect.StructField
	GoMethSx         SexpArray
	GoFieldSx        SexpArray
	GoType           reflect.Type
	NumMethod        int
	GoShadowStruct   interface{}
	GoShadowStructVa reflect.Value
	ShadowSet        bool

	// json tag name -> pointers to example values, as factories for SexpToGoStructs()
	JsonTagMap map[string]*HashFieldDet
	DetOrder   []*HashFieldDet

	// for using these as a scoping model
	DefnEnv    *SexpHash
	SuperClass *SexpHash
	ZMain      SexpFunction
	ZMethods   map[string]*SexpFunction
	Env        *Zlisp
}

func GetFuncArgArray

func GetFuncArgArray(arr *SexpArray, env *Zlisp, where string) (*SexpHash, error)

func MakeHash

func MakeHash(args []Sexp, typename string, env *Zlisp) (*SexpHash, error)

func (*SexpHash) BindSymbol

func (h *SexpHash) BindSymbol(key *SexpSymbol, val Sexp) error

func (*SexpHash) CloneFrom

func (p *SexpHash) CloneFrom(src *SexpHash)

CloneFrom copys all the internals of src into p, effectively blanking out whatever p held and replacing it with a copy of src.

func (*SexpHash) CopyMap

func (p *SexpHash) CopyMap() *map[int][]*SexpPair

func (*SexpHash) DotPathHashGet

func (h *SexpHash) DotPathHashGet(env *Zlisp, sym *SexpSymbol) (Sexp, error)

func (*SexpHash) FillHashFromShadow

func (h *SexpHash) FillHashFromShadow(env *Zlisp, src interface{}) error

func (*SexpHash) HashDelete

func (hash *SexpHash) HashDelete(key Sexp) error

func (*SexpHash) HashGet

func (hash *SexpHash) HashGet(env *Zlisp, key Sexp) (res Sexp, err error)

func (*SexpHash) HashGetDefault

func (hash *SexpHash) HashGetDefault(env *Zlisp, key Sexp, defaultval Sexp) (Sexp, error)

func (*SexpHash) HashPairi

func (hash *SexpHash) HashPairi(pos int) (*SexpPair, error)

func (*SexpHash) HashSet

func (hash *SexpHash) HashSet(key Sexp, val Sexp) error

func (*SexpHash) Lookup

func (h *SexpHash) Lookup(env *Zlisp, key Sexp) (expr Sexp, err error)

func (*SexpHash) NewSexpHashSelector

func (h *SexpHash) NewSexpHashSelector(sym *SexpSymbol) *SexpHashSelector

func (*SexpHash) RunZmethod

func (h *SexpHash) RunZmethod(method string, args []Sexp) (Sexp, error)

func (*SexpHash) SetDefnEnv

func (h *SexpHash) SetDefnEnv(p *SexpHash)

func (*SexpHash) SetGoStructFactory

func (h *SexpHash) SetGoStructFactory(factory *RegisteredType)

func (*SexpHash) SetMain

func (h *SexpHash) SetMain(p *SexpFunction)

func (*SexpHash) SetMethodList

func (h *SexpHash) SetMethodList(env *Zlisp) error

func (*SexpHash) SexpString

func (hash *SexpHash) SexpString(ps *PrintState) string

func (*SexpHash) ShortName

func (hash *SexpHash) ShortName() string

func (*SexpHash) Type

func (r *SexpHash) Type() *RegisteredType

func (*SexpHash) TypeCheckField

func (h *SexpHash) TypeCheckField(key Sexp, val Sexp) error

type SexpHashSelector

type SexpHashSelector struct {
	Select    Sexp
	Container *SexpHash
}

SexpHashSelector: reference to a symbol in a hash table.

func (*SexpHashSelector) AssignToSelection

func (x *SexpHashSelector) AssignToSelection(env *Zlisp, rhs Sexp) error

func (*SexpHashSelector) RHS

func (x *SexpHashSelector) RHS(env *Zlisp) (sx Sexp, err error)

RHS applies the selector to the contain and returns the value obtained.

func (*SexpHashSelector) SexpString

func (si *SexpHashSelector) SexpString(ps *PrintState) string

func (*SexpHashSelector) Type

func (si *SexpHashSelector) Type() *RegisteredType

Type returns the type of the value.

type SexpInt

type SexpInt struct {
	Val int64
	Typ *RegisteredType
}

func (*SexpInt) SexpString

func (i *SexpInt) SexpString(ps *PrintState) string

func (*SexpInt) Type

func (r *SexpInt) Type() *RegisteredType

type SexpInterfaceDecl

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

SexpInterfaceDecl

func (*SexpInterfaceDecl) SexpString

func (r *SexpInterfaceDecl) SexpString(ps *PrintState) string

func (*SexpInterfaceDecl) Type

func (r *SexpInterfaceDecl) Type() *RegisteredType

type SexpPair

type SexpPair struct {
	Head Sexp
	Tail Sexp
}

func Cons

func Cons(a Sexp, b Sexp) *SexpPair

func (*SexpPair) SexpString

func (pair *SexpPair) SexpString(ps *PrintState) string

func (*SexpPair) Type

func (r *SexpPair) Type() *RegisteredType

type SexpPointer

type SexpPointer struct {
	ReflectTarget reflect.Value
	Target        Sexp
	PointedToType *RegisteredType
	MyType        *RegisteredType
}

func NewSexpPointer

func NewSexpPointer(pointedTo Sexp) *SexpPointer

func (*SexpPointer) SexpString

func (p *SexpPointer) SexpString(ps *PrintState) string

func (*SexpPointer) Type

func (p *SexpPointer) Type() *RegisteredType

type SexpRaw

type SexpRaw struct {
	Val []byte
	Typ *RegisteredType
}

func MakeRaw

func MakeRaw(args []Sexp) (*SexpRaw, error)

func (*SexpRaw) SexpString

func (r *SexpRaw) SexpString(ps *PrintState) string

func (*SexpRaw) Type

func (r *SexpRaw) Type() *RegisteredType

type SexpReflect

type SexpReflect struct {
	Val reflect.Value
}

func (*SexpReflect) SexpString

func (r *SexpReflect) SexpString(ps *PrintState) string

func (*SexpReflect) Type

func (r *SexpReflect) Type() *RegisteredType

type SexpRegexp

type SexpRegexp regexp.Regexp

func (*SexpRegexp) SexpString

func (re *SexpRegexp) SexpString(ps *PrintState) string

func (*SexpRegexp) Type

func (r *SexpRegexp) Type() *RegisteredType

type SexpSemicolon

type SexpSemicolon struct{}

func (*SexpSemicolon) SexpString

func (s *SexpSemicolon) SexpString(ps *PrintState) string

func (*SexpSemicolon) Type

func (r *SexpSemicolon) Type() *RegisteredType

type SexpSentinel

type SexpSentinel struct {
	Val int
}

func (*SexpSentinel) SexpString

func (sent *SexpSentinel) SexpString(ps *PrintState) string

func (*SexpSentinel) Type

func (r *SexpSentinel) Type() *RegisteredType

type SexpStackmark

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

func (*SexpStackmark) SexpString

func (mark *SexpStackmark) SexpString(ps *PrintState) string

func (*SexpStackmark) Type

func (r *SexpStackmark) Type() *RegisteredType

type SexpStr

type SexpStr struct {
	S string

	Typ *RegisteredType
	// contains filtered or unexported fields
}

func AppendStr

func AppendStr(str *SexpStr, expr Sexp) (*SexpStr, error)

func ConcatStr

func ConcatStr(str *SexpStr, rest []Sexp) (*SexpStr, error)

func TypeOf

func TypeOf(expr Sexp) *SexpStr

func (*SexpStr) SexpString

func (s *SexpStr) SexpString(ps *PrintState) string

func (SexpStr) Type

func (r SexpStr) Type() *RegisteredType

type SexpSymbol

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

func (*SexpSymbol) AssignToSelection

func (sym *SexpSymbol) AssignToSelection(env *Zlisp, rhs Sexp) error

func (SexpSymbol) Name

func (sym SexpSymbol) Name() string

func (SexpSymbol) Number

func (sym SexpSymbol) Number() int

func (*SexpSymbol) RHS

func (sym *SexpSymbol) RHS(env *Zlisp) (Sexp, error)

func (*SexpSymbol) SexpString

func (sym *SexpSymbol) SexpString(ps *PrintState) string

func (*SexpSymbol) Type

func (r *SexpSymbol) Type() *RegisteredType

type SexpTime

type SexpTime struct {
	Tm time.Time
}

func (*SexpTime) SexpString

func (t *SexpTime) SexpString(ps *PrintState) string

func (*SexpTime) Type

func (r *SexpTime) Type() *RegisteredType

type SexpUint64

type SexpUint64 struct {
	Val uint64
	Typ *RegisteredType
}

func (*SexpUint64) SexpString

func (i *SexpUint64) SexpString(ps *PrintState) string

func (*SexpUint64) Type

func (r *SexpUint64) Type() *RegisteredType

type SexpUserVarDefn

type SexpUserVarDefn struct {
	Name string
}

type ShortNamer

type ShortNamer interface {
	ShortName() string
}

type Showable

type Showable interface {
	Show(env *Zlisp, ps *PrintState, label string) (string, error)
}

type Snoopy

type Snoopy struct {
	Plane    `json:"plane" msg:"plane"`
	Cry      string  `json:"cry" msg:"cry"`
	Pack     []int   `json:"pack"`
	Carrying []Flyer `json:"carrying"`
}

func (*Snoopy) EchoWeather

func (p *Snoopy) EchoWeather(w *Weather) *Weather

func (*Snoopy) Fly

func (p *Snoopy) Fly(w *Weather) (s string, err error)

func (*Snoopy) GetCry

func (p *Snoopy) GetCry() string

func (*Snoopy) Sideeffect

func (p *Snoopy) Sideeffect()

type SquashInstr

type SquashInstr int

func (SquashInstr) Execute

func (s SquashInstr) Execute(env *Zlisp) error

func (SquashInstr) InstrString

func (s SquashInstr) InstrString() string

type Stack

type Stack struct {
	Name string // type name

	// package support:
	PackageName string
	IsPackage   bool
	// contains filtered or unexported fields
}

func (*Stack) BindSymbol

func (stack *Stack) BindSymbol(sym *SexpSymbol, expr Sexp) error

func (*Stack) Clone

func (stack *Stack) Clone() *Stack

func (*Stack) DeleteSymbolFromTopOfStackScope

func (stack *Stack) DeleteSymbolFromTopOfStackScope(sym *SexpSymbol) error

func (*Stack) Get

func (stack *Stack) Get(n int) (StackElem, error)

func (*Stack) GetExpr

func (stack *Stack) GetExpr(n int) (Sexp, error)

func (*Stack) GetExpressions

func (stack *Stack) GetExpressions(n int) ([]Sexp, error)

func (*Stack) GetTop

func (stack *Stack) GetTop() StackElem

func (*Stack) IsEmpty

func (stack *Stack) IsEmpty() bool

func (*Stack) IsStackElem

func (stack *Stack) IsStackElem()

func (*Stack) LookupSymbol

func (stack *Stack) LookupSymbol(sym *SexpSymbol, setVal *Sexp) (Sexp, error, *Scope)

func (*Stack) LookupSymbolNonGlobal

func (stack *Stack) LookupSymbolNonGlobal(sym *SexpSymbol) (Sexp, error, *Scope)

LookupSymbolNonGlobal - closures use this to only find symbols below the global scope, to avoid copying globals it'll always be-able to ref

func (*Stack) LookupSymbolUntilFunction

func (stack *Stack) LookupSymbolUntilFunction(sym *SexpSymbol, setVal *Sexp, maximumFuncToSearch int, checkCaptures bool) (Sexp, error, *Scope)

lookup symbols, but don't go beyond a function boundary -- a user-defined function boundary that is. We certainly have to go up beyond all built-in operators like '+' and '-', '*' and '/'.

func (*Stack) Pop

func (stack *Stack) Pop() (StackElem, error)

func (*Stack) PopAddr

func (stack *Stack) PopAddr() (*SexpFunction, int, error)

func (*Stack) PopExpr

func (stack *Stack) PopExpr() (Sexp, error)

func (*Stack) PopExpressions

func (stack *Stack) PopExpressions(n int) ([]Sexp, error)

func (*Stack) PopScope

func (stack *Stack) PopScope() error

func (*Stack) PrintScopeStack

func (stack *Stack) PrintScopeStack()

func (*Stack) PrintStack

func (stack *Stack) PrintStack()

func (*Stack) Push

func (stack *Stack) Push(elem StackElem)

func (*Stack) PushAddr

func (stack *Stack) PushAddr(function *SexpFunction, pc int)

func (*Stack) PushAllTo

func (stack *Stack) PushAllTo(target *Stack) int

func (*Stack) PushExpr

func (stack *Stack) PushExpr(expr Sexp)

func (*Stack) PushExpressions

func (stack *Stack) PushExpressions(expr []Sexp) error

func (*Stack) PushScope

func (stack *Stack) PushScope()

func (*Stack) SexpString

func (s *Stack) SexpString(ps *PrintState) string

func (*Stack) Show

func (stack *Stack) Show(env *Zlisp, ps *PrintState, label string) (string, error)

func (*Stack) Size

func (stack *Stack) Size() int

func (*Stack) Top

func (stack *Stack) Top() int

func (*Stack) TruncateToSize

func (stack *Stack) TruncateToSize(newsize int)

set newsize to 0 to truncate everything

func (*Stack) Type

func (s *Stack) Type() *RegisteredType

Type() satisfies the Sexp interface, returning the type of the value.

type StackElem

type StackElem interface {
	IsStackElem()
}

type StmtMuncher

type StmtMuncher func(env *Zlisp, pr *Pratt) (Sexp, error)

type SymtabE

type SymtabE struct {
	Key string
	Val string
}

type SymtabSorter

type SymtabSorter []*SymtabE

func (SymtabSorter) Len

func (a SymtabSorter) Len() int

func (SymtabSorter) Less

func (a SymtabSorter) Less(i, j int) bool

func (SymtabSorter) Swap

func (a SymtabSorter) Swap(i, j int)

type Token

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

func (Token) String

func (t Token) String() string

type TokenType

type TokenType int
const (
	TokenTypeEmpty TokenType = iota
	TokenLParen
	TokenRParen
	TokenLSquare
	TokenRSquare
	TokenLCurly
	TokenRCurly
	TokenDot
	TokenQuote
	TokenBacktick
	TokenTilde
	TokenTildeAt
	TokenSymbol
	TokenBool
	TokenDecimal
	TokenHex
	TokenOct
	TokenBinary
	TokenFloat
	TokenChar
	TokenString
	TokenCaret
	TokenColonOperator
	TokenThreadingOperator
	TokenBackslash
	TokenDollar
	TokenDotSymbol
	TokenFreshAssign
	TokenBeginBacktickString
	TokenBacktickString
	TokenComment
	TokenBeginBlockComment
	TokenEndBlockComment
	TokenSemicolon
	TokenSymbolColon
	TokenComma
	TokenUint64
	TokenEnd
)

type TypeCheckable

type TypeCheckable interface {
	TypeCheck() error
}

type UpdateInstr

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

Update takes top of datastack and assigns it to sym when sym is found already in the current scope or up the stack. Used to implement (set v 10) when v is not in the local scope.

func (UpdateInstr) Execute

func (p UpdateInstr) Execute(env *Zlisp) error

func (UpdateInstr) InstrString

func (p UpdateInstr) InstrString() string

type VectorizeInstr

type VectorizeInstr int

func (VectorizeInstr) Execute

func (s VectorizeInstr) Execute(env *Zlisp) error

func (VectorizeInstr) InstrString

func (s VectorizeInstr) InstrString() string

type Weather

type Weather struct {
	Time    time.Time `json:"time" msg:"time"`
	Size    int64     `json:"size" msg:"size"`
	Type    string    `json:"type" msg:"type"`
	Details []byte    `json:"details" msg:"details"`
}

func (*Weather) DecodeMsg

func (z *Weather) DecodeMsg(dc *msgp.Reader) (err error)

DecodeMsg implements msgp.Decodable

func (*Weather) EncodeMsg

func (z *Weather) EncodeMsg(en *msgp.Writer) (err error)

EncodeMsg implements msgp.Encodable

func (*Weather) IsSunny

func (w *Weather) IsSunny() bool

func (*Weather) MarshalMsg

func (z *Weather) MarshalMsg(b []byte) (o []byte, err error)

MarshalMsg implements msgp.Marshaler

func (*Weather) Msgsize

func (z *Weather) Msgsize() (s int)

Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message

func (*Weather) UnmarshalMsg

func (z *Weather) UnmarshalMsg(bts []byte) (o []byte, err error)

UnmarshalMsg implements msgp.Unmarshaler

type Wings

type Wings struct {
	SpanCm int
}

type Zlisp

type Zlisp struct {
	Pretty bool

	// API use, since infix is already default at repl
	WrapLoadExpressionsInInfix bool
	// contains filtered or unexported fields
}

func NewZlisp

func NewZlisp() *Zlisp

func NewZlispSandbox

func NewZlispSandbox() *Zlisp

NewZlispSandbox returns a new *Zlisp instance that does not allow the user to get to the outside world

func NewZlispWithFuncs

func NewZlispWithFuncs(funcs map[string]ZlispUserFunction) *Zlisp

NewZlispWithFuncs returns a new *Zlisp instance with access to only the given builtin functions

func (*Zlisp) AddBuilder

func (env *Zlisp) AddBuilder(name string, function ZlispUserFunction)

func (*Zlisp) AddFunction

func (env *Zlisp) AddFunction(name string, function ZlispUserFunction)

func (*Zlisp) AddGlobal

func (env *Zlisp) AddGlobal(name string, obj Sexp)

func (*Zlisp) AddMacro

func (env *Zlisp) AddMacro(name string, function ZlispUserFunction)

func (*Zlisp) AddPostHook

func (env *Zlisp) AddPostHook(fun PostHook)

func (*Zlisp) AddPreHook

func (env *Zlisp) AddPreHook(fun PreHook)

func (*Zlisp) Apply

func (env *Zlisp) Apply(fun *SexpFunction, args []Sexp) (Sexp, error)

func (*Zlisp) Assignment

func (env *Zlisp) Assignment(op string, bp int) *InfixOp

Assignment creates a new assignment operator for infix processing.

func (*Zlisp) CallFunction

func (env *Zlisp) CallFunction(function *SexpFunction, nargs int) error

func (*Zlisp) CallUserFunction

func (env *Zlisp) CallUserFunction(
	function *SexpFunction, name string, nargs int) (nargReturned int, err error)

func (*Zlisp) Clear

func (env *Zlisp) Clear()

func (*Zlisp) Clone

func (env *Zlisp) Clone() *Zlisp

func (*Zlisp) Compare

func (env *Zlisp) Compare(a Sexp, b Sexp) (int, error)

func (*Zlisp) CurrentFunctionSize

func (env *Zlisp) CurrentFunctionSize() int

func (*Zlisp) DetectSigils

func (env *Zlisp) DetectSigils(sym *SexpSymbol)

func (*Zlisp) DumpEnvironment

func (env *Zlisp) DumpEnvironment()

func (*Zlisp) DumpFunctionByName

func (env *Zlisp) DumpFunctionByName(name string) error

func (*Zlisp) DumpSymTable

func (env *Zlisp) DumpSymTable()

func (*Zlisp) Duplicate

func (env *Zlisp) Duplicate() *Zlisp

func (*Zlisp) EliminateColonAndCommaFromArgs

func (env *Zlisp) EliminateColonAndCommaFromArgs(args []Sexp) []Sexp

func (*Zlisp) EvalExpressions

func (env *Zlisp) EvalExpressions(xs []Sexp) (Sexp, error)

for most things now (except the main repl), prefer EvalFunction() instead of EvalExpressions.

func (*Zlisp) EvalString

func (env *Zlisp) EvalString(str string) (Sexp, error)

func (*Zlisp) FilterAny

func (env *Zlisp) FilterAny(x Sexp, f Filter) (filtered Sexp, keep bool)

func (*Zlisp) FilterArray

func (env *Zlisp) FilterArray(x []Sexp, f Filter) []Sexp

func (*Zlisp) FilterHash

func (env *Zlisp) FilterHash(h *SexpHash, f Filter) *SexpHash

func (*Zlisp) FilterList

func (env *Zlisp) FilterList(h *SexpPair, f Filter) Sexp

func (*Zlisp) FindLoop

func (env *Zlisp) FindLoop(target *Loop) (int, error)

scan the instruction stream to locate loop start

func (*Zlisp) FindObject

func (env *Zlisp) FindObject(name string) (Sexp, bool)

func (*Zlisp) FunctionCallNameTypeCheck

func (env *Zlisp) FunctionCallNameTypeCheck(f *SexpFunction, nargs *int) error

FunctionCallNameTypeCheck type checks a function call.

func (*Zlisp) GenSymbol

func (env *Zlisp) GenSymbol(prefix string) *SexpSymbol

func (*Zlisp) GetStackTrace

func (env *Zlisp) GetStackTrace(err error) string

func (*Zlisp) HasMacro

func (env *Zlisp) HasMacro(sym *SexpSymbol) bool

func (*Zlisp) ImportBaseTypes

func (env *Zlisp) ImportBaseTypes()

func (*Zlisp) ImportChannels

func (env *Zlisp) ImportChannels()

func (*Zlisp) ImportDemoData

func (env *Zlisp) ImportDemoData()

func (*Zlisp) ImportEval

func (env *Zlisp) ImportEval()

func (*Zlisp) ImportGoroutines

func (env *Zlisp) ImportGoroutines()

func (*Zlisp) ImportMsgpackMap

func (env *Zlisp) ImportMsgpackMap()

func (*Zlisp) ImportPackageBuilder

func (env *Zlisp) ImportPackageBuilder()

A builder is a special kind of function. Like a macro it receives the un-evaluated tree of symbols from its caller. A builder can therefore be used to build new types and declarations new functions/methods.

Like a function, a builder is called at run/evaluation time, not at definition time.

Since it receives an un-evaluated tree of symbols, a builder must manually evaluate any arguments it wishes to find bindings for.

The primary use here is to be able to define packages, structs, interfaces, functions, methods, and type aliases.

func (*Zlisp) ImportRandom

func (env *Zlisp) ImportRandom()

func (*Zlisp) ImportRegex

func (env *Zlisp) ImportRegex()

func (*Zlisp) ImportTime

func (env *Zlisp) ImportTime()

func (*Zlisp) Infix

func (env *Zlisp) Infix(op string, bp int) *InfixOp

Infix creates a new infix operator

func (*Zlisp) InfixF

func (env *Zlisp) InfixF(op string, bp int, f func(env *Zlisp, op string, bp int) *InfixOp) *InfixOp

func (*Zlisp) Infixr

func (env *Zlisp) Infixr(op string, bp int) *InfixOp

Infix creates a new (right-associative) short-circuiting infix operator, used for `and` and `or` in infix processing.

func (*Zlisp) InitInfixOps

func (env *Zlisp) InitInfixOps()

InitInfixOps establishes the env.infixOps definitions required for infix parsing using the Pratt parser.

func (*Zlisp) IsBuiltinSym

func (env *Zlisp) IsBuiltinSym(sym *SexpSymbol) (builtin bool, typ string)

func (*Zlisp) LeftBindingPower

func (env *Zlisp) LeftBindingPower(sx Sexp) (int, error)

func (*Zlisp) LexicalBindSymbol

func (env *Zlisp) LexicalBindSymbol(sym *SexpSymbol, expr Sexp) error

func (*Zlisp) LexicalLookupSymbol

func (env *Zlisp) LexicalLookupSymbol(sym *SexpSymbol, setVal *Sexp) (Sexp, error, *Scope)

func (*Zlisp) LoadExpressions

func (env *Zlisp) LoadExpressions(xs []Sexp) error

func (*Zlisp) LoadFile

func (env *Zlisp) LoadFile(file io.Reader) error

func (*Zlisp) LoadStream

func (env *Zlisp) LoadStream(stream io.RuneScanner) error

func (*Zlisp) LoadString

func (env *Zlisp) LoadString(str string) error

func (*Zlisp) MakeDotSymbol

func (env *Zlisp) MakeDotSymbol(name string) *SexpSymbol

func (*Zlisp) MakeFunction

func (env *Zlisp) MakeFunction(name string, nargs int, varargs bool,
	fun ZlispFunction, orig Sexp) *SexpFunction

func (*Zlisp) MakeSymbol

func (env *Zlisp) MakeSymbol(name string) *SexpSymbol

func (*Zlisp) NewNamedScope

func (env *Zlisp) NewNamedScope(name string) *Scope

func (*Zlisp) NewParser

func (env *Zlisp) NewParser() *Parser

func (*Zlisp) NewScope

func (env *Zlisp) NewScope() *Scope

func (*Zlisp) NewSexpArray

func (env *Zlisp) NewSexpArray(arr []Sexp) *SexpArray

func (*Zlisp) NewStack

func (env *Zlisp) NewStack(size int) *Stack

func (*Zlisp) ParseFile

func (env *Zlisp) ParseFile(file string) ([]Sexp, error)

func (*Zlisp) PostfixAssign

func (env *Zlisp) PostfixAssign(op string, bp int) *InfixOp

PostfixAssign creates a new postfix assignment operator for infix processing.

func (*Zlisp) Prefix

func (env *Zlisp) Prefix(op string, bp int) *InfixOp

Prefix creates a new prefix operator, like `not`, for infix processing.

func (*Zlisp) ReachedEnd

func (env *Zlisp) ReachedEnd() bool

func (*Zlisp) ReplLineInfixWrap

func (env *Zlisp) ReplLineInfixWrap(line string) string

func (*Zlisp) ResolveDotSym

func (env *Zlisp) ResolveDotSym(arg []Sexp) ([]Sexp, error)

func (*Zlisp) ReturnFromFunction

func (env *Zlisp) ReturnFromFunction() error

func (*Zlisp) Run

func (env *Zlisp) Run() (Sexp, error)

func (*Zlisp) SetBooter

func (env *Zlisp) SetBooter(b Booter)

allow clients to establish a callback to happen after reinflating a Go struct. These structs need to be "booted" to be ready to go.

func (*Zlisp) ShowGlobalStack

func (env *Zlisp) ShowGlobalStack() error

func (*Zlisp) ShowStackStackAndScopeStack

func (env *Zlisp) ShowStackStackAndScopeStack() error

func (*Zlisp) SourceExpressions

func (env *Zlisp) SourceExpressions(expressions []Sexp) error

SourceExpressions, this should be called from a user func context

func (*Zlisp) SourceFile

func (env *Zlisp) SourceFile(file *os.File) error

func (*Zlisp) SourceStream

func (env *Zlisp) SourceStream(stream io.RuneScanner) error

func (*Zlisp) StandardSetup

func (env *Zlisp) StandardSetup()

func (*Zlisp) Stop

func (env *Zlisp) Stop() error

func (*Zlisp) SubstituteRHS

func (env *Zlisp) SubstituteRHS(args []Sexp) ([]Sexp, error)

SubstituteRHS locates any SexpSelector(s) (Selector implementers, really) and substitutes the value of x.RHS() for each x in args.

type ZlispConfig

type ZlispConfig struct {
	CpuProfile          string
	MemProfile          string
	ExitOnFailure       bool
	CountFuncCalls      bool
	Flags               *flag.FlagSet
	ExtensionsVersion   string
	Command             string
	Sandboxed           bool
	Quiet               bool
	Trace               bool
	LoadDemoStructs     bool
	AfterScriptDontExit bool

	// liner bombs under emacs, avoid it with this flag.
	NoLiner bool
	Prompt  string // default "zygo> "

}

configure a glisp repl

func NewZlispConfig

func NewZlispConfig(cmdname string) *ZlispConfig

func (*ZlispConfig) DefineFlags

func (c *ZlispConfig) DefineFlags()

call DefineFlags before myflags.Parse()

func (*ZlispConfig) ValidateConfig

func (c *ZlispConfig) ValidateConfig() error

call c.ValidateConfig() after myflags.Parse()

type ZlispFunction

type ZlispFunction []Instruction

type ZlispUserFunction

type ZlispUserFunction func(*Zlisp, string, []Sexp) (Sexp, error)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL