Documentation ¶
Index ¶
- Constants
- type Action
- func (u *Action) Compile(lib *Library) error
- func (u *Action) Exec(stt State) error
- func (u Action) MarshalJSON() ([]byte, error)
- func (u Action) MarshalYAML() (interface{}, error)
- func (u *Action) MustExecUpdate(stt *MemState)
- func (u *Action) UnmarshalJSON(data []byte) error
- func (u *Action) UnmarshalYAML(value *yaml.Node) error
- type ActionBound
- type ActionIf
- type ActionNative
- type ActionWhile
- type Binding
- type BoundState
- type Condition
- func (c *Condition) Compile(lib *Library) error
- func (c *Condition) Eval(stt State) (bool, error)
- func (c Condition) MarshalJSON() ([]byte, error)
- func (c Condition) MarshalYAML() (interface{}, error)
- func (c Condition) MustEval(stt State) bool
- func (c *Condition) UnmarshalJSON(data []byte) error
- func (c *Condition) UnmarshalYAML(value *yaml.Node) error
- type ConditionNative
- type Definitions
- type Expression
- type ExpressionNative
- type Factory
- type GenericMap
- type LangError
- type LeafType
- type Library
- func (lib *Library) AddDefinitions(defs Definitions) error
- func (lib *Library) Compile() error
- func (lib *Library) Copy() *Library
- func (lib *Library) FullName() string
- func (lib *Library) GetAction(name string) (*Action, error)
- func (lib *Library) GetCondition(name string) (*Condition, error)
- func (lib *Library) GetExpression(name string) (*Expression, error)
- func (lib *Library) GetLibrary(name string) (*Library, error)
- func (lib *Library) GetType(name string) (*Type, error)
- func (lib *Library) LoadFromDir(dir string) error
- func (lib *Library) MustGetAction(name string) *Action
- func (lib *Library) MustGetCondition(name string) *Condition
- func (lib *Library) MustGetExpression(name string) *Expression
- func (lib *Library) MustGetType(name string) *Type
- func (lib *Library) RegisterAction(name string, native ActionNative, valueType *Type) error
- func (lib *Library) RegisterCondition(name string, cond ConditionNative) error
- type MemState
- func (stt *MemState) AddUpdate(cond *Condition, udt *Action)
- func (stt *MemState) Detach()
- func (stt *MemState) FullName() string
- func (stt *MemState) GetValue(name string) (*ValueHolder, error)
- func (stt *MemState) Interface() NativeInterface
- func (stt *MemState) Mem() *MemState
- func (stt *MemState) NewChild(name string, values *ValueHolder, childBinding *TwoBinding) (*MemState, error)
- func (stt *MemState) RemoveChild(name string) error
- func (stt *MemState) RunUpdates() error
- func (stt *MemState) SetValue(name string, value any) error
- func (stt *MemState) String() string
- func (stt *MemState) Take(state *MemState, mapping Binding) error
- func (stt *MemState) Type() *Type
- func (stt *MemState) ValueMux() *sync.Mutex
- type NativeInterface
- type Parser
- type State
- type StateAction
- type TwoBinding
- type Type
- type ValueHolder
- type WebState
- func (wst *WebState) FullName() string
- func (wst *WebState) GetValue(name string) (*ValueHolder, error)
- func (wst *WebState) Interface() NativeInterface
- func (wst *WebState) Mem() *MemState
- func (wst *WebState) RemoveChild(name string) error
- func (wst *WebState) Run()
- func (wst *WebState) SetValue(name string, value any) error
- func (wst *WebState) String() string
- func (wst *WebState) Sync(name string) error
- func (wst *WebState) Type() *Type
- type WebsocketServer
Constants ¶
View Source
const ( LeafString = LeafType(iota + 1) LeafFloat LeafInteger LeafBoolean LeafRaw )
View Source
const BindingSep = "<=>"
View Source
const BindingSepIn = "->"
View Source
const BindingSepOut = "<-"
View Source
const LibSep = "."
View Source
const StateSep = "/"
View Source
const ValueSep = "."
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Action ¶
type Action struct {
// contains filtered or unexported fields
}
func (Action) MarshalJSON ¶
func (Action) MarshalYAML ¶
func (*Action) MustExecUpdate ¶
func (*Action) UnmarshalJSON ¶
func (*Action) UnmarshalYAML ¶
type ActionBound ¶
type ActionBound struct { Binding *TwoBinding `yaml:"binding"` Action *Action `yaml:"update"` }
type ActionIf ¶
type ActionIf struct { Condition *Condition `yaml:"condition"` Expression *Expression Then *Action `yaml:"then"` Else *Action `yaml:"else"` }
type ActionNative ¶
type ActionNative func(stateInterface NativeInterface) error
type ActionWhile ¶
type Binding ¶
Binding maps values from a context onto another context, where keys are the targets and values are the source
type BoundState ¶
type Condition ¶
type Condition struct {
// contains filtered or unexported fields
}
func (Condition) MarshalJSON ¶
func (Condition) MarshalYAML ¶
func (*Condition) UnmarshalJSON ¶
func (*Condition) UnmarshalYAML ¶
type ConditionNative ¶
type ConditionNative func(stateInterface NativeInterface) (bool, error)
type Definitions ¶
type Expression ¶
type Expression struct { Name string `json:"name" yaml:"name"` Value any `json:"value" yaml:"value"` Variable string `json:"variable" yaml:"variable"` Reference string `json:"reference" yaml:"reference"` Operation string `json:"operation" yaml:"operation"` Children []*Expression `json:"children" yaml:"children"` Native ExpressionNative `json:"-" yaml:"-"` // contains filtered or unexported fields }
func (*Expression) Compile ¶
func (c *Expression) Compile(lib *Library) error
func (Expression) MustEval ¶
func (c Expression) MustEval(stt State) any
type ExpressionNative ¶
type ExpressionNative func(stateInterface NativeInterface) (any, error)
type Factory ¶
type GenericMap ¶
type LangError ¶
type LangError struct { Ctx antlr.ParserRuleContext Err error // contains filtered or unexported fields }
type LeafType ¶
type LeafType int
func (*LeafType) FromString ¶
func (LeafType) MarshalJSON ¶
func (LeafType) MarshalYAML ¶
func (*LeafType) UnmarshalJSON ¶
func (*LeafType) UnmarshalYAML ¶
type Library ¶
type Library struct { Name string Parent *Library Children map[string]*Library Definitions Definitions }
Library contains definitions and hooks to the native environment. It is independent of states.
func NewLibrary ¶
func NewLibrary() *Library
func (*Library) AddDefinitions ¶
func (lib *Library) AddDefinitions(defs Definitions) error
func (*Library) GetExpression ¶
func (lib *Library) GetExpression(name string) (*Expression, error)
func (*Library) LoadFromDir ¶
func (*Library) MustGetAction ¶
func (*Library) MustGetCondition ¶
func (*Library) MustGetExpression ¶
func (lib *Library) MustGetExpression(name string) *Expression
func (*Library) MustGetType ¶
func (*Library) RegisterAction ¶
func (lib *Library) RegisterAction(name string, native ActionNative, valueType *Type) error
func (*Library) RegisterCondition ¶
func (lib *Library) RegisterCondition(name string, cond ConditionNative) error
type MemState ¶
type MemState struct { // Name of the state Name string // Parent contains the parent state to achieve mapping Parent *BoundState // Children were produced from this state Children map[string]*BoundState // ValueHolder contains values of this state Values *ValueHolder // Actions are invoked on each state change Actions []*StateAction // contains filtered or unexported fields }
func NewMemState ¶
func NewMemState(name string, values *ValueHolder) (*MemState, error)
func (*MemState) Interface ¶
func (stt *MemState) Interface() NativeInterface
func (*MemState) NewChild ¶
func (stt *MemState) NewChild(name string, values *ValueHolder, childBinding *TwoBinding) (*MemState, error)
func (*MemState) RemoveChild ¶
func (*MemState) RunUpdates ¶
type NativeInterface ¶
type Parser ¶
type Parser struct {
// contains filtered or unexported fields
}
func (*Parser) ParseSource ¶
type StateAction ¶
type TwoBinding ¶
TwoBinding specifies how two states should update each other At some point, we can think of an extension to allow for cross-machine bindings
func MustParseBinding ¶
func MustParseBinding(strs ...string) *TwoBinding
func ParseTwoBinding ¶
func ParseTwoBinding(strs []string) (*TwoBinding, error)
func (TwoBinding) MarshalJSON ¶
func (tb TwoBinding) MarshalJSON() ([]byte, error)
func (TwoBinding) MarshalYAML ¶
func (tb TwoBinding) MarshalYAML() (interface{}, error)
func (*TwoBinding) UnmarshalJSON ¶
func (tb *TwoBinding) UnmarshalJSON(data []byte) error
func (*TwoBinding) UnmarshalYAML ¶
func (tb *TwoBinding) UnmarshalYAML(value *yaml.Node) error
type Type ¶
type Type struct {
// contains filtered or unexported fields
}
func MustParseType ¶
func (Type) MarshalJSON ¶
func (Type) MarshalYAML ¶
func (*Type) UnmarshalJSON ¶
func (*Type) UnmarshalYAML ¶
type ValueHolder ¶
type ValueHolder struct { Type *Type `json:"type,omitempty"` Value any `json:"value,omitempty"` // contains filtered or unexported fields }
func (*ValueHolder) Copy ¶
func (v *ValueHolder) Copy() *ValueHolder
func (*ValueHolder) GetValue ¶
func (v *ValueHolder) GetValue(name string) (*ValueHolder, error)
func (*ValueHolder) String ¶
func (v *ValueHolder) String() string
type WebState ¶
type WebState struct {
// contains filtered or unexported fields
}
func NewWebState ¶
func (*WebState) Interface ¶
func (wst *WebState) Interface() NativeInterface
func (*WebState) RemoveChild ¶
type WebsocketServer ¶
type WebsocketServer struct {
// contains filtered or unexported fields
}
func NewWebsocketServer ¶
func NewWebsocketServer(addr string, path string) (*WebsocketServer, error)
func (*WebsocketServer) AddFactory ¶
func (ws *WebsocketServer) AddFactory(st *MemState, factory string, token string, binding *TwoBinding, value *ValueHolder) (*Factory, error)
func (*WebsocketServer) Shutdown ¶
func (ws *WebsocketServer) Shutdown() error
func (*WebsocketServer) Start ¶
func (ws *WebsocketServer) Start() error
Source Files ¶
Click to show internal directories.
Click to hide internal directories.