Documentation ¶
Overview ¶
Package parser provides functions for turning token stream into an AST (Symbolic Expressions)
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrEOF = errors.New("end of file")
ErrEOF is returned when the parser has consumed all tokens.
Functions ¶
This section is empty.
Types ¶
type KeywordExpr ¶ added in v0.0.2
type KeywordExpr struct {
Keyword string
}
KeywordExpr represents a keyword literal.
func (KeywordExpr) Eval ¶ added in v0.0.2
func (ke KeywordExpr) Eval(scope Scope) (interface{}, error)
Eval returns the keyword itself.
func (KeywordExpr) String ¶ added in v0.0.2
func (ke KeywordExpr) String() string
type ListExpr ¶
type ListExpr struct {
List []Expr
}
ListExpr represents a list (i.e., a function call) expression.
type MacroFunc ¶
MacroFunc will receive un-evaluated list of s-expressions and the current scope. In addition, if the macro was accessed through a name the name will be passed as well. If the macro was not accessed by name (e.g. was result of another list etc.), name will be empty string.
type MapExpr ¶ added in v0.0.2
type MapExpr struct {
// contains filtered or unexported fields
}
MapExpr represents a map literal expression.
type ModuleExpr ¶
ModuleExpr represents a list of Exprs.
func (ModuleExpr) Eval ¶
func (me ModuleExpr) Eval(scope Scope) (interface{}, error)
Eval executes each expression in the module and returns the last result.
func (ModuleExpr) String ¶
func (me ModuleExpr) String() string
type NumberExpr ¶
type NumberExpr struct { NumStr string Number interface{} }
NumberExpr represents number s-expression.
func (NumberExpr) Eval ¶
func (ne NumberExpr) Eval(scope Scope) (interface{}, error)
Eval for a number returns itself.
func (NumberExpr) String ¶
func (ne NumberExpr) String() string
type QuoteExpr ¶
type QuoteExpr struct {
// contains filtered or unexported fields
}
QuoteExpr implements the quote-literal form.
func (QuoteExpr) UnquoteEval ¶
UnquoteEval unquotes and evaluates the underlying expression.
type Scope ¶
type Scope interface { Get(name string) (interface{}, error) Doc(name string) string Bind(name string, v interface{}, doc ...string) error Root() Scope }
Scope is responsible for managing bindings.
type ScopedFunc ¶
ScopedFunc are like normal functions but get access to the current scope. Eval is an example of a ScopedFunc.
type StringExpr ¶
type StringExpr struct {
// contains filtered or unexported fields
}
StringExpr represents single and double quoted strings.
func (StringExpr) Eval ¶
func (se StringExpr) Eval(_ Scope) (interface{}, error)
Eval returns unquoted version of the STRING token.
func (StringExpr) String ¶
func (se StringExpr) String() string
type SymbolExpr ¶
type SymbolExpr struct {
Symbol string
}
SymbolExpr represents a symbol.
func (SymbolExpr) Eval ¶
func (se SymbolExpr) Eval(scope Scope) (interface{}, error)
Eval returns the symbol name itself.
func (SymbolExpr) ExpType ¶
func (se SymbolExpr) ExpType() string
ExpType returns s-expression type name.
func (SymbolExpr) String ¶
func (se SymbolExpr) String() string
type VectorExpr ¶
type VectorExpr struct {
List []Expr
}
VectorExpr represents a vector form.
func (VectorExpr) Eval ¶
func (ve VectorExpr) Eval(scope Scope) (interface{}, error)
Eval creates a golang slice.
func (VectorExpr) String ¶
func (ve VectorExpr) String() string