Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetTypeString ¶
GetTypeString returns the name of the type for the Value object.
Types ¶
type Environment ¶
type Environment struct { // Vars are the symbol mappings for the environment context Vars map[Symbol]Value // Macros is the collection of syntax extension procedures that can // expand incoming symbolic expressions before executing them. Macros map[Symbol]Procedure // Parent is the enclosing environment object Parent *Environment // contains filtered or unexported fields }
Environment represents the symbol mappings for a given context; can be nested.
func NewEnvironment ¶
func NewEnvironment(parent *Environment) *Environment
NewEnvironment creates a new environment context with an optional parent context.
func (*Environment) Copy ¶
func (env *Environment) Copy() *Environment
Copy returns a new copy of the Environment with a separate Vars map so that changes to the copy do not affect the Vars of the original Environment.
func (*Environment) Find ¶
func (env *Environment) Find(s Symbol) (Value, bool)
Find attempts to find the symbol in the current environment mapping or it's parent environment. Returns a bool indicating if the Value was found.
func (*Environment) FindMacro ¶
func (env *Environment) FindMacro(s Symbol) (p Procedure, success bool)
FindMacro attempts to find the symbol in the current environment macros or it's parent environment. Returns a bool indicating if the macro Procedure was found.
func (*Environment) SetupPrimitives ¶
func (env *Environment) SetupPrimitives()
SetupPrimitives will add in the primitive functions to the given environment.
type Procedure ¶
type Procedure struct { //ParentEnv is the environment the procedure was defined in ParentEnv *Environment // Body is sexp that will be evaluated when the procedure is called Body Value // Args is the list of procedure arguments accepted Args List VariableParameters bool }
Procedure is a user defined function
type RuseCommand ¶
type RuseCommand int
RuseCommand aliases the int type for commands to send to the Ruse server
type SyntaxError ¶
type SyntaxError struct { // Message is the error message for the syntax error Message string // Filename is the name of the file associated with the error Filename string // LineNumber is the line number where the error occurred LineNumber int }
SyntaxError is an error type for syntax problems in the source code.
func NewSyntaxError ¶
func NewSyntaxError(msg string, fn string, ln int) *SyntaxError
NewSyntaxError creates a new error value for syntax problems.
func (*SyntaxError) Error ¶
func (err *SyntaxError) Error() string
Error prints the syntax error message out to a string.
type Value ¶
type Value interface{}
Value is the common interface between scheme data types (e.g. number, symbol, lists)
func Eval ¶
func Eval(v Value, env *Environment) Value
Eval evalutes a sexp value in a given environment and returns the result.
func ParseString ¶
ParseString takes a source code chunk in string form and parses it returning the resulting Value or an error.