Documentation ¶
Index ¶
- func ApplyTemplate(template *Template, param interface{}, context *Context) (result interface{})
- func CacheTemplate(arg interface{}, templates map[string]*pongo2.Template, ...) error
- func CompileFile(file string) error
- func ContainsTemplate(arg interface{}) bool
- func GetByKeys(keys []string, value interface{}) (interface{}, error)
- func KeyToList(keys string) []string
- func LoadYAML(buf []byte) (*yaml.Node, error)
- func LoadYAMLFile(file string) (*yaml.Node, error)
- func MapToValue(a map[string]interface{}) (result map[string]Value, err error)
- func MappingNodeToMap(node *yaml.Node) (result map[string]*yaml.Node)
- func RegisterMiniGoFunc(name string, f MiniGoFunc)
- func RegisterStmtParser(funcName string, callback StmtParser)
- func RunTests(dir string) (total, success, failed int)
- func StmtsToFunc(funcName string, stmts []*Stmt) (func(*Context) (interface{}, error), error)
- type Constant
- type Context
- func (context *Context) Clear(key string)
- func (context *Context) Data() map[string]interface{}
- func (context *Context) Extend(values map[string]interface{}) *Context
- func (context *Context) Get(key string) (interface{}, error)
- func (context *Context) HasKey(key string) bool
- func (context *Context) MayGet(key string) interface{}
- func (context *Context) MaybeInt(key string) int
- func (context *Context) MaybeList(key string) []interface{}
- func (context *Context) MaybeMap(key string) map[string]interface{}
- func (context *Context) MaybeString(key string) string
- func (context *Context) Set(key string, value interface{})
- func (context *Context) SetByKeys(key string, value interface{})
- func (context *Context) SetMap(data map[string]interface{})
- type DebuggerRPC
- type Environment
- func (env *Environment) Clone() ext.Environment
- func (env *Environment) HandleEvent(event string, context map[string]interface{}) (err error)
- func (env *Environment) IsEventHandled(event string, context map[string]interface{}) bool
- func (env *Environment) Load(source, code string) error
- func (env *Environment) LoadExtensionsForPath(extensions []*schema.Extension, timeLimit time.Duration, ...) error
- type Error
- type MiniGo
- type MiniGoFunc
- type MiniGoValue
- type Nil
- type Op
- type OpCode
- type Stack
- type Stmt
- type StmtParser
- type Template
- type VM
- type Value
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ApplyTemplate ¶
ApplyTemplate apply template code for input params.
func CacheTemplate ¶
func CacheTemplate(arg interface{}, templates map[string]*pongo2.Template, minigos map[string]*MiniGo) error
CacheTemplate caches template to the statement
func CompileFile ¶
CompileFile compiles miniGo code and register func
func ContainsTemplate ¶
func ContainsTemplate(arg interface{}) bool
ContainsTemplate checks an object contains template or not
func LoadYAMLFile ¶
LoadYAMLFile loads YAML from file
func MapToValue ¶
MapToValue converts interface map to value map
func MappingNodeToMap ¶
MappingNodeToMap convert yaml node to map
func RegisterMiniGoFunc ¶
func RegisterMiniGoFunc(name string, f MiniGoFunc)
RegisterMiniGoFunc register minigo func
func RegisterStmtParser ¶
func RegisterStmtParser(funcName string, callback StmtParser)
RegisterStmtParser registers new parser per function
Types ¶
type Constant ¶
type Constant struct {
// contains filtered or unexported fields
}
Constant represents donburi consntant.
type Context ¶
type Context struct { VM *VM // contains filtered or unexported fields }
Context is execution context in gohan script. Variables are stored in this context object.
func (*Context) MaybeString ¶
MaybeString returns a string
type DebuggerRPC ¶
type DebuggerRPC struct {
// contains filtered or unexported fields
}
DebuggerRPC is a proecess to handle remote debuggging
type Environment ¶
type Environment struct { VM *VM // contains filtered or unexported fields }
Environment gohan script based environment for gohan extension
func NewEnvironment ¶
func NewEnvironment() *Environment
NewEnvironment create new gohan extension environment based on context
func (*Environment) Clone ¶
func (env *Environment) Clone() ext.Environment
Clone makes clone of the environment
func (*Environment) HandleEvent ¶
func (env *Environment) HandleEvent(event string, context map[string]interface{}) (err error)
HandleEvent handles event
func (*Environment) IsEventHandled ¶
func (env *Environment) IsEventHandled(event string, context map[string]interface{}) bool
IsEventHandled returns whether a given event is handled by this environment
func (*Environment) Load ¶
func (env *Environment) Load(source, code string) error
Load loads script for environment
func (*Environment) LoadExtensionsForPath ¶
func (env *Environment) LoadExtensionsForPath(extensions []*schema.Extension, timeLimit time.Duration, timeLimits []*schema.PathEventTimeLimit, path string) error
LoadExtensionsForPath for returns extensions for specific path
type Error ¶
type Error struct {
// contains filtered or unexported fields
}
Error represent error for gohanscript
type MiniGo ¶
type MiniGo struct {
// contains filtered or unexported fields
}
MiniGo is tiny interpreter for evaluating small expression in the gohan script MiniGo uses go parser, and implements subset of functions
func CompileExpr ¶
CompileExpr compiles single line of code
func CompileGoStmt ¶
CompileGoStmt compiles miniGo code and register func
type MiniGoFunc ¶
type MiniGoFunc func(vm *VM, args []interface{}) []interface{}
MiniGoFunc represents function which can be used in minigo
type MiniGoValue ¶
type MiniGoValue struct {
// contains filtered or unexported fields
}
MiniGoValue reprensents minigo value
func NewMiniGoValue ¶
func NewMiniGoValue(param interface{}) (*MiniGoValue, error)
NewMiniGoValue makes a MiniGoValue value
func (*MiniGoValue) Value ¶
func (i *MiniGoValue) Value(context *Context) interface{}
Value returns nil
type OpCode ¶
type OpCode int
OpCode ...
const ( // ILLEGAL tokens ILLEGAL OpCode = iota POP PUSH CALL GET SET // Identifiers and basic type literals // (these tokens stand for classes of literals) IDENT // main INT // 12345 FLOAT // 123.45 IMAG // 123.45i CHAR // 'a' STRING // "abc" // Operators and delimiters ADD // + SUB // - MUL // * QUO // / REM // % AND // & OR // | XOR // ^ SHL // << SHR // >> AND_NOT // &^ ADD_ASSIGN // += SUB_ASSIGN // -= MUL_ASSIGN // *= QUO_ASSIGN // /= REM_ASSIGN // %= AND_ASSIGN // &= OR_ASSIGN // |= XOR_ASSIGN // ^= SHL_ASSIGN // <<= SHR_ASSIGN // >>= AND_NOT_ASSIGN // &^= LAND // && LOR // || ARROW // <- INC // ++ DEC // -- EQL // == LSS // < GTR // > ASSIGN // = NOT // ! NEQ // != LEQ // <= GEQ // >= DEFINE // := ELLIPSIS // ... GETPROP SETPROP INCPROP DECPROP GETINDEX SETINDEX INCINDEX DECINDEX GOTO GOTOIF RANGE RET SUB_UNARY )
type Stack ¶
type Stack struct {
// contains filtered or unexported fields
}
Stack express stack in running context
type Stmt ¶
type Stmt struct { Name string When *MiniGo Until *MiniGo File string Dir string Line int Column int Vars map[string]Value Rescue []*Stmt Always []*Stmt ElseStmt []*Stmt Retry int Delay int Worker int Args map[string]Value WithItems Value LoopVar string WithDict Value Register string RawData map[string]interface{} RawNode map[string]*yaml.Node // contains filtered or unexported fields }
Stmt represents gohan script statement. Stmt is responseible to generate go function from YAML definitions.
type StmtParser ¶
StmtParser converts gohan script statement for golang function. You can register your parser using RegisterStmtParser call, so that you can have new gohan script function implemented by go
func GetStmtParser ¶
func GetStmtParser(funcName string) StmtParser
GetStmtParser returns parser for specific per function
type Template ¶
type Template struct {
// contains filtered or unexported fields
}
Template reprensents a value includes templates
type VM ¶
type VM struct { Context *Context StopChan chan func() // contains filtered or unexported fields }
VM is a struct for Gohan script.
func (*VM) LoadString ¶
LoadString loads gohan script code from string and make func