glisp

package
v0.0.0-...-e484114 Latest Latest
Warning

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

Go to latest
Published: Jan 28, 2016 License: BSD-2-Clause Imports: 12 Imported by: 0

Documentation

Index

Constants

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

Variables

View Source
var (
	BoolRegex    = regexp.MustCompile("^(true|false)$")
	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("^[^'#]+$")
	CharRegex    = regexp.MustCompile("^#\\\\?.$")
	FloatRegex   = regexp.MustCompile("^-?([0-9]+\\.[0-9]*)|(\\.[0-9]+)|([0-9]+(\\.[0-9]*)?[eE](-?[0-9]+))$")
)
View Source
var BuiltinFunctions = map[string]GlispUserFunction{
	"<":          CompareFunction,
	">":          CompareFunction,
	"<=":         CompareFunction,
	">=":         CompareFunction,
	"=":          CompareFunction,
	"not=":       CompareFunction,
	"sll":        BinaryIntFunction,
	"sra":        BinaryIntFunction,
	"srl":        BinaryIntFunction,
	"mod":        BinaryIntFunction,
	"+":          NumericFunction,
	"-":          NumericFunction,
	"*":          NumericFunction,
	"/":          NumericFunction,
	"bit-and":    BitwiseFunction,
	"bit-or":     BitwiseFunction,
	"bit-xor":    BitwiseFunction,
	"bit-not":    ComplementFunction,
	"read":       ReadFunction,
	"cons":       ConsFunction,
	"first":      FirstFunction,
	"rest":       RestFunction,
	"car":        FirstFunction,
	"cdr":        RestFunction,
	"list?":      TypeQueryFunction,
	"null?":      TypeQueryFunction,
	"array?":     TypeQueryFunction,
	"hash?":      TypeQueryFunction,
	"number?":    TypeQueryFunction,
	"int?":       TypeQueryFunction,
	"float?":     TypeQueryFunction,
	"char?":      TypeQueryFunction,
	"symbol?":    TypeQueryFunction,
	"string?":    TypeQueryFunction,
	"zero?":      TypeQueryFunction,
	"empty?":     TypeQueryFunction,
	"println":    PrintFunction,
	"print":      PrintFunction,
	"not":        NotFunction,
	"apply":      ApplyFunction,
	"map":        MapFunction,
	"make-array": MakeArrayFunction,
	"aget":       ArrayAccessFunction,
	"aset!":      ArrayAccessFunction,
	"sget":       SgetFunction,
	"hget":       HashAccessFunction,
	"hset!":      HashAccessFunction,
	"hdel!":      HashAccessFunction,
	"slice":      SliceFunction,
	"len":        LenFunction,
	"append":     AppendFunction,
	"concat":     ConcatFunction,
	"array":      ConstructorFunction,
	"list":       ConstructorFunction,
	"hash":       ConstructorFunction,
	"symnum":     SymnumFunction,
	"str":        StringifyFunction,
}
View Source
var MissingFunction = SexpFunction{"__missing", true, 0, false, nil, nil, nil}
View Source
var NotAList = errors.New("not a list")
View Source
var OutOfBounds error = errors.New("jump out of bounds")
View Source
var SexpFloatSize = reflect.TypeOf(SexpFloat(0.0)).Bits()
View Source
var SexpIntSize = reflect.TypeOf(SexpInt(0)).Bits()
View Source
var UnexpectedEnd error = errors.New("Unexpected end of input")
View Source
var WrongNargs error = errors.New("wrong number of arguments")
View Source
var WrongType error = errors.New("operands have invalid type")

Functions

func Compare

func Compare(a Sexp, b Sexp) (int, error)

func DecodeChar

func DecodeChar(atom string) (string, error)

func DumpFunction

func DumpFunction(fun GlispFunction)

func EscapeChar

func EscapeChar(char rune) (rune, error)

func HashCountKeys

func HashCountKeys(hash SexpHash) int

func HashExpression

func HashExpression(expr Sexp) (int, error)

func HashIsEmpty

func HashIsEmpty(hash SexpHash) bool

func IsArray

func IsArray(expr Sexp) bool

func IsChar

func IsChar(expr Sexp) bool

func IsEmpty

func IsEmpty(expr Sexp) bool

func IsFloat

func IsFloat(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 SetHashKeyOrder

func SetHashKeyOrder(hash *SexpHash, keyOrd Sexp) error

func StringToRunes

func StringToRunes(str string) []rune

func Version

func Version() string

Types

type AddScopeInstr

type AddScopeInstr int

func (AddScopeInstr) Execute

func (a AddScopeInstr) Execute(env *Glisp) 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 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 *Glisp) error

func (BindlistInstr) InstrString

func (b BindlistInstr) InstrString() string

type BranchInstr

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

func (BranchInstr) Execute

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

func (BranchInstr) InstrString

func (b BranchInstr) InstrString() string

type CallInstr

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

func (CallInstr) Execute

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

func (CallInstr) InstrString

func (c CallInstr) InstrString() string

type DataStackElem

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

func (DataStackElem) IsStackElem

func (d DataStackElem) IsStackElem()

type DispatchInstr

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

func (DispatchInstr) Execute

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

func (DispatchInstr) InstrString

func (d DispatchInstr) InstrString() string

type DupInstr

type DupInstr int

func (DupInstr) Execute

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

func (DupInstr) InstrString

func (d DupInstr) InstrString() string

type ExplodeInstr

type ExplodeInstr int

func (ExplodeInstr) Execute

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

func (ExplodeInstr) InstrString

func (e ExplodeInstr) InstrString() string

type Generator

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

func NewGenerator

func NewGenerator(env *Glisp) *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) GenerateBegin

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

func (*Generator) GenerateCall

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

func (*Generator) GenerateCallBySymbol

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

func (*Generator) GenerateCond

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

func (*Generator) GenerateDef

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

func (*Generator) GenerateDefmac

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

func (*Generator) GenerateDefn

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

func (*Generator) GenerateDispatch

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

func (*Generator) GenerateFn

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

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) GenerateQuote

func (gen *Generator) GenerateQuote(args []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) Reset

func (gen *Generator) Reset()

type GetInstr

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

func (GetInstr) Execute

func (g GetInstr) Execute(env *Glisp) error

func (GetInstr) InstrString

func (g GetInstr) InstrString() string

type Glisp

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

func NewGlisp

func NewGlisp() *Glisp

func (*Glisp) AddFunction

func (env *Glisp) AddFunction(name string, function GlispUserFunction)

func (*Glisp) AddGlobal

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

func (*Glisp) AddMacro

func (env *Glisp) AddMacro(name string, function GlispUserFunction)

func (*Glisp) AddPostHook

func (env *Glisp) AddPostHook(fun PostHook)

func (*Glisp) AddPreHook

func (env *Glisp) AddPreHook(fun PreHook)

func (*Glisp) Apply

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

func (*Glisp) CallFunction

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

func (*Glisp) CallUserFunction

func (env *Glisp) CallUserFunction(
	function SexpFunction, name string, nargs int) error

func (*Glisp) Clear

func (env *Glisp) Clear()

func (*Glisp) Clone

func (env *Glisp) Clone() *Glisp

func (*Glisp) CurrentFunctionSize

func (env *Glisp) CurrentFunctionSize() int

func (*Glisp) DumpEnvironment

func (env *Glisp) DumpEnvironment()

func (*Glisp) DumpFunctionByName

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

func (*Glisp) Duplicate

func (env *Glisp) Duplicate() *Glisp

func (*Glisp) EvalString

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

func (*Glisp) FindObject

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

func (*Glisp) GenSymbol

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

func (*Glisp) GetStackTrace

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

func (*Glisp) ImportEval

func (env *Glisp) ImportEval()

func (*Glisp) LoadExpressions

func (env *Glisp) LoadExpressions(expressions []Sexp) error

func (*Glisp) LoadFile

func (env *Glisp) LoadFile(file *os.File) error

func (*Glisp) LoadStream

func (env *Glisp) LoadStream(stream io.Reader) error

LoadStream, load this in via running a __main function and setting main on the environment

func (*Glisp) LoadString

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

func (*Glisp) MakeSymbol

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

func (*Glisp) ParseFile

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

ParseFile, used in the generator at read time to dynamiclly add more defs from other files

func (*Glisp) ParseStream

func (env *Glisp) ParseStream(in io.Reader) ([]Sexp, error)

func (*Glisp) ReachedEnd

func (env *Glisp) ReachedEnd() bool

func (*Glisp) ReturnFromFunction

func (env *Glisp) ReturnFromFunction() error

func (*Glisp) Run

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

func (*Glisp) SourceExpressions

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

func (*Glisp) SourceFile

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

func (*Glisp) SourceStream

func (env *Glisp) SourceStream(stream io.Reader) error

SourceStream, load this in via a __source dynamic function, after it runs it no longer exists

type GlispFunction

type GlispFunction []Instruction

type GlispUserFunction

type GlispUserFunction func(*Glisp, string, []Sexp) (Sexp, error)

type GotoInstr

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

func (GotoInstr) Execute

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

func (GotoInstr) InstrString

func (g GotoInstr) InstrString() string

type HashizeInstr

type HashizeInstr struct {
	HashLen  int
	TypeName string
}

func (HashizeInstr) Execute

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

func (HashizeInstr) InstrString

func (s HashizeInstr) InstrString() string

type Instruction

type Instruction interface {
	InstrString() string
	Execute(env *Glisp) 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 *Glisp) error

func (JumpInstr) InstrString

func (j JumpInstr) InstrString() string

type Lexer

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

func NewLexerFromStream

func NewLexerFromStream(stream io.RuneReader) *Lexer

func (*Lexer) GetNextToken

func (lexer *Lexer) GetNextToken() (Token, 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() (Token, error)

type LexerState

type LexerState int
const (
	LexerNormal LexerState = iota
	LexerComment
	LexerStrLit
	LexerStrEscaped
	LexerUnquote
)

type Loop

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

func (*Loop) IsStackElem

func (loop *Loop) IsStackElem()

type NumericOp

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

type Parser

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

type PopInstr

type PopInstr int

func (PopInstr) Execute

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

func (PopInstr) InstrString

func (p PopInstr) InstrString() string

type PostHook

type PostHook func(*Glisp, string, Sexp)

type PreHook

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

type PushInstr

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

func (PushInstr) Execute

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

func (PushInstr) InstrString

func (p PushInstr) InstrString() string

type PushInstrClosure

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

func (PushInstrClosure) Execute

func (p PushInstrClosure) Execute(env *Glisp) error

func (PushInstrClosure) InstrString

func (p PushInstrClosure) InstrString() string

type PutInstr

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

func (PutInstr) Execute

func (p PutInstr) Execute(env *Glisp) error

func (PutInstr) InstrString

func (p PutInstr) InstrString() string

type RemoveScopeInstr

type RemoveScopeInstr int

func (RemoveScopeInstr) Execute

func (a RemoveScopeInstr) Execute(env *Glisp) 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 *Glisp) error

func (ReturnInstr) InstrString

func (r ReturnInstr) InstrString() string

type Scope

type Scope map[int]Sexp

func (Scope) IsStackElem

func (s Scope) IsStackElem()

type Sexp

type Sexp interface {
	SexpString() string
}

func AppendFunction

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

func ApplyFunction

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

func ArrayAccessFunction

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

func BinaryIntFunction

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

func BitwiseFunction

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

func CompareFunction

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

func ComplementFunction

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

func ConcatFunction

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

func ConcatList

func ConcatList(a SexpPair, b Sexp) (Sexp, error)

func ConsFunction

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

func ConstructorFunction

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

func EvalFunction

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

func FirstFunction

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

func HashAccessFunction

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

func IntegerDo

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

func LenFunction

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

func ListToArray

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

func MakeArrayFunction

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

func MakeList

func MakeList(expressions []Sexp) Sexp

func MapFunction

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

func MapList

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

func NotFunction

func NotFunction(env *Glisp, 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 *Glisp, 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 ParseArray

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

func ParseExpression

func ParseExpression(parser *Parser) (Sexp, error)

func ParseHash

func ParseHash(parser *Parser) (Sexp, error)

func ParseList

func ParseList(parser *Parser) (Sexp, error)

func ParseTokens

func ParseTokens(env *Glisp, lexer *Lexer) ([]Sexp, error)

func PrintFunction

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

func ReadFunction

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

func RestFunction

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

func SgetFunction

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

func SliceFunction

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

func SourceFileFunction

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

func StringifyFunction

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

func SymnumFunction

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

func TypeQueryFunction

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

type SexpArray

type SexpArray []Sexp

func ConcatArray

func ConcatArray(arr SexpArray, expr Sexp) (SexpArray, error)

func MapArray

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

func (SexpArray) SexpString

func (arr SexpArray) SexpString() string

type SexpBool

type SexpBool bool

func (SexpBool) SexpString

func (b SexpBool) SexpString() string

type SexpChar

type SexpChar rune

func (SexpChar) SexpString

func (c SexpChar) SexpString() string

type SexpFloat

type SexpFloat float64

func (SexpFloat) SexpString

func (f SexpFloat) SexpString() string

type SexpFunction

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

func MakeFunction

func MakeFunction(name string, nargs int, varargs bool,
	fun GlispFunction) SexpFunction

func MakeUserFunction

func MakeUserFunction(name string, ufun GlispUserFunction) SexpFunction

func (SexpFunction) SexpString

func (sf SexpFunction) SexpString() string

type SexpHash

type SexpHash struct {
	TypeName *string
	Map      map[int][]SexpPair
	KeyOrder *[]Sexp // must user pointers here, else hset! will fail to update.
	GoStruct *interface{}
	NumKeys  *int
}

func MakeHash

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

func (*SexpHash) HashDelete

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

func (*SexpHash) HashGet

func (hash *SexpHash) HashGet(key Sexp) (Sexp, error)

func (*SexpHash) HashGetDefault

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

func (*SexpHash) HashSet

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

func (SexpHash) SexpString

func (hash SexpHash) SexpString() string

type SexpInt

type SexpInt int

func (SexpInt) SexpString

func (i SexpInt) SexpString() string

type SexpPair

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

func Cons

func Cons(a Sexp, b Sexp) SexpPair

func (SexpPair) Head

func (pair SexpPair) Head() Sexp

func (SexpPair) SexpString

func (pair SexpPair) SexpString() string

func (SexpPair) Tail

func (pair SexpPair) Tail() Sexp

type SexpSentinel

type SexpSentinel int
const (
	SexpNull SexpSentinel = iota
	SexpEnd
	SexpMarker
)

func (SexpSentinel) SexpString

func (sent SexpSentinel) SexpString() string

type SexpStackmark

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

func (SexpStackmark) SexpString

func (mark SexpStackmark) SexpString() string

type SexpStr

type SexpStr string

func AppendStr

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

func ConcatStr

func ConcatStr(str SexpStr, expr Sexp) (SexpStr, error)

func (SexpStr) SexpString

func (s SexpStr) SexpString() string

type SexpSymbol

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

func (SexpSymbol) Name

func (sym SexpSymbol) Name() string

func (SexpSymbol) Number

func (sym SexpSymbol) Number() int

func (SexpSymbol) SexpString

func (sym SexpSymbol) SexpString() string

type SquashInstr

type SquashInstr int

func (SquashInstr) Execute

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

func (SquashInstr) InstrString

func (s SquashInstr) InstrString() string

type Stack

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

func NewStack

func NewStack(size int) *Stack

func (*Stack) BindSymbol

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

func (*Stack) Clone

func (stack *Stack) Clone() *Stack

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) IsEmpty

func (stack *Stack) IsEmpty() bool

func (*Stack) IsStackElem

func (stack *Stack) IsStackElem()

func (*Stack) LookupSymbol

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

func (*Stack) LookupSymbolNonGlobal

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

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) 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) 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) PushScope

func (stack *Stack) PushScope()

func (*Stack) Top

func (stack *Stack) Top() int

type StackElem

type StackElem interface {
	IsStackElem()
}

type Token

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

func DecodeAtom

func DecodeAtom(atom string) (Token, error)

func DecodeBrace

func DecodeBrace(brace rune) Token

func (Token) String

func (t Token) String() string

type TokenType

type TokenType int
const (
	TokenLParen TokenType = iota
	TokenRParen
	TokenLSquare
	TokenRSquare
	TokenLCurly
	TokenRCurly
	TokenDot
	TokenQuote
	TokenBacktick
	TokenTilde
	TokenTildeAt
	TokenSymbol
	TokenBool
	TokenDecimal
	TokenHex
	TokenOct
	TokenBinary
	TokenFloat
	TokenChar
	TokenString
	TokenEnd
)

type VectorizeInstr

type VectorizeInstr int

func (VectorizeInstr) Execute

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

func (VectorizeInstr) InstrString

func (s VectorizeInstr) InstrString() string

Jump to

Keyboard shortcuts

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