123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172 |
- /*
- * Public Domain Software
- *
- * I (Matthias Ladkau) am the author of the source code in this file.
- * I have placed the source code in this file in the public domain.
- *
- * For further information see: http://creativecommons.org/publicdomain/zero/1.0/
- */
- package parser
- /*
- RuntimeProvider provides runtime components for a parse tree.
- */
- type RuntimeProvider interface {
- /*
- Runtime returns a runtime component for a given ASTNode.
- */
- Runtime(node *ASTNode) Runtime
- }
- /*
- Runtime provides the runtime for an ASTNode.
- */
- type Runtime interface {
- /*
- Validate this runtime component and all its child components.
- */
- Validate() error
- /*
- Eval evaluate this runtime component. It gets passed the current variable
- scope and the instance state.
- The instance state is created per execution instance and can be used
- for generator functions to store their current state.
- */
- Eval(Scope, map[string]interface{}) (interface{}, error)
- }
- /*
- Scope models an environment which stores data.
- */
- type Scope interface {
- /*
- NewChild creates a new child scope.
- */
- NewChild(name string) Scope
- /*
- Parent returns the parent scope or nil.
- */
- Parent() Scope
- /*
- SetValue sets a new value for a variable.
- */
- SetValue(varName string, varValue interface{}) error
- /*
- GetValue gets the current value of a variable.
- */
- GetValue(varName string) (interface{}, bool, error)
- /*
- String returns a string representation of this scope.
- */
- String() string
- }
|