zclsyntax: RelativeTraversalExpr

This is similar to ScopeTraversalExpr, but it traverses relative to the
result of another expression rather than relative to a variable in the
scope.
This commit is contained in:
Martin Atkins 2017-06-04 18:40:15 -07:00
parent 6f2bd0009c
commit 0d0404867c
2 changed files with 28 additions and 0 deletions

View File

@ -70,6 +70,30 @@ func (e *ScopeTraversalExpr) StartRange() zcl.Range {
return e.SrcRange
}
// RelativeTraversalExpr is an Expression that retrieves a value from another
// value using a _relative_ traversal.
type RelativeTraversalExpr struct {
Source Expression
Traversal zcl.Traversal
SrcRange zcl.Range
}
func (e *RelativeTraversalExpr) walkChildNodes(w internalWalkFunc) {
// Scope traversals have no child nodes
}
func (e *RelativeTraversalExpr) Value(ctx *zcl.EvalContext) (cty.Value, zcl.Diagnostics) {
panic("RelativeTraversalExpr.Value not yet implemented")
}
func (e *RelativeTraversalExpr) Range() zcl.Range {
return e.SrcRange
}
func (e *RelativeTraversalExpr) StartRange() zcl.Range {
return e.SrcRange
}
// FunctionCallExpr is an Expression that calls a function from the EvalContext
// and returns its result.
type FunctionCallExpr struct {

View File

@ -27,6 +27,10 @@ func (e *ObjectConsExpr) Variables() []zcl.Traversal {
return Variables(e)
}
func (e *RelativeTraversalExpr) Variables() []zcl.Traversal {
return Variables(e)
}
func (e *ScopeTraversalExpr) Variables() []zcl.Traversal {
return Variables(e)
}