hcl/zcl/zclsyntax/variables.go
2017-05-27 17:33:09 -07:00

21 lines
477 B
Go

package zclsyntax
import (
"github.com/zclconf/go-zcl/zcl"
)
// Variables returns all of the variables referenced within a given experssion.
//
// This is the implementation of the "Variables" method on every native
// expression.
func Variables(expr Expression) []zcl.Traversal {
var vars []zcl.Traversal
VisitAll(expr, func(n Node) zcl.Diagnostics {
if ste, ok := n.(*ScopeTraversalExpr); ok {
vars = append(vars, ste.Traversal)
}
return nil
})
return vars
}