lang

package
v0.0.0-...-173ccf6 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 5, 2018 License: GPL-3.0 Imports: 25 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// Name is the name of this frontend.
	Name = "lang"
	// Start is the entry point filename that we use. It is arbitrary.
	Start = "/start." + FileNameExtension // FIXME: replace with a proper code entry point schema (directory schema)
)
View Source
const (
	ErrLexerUnrecognized      = interfaces.Error("unrecognized")
	ErrLexerStringBadEscaping = interfaces.Error("string: bad escaping")
	ErrLexerIntegerOverflow   = interfaces.Error("integer: overflow")
	ErrLexerFloatOverflow     = interfaces.Error("float: overflow")
	ErrParseError             = interfaces.Error("parser")
	ErrParseAdditionalEquals  = interfaces.Error(errstrParseAdditionalEquals)
	ErrParseExpectingComma    = interfaces.Error(errstrParseExpectingComma)
)

These constants represent the different possible lexer/parser errors.

View Source
const (
	// EdgeNotify declares an edge a -> b, such that a notification occurs.
	// This is most similar to "notify" in Puppet.
	EdgeNotify = "notify"

	// EdgeBefore declares an edge a -> b, such that no notification occurs.
	// This is most similar to "before" in Puppet.
	EdgeBefore = "before"

	// EdgeListen declares an edge a <- b, such that a notification occurs.
	// This is most similar to "subscribe" in Puppet.
	EdgeListen = "listen"

	// EdgeDepend declares an edge a <- b, such that no notification occurs.
	// This is most similar to "require" in Puppet.
	EdgeDepend = "depend"
)
View Source
const (
	// FileNameExtension is the filename extension used for languages files.
	FileNameExtension = "mcl" // alternate suggestions welcome!

)

Variables

This section is empty.

Functions

func InterpolateStr

func InterpolateStr(str string, pos *Pos) (interfaces.Expr, error)

InterpolateStr interpolates a string and returns the representative AST. This particular implementation uses the hashicorp hil library and syntax to do so.

func LexParse

func LexParse(input io.Reader) (interfaces.Stmt, error)

LexParse runs the lexer/parser machinery and returns the AST.

Types

type ExprBool

type ExprBool struct {
	V bool
}

ExprBool is a representation of a boolean.

func (*ExprBool) Func

func (obj *ExprBool) Func() (interfaces.Func, error)

Func returns the reactive stream of values that this expression produces.

func (*ExprBool) Graph

func (obj *ExprBool) Graph() (*pgraph.Graph, error)

Graph returns the reactive function graph which is expressed by this node. It includes any vertices produced by this node, and the appropriate edges to any vertices that are produced by its children. Nodes which fulfill the Expr interface directly produce vertices (and possible children) where as nodes that fulfill the Stmt interface do not produces vertices, where as their children might. This returns a graph with a single vertex (itself) in it.

func (*ExprBool) Interpolate

func (obj *ExprBool) Interpolate() (interfaces.Expr, error)

Interpolate returns a new node (or itself) once it has been expanded. This generally increases the size of the AST when it is used. It calls Interpolate on any child elements and builds the new node with those new node contents. Here it simply returns itself, as no interpolation is possible.

func (*ExprBool) SetScope

func (obj *ExprBool) SetScope(*interfaces.Scope) error

SetScope does nothing for this struct, because it has no child nodes, and it does not need to know about the parent scope.

func (*ExprBool) SetType

func (obj *ExprBool) SetType(typ *types.Type) error

SetType will make no changes if called here. It will error if anything other than a Bool is passed in, and doesn't need to be called for this expr to work.

func (*ExprBool) SetValue

func (obj *ExprBool) SetValue(value types.Value) error

SetValue for a bool expression is always populated statically, and does not ever receive any incoming values (no incoming edges) so this should never be called. It has been implemented for uniformity.

func (*ExprBool) String

func (obj *ExprBool) String() string

String returns a short representation of this expression.

func (*ExprBool) Type

func (obj *ExprBool) Type() (*types.Type, error)

Type returns the type of this expression. This method always returns Bool here.

func (*ExprBool) Unify

func (obj *ExprBool) Unify() ([]interfaces.Invariant, error)

Unify returns the list of invariants that this node produces. It recursively calls Unify on any children elements that exist in the AST, and returns the collection to the caller.

func (*ExprBool) Value

func (obj *ExprBool) Value() (types.Value, error)

Value returns the value of this expression in our type system. This will usually only be valid once the engine has run and values have been produced. This might get called speculatively (early) during unification to learn more. This particular value is always known since it is a constant.

type ExprCall

type ExprCall struct {
	V types.Value // stored result (set with SetValue)

	Name string
	Args []interfaces.Expr // list of args in parsed order
	// contains filtered or unexported fields
}

ExprCall is a representation of a function call. This does not represent the declaration or implementation of a new function value.

func (*ExprCall) Func

func (obj *ExprCall) Func() (interfaces.Func, error)

Func returns the reactive stream of values that this expression produces.

func (*ExprCall) Graph

func (obj *ExprCall) Graph() (*pgraph.Graph, error)

Graph returns the reactive function graph which is expressed by this node. It includes any vertices produced by this node, and the appropriate edges to any vertices that are produced by its children. Nodes which fulfill the Expr interface directly produce vertices (and possible children) where as nodes that fulfill the Stmt interface do not produces vertices, where as their children might. This returns a graph with a single vertex (itself) in it, and the edges from all of the child graphs to this.

func (*ExprCall) Interpolate

func (obj *ExprCall) Interpolate() (interfaces.Expr, error)

Interpolate returns a new node (or itself) once it has been expanded. This generally increases the size of the AST when it is used. It calls Interpolate on any child elements and builds the new node with those new node contents.

func (*ExprCall) SetScope

func (obj *ExprCall) SetScope(scope *interfaces.Scope) error

SetScope stores the scope for later use in this resource and it's children, which it propagates this downwards to.

func (*ExprCall) SetType

func (obj *ExprCall) SetType(typ *types.Type) error

SetType is used to set the type of this expression once it is known. This usually happens during type unification, but it can also happen during parsing if a type is specified explicitly. Since types are static and don't change on expressions, if you attempt to set a different type than what has previously been set (when not initially known) this will error. Remember that for this function expression, the type is the *return type* of the function, not the full type of the function signature.

func (*ExprCall) SetValue

func (obj *ExprCall) SetValue(value types.Value) error

SetValue here is used to store the result of the last computation of this expression node after it has received all the required input values. This value is cached and can be retrieved by calling Value.

func (*ExprCall) String

func (obj *ExprCall) String() string

String returns a short representation of this expression.

func (*ExprCall) Type

func (obj *ExprCall) Type() (*types.Type, error)

Type returns the type of this expression, which is the return type of the function call.

func (*ExprCall) Unify

func (obj *ExprCall) Unify() ([]interfaces.Invariant, error)

Unify returns the list of invariants that this node produces. It recursively calls Unify on any children elements that exist in the AST, and returns the collection to the caller.

func (*ExprCall) Value

func (obj *ExprCall) Value() (types.Value, error)

Value returns the value of this expression in our type system. This will usually only be valid once the engine has run and values have been produced. This might get called speculatively (early) during unification to learn more. It is often unlikely that this kind of speculative execution finds something. This particular implementation of the function returns the previously stored and cached value as received by SetValue.

type ExprFloat

type ExprFloat struct {
	V float64
}

ExprFloat is a representation of a float.

func (*ExprFloat) Func

func (obj *ExprFloat) Func() (interfaces.Func, error)

Func returns the reactive stream of values that this expression produces.

func (*ExprFloat) Graph

func (obj *ExprFloat) Graph() (*pgraph.Graph, error)

Graph returns the reactive function graph which is expressed by this node. It includes any vertices produced by this node, and the appropriate edges to any vertices that are produced by its children. Nodes which fulfill the Expr interface directly produce vertices (and possible children) where as nodes that fulfill the Stmt interface do not produces vertices, where as their children might. This returns a graph with a single vertex (itself) in it.

func (*ExprFloat) Interpolate

func (obj *ExprFloat) Interpolate() (interfaces.Expr, error)

Interpolate returns a new node (or itself) once it has been expanded. This generally increases the size of the AST when it is used. It calls Interpolate on any child elements and builds the new node with those new node contents. Here it simply returns itself, as no interpolation is possible.

func (*ExprFloat) SetScope

func (obj *ExprFloat) SetScope(*interfaces.Scope) error

SetScope does nothing for this struct, because it has no child nodes, and it does not need to know about the parent scope.

func (*ExprFloat) SetType

func (obj *ExprFloat) SetType(typ *types.Type) error

SetType will make no changes if called here. It will error if anything other than a Float is passed in, and doesn't need to be called for this expr to work.

func (*ExprFloat) SetValue

func (obj *ExprFloat) SetValue(value types.Value) error

SetValue for a float expression is always populated statically, and does not ever receive any incoming values (no incoming edges) so this should never be called. It has been implemented for uniformity.

func (*ExprFloat) String

func (obj *ExprFloat) String() string

String returns a short representation of this expression.

func (*ExprFloat) Type

func (obj *ExprFloat) Type() (*types.Type, error)

Type returns the type of this expression. This method always returns Float here.

func (*ExprFloat) Unify

func (obj *ExprFloat) Unify() ([]interfaces.Invariant, error)

Unify returns the list of invariants that this node produces. It recursively calls Unify on any children elements that exist in the AST, and returns the collection to the caller.

func (*ExprFloat) Value

func (obj *ExprFloat) Value() (types.Value, error)

Value returns the value of this expression in our type system. This will usually only be valid once the engine has run and values have been produced. This might get called speculatively (early) during unification to learn more. This particular value is always known since it is a constant.

type ExprFunc

type ExprFunc struct {
	V func([]types.Value) (types.Value, error)
	// contains filtered or unexported fields
}

ExprFunc is a representation of a function value. This is not a function call, that is represented by ExprCall. XXX: this is currently not fully implemented, and parts may be incorrect.

func (*ExprFunc) Func

func (obj *ExprFunc) Func() (interfaces.Func, error)

Func returns the reactive stream of values that this expression produces.

func (*ExprFunc) Graph

func (obj *ExprFunc) Graph() (*pgraph.Graph, error)

Graph returns the reactive function graph which is expressed by this node. It includes any vertices produced by this node, and the appropriate edges to any vertices that are produced by its children. Nodes which fulfill the Expr interface directly produce vertices (and possible children) where as nodes that fulfill the Stmt interface do not produces vertices, where as their children might. This returns a graph with a single vertex (itself) in it.

func (*ExprFunc) Interpolate

func (obj *ExprFunc) Interpolate() (interfaces.Expr, error)

Interpolate returns a new node (or itself) once it has been expanded. This generally increases the size of the AST when it is used. It calls Interpolate on any child elements and builds the new node with those new node contents. Here it simply returns itself, as no interpolation is possible.

func (*ExprFunc) SetScope

func (obj *ExprFunc) SetScope(*interfaces.Scope) error

SetScope does nothing for this struct, because it has no child nodes, and it does not need to know about the parent scope. XXX: this may not be true in the future...

func (*ExprFunc) SetType

func (obj *ExprFunc) SetType(typ *types.Type) error

SetType is used to set the type of this expression once it is known. This usually happens during type unification, but it can also happen during parsing if a type is specified explicitly. Since types are static and don't change on expressions, if you attempt to set a different type than what has previously been set (when not initially known) this will error.

func (*ExprFunc) SetValue

func (obj *ExprFunc) SetValue(value types.Value) error

SetValue for a func expression is always populated statically, and does not ever receive any incoming values (no incoming edges) so this should never be called. It has been implemented for uniformity.

func (*ExprFunc) String

func (obj *ExprFunc) String() string

String returns a short representation of this expression. FIXME: fmt.Sprintf("func(%+v)", obj.V) fails `go vet` (bug?), so wait until we have a better printable function value and put that here instead.

func (*ExprFunc) Type

func (obj *ExprFunc) Type() (*types.Type, error)

Type returns the type of this expression.

func (*ExprFunc) Unify

func (obj *ExprFunc) Unify() ([]interfaces.Invariant, error)

Unify returns the list of invariants that this node produces. It recursively calls Unify on any children elements that exist in the AST, and returns the collection to the caller.

func (*ExprFunc) Value

func (obj *ExprFunc) Value() (types.Value, error)

Value returns the value of this expression in our type system. This will usually only be valid once the engine has run and values have been produced. This might get called speculatively (early) during unification to learn more. This particular value is always known since it is a constant.

type ExprIf

type ExprIf struct {
	Condition  interfaces.Expr
	ThenBranch interfaces.Expr // could be an ExprBranch
	ElseBranch interfaces.Expr // could be an ExprBranch
	// contains filtered or unexported fields
}

ExprIf represents an if expression which *must* have both branches, and which returns a value. As a result, it has a type. This is different from a StmtIf, which does not need to have both branches, and which does not return a value.

func (*ExprIf) Func

func (obj *ExprIf) Func() (interfaces.Func, error)

Func returns a function which returns the correct branch based on the ever changing conditional boolean input.

func (*ExprIf) Graph

func (obj *ExprIf) Graph() (*pgraph.Graph, error)

Graph returns the reactive function graph which is expressed by this node. It includes any vertices produced by this node, and the appropriate edges to any vertices that are produced by its children. Nodes which fulfill the Expr interface directly produce vertices (and possible children) where as nodes that fulfill the Stmt interface do not produces vertices, where as their children might. This particular if expression doesn't do anything clever here other than adding in both branches of the graph. Since we're functional, this shouldn't have any ill effects. XXX: is this completely true if we're running technically impure, but safe built-in functions on both branches? Can we turn off half of this?

func (*ExprIf) Interpolate

func (obj *ExprIf) Interpolate() (interfaces.Expr, error)

Interpolate returns a new node (or itself) once it has been expanded. This generally increases the size of the AST when it is used. It calls Interpolate on any child elements and builds the new node with those new node contents.

func (*ExprIf) SetScope

func (obj *ExprIf) SetScope(scope *interfaces.Scope) error

SetScope stores the scope for later use in this resource and it's children, which it propagates this downwards to.

func (*ExprIf) SetType

func (obj *ExprIf) SetType(typ *types.Type) error

SetType is used to set the type of this expression once it is known. This usually happens during type unification, but it can also happen during parsing if a type is specified explicitly. Since types are static and don't change on expressions, if you attempt to set a different type than what has previously been set (when not initially known) this will error.

func (*ExprIf) SetValue

func (obj *ExprIf) SetValue(value types.Value) error

SetValue here is a no-op, because algorithmically when this is called from the func engine, the child fields (the branches expr's) will have had this done to them first, and as such when we try and retrieve the set value from this expression by calling `Value`, it will build it from scratch!

func (*ExprIf) String

func (obj *ExprIf) String() string

String returns a short representation of this expression.

func (*ExprIf) Type

func (obj *ExprIf) Type() (*types.Type, error)

Type returns the type of this expression.

func (*ExprIf) Unify

func (obj *ExprIf) Unify() ([]interfaces.Invariant, error)

Unify returns the list of invariants that this node produces. It recursively calls Unify on any children elements that exist in the AST, and returns the collection to the caller.

func (*ExprIf) Value

func (obj *ExprIf) Value() (types.Value, error)

Value returns the value of this expression in our type system. This will usually only be valid once the engine has run and values have been produced. This might get called speculatively (early) during unification to learn more. This particular expression evaluates the condition and returns the correct branch's value accordingly.

type ExprInt

type ExprInt struct {
	V int64
}

ExprInt is a representation of an int.

func (*ExprInt) Func

func (obj *ExprInt) Func() (interfaces.Func, error)

Func returns the reactive stream of values that this expression produces.

func (*ExprInt) Graph

func (obj *ExprInt) Graph() (*pgraph.Graph, error)

Graph returns the reactive function graph which is expressed by this node. It includes any vertices produced by this node, and the appropriate edges to any vertices that are produced by its children. Nodes which fulfill the Expr interface directly produce vertices (and possible children) where as nodes that fulfill the Stmt interface do not produces vertices, where as their children might. This returns a graph with a single vertex (itself) in it.

func (*ExprInt) Interpolate

func (obj *ExprInt) Interpolate() (interfaces.Expr, error)

Interpolate returns a new node (or itself) once it has been expanded. This generally increases the size of the AST when it is used. It calls Interpolate on any child elements and builds the new node with those new node contents. Here it simply returns itself, as no interpolation is possible.

func (*ExprInt) SetScope

func (obj *ExprInt) SetScope(*interfaces.Scope) error

SetScope does nothing for this struct, because it has no child nodes, and it does not need to know about the parent scope.

func (*ExprInt) SetType

func (obj *ExprInt) SetType(typ *types.Type) error

SetType will make no changes if called here. It will error if anything other than an Int is passed in, and doesn't need to be called for this expr to work.

func (*ExprInt) SetValue

func (obj *ExprInt) SetValue(value types.Value) error

SetValue for an int expression is always populated statically, and does not ever receive any incoming values (no incoming edges) so this should never be called. It has been implemented for uniformity.

func (*ExprInt) String

func (obj *ExprInt) String() string

String returns a short representation of this expression.

func (*ExprInt) Type

func (obj *ExprInt) Type() (*types.Type, error)

Type returns the type of this expression. This method always returns Int here.

func (*ExprInt) Unify

func (obj *ExprInt) Unify() ([]interfaces.Invariant, error)

Unify returns the list of invariants that this node produces. It recursively calls Unify on any children elements that exist in the AST, and returns the collection to the caller.

func (*ExprInt) Value

func (obj *ExprInt) Value() (types.Value, error)

Value returns the value of this expression in our type system. This will usually only be valid once the engine has run and values have been produced. This might get called speculatively (early) during unification to learn more. This particular value is always known since it is a constant.

type ExprList

type ExprList struct {

	//Elements []*ExprListElement
	Elements []interfaces.Expr
	// contains filtered or unexported fields
}

ExprList is a representation of a list.

func (*ExprList) Func

func (obj *ExprList) Func() (interfaces.Func, error)

Func returns the reactive stream of values that this expression produces.

func (*ExprList) Graph

func (obj *ExprList) Graph() (*pgraph.Graph, error)

Graph returns the reactive function graph which is expressed by this node. It includes any vertices produced by this node, and the appropriate edges to any vertices that are produced by its children. Nodes which fulfill the Expr interface directly produce vertices (and possible children) where as nodes that fulfill the Stmt interface do not produces vertices, where as their children might. This returns a graph with a single vertex (itself) in it, and the edges from all of the child graphs to this.

func (*ExprList) Interpolate

func (obj *ExprList) Interpolate() (interfaces.Expr, error)

Interpolate returns a new node (or itself) once it has been expanded. This generally increases the size of the AST when it is used. It calls Interpolate on any child elements and builds the new node with those new node contents.

func (*ExprList) SetScope

func (obj *ExprList) SetScope(scope *interfaces.Scope) error

SetScope stores the scope for later use in this resource and it's children, which it propagates this downwards to.

func (*ExprList) SetType

func (obj *ExprList) SetType(typ *types.Type) error

SetType is used to set the type of this expression once it is known. This usually happens during type unification, but it can also happen during parsing if a type is specified explicitly. Since types are static and don't change on expressions, if you attempt to set a different type than what has previously been set (when not initially known) this will error.

func (*ExprList) SetValue

func (obj *ExprList) SetValue(value types.Value) error

SetValue here is a no-op, because algorithmically when this is called from the func engine, the child elements (the list elements) will have had this done to them first, and as such when we try and retrieve the set value from this expression by calling `Value`, it will build it from scratch!

func (*ExprList) String

func (obj *ExprList) String() string

String returns a short representation of this expression.

func (*ExprList) Type

func (obj *ExprList) Type() (*types.Type, error)

Type returns the type of this expression.

func (*ExprList) Unify

func (obj *ExprList) Unify() ([]interfaces.Invariant, error)

Unify returns the list of invariants that this node produces. It recursively calls Unify on any children elements that exist in the AST, and returns the collection to the caller.

func (*ExprList) Value

func (obj *ExprList) Value() (types.Value, error)

Value returns the value of this expression in our type system. This will usually only be valid once the engine has run and values have been produced. This might get called speculatively (early) during unification to learn more.

type ExprMap

type ExprMap struct {
	KVs []*ExprMapKV
	// contains filtered or unexported fields
}

ExprMap is a representation of a (dictionary) map.

func (*ExprMap) Func

func (obj *ExprMap) Func() (interfaces.Func, error)

Func returns the reactive stream of values that this expression produces.

func (*ExprMap) Graph

func (obj *ExprMap) Graph() (*pgraph.Graph, error)

Graph returns the reactive function graph which is expressed by this node. It includes any vertices produced by this node, and the appropriate edges to any vertices that are produced by its children. Nodes which fulfill the Expr interface directly produce vertices (and possible children) where as nodes that fulfill the Stmt interface do not produces vertices, where as their children might. This returns a graph with a single vertex (itself) in it, and the edges from all of the child graphs to this.

func (*ExprMap) Interpolate

func (obj *ExprMap) Interpolate() (interfaces.Expr, error)

Interpolate returns a new node (or itself) once it has been expanded. This generally increases the size of the AST when it is used. It calls Interpolate on any child elements and builds the new node with those new node contents.

func (*ExprMap) SetScope

func (obj *ExprMap) SetScope(scope *interfaces.Scope) error

SetScope stores the scope for later use in this resource and it's children, which it propagates this downwards to.

func (*ExprMap) SetType

func (obj *ExprMap) SetType(typ *types.Type) error

SetType is used to set the type of this expression once it is known. This usually happens during type unification, but it can also happen during parsing if a type is specified explicitly. Since types are static and don't change on expressions, if you attempt to set a different type than what has previously been set (when not initially known) this will error.

func (*ExprMap) SetValue

func (obj *ExprMap) SetValue(value types.Value) error

SetValue here is a no-op, because algorithmically when this is called from the func engine, the child key/value's (the map elements) will have had this done to them first, and as such when we try and retrieve the set value from this expression by calling `Value`, it will build it from scratch!

func (*ExprMap) String

func (obj *ExprMap) String() string

String returns a short representation of this expression.

func (*ExprMap) Type

func (obj *ExprMap) Type() (*types.Type, error)

Type returns the type of this expression.

func (*ExprMap) Unify

func (obj *ExprMap) Unify() ([]interfaces.Invariant, error)

Unify returns the list of invariants that this node produces. It recursively calls Unify on any children elements that exist in the AST, and returns the collection to the caller.

func (*ExprMap) Value

func (obj *ExprMap) Value() (types.Value, error)

Value returns the value of this expression in our type system. This will usually only be valid once the engine has run and values have been produced. This might get called speculatively (early) during unification to learn more.

type ExprMapKV

type ExprMapKV struct {
	Key interfaces.Expr // keys can be strings, int's, etc...
	Val interfaces.Expr
}

ExprMapKV represents a key and value pair in a (dictionary) map. This does not satisfy the Expr interface.

type ExprStr

type ExprStr struct {
	V string // value of this string
}

ExprStr is a representation of a string.

func (*ExprStr) Func

func (obj *ExprStr) Func() (interfaces.Func, error)

Func returns the reactive stream of values that this expression produces.

func (*ExprStr) Graph

func (obj *ExprStr) Graph() (*pgraph.Graph, error)

Graph returns the reactive function graph which is expressed by this node. It includes any vertices produced by this node, and the appropriate edges to any vertices that are produced by its children. Nodes which fulfill the Expr interface directly produce vertices (and possible children) where as nodes that fulfill the Stmt interface do not produces vertices, where as their children might. This returns a graph with a single vertex (itself) in it.

func (*ExprStr) Interpolate

func (obj *ExprStr) Interpolate() (interfaces.Expr, error)

Interpolate returns a new node (or itself) once it has been expanded. This generally increases the size of the AST when it is used. It calls Interpolate on any child elements and builds the new node with those new node contents. Here it attempts to expand the string if there are any internal variables which need interpolation. If any are found, it returns a larger AST which has a function which returns a string as its root. Otherwise it returns itself.

func (*ExprStr) SetScope

func (obj *ExprStr) SetScope(*interfaces.Scope) error

SetScope does nothing for this struct, because it has no child nodes, and it does not need to know about the parent scope.

func (*ExprStr) SetType

func (obj *ExprStr) SetType(typ *types.Type) error

SetType will make no changes if called here. It will error if anything other than an Str is passed in, and doesn't need to be called for this expr to work.

func (*ExprStr) SetValue

func (obj *ExprStr) SetValue(value types.Value) error

SetValue for an str expression is always populated statically, and does not ever receive any incoming values (no incoming edges) so this should never be called. It has been implemented for uniformity.

func (*ExprStr) String

func (obj *ExprStr) String() string

String returns a short representation of this expression.

func (*ExprStr) Type

func (obj *ExprStr) Type() (*types.Type, error)

Type returns the type of this expression. This method always returns Str here.

func (*ExprStr) Unify

func (obj *ExprStr) Unify() ([]interfaces.Invariant, error)

Unify returns the list of invariants that this node produces. It recursively calls Unify on any children elements that exist in the AST, and returns the collection to the caller.

func (*ExprStr) Value

func (obj *ExprStr) Value() (types.Value, error)

Value returns the value of this expression in our type system. This will usually only be valid once the engine has run and values have been produced. This might get called speculatively (early) during unification to learn more. This particular value is always known since it is a constant.

type ExprStruct

type ExprStruct struct {
	Fields []*ExprStructField // the list (fields) are intentionally ordered!
	// contains filtered or unexported fields
}

ExprStruct is a representation of a struct.

func (*ExprStruct) Func

func (obj *ExprStruct) Func() (interfaces.Func, error)

Func returns the reactive stream of values that this expression produces.

func (*ExprStruct) Graph

func (obj *ExprStruct) Graph() (*pgraph.Graph, error)

Graph returns the reactive function graph which is expressed by this node. It includes any vertices produced by this node, and the appropriate edges to any vertices that are produced by its children. Nodes which fulfill the Expr interface directly produce vertices (and possible children) where as nodes that fulfill the Stmt interface do not produces vertices, where as their children might. This returns a graph with a single vertex (itself) in it, and the edges from all of the child graphs to this.

func (*ExprStruct) Interpolate

func (obj *ExprStruct) Interpolate() (interfaces.Expr, error)

Interpolate returns a new node (or itself) once it has been expanded. This generally increases the size of the AST when it is used. It calls Interpolate on any child elements and builds the new node with those new node contents.

func (*ExprStruct) SetScope

func (obj *ExprStruct) SetScope(scope *interfaces.Scope) error

SetScope stores the scope for later use in this resource and it's children, which it propagates this downwards to.

func (*ExprStruct) SetType

func (obj *ExprStruct) SetType(typ *types.Type) error

SetType is used to set the type of this expression once it is known. This usually happens during type unification, but it can also happen during parsing if a type is specified explicitly. Since types are static and don't change on expressions, if you attempt to set a different type than what has previously been set (when not initially known) this will error.

func (*ExprStruct) SetValue

func (obj *ExprStruct) SetValue(value types.Value) error

SetValue here is a no-op, because algorithmically when this is called from the func engine, the child fields (the struct elements) will have had this done to them first, and as such when we try and retrieve the set value from this expression by calling `Value`, it will build it from scratch!

func (*ExprStruct) String

func (obj *ExprStruct) String() string

String returns a short representation of this expression.

func (*ExprStruct) Type

func (obj *ExprStruct) Type() (*types.Type, error)

Type returns the type of this expression.

func (*ExprStruct) Unify

func (obj *ExprStruct) Unify() ([]interfaces.Invariant, error)

Unify returns the list of invariants that this node produces. It recursively calls Unify on any children elements that exist in the AST, and returns the collection to the caller.

func (*ExprStruct) Value

func (obj *ExprStruct) Value() (types.Value, error)

Value returns the value of this expression in our type system. This will usually only be valid once the engine has run and values have been produced. This might get called speculatively (early) during unification to learn more.

type ExprStructField

type ExprStructField struct {
	Name  string
	Value interfaces.Expr
}

ExprStructField represents a name value pair in a struct field. This does not satisfy the Expr interface.

type ExprVar

type ExprVar struct {
	Name string // name of the variable
	// contains filtered or unexported fields
}

ExprVar is a representation of a variable lookup. It returns the expression that that variable refers to.

func (*ExprVar) Func

func (obj *ExprVar) Func() (interfaces.Func, error)

Func returns a "pass-through" function which receives the bound value, and passes it to the consumer. This is essential for satisfying the type checker of the function graph engine.

func (*ExprVar) Graph

func (obj *ExprVar) Graph() (*pgraph.Graph, error)

Graph returns the reactive function graph which is expressed by this node. It includes any vertices produced by this node, and the appropriate edges to any vertices that are produced by its children. Nodes which fulfill the Expr interface directly produce vertices (and possible children) where as nodes that fulfill the Stmt interface do not produces vertices, where as their children might. This returns a graph with a single vertex (itself) in it, and the edges from all of the child graphs to this. The child graph in this case is the graph which is obtained from the bound expression. The edge points from that expression to this vertex. The function used for this vertex is a simple placeholder which sucks incoming values in and passes them on. This is important for filling the logical requirements of the graph type checker, and to avoid duplicating production of the incoming input value from the bound expression.

func (*ExprVar) Interpolate

func (obj *ExprVar) Interpolate() (interfaces.Expr, error)

Interpolate returns a new node (or itself) once it has been expanded. This generally increases the size of the AST when it is used. It calls Interpolate on any child elements and builds the new node with those new node contents. Here it returns itself, since variable names cannot be interpolated. We don't support variable, variables or anything crazy like that.

func (*ExprVar) SetScope

func (obj *ExprVar) SetScope(scope *interfaces.Scope) error

SetScope stores the scope for use in this resource.

func (*ExprVar) SetType

func (obj *ExprVar) SetType(typ *types.Type) error

SetType is used to set the type of this expression once it is known. This usually happens during type unification, but it can also happen during parsing if a type is specified explicitly. Since types are static and don't change on expressions, if you attempt to set a different type than what has previously been set (when not initially known) this will error.

func (*ExprVar) SetValue

func (obj *ExprVar) SetValue(value types.Value) error

SetValue here is a no-op, because algorithmically when this is called from the func engine, the child fields (the dest lookup expr) will have had this done to them first, and as such when we try and retrieve the set value from this expression by calling `Value`, it will build it from scratch!

func (*ExprVar) String

func (obj *ExprVar) String() string

String returns a short representation of this expression.

func (*ExprVar) Type

func (obj *ExprVar) Type() (*types.Type, error)

Type returns the type of this expression.

func (*ExprVar) Unify

func (obj *ExprVar) Unify() ([]interfaces.Invariant, error)

Unify returns the list of invariants that this node produces. It recursively calls Unify on any children elements that exist in the AST, and returns the collection to the caller.

func (*ExprVar) Value

func (obj *ExprVar) Value() (types.Value, error)

Value returns the value of this expression in our type system. This will usually only be valid once the engine has run and values have been produced. This might get called speculatively (early) during unification to learn more. This returns the value this variable points to. It is able to do so because it can lookup in the previous set scope which expression this points to, and then it can call Value on that expression.

type GAPI

type GAPI struct {
	InputURI string // input URI of code file system to run
	// contains filtered or unexported fields
}

GAPI implements the main lang GAPI interface.

func (*GAPI) Cli

func (obj *GAPI) Cli(c *cli.Context, fs resources.Fs) (*gapi.Deploy, error)

Cli takes a cli.Context, and returns our GAPI if activated. All arguments should take the prefix of the registered name. On activation, if there are any validation problems, you should return an error. If this was not activated, then you should return a nil GAPI and a nil error.

func (*GAPI) CliFlags

func (obj *GAPI) CliFlags() []cli.Flag

CliFlags returns a list of flags used by this deploy subcommand.

func (*GAPI) Close

func (obj *GAPI) Close() error

Close shuts down the lang GAPI.

func (*GAPI) Graph

func (obj *GAPI) Graph() (*pgraph.Graph, error)

Graph returns a current Graph.

func (*GAPI) Init

func (obj *GAPI) Init(data gapi.Data) error

Init initializes the lang GAPI struct.

func (*GAPI) LangClose

func (obj *GAPI) LangClose() error

LangClose is a wrapper around the lang Close method.

func (*GAPI) LangInit

func (obj *GAPI) LangInit() error

LangInit is a wrapper around the lang Init method.

func (*GAPI) Next

func (obj *GAPI) Next() chan gapi.Next

Next returns nil errors every time there could be a new graph.

type Lang

type Lang struct {
	Input    io.Reader // os.Stdin or anything that satisfies this interface
	Hostname string
	World    resources.World
	Debug    bool
	// contains filtered or unexported fields
}

Lang is the main language lexer/parser object.

func (*Lang) Close

func (obj *Lang) Close() error

Close shuts down the lang struct and causes all the funcs to shutdown. It must be called when finished after any successful Init ran.

func (*Lang) Init

func (obj *Lang) Init() error

Init initializes the lang struct, and starts up the initial data sources. NOTE: The trick is that we need to get the list of funcs to watch AND start watching them, *before* we pull their values, that way we'll know if they changed from the values we wanted.

func (*Lang) Interpret

func (obj *Lang) Interpret() (*pgraph.Graph, error)

Interpret runs the interpreter and returns a graph and corresponding error.

func (*Lang) Stream

func (obj *Lang) Stream() chan error

Stream returns a channel of graph change requests or errors. These are usually sent when a func output changes.

type LexParseErr

type LexParseErr struct {
	Err interfaces.Error
	Str string
	Row int // this is zero-indexed (the first line is 0)
	Col int // this is zero-indexed (the first char is 0)
}

LexParseErr is a permanent failure error to notify about borkage.

func (*LexParseErr) Error

func (e *LexParseErr) Error() string

Error displays this error with all the relevant state information.

type Pos

type Pos struct {
	Line     int    // line number starting at 1
	Column   int    // column number starting at 1
	Filename string // optional source filename, if known
}

Pos represents a position in the code. TODO: consider expanding with range characteristics.

type StmtBind

type StmtBind struct {
	Ident string
	Value interfaces.Expr
}

StmtBind is a representation of an assignment, which binds a variable to an expression.

func (*StmtBind) Graph

func (obj *StmtBind) Graph() (*pgraph.Graph, error)

Graph returns the reactive function graph which is expressed by this node. It includes any vertices produced by this node, and the appropriate edges to any vertices that are produced by its children. Nodes which fulfill the Expr interface directly produce vertices (and possible children) where as nodes that fulfill the Stmt interface do not produces vertices, where as their children might. This particular bind statement adds its linked expression to the graph. It is not logically done in the ExprVar since that could exist multiple times for the single binding operation done here.

func (*StmtBind) Interpolate

func (obj *StmtBind) Interpolate() (interfaces.Stmt, error)

Interpolate returns a new node (or itself) once it has been expanded. This generally increases the size of the AST when it is used. It calls Interpolate on any child elements and builds the new node with those new node contents.

func (*StmtBind) Output

func (obj *StmtBind) Output() (*interfaces.Output, error)

Output for the bind statement produces no output. Any values of interest come from the use of the var which this binds the expression to.

func (*StmtBind) SetScope

func (obj *StmtBind) SetScope(scope *interfaces.Scope) error

SetScope sets the scope of the child expression bound to it. It seems this is necessary in order to reach this, in particular in situations when a bound expression points to a previously bound expression.

func (*StmtBind) Unify

func (obj *StmtBind) Unify() ([]interfaces.Invariant, error)

Unify returns the list of invariants that this node produces. It recursively calls Unify on any children elements that exist in the AST, and returns the collection to the caller.

type StmtComment

type StmtComment struct {
	Value string
}

StmtComment is a representation of a comment. It is currently unused. It probably makes sense to make a third kind of Node (not a Stmt or an Expr) so that comments can still be part of the AST (for eventual automatic code formatting) but so that they can exist anywhere in the code. Currently these are dropped by the lexer.

func (*StmtComment) Graph

func (obj *StmtComment) Graph() (*pgraph.Graph, error)

Graph returns the reactive function graph which is expressed by this node. It includes any vertices produced by this node, and the appropriate edges to any vertices that are produced by its children. Nodes which fulfill the Expr interface directly produce vertices (and possible children) where as nodes that fulfill the Stmt interface do not produces vertices, where as their children might. This particular graph does nothing clever.

func (*StmtComment) Interpolate

func (obj *StmtComment) Interpolate() (interfaces.Stmt, error)

Interpolate returns a new node (or itself) once it has been expanded. This generally increases the size of the AST when it is used. It calls Interpolate on any child elements and builds the new node with those new node contents. Here it simply returns itself, as no interpolation is possible.

func (*StmtComment) Output

func (obj *StmtComment) Output() (*interfaces.Output, error)

Output for the comment statement produces no output.

func (*StmtComment) SetScope

func (obj *StmtComment) SetScope(*interfaces.Scope) error

SetScope does nothing for this struct, because it has no child nodes, and it does not need to know about the parent scope.

func (*StmtComment) Unify

func (obj *StmtComment) Unify() ([]interfaces.Invariant, error)

Unify returns the list of invariants that this node produces. It recursively calls Unify on any children elements that exist in the AST, and returns the collection to the caller.

type StmtEdge

type StmtEdge struct {
	EdgeHalfList []*StmtEdgeHalf // represents a chain of edges

	// TODO: should notify be an Expr?
	Notify bool // specifies that this edge sends a notification as well
}

StmtEdge is a representation of a dependency. It also supports send/recv. Edges represents that the first resource (Kind/Name) listed in the EdgeHalfList should happen in the resource graph *before* the next resource in the list. If there are multiple StmtEdgeHalf structs listed, then they should represent a chain, eg: a->b->c, should compile into a->b & b->c. If specified, values are sent and received along these edges if the Send/Recv names are compatible and listed. In this case of Send/Recv, only lists of length two are legal.

func (*StmtEdge) Graph

func (obj *StmtEdge) Graph() (*pgraph.Graph, error)

Graph returns the reactive function graph which is expressed by this node. It includes any vertices produced by this node, and the appropriate edges to any vertices that are produced by its children. Nodes which fulfill the Expr interface directly produce vertices (and possible children) where as nodes that fulfill the Stmt interface do not produces vertices, where as their children might. It is interesting to note that nothing directly adds an edge to the edges created, but rather, once all the values (expressions) with no outgoing function graph edges have produced at least a single value, then the edges know they're able to be built.

func (*StmtEdge) Interpolate

func (obj *StmtEdge) Interpolate() (interfaces.Stmt, error)

Interpolate returns a new node (or itself) once it has been expanded. This generally increases the size of the AST when it is used. It calls Interpolate on any child elements and builds the new node with those new node contents. TODO: could we expand the Name's from the EdgeHalf (if they're lists) to have them return a list of Edges's ? XXX: type check the kind1:send -> kind2:recv fields are compatible! XXX: we won't know the names yet, but it's okay.

func (*StmtEdge) Output

func (obj *StmtEdge) Output() (*interfaces.Output, error)

Output returns the output that this "program" produces. This output is what is used to build the output graph. This only exists for statements. The analogous function for expressions is Value. Those Value functions might get called by this Output function if they are needed to produce the output. In the case of this edge statement, this is definitely the case. This edge stmt returns output consisting of edges.

func (*StmtEdge) SetScope

func (obj *StmtEdge) SetScope(scope *interfaces.Scope) error

SetScope stores the scope for later use in this resource and it's children, which it propagates this downwards to.

func (*StmtEdge) Unify

func (obj *StmtEdge) Unify() ([]interfaces.Invariant, error)

Unify returns the list of invariants that this node produces. It recursively calls Unify on any children elements that exist in the AST, and returns the collection to the caller.

type StmtEdgeHalf

type StmtEdgeHalf struct {
	Kind     string          // kind of resource, eg: pkg, file, svc, etc...
	Name     interfaces.Expr // unique name for the res of this kind
	SendRecv string          // name of field to send/recv from, empty to ignore
}

StmtEdgeHalf represents half of an edge in the parsed edge representation. This does not satisfy the Stmt interface.

func (*StmtEdgeHalf) Graph

func (obj *StmtEdgeHalf) Graph() (*pgraph.Graph, error)

Graph returns the reactive function graph which is expressed by this node. It includes any vertices produced by this node, and the appropriate edges to any vertices that are produced by its children. Nodes which fulfill the Expr interface directly produce vertices (and possible children) where as nodes that fulfill the Stmt interface do not produces vertices, where as their children might. It is interesting to note that nothing directly adds an edge to the resources created, but rather, once all the values (expressions) with no outgoing edges have produced at least a single value, then the resources know they're able to be built.

func (*StmtEdgeHalf) Interpolate

func (obj *StmtEdgeHalf) Interpolate() (*StmtEdgeHalf, error)

Interpolate returns a new node (or itself) once it has been expanded. This generally increases the size of the AST when it is used. It calls Interpolate on any child elements and builds the new node with those new node contents. This interpolate is different It is different from the interpolate found in the Expr and Stmt interfaces because it returns a different type as output.

func (*StmtEdgeHalf) SetScope

func (obj *StmtEdgeHalf) SetScope(scope *interfaces.Scope) error

SetScope stores the scope for later use in this resource and it's children, which it propagates this downwards to.

func (*StmtEdgeHalf) Unify

func (obj *StmtEdgeHalf) Unify() ([]interfaces.Invariant, error)

Unify returns the list of invariants that this node produces. It recursively calls Unify on any children elements that exist in the AST, and returns the collection to the caller.

type StmtIf

type StmtIf struct {
	Condition  interfaces.Expr
	ThenBranch interfaces.Stmt // optional, but usually present
	ElseBranch interfaces.Stmt // optional
}

StmtIf represents an if condition that contains between one and two branches of statements to be executed based on the evaluation of the boolean condition over time. In particular, this is different from an ExprIf which returns a value, where as this produces some Output. Normally if one of the branches is optional, it is the else branch, although this struct allows either to be optional, even if it is not commonly used.

func (*StmtIf) Graph

func (obj *StmtIf) Graph() (*pgraph.Graph, error)

Graph returns the reactive function graph which is expressed by this node. It includes any vertices produced by this node, and the appropriate edges to any vertices that are produced by its children. Nodes which fulfill the Expr interface directly produce vertices (and possible children) where as nodes that fulfill the Stmt interface do not produces vertices, where as their children might. This particular if statement doesn't do anything clever here other than adding in both branches of the graph. Since we're functional, this shouldn't have any ill effects. XXX: is this completely true if we're running technically impure, but safe built-in functions on both branches? Can we turn off half of this?

func (*StmtIf) Interpolate

func (obj *StmtIf) Interpolate() (interfaces.Stmt, error)

Interpolate returns a new node (or itself) once it has been expanded. This generally increases the size of the AST when it is used. It calls Interpolate on any child elements and builds the new node with those new node contents.

func (*StmtIf) Output

func (obj *StmtIf) Output() (*interfaces.Output, error)

Output returns the output that this "program" produces. This output is what is used to build the output graph. This only exists for statements. The analogous function for expressions is Value. Those Value functions might get called by this Output function if they are needed to produce the output.

func (*StmtIf) SetScope

func (obj *StmtIf) SetScope(scope *interfaces.Scope) error

SetScope stores the scope for later use in this resource and it's children, which it propagates this downwards to.

func (*StmtIf) Unify

func (obj *StmtIf) Unify() ([]interfaces.Invariant, error)

Unify returns the list of invariants that this node produces. It recursively calls Unify on any children elements that exist in the AST, and returns the collection to the caller.

type StmtProg

type StmtProg struct {
	Prog []interfaces.Stmt
}

StmtProg represents a list of stmt's. This usually occurs at the top-level of any program, and often within an if stmt. It also contains the logic so that the bind statement's are correctly applied in this scope, and irrespective of their order of definition.

func (*StmtProg) Graph

func (obj *StmtProg) Graph() (*pgraph.Graph, error)

Graph returns the reactive function graph which is expressed by this node. It includes any vertices produced by this node, and the appropriate edges to any vertices that are produced by its children. Nodes which fulfill the Expr interface directly produce vertices (and possible children) where as nodes that fulfill the Stmt interface do not produces vertices, where as their children might.

func (*StmtProg) Interpolate

func (obj *StmtProg) Interpolate() (interfaces.Stmt, error)

Interpolate returns a new node (or itself) once it has been expanded. This generally increases the size of the AST when it is used. It calls Interpolate on any child elements and builds the new node with those new node contents.

func (*StmtProg) Output

func (obj *StmtProg) Output() (*interfaces.Output, error)

Output returns the output that this "program" produces. This output is what is used to build the output graph. This only exists for statements. The analogous function for expressions is Value. Those Value functions might get called by this Output function if they are needed to produce the output.

func (*StmtProg) SetScope

func (obj *StmtProg) SetScope(scope *interfaces.Scope) error

SetScope propagates the scope into its list of statements. It does so cleverly by first collecting all bind statements and adding those into the scope after checking for any collisions. Finally it pushes the new scope downwards to all child statements.

func (*StmtProg) Unify

func (obj *StmtProg) Unify() ([]interfaces.Invariant, error)

Unify returns the list of invariants that this node produces. It recursively calls Unify on any children elements that exist in the AST, and returns the collection to the caller.

type StmtRes

type StmtRes struct {
	Kind     string            // kind of resource, eg: pkg, file, svc, etc...
	Name     interfaces.Expr   // unique name for the res of this kind
	Contents []StmtResContents // list of fields/edges in parsed order
}

StmtRes is a representation of a resource and possibly some edges. TODO: consider expanding Name (if it's a list) to have this return a list of Res's in the Output function. Alternatively, it could be a map[name]struct{}, or even a map[[]name]struct{}.

func (*StmtRes) Graph

func (obj *StmtRes) Graph() (*pgraph.Graph, error)

Graph returns the reactive function graph which is expressed by this node. It includes any vertices produced by this node, and the appropriate edges to any vertices that are produced by its children. Nodes which fulfill the Expr interface directly produce vertices (and possible children) where as nodes that fulfill the Stmt interface do not produces vertices, where as their children might. It is interesting to note that nothing directly adds an edge to the resources created, but rather, once all the values (expressions) with no outgoing edges have produced at least a single value, then the resources know they're able to be built.

func (*StmtRes) Interpolate

func (obj *StmtRes) Interpolate() (interfaces.Stmt, error)

Interpolate returns a new node (or itself) once it has been expanded. This generally increases the size of the AST when it is used. It calls Interpolate on any child elements and builds the new node with those new node contents.

func (*StmtRes) Output

func (obj *StmtRes) Output() (*interfaces.Output, error)

Output returns the output that this "program" produces. This output is what is used to build the output graph. This only exists for statements. The analogous function for expressions is Value. Those Value functions might get called by this Output function if they are needed to produce the output. In the case of this resource statement, this is definitely the case. XXX: Add MetaParams as a simple meta field with a struct of the right type...

func (*StmtRes) SetScope

func (obj *StmtRes) SetScope(scope *interfaces.Scope) error

SetScope stores the scope for later use in this resource and it's children, which it propagates this downwards to.

func (*StmtRes) Unify

func (obj *StmtRes) Unify() ([]interfaces.Invariant, error)

Unify returns the list of invariants that this node produces. It recursively calls Unify on any children elements that exist in the AST, and returns the collection to the caller.

type StmtResContents

type StmtResContents interface {
	Interpolate() (StmtResContents, error) // different!
	SetScope(*interfaces.Scope) error
	Unify(kind string) ([]interfaces.Invariant, error) // different!
	Graph() (*pgraph.Graph, error)
}

StmtResContents is the interface that is met by the resource contents. Look closely for while it is similar to the Stmt interface, it is quite different.

type StmtResEdge

type StmtResEdge struct {
	Property  string // TODO: iota constant instead?
	EdgeHalf  *StmtEdgeHalf
	Condition interfaces.Expr // the value will be used if nil or true
}

StmtResEdge represents a single edge property in the parsed resource representation. This does not satisfy the Stmt interface.

func (*StmtResEdge) Graph

func (obj *StmtResEdge) Graph() (*pgraph.Graph, error)

Graph returns the reactive function graph which is expressed by this node. It includes any vertices produced by this node, and the appropriate edges to any vertices that are produced by its children. Nodes which fulfill the Expr interface directly produce vertices (and possible children) where as nodes that fulfill the Stmt interface do not produces vertices, where as their children might. It is interesting to note that nothing directly adds an edge to the resources created, but rather, once all the values (expressions) with no outgoing edges have produced at least a single value, then the resources know they're able to be built.

func (*StmtResEdge) Interpolate

func (obj *StmtResEdge) Interpolate() (StmtResContents, error)

Interpolate returns a new node (or itself) once it has been expanded. This generally increases the size of the AST when it is used. It calls Interpolate on any child elements and builds the new node with those new node contents. This interpolate is different It is different from the interpolate found in the Expr and Stmt interfaces because it returns a different type as output.

func (*StmtResEdge) SetScope

func (obj *StmtResEdge) SetScope(scope *interfaces.Scope) error

SetScope stores the scope for later use in this resource and it's children, which it propagates this downwards to.

func (*StmtResEdge) Unify

func (obj *StmtResEdge) Unify(kind string) ([]interfaces.Invariant, error)

Unify returns the list of invariants that this node produces. It recursively calls Unify on any children elements that exist in the AST, and returns the collection to the caller. It is different from the Unify found in the Expr and Stmt interfaces because it adds an input parameter.

type StmtResField

type StmtResField struct {
	Field     string
	Value     interfaces.Expr
	Condition interfaces.Expr // the value will be used if nil or true
}

StmtResField represents a single field in the parsed resource representation. This does not satisfy the Stmt interface.

func (*StmtResField) Graph

func (obj *StmtResField) Graph() (*pgraph.Graph, error)

Graph returns the reactive function graph which is expressed by this node. It includes any vertices produced by this node, and the appropriate edges to any vertices that are produced by its children. Nodes which fulfill the Expr interface directly produce vertices (and possible children) where as nodes that fulfill the Stmt interface do not produces vertices, where as their children might. It is interesting to note that nothing directly adds an edge to the resources created, but rather, once all the values (expressions) with no outgoing edges have produced at least a single value, then the resources know they're able to be built.

func (*StmtResField) Interpolate

func (obj *StmtResField) Interpolate() (StmtResContents, error)

Interpolate returns a new node (or itself) once it has been expanded. This generally increases the size of the AST when it is used. It calls Interpolate on any child elements and builds the new node with those new node contents. This interpolate is different It is different from the interpolate found in the Expr and Stmt interfaces because it returns a different type as output.

func (*StmtResField) SetScope

func (obj *StmtResField) SetScope(scope *interfaces.Scope) error

SetScope stores the scope for later use in this resource and it's children, which it propagates this downwards to.

func (*StmtResField) Unify

func (obj *StmtResField) Unify(kind string) ([]interfaces.Invariant, error)

Unify returns the list of invariants that this node produces. It recursively calls Unify on any children elements that exist in the AST, and returns the collection to the caller. It is different from the Unify found in the Expr and Stmt interfaces because it adds an input parameter.

Directories

Path Synopsis
Package funcs provides a framework for functions that change over time.
Package funcs provides a framework for functions that change over time.
facts
Package facts provides a framework for language values that change over time.
Package facts provides a framework for language values that change over time.
Package types provides a framework for our language values and types.
Package types provides a framework for our language values and types.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL