lisp

package
v0.0.0-...-27647ab Latest Latest
Warning

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

Go to latest
Published: Oct 17, 2023 License: BSD-3-Clause Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	UnexpectedEofErr  = ParseError{errors.New("unexpected EOF")}
	UnexpectedCharErr = ParseError{errors.New("unexpected char")}
)

Functions

func AppendValue

func AppendValue(p **Cons, q **Cons, v Value)

func AsDisplay

func AsDisplay(v Value) string

func AsNumbers

func AsNumbers(v1 Value, v2 Value) (Number, Number, NumKind)

func AsString

func AsString(v Value) string

func NumberEq

func NumberEq(a Value, b Value) bool

func NumberGe

func NumberGe(a Value, b Value) bool

func NumberGt

func NumberGt(a Value, b Value) bool

func NumberLe

func NumberLe(a Value, b Value) bool

func NumberLt

func NumberLt(a Value, b Value) bool

func NumberNe

func NumberNe(a Value, b Value) bool

Types

type Atom

type Atom string

func (Atom) IsIdentity

func (Atom) IsIdentity() bool

func (Atom) String

func (v Atom) String() string

type Bool

type Bool bool

func (Bool) IsIdentity

func (Bool) IsIdentity() bool

func (Bool) String

func (v Bool) String() string

type Callable

type Callable interface {
	Value
	Call([]Value) Value
}

type Char

type Char rune

func (Char) IsIdentity

func (Char) IsIdentity() bool

func (Char) String

func (v Char) String() string

type Compiler

type Compiler struct{}

func NewCompiler

func NewCompiler() *Compiler

func (*Compiler) Compile

func (co *Compiler) Compile(src *Cons) (p Program)

type Complex

type Complex complex128

func (Complex) AsComplex

func (v Complex) AsComplex() Complex

func (Complex) AsFloat

func (v Complex) AsFloat() Float

func (Complex) AsInt

func (v Complex) AsInt() Int

func (Complex) AsRealNumber

func (v Complex) AsRealNumber() float64

func (Complex) IsIdentity

func (Complex) IsIdentity() bool

func (Complex) Kind

func (v Complex) Kind() NumKind

func (Complex) Magnitude

func (v Complex) Magnitude() Float

func (Complex) String

func (v Complex) String() string

type Cons

type Cons struct {
	Car, Cdr Value
}

func AsCons

func AsCons(v Value) (*Cons, bool)

func AsPair

func AsPair(car, cdr Value) *Cons

func MakeList

func MakeList(vs ...Value) *Cons

func (*Cons) IsIdentity

func (*Cons) IsIdentity() bool

func (*Cons) String

func (v *Cons) String() string

type Float

type Float float64

func (Float) AsComplex

func (v Float) AsComplex() Complex

func (Float) AsFloat

func (v Float) AsFloat() Float

func (Float) AsInt

func (v Float) AsInt() Int

func (Float) IsIdentity

func (Float) IsIdentity() bool

func (Float) Kind

func (v Float) Kind() NumKind

func (Float) String

func (v Float) String() string

type Instr

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

func (Instr) String

func (i Instr) String() string

type Int

type Int int64

func (Int) AsComplex

func (v Int) AsComplex() Complex

func (Int) AsFloat

func (v Int) AsFloat() Float

func (Int) AsInt

func (v Int) AsInt() Int

func (Int) IsIdentity

func (Int) IsIdentity() bool

func (Int) Kind

func (v Int) Kind() NumKind

func (Int) String

func (v Int) String() string

type Intrinsic

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

func (*Intrinsic) Call

func (it *Intrinsic) Call(args []Value) Value

func (*Intrinsic) IsIdentity

func (it *Intrinsic) IsIdentity() bool

func (*Intrinsic) String

func (it *Intrinsic) String() string

type LoadedProc

type LoadedProc struct {
	*Proc
	*Scope
}

func (LoadedProc) Call

func (p LoadedProc) Call(args []Value) Value

type NumKind

type NumKind int8
const (
	NumInt NumKind = iota
	NumFloat
	NumComplex
)

func (NumKind) Coerce

func (k NumKind) Coerce(vt NumKind) NumKind

type Number

type Number interface {
	Value

	Kind() NumKind
	AsInt() Int
	AsFloat() Float
	AsComplex() Complex
}

func AsNumber

func AsNumber(v Value) Number

type Op

type Op int8
const (
	OpInvalid Op = iota

	OpApply
	OpAsFalse
	OpAsTrue
	OpCar
	OpCdr
	OpCons
	OpDefine
	OpDrop
	OpGoto
	OpIfFalse
	OpLdConst
	OpLdProc
	OpLdVar
	OpReturn
	OpSet
)

func (Op) String

func (o Op) String() string

type ParseError

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

func (ParseError) Error

func (e ParseError) Error() string

func (ParseError) Unwrap

func (e ParseError) Unwrap() error

type Parser

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

func NewParser

func NewParser(r io.Reader) *Parser

func (*Parser) Parse

func (pa *Parser) Parse() (ret *Cons, err error)

type Proc

type Proc struct {
	Name string
	Code Program
	Args []string
}

func (*Proc) IsIdentity

func (p *Proc) IsIdentity() bool

func (*Proc) LoadWithScope

func (p *Proc) LoadWithScope(scope *Scope) LoadedProc

func (*Proc) String

func (p *Proc) String() string

type Program

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

func (Program) String

func (p Program) String() string

type Reflect

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

func (Reflect) IsIdentity

func (r Reflect) IsIdentity() bool

func (Reflect) String

func (r Reflect) String() string

type RuneWriter

type RuneWriter interface {
	WriteRune(r rune) (int, error)
}

type Scope

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

func NewScope

func NewScope(parent *Scope) *Scope

func (*Scope) Derive

func (sc *Scope) Derive(proc *Proc, vals []Value) (ret *Scope)

func (*Scope) Get

func (sc *Scope) Get(key string) (v Value, ok bool)

func (*Scope) Merge

func (sc *Scope) Merge(proc *Proc, vals []Value)

func (*Scope) Set

func (sc *Scope) Set(key string, val Value)

type String

type String string

func (String) IsIdentity

func (String) IsIdentity() bool

func (String) String

func (v String) String() string

type Value

type Value interface {
	IsIdentity() bool

	String() string
	// contains filtered or unexported methods
}

func AsValue

func AsValue(v any) Value

func Evaluate

func Evaluate(s *Scope, p Program) Value

func NumberAdd

func NumberAdd(a Value, b Value) Value

func NumberDiv

func NumberDiv(a Value, b Value) Value

func NumberMul

func NumberMul(a Value, b Value) Value

func NumberSub

func NumberSub(a Value, b Value) Value

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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