Documentation ¶
Index ¶
- Constants
- func Array(ctx *Context, args ...parser.Value) parser.Value
- func Coerce(ctx *Context, args ...parser.Value) parser.Value
- func ConcatIdentifier(funcPrefix parser.Identifier, funcName parser.Identifier) parser.Identifier
- func Def(ctx *Context, args ...parser.Value) parser.Value
- func Eval(ctx *Context, raw ...parser.Value) parser.Value
- func For(ctx *Context, args ...parser.Value) parser.Value
- func If(ctx *Context, args ...parser.Value) parser.Value
- func Import(ctx *Context, args ...parser.Value) (v parser.Value)
- func Invoke(ctx *Context, args ...parser.Value) parser.Value
- func Lambda(ctx *Context, args ...parser.Value) parser.Value
- func Length(elt []parser.Value) int64
- func Let(ctx *Context, args ...parser.Value) parser.Value
- func MethodNameTransform(name string) (newName string)
- func OpAdd(values ...interface{}) interface{}
- func OpEqual(values ...interface{}) interface{}
- func OpGreater(values ...interface{}) interface{}
- func OpGreaterEqual(values ...interface{}) interface{}
- func OpLess(values ...interface{}) interface{}
- func OpLessEqual(values ...interface{}) interface{}
- func OpMul(values ...interface{}) interface{}
- func OpNotEqual(values ...interface{}) interface{}
- func OpPow(values ...float64) float64
- func OpSub(values ...interface{}) interface{}
- func Package(name string, values ...interface{}) interface{}
- func Panic(v interface{})
- func Print(args ...interface{})
- func Println(args ...interface{})
- func Sprintf(args ...interface{}) string
- func Type(v interface{}) string
- type Adapter
- type CSVLib
- type Context
- func (c *Context) Dump()
- func (c *Context) Get(id parser.Identifier) parser.Value
- func (c *Context) MustEval(input parser.Value) parser.Value
- func (c *Context) RegisterType(typedNil interface{})
- func (c *Context) Set(id parser.Identifier, v parser.Value) parser.Value
- func (c *Context) SetFn(id parser.Identifier, v interface{}, adapters ...Adapter)
- func (c *Context) TryEval(input parser.Value) (parser.Value, error)
- type Error
- type ErrorCode
- type Internal
- type StdLib
- type StringsLib
Constants ¶
const ( // ErrPanic is an error caused by a panic within the interpreter. ErrPanic = iota // ErrUnknownVariable is raised when trying to resolve an unknown symbol. ErrUnknownVariable )
Variables ¶
This section is empty.
Functions ¶
func ConcatIdentifier ¶
func ConcatIdentifier(funcPrefix parser.Identifier, funcName parser.Identifier) parser.Identifier
ConcatIdentifier ...
func If ¶
If implements the 'if' builtin function. It has to be an Internal interface - otherwise, both true & false expressions would have been already evaluated.
func Lambda ¶
Lambda anonymous functions that are evaluated only when they are encountered in the program
func MethodNameTransform ¶
MethodNameTransform ...
func OpAdd ¶
func OpAdd(values ...interface{}) interface{}
OpAdd implements the '+' function. It tries to determine automatically the type based on the first argument.
func OpEqual ¶
func OpEqual(values ...interface{}) interface{}
OpEqual implements the == comparaison operator. It can work on more than 2 arguments - it will return true only if they have all the same value.
func OpGreater ¶
func OpGreater(values ...interface{}) interface{}
OpGreater implements the > comparaison operator.
func OpGreaterEqual ¶
func OpGreaterEqual(values ...interface{}) interface{}
OpGreaterEqual implements the >= comparaison operator.
func OpLess ¶
func OpLess(values ...interface{}) interface{}
OpLess implements the < comparaison operator.
func OpLessEqual ¶
func OpLessEqual(values ...interface{}) interface{}
OpLessEqual implements the <= comparaison operator.
func OpMul ¶
func OpMul(values ...interface{}) interface{}
OpMul implements the '*' function. It tries to determine automatically the type based on the first argument.
func OpNotEqual ¶
func OpNotEqual(values ...interface{}) interface{}
OpNotEqual implements the != comparaison operator.
func OpPow ¶
OpPow implements exponentiation '**' function. returns x**y, the base-x exponential of y TODO: https://github.com/rumlang/rum/issues/139
func OpSub ¶
func OpSub(values ...interface{}) interface{}
OpSub implements the '-' function. It tries to determine automatically the type based on the first argument.
Types ¶
type Adapter ¶
type Adapter func(values ...interface{}) ([]interface{}, error)
Adapter is an function type can be used to change/check params to registred golang functions
func CheckArity ¶
CheckArity return an function to check if the arity of function call is n
func ParamToFloat64 ¶
ParamToFloat64 return an Adapter to convert the p nth param to float64 type
func ParamToInt64 ¶
ParamToInt64 return an Adapter to convert the p nth param to int64 type
type Context ¶
type Context struct {
// contains filtered or unexported fields
}
Context contains details about the current execution frame.
func NewContext ¶
NewContext create new runtime context instance and load default parser funcrions
func (*Context) Get ¶
func (c *Context) Get(id parser.Identifier) parser.Value
Get returns the content of the specified variable. It will automatically look up parent context if needed. Generate a panic with an Error object if the specified variable does not exists.
func (*Context) MustEval ¶
MustEval evaluates the provided value, generatic panics when something bad happens. Panics will be *Error instances, containing the call stack.
func (*Context) RegisterType ¶
func (c *Context) RegisterType(typedNil interface{})
RegisterType register an new type in runtime. A nil or zero typed value must be the parameter
type Error ¶
type Error struct { Code ErrorCode Msg string // Stack is the glop call stack corresponding to where the error was raised. // First value is inner-most eval'ed value. Stack []parser.Value PanicRecovered interface{} PanicStack []byte }
Error is sent through panic when something went wrong during the execution.
type Internal ¶
Internal is the type used to recognized internal functions (for which arguments are not evaluated automatically) from regular functions.
type StdLib ¶
type StdLib interface {
LoadLib(ctx *Context, funcPrefix parser.Identifier)
}
StdLib ...
type StringsLib ¶
type StringsLib struct{}
StringsLib struct
func (*StringsLib) LoadLib ¶
func (l *StringsLib) LoadLib(ctx *Context, funcPrefix parser.Identifier)
LoadLib function to StringLib struct