Documentation ¶
Index ¶
Constants ¶
const EofRune rune = -1 // Returned by Parser.SkipSpace at EOF.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Context ¶
type Context struct {
// contains filtered or unexported fields
}
A Context holds the state of an interpreter.
func NewContext ¶
NewContext returns a Context ready to execute. The argument specifies the maximum stack depth to allow, with <=0 meaning unlimited.
func (*Context) Eval ¶
Eval returns value of the expression. The result depends on the expr: - for atoms, the value of the atom - for function definitions (defn ...), the list of defined functions - for general expressions, the value of executing apply[λ[;expr];nil], that is, a vacuous lambda with expr as its body and no arguments.
func (*Context) StackTrace ¶
StackTrace returns a printout of the execution stack. The most recent call appears first. Long stacks are trimmed in the middle.
type EOF ¶
type EOF string // End of file on input.
Types used to signal to the outside. Both are returned through panic, which the caller is expected to recover from.
type Error ¶
type Error string // Error on execution or parse.
Types used to signal to the outside. Both are returned through panic, which the caller is expected to recover from.
type Expr ¶
type Expr struct {
// contains filtered or unexported fields
}
Expr represents an arbitrary expression.
func Car ¶
Car implements the Lisp function CAR. Car and Cdr are functions not methods so (CADR X) is Car(Cdr(x)) not x.Cdr().Car().
func (*Expr) SExprString ¶
SExprString returns the expression as a formatted S-Expression.
type Parser ¶
type Parser struct {
// contains filtered or unexported fields
}
Parser is the parser for lists.
func NewParser ¶
func NewParser(r io.RuneReader) *Parser
NewParser returns a new parser that will read from the RuneReader. Parse errors cause panics of type Error that the caller must handle.
func (*Parser) SkipToEndOfLine ¶
func (p *Parser) SkipToEndOfLine()
SkipToNewline advances the input past the next newline.