Versions in this module Expand all Collapse all v0 v0.2.0 Mar 13, 2019 v0.1.0 Jul 23, 2018 Changes in this version + const ElseSymbol + const LambdaSymbol + const QuasiquoteSymbol + const QuoteSymbol + const UnquoteSymbol + var ErrBound = errors.New("symbol is already bound locally") + var ErrCarNil = errors.New("car cannot be nil") + var ErrCouldBeNil = errors.New("value could be nil") + var ErrDivByZero = errors.New("division by zero") + var ErrFuncName = errors.New("function name is not a symbol") + var ErrInvalidCall = errors.New("invalid function call") + var ErrInvalidUTF8 = errors.New("invalid UTF8 string") + var ErrNil = errors.New("value cannot be nil") + var ErrNotBound = errors.New("symbol is not bound to a value") + var ErrNotCell = errors.New("not a cell") + var ErrNotFunc = errors.New("the expression is not a function") + var ErrNotList = errors.New("not a list") + var ErrNotSymbol = errors.New("not a symbol") + var ErrSymNotFound = errors.New("could not resolve symbol") + var ErrTypeExtraArg = errors.New("extra function argument") + var ErrTypeMissingArg = errors.New("missing function argument") + var ErrUnknownFunc = errors.New("unknown function") + var LibCell = map[string]InterpreterFuncHandler + var LibClosure = map[string]InterpreterFuncHandler + var LibCond = map[string]InterpreterFuncHandler + var LibLambda = map[string]InterpreterFuncHandler + var LibMeta = map[string]InterpreterFuncHandler + var LibOp = map[string]InterpreterFuncHandler + var LibType = map[string]InterpreterFuncHandler + func CellID() uint64 + func Error(msg string, meta Meta, ident string) error + func InterpreterOptBuiltinLibs(itr *Interpreter) + func IsList(exp SExp) bool + func WrapError(err error, meta Meta, ident string) error + type Closure struct + func NewClosure(opts ...ClosureOpt) *Closure + func (c *Closure) Get(key string) (SExp, bool) + func (c *Closure) Local(key string) (SExp, bool) + func (c *Closure) Resolve(sym SExp) (SExp, error) + func (c *Closure) Set(key string, val SExp) + func (c *Closure) SetLocal(key string, val SExp) + type ClosureOpt func(*Closure) + func ClosureOptEnv(env []string) ClosureOpt + func ClosureOptParent(parent *Closure) ClosureOpt + func ClosureOptResolver(resolve ResolveHandler) ClosureOpt + type FuncData struct + ParentClosure *Closure + type Interpreter struct + func NewInterpreter(opts ...InterpreterOpt) *Interpreter + func (itr *Interpreter) AddFuncHandler(name string, handler InterpreterFuncHandler) + func (itr *Interpreter) DeleteFuncHandler(name string) + func (itr *Interpreter) EvalInput(ctx context.Context, in string) error + func (itr *Interpreter) EvalInstrs(ctx context.Context, instrs SExp) error + type InterpreterContext struct + Args SExp + Closure *Closure + Ctx context.Context + Eval func(*InterpreterContext, SExp, bool) (SExp, error) + EvalBody func(*InterpreterContext, SExp, bool) (SExp, error) + EvalList func(*InterpreterContext, SExp, bool) (SExp, error) + EvalListToSlice func(*InterpreterContext, SExp, bool) (SExpSlice, error) + EvalListToStrings func(*InterpreterContext, SExp, bool) ([]string, error) + IsTail bool + Meta Meta + Name string + QuasiquoteLevel int + type InterpreterFuncHandler func(*InterpreterContext) (SExp, error) + type InterpreterOpt func(*Interpreter) + func InterpreterOptClosure(c *Closure) InterpreterOpt + func InterpreterOptErrorHandler(h func(error)) InterpreterOpt + func InterpreterOptFuncHandlers(m map[string]InterpreterFuncHandler) InterpreterOpt + func InterpreterOptTailOptimizations(e bool) InterpreterOpt + func InterpreterOptValueHandler(h func(SExp)) InterpreterOpt + type LazyCall struct + Args SExpSlice + FuncID uint64 + type Meta struct + Line int + Offset int + UserData interface{} + type ParseError struct + Tok Token + func (err ParseError) Error() string + type Parser struct + func NewParser(scanner *Scanner) *Parser + func (p *Parser) List(in string) (SExp, error) + func (p *Parser) Parse(in string) (SExp, error) + type PrimitiveType uint8 + const PrimitiveBool + const PrimitiveInt64 + const PrimitiveInvalid + const PrimitiveList + const PrimitiveString + func (t PrimitiveType) String() string + type ResolveHandler func(closure *Closure, sym SExp) (SExp, error) + type SExp interface + BoolVal func() (bool, bool) + Car func() SExp + Cdr func() SExp + Equals func(SExp) bool + ID func() uint64 + Int64Val func() (int64, bool) + IsAtom func() bool + IsNil func() bool + Meta func() Meta + MustBoolVal func() bool + MustInt64Val func() int64 + MustStringVal func() string + MustSymbolVal func() string + String func() string + StringVal func() (string, bool) + SymbolVal func() (string, bool) + UnderlyingType func() SExpType + func Bool(val bool, meta Meta) SExp + func Cons(car, cdr SExp, meta Meta) SExp + func Int64(val int64, meta Meta) SExp + func LibCellCar(ctx *InterpreterContext) (SExp, error) + func LibCellCdr(ctx *InterpreterContext) (SExp, error) + func LibCellCons(ctx *InterpreterContext) (SExp, error) + func LibClosureLet(ctx *InterpreterContext) (SExp, error) + func LibCondIf(ctx *InterpreterContext) (SExp, error) + func LibCondUnless(ctx *InterpreterContext) (SExp, error) + func LibLambdaLambda(ctx *InterpreterContext) (SExp, error) + func LibMetaEval(ctx *InterpreterContext) (SExp, error) + func LibMetaQuasiquote(ctx *InterpreterContext) (SExp, error) + func LibMetaQuote(ctx *InterpreterContext) (SExp, error) + func LibMetaUnquote(ctx *InterpreterContext) (SExp, error) + func LibOpAdd(ctx *InterpreterContext) (SExp, error) + func LibOpAnd(ctx *InterpreterContext) (SExp, error) + func LibOpDiv(ctx *InterpreterContext) (SExp, error) + func LibOpEq(ctx *InterpreterContext) (SExp, error) + func LibOpGt(ctx *InterpreterContext) (SExp, error) + func LibOpGte(ctx *InterpreterContext) (SExp, error) + func LibOpLt(ctx *InterpreterContext) (SExp, error) + func LibOpLte(ctx *InterpreterContext) (SExp, error) + func LibOpMod(ctx *InterpreterContext) (SExp, error) + func LibOpMul(ctx *InterpreterContext) (SExp, error) + func LibOpNot(ctx *InterpreterContext) (SExp, error) + func LibOpOr(ctx *InterpreterContext) (SExp, error) + func LibOpSub(ctx *InterpreterContext) (SExp, error) + func LibTypeIsAtom(ctx *InterpreterContext) (SExp, error) + func LibTypeIsBool(ctx *InterpreterContext) (SExp, error) + func LibTypeIsInt64(ctx *InterpreterContext) (SExp, error) + func LibTypeIsList(ctx *InterpreterContext) (SExp, error) + func LibTypeIsNil(ctx *InterpreterContext) (SExp, error) + func LibTypeIsString(ctx *InterpreterContext) (SExp, error) + func LibTypeIsSym(ctx *InterpreterContext) (SExp, error) + func Nil() SExp + func ResolveName(_ *Closure, sym SExp) (SExp, error) + func String(val string, meta Meta) SExp + func Symbol(val string, meta Meta) SExp + type SExpSlice []SExp + func ToSlice(exp SExp) SExpSlice + func (s SExpSlice) Strings(quote bool) []string + type SExpType uint8 + const SExpBool + const SExpCell + const SExpInt64 + const SExpInvalid + const SExpString + const SExpSymbol + func (t SExpType) String() string + type ScanError struct + Line int + Offset int + Rune rune + func (err ScanError) Error() string + type Scanner struct + func NewScanner(opts ...ScannerOpt) *Scanner + func (s *Scanner) Emit() Token + func (s *Scanner) SetInput(in string) + func (s *Scanner) SetReader(reader io.RuneScanner) + type ScannerOpt func(*Scanner) + func ScannerOptErrorHandler(h func(error)) ScannerOpt + type Token struct + Line int + Offset int + Type TokenType + Value string + func (t Token) String() string + type TokenType uint8 + const TokEOF + const TokFalse + const TokInt + const TokInvalid + const TokLBrace + const TokLParen + const TokLine + const TokQuasiquote + const TokQuote + const TokRBrace + const TokRParen + const TokString + const TokSymbol + const TokTrue + const TokUnquote + func (tok TokenType) String() string + type TypeInfo struct + Params []*TypeInfo + Subtype *TypeInfo + Type PrimitiveType