ast
packageThis package is not in the latest version of its module.
Details
Validgo.mod file
The Go module system was introduced in Go 1.11 and is the official dependency management solution for Go.
Redistributable license
Redistributable licenses place minimal restrictions on how software can be used, modified, and redistributed.
Tagged version
Modules with tagged versions give importers more predictable builds.
Stable version
When a project reaches major version v1 it is considered stable.
- Learn more about best practices
Repository
Links
Documentation¶
Overview¶
Package ast declares data structures useful for parsed and checked abstract syntax trees
Index¶
- func AlphaProtoConstantAsVal(c *exprpb.Constant) (ref.Val, error)
- func ConstantToVal(c *exprpb.Constant) (ref.Val, error)
- func EntryExprToProto(e EntryExpr) (*exprpb.Expr_CreateStruct_Entry, error)
- func ExprToProto(e Expr) (*exprpb.Expr, error)
- func Heights(a *AST) map[int64]int
- func MaxID(a *AST) int64
- func PostOrderVisit(expr Expr, visitor Visitor)
- func PreOrderVisit(expr Expr, visitor Visitor)
- func ProtoConstantAsVal(c *celpb.Constant) (ref.Val, error)
- func ReferenceInfoToProto(info *ReferenceInfo) (*exprpb.Reference, error)
- func SourceInfoToProto(info *SourceInfo) (*exprpb.SourceInfo, error)
- func ToProto(ast *AST) (*exprpb.CheckedExpr, error)
- func ValToConstant(v ref.Val) (*exprpb.Constant, error)
- type AST
- func (a *AST) Expr() Expr
- func (a *AST) GetOverloadIDs(id int64) []string
- func (a *AST) GetType(id int64) *types.Type
- func (a *AST) IsChecked() bool
- func (a *AST) ReferenceMap() map[int64]*ReferenceInfo
- func (a *AST) SetReference(id int64, r *ReferenceInfo)
- func (a *AST) SetType(id int64, t *types.Type)
- func (a *AST) SourceInfo() *SourceInfo
- func (a *AST) TypeMap() map[int64]*types.Type
- type CallExpr
- type ComprehensionExpr
- type EntryExpr
- type EntryExprKind
- type Expr
- type ExprFactory
- type ExprKind
- type ExprMatcher
- type IDGenerator
- type ListExpr
- type MapEntry
- type MapExpr
- type NavigableExpr
- type OffsetRange
- type ReferenceInfo
- type SelectExpr
- type SourceInfo
- func (s *SourceInfo) ClearMacroCall(id int64)
- func (s *SourceInfo) ClearOffsetRange(id int64)
- func (s *SourceInfo) ComputeOffset(line, col int32) int32
- func (s *SourceInfo) Description() string
- func (s *SourceInfo) GetLocationByOffset(offset int32) common.Location
- func (s *SourceInfo) GetMacroCall(id int64) (Expr, bool)
- func (s *SourceInfo) GetOffsetRange(id int64) (OffsetRange, bool)
- func (s *SourceInfo) GetStartLocation(id int64) common.Location
- func (s *SourceInfo) GetStopLocation(id int64) common.Location
- func (s *SourceInfo) LineOffsets() []int32
- func (s *SourceInfo) MacroCalls() map[int64]Expr
- func (s *SourceInfo) OffsetRanges() map[int64]OffsetRange
- func (s *SourceInfo) SetMacroCall(id int64, e Expr)
- func (s *SourceInfo) SetOffsetRange(id int64, o OffsetRange)
- func (s *SourceInfo) SyntaxVersion() string
- type StructExpr
- type StructField
- type Visitor
Constants¶
This section is empty.
Variables¶
This section is empty.
Functions¶
funcAlphaProtoConstantAsVal¶added inv0.22.0
AlphaProtoConstantAsVal converts a v1alpha1.Constant protobuf to a CEL-native ref.Val.
funcConstantToVal¶
ConstantToVal converts a protobuf Constant to a CEL-native ref.Val.
funcEntryExprToProto¶added inv0.17.2
func EntryExprToProto(eEntryExpr) (*exprpb.Expr_CreateStruct_Entry,error)
EntryExprToProto converts an ast.EntryExpr to a protobuf CreateStruct entry
funcExprToProto¶added inv0.17.2
ExprToProto serializes an ast.Expr value to a protobuf Expr representation.
funcHeights¶added inv0.24.0
Heights computes the heights of all AST expressions and returns a map from expression id to height.
funcMaxID¶added inv0.18.0
MaxID returns the upper-bound, non-inclusive, of ids present within the AST's Expr value.
funcPostOrderVisit¶added inv0.18.0
PostOrderVisit walks the expression graph and calls the visitor in post-order (bottom-up).
funcPreOrderVisit¶added inv0.18.0
PreOrderVisit walks the expression graph and calls the visitor in pre-order (top-down).
funcProtoConstantAsVal¶added inv0.22.0
ProtoConstantAsVal converts a canonical celpb.Constant protobuf to a CEL-native ref.Val.
funcReferenceInfoToProto¶added inv0.17.2
func ReferenceInfoToProto(info *ReferenceInfo) (*exprpb.Reference,error)
ReferenceInfoToProto converts a ReferenceInfo instance to a protobuf Reference suitable for serialization.
funcSourceInfoToProto¶added inv0.17.2
func SourceInfoToProto(info *SourceInfo) (*exprpb.SourceInfo,error)
SourceInfoToProto serializes an ast.SourceInfo value to a protobuf SourceInfo object.
Types¶
typeAST¶added inv0.17.2
type AST struct {// contains filtered or unexported fields}AST contains a protobuf expression and source info along with CEL-native type and reference information.
funcCopy¶added inv0.17.2
Copy creates a deep copy of the Expr and SourceInfo values in the input AST.
Copies of the Expr value are generated using an internal default ExprFactory.
funcNewAST¶added inv0.17.2
func NewAST(eExpr, sourceInfo *SourceInfo) *AST
NewAST creates a base AST instance with an ast.Expr and ast.SourceInfo value.
funcNewCheckedAST¶added inv0.17.2
func NewCheckedAST(parsed *AST, typeMap map[int64]*types.Type, refMap map[int64]*ReferenceInfo) *AST
NewCheckedAST wraps an parsed AST and augments it with type and reference metadata.
funcToAST¶added inv0.17.2
func ToAST(checked *exprpb.CheckedExpr) (*AST,error)
ToAST converts a CheckedExpr protobuf to an AST instance.
func (*AST)GetOverloadIDs¶added inv0.17.2
GetOverloadIDs returns the set of overload function names for a given expression id.
If the expression id is not a function call, or the AST is not type-checked, the result will be empty.
func (*AST)GetType¶added inv0.17.2
GetType returns the type for the expression at the given id, if one exists, else types.DynType.
func (*AST)ReferenceMap¶added inv0.17.2
func (a *AST) ReferenceMap() map[int64]*ReferenceInfo
ReferenceMap returns the map of expression id to identifier, constant, and function references.
func (*AST)SetReference¶added inv0.17.2
func (a *AST) SetReference(idint64, r *ReferenceInfo)
SetReference adds a reference to the checked AST type map.
func (*AST)SourceInfo¶added inv0.17.2
func (a *AST) SourceInfo() *SourceInfo
SourceInfo returns the source metadata associated with the parse / type-check passes.
typeCallExpr¶added inv0.17.2
type CallExpr interface {// FunctionName returns the name of the function.FunctionName()string// IsMemberFunction returns whether the call has a non-nil target indicating it is a member functionIsMemberFunction()bool// Target returns the target of the expression if one is present.Target()Expr// Args returns the list of call arguments, excluding the target.Args() []Expr// contains filtered or unexported methods}CallExpr defines an interface for inspecting a function call and its arguments.
typeComprehensionExpr¶added inv0.17.2
type ComprehensionExpr interface {// IterRange returns the iteration range expression.IterRange()Expr// IterVar returns the iteration variable name.//// For one-variable comprehensions, the iter var refers to the element value// when iterating over a list, or the map key when iterating over a map.//// For two-variable comprehneions, the iter var refers to the list index or the// map key.IterVar()string// IterVar2 returns the second iteration variable name.//// When the value is non-empty, the comprehension is a two-variable comprehension.IterVar2()string// HasIterVar2 returns true if the second iteration variable is non-empty.HasIterVar2()bool// AccuVar returns the accumulation variable name.AccuVar()string// AccuInit returns the accumulation variable initialization expression.AccuInit()Expr// LoopCondition returns the loop condition expression.LoopCondition()Expr// LoopStep returns the loop step expression.LoopStep()Expr// Result returns the comprehension result expression.Result()Expr// contains filtered or unexported methods}ComprehensionExpr defines an interface for inspecting a comprehension expression.
typeEntryExpr¶added inv0.17.2
type EntryExpr interface {// ID of the entry as it appears in the AST.ID()int64// Kind of the entry expression node. See EntryExprKind for valid enum values.Kind()EntryExprKind// AsMapEntry casts the EntryExpr to a MapEntry.//// The Kind() must be equal to MapEntryKind for the conversion to be well-defined.AsMapEntry()MapEntry// AsStructField casts the EntryExpr to a StructField//// The Kind() must be equal to StructFieldKind for the conversion to be well-defined.AsStructField()StructField// RenumberIDs performs an in-place update of the expression and all of its descendents numeric ids.RenumberIDs(IDGenerator)// contains filtered or unexported methods}EntryExpr represents the base entry expression in a CEL map or struct literal.
funcProtoToEntryExpr¶added inv0.17.2
func ProtoToEntryExpr(e *exprpb.Expr_CreateStruct_Entry) (EntryExpr,error)
ProtoToEntryExpr converts a protobuf struct/map entry to an ast.EntryExpr
typeEntryExprKind¶added inv0.17.2
type EntryExprKindint
EntryExprKind represents the possible EntryExpr kinds.
const (// UnspecifiedEntryExprKind indicates that the entry expr is not set.UnspecifiedEntryExprKindEntryExprKind =iota// MapEntryKind indicates that the entry is a MapEntry type with key and value expressions.MapEntryKind// StructFieldKind indicates that the entry is a StructField with a field name and initializer// expression.StructFieldKind)
typeExpr¶added inv0.17.2
type Expr interface {// ID of the expression as it appears in the ASTID()int64// Kind of the expression node. See ExprKind for the valid enum values.Kind()ExprKind// AsCall adapts the expr into a CallExpr//// The Kind() must be equal to a CallKind for the conversion to be well-defined.AsCall()CallExpr// AsComprehension adapts the expr into a ComprehensionExpr.//// The Kind() must be equal to a ComprehensionKind for the conversion to be well-defined.AsComprehension()ComprehensionExpr// AsIdent adapts the expr into an identifier string.//// The Kind() must be equal to an IdentKind for the conversion to be well-defined.AsIdent()string// AsLiteral adapts the expr into a constant ref.Val.//// The Kind() must be equal to a LiteralKind for the conversion to be well-defined.AsLiteral()ref.Val// AsList adapts the expr into a ListExpr.//// The Kind() must be equal to a ListKind for the conversion to be well-defined.AsList()ListExpr// AsMap adapts the expr into a MapExpr.//// The Kind() must be equal to a MapKind for the conversion to be well-defined.AsMap()MapExpr// AsSelect adapts the expr into a SelectExpr.//// The Kind() must be equal to a SelectKind for the conversion to be well-defined.AsSelect()SelectExpr// AsStruct adapts the expr into a StructExpr.//// The Kind() must be equal to a StructKind for the conversion to be well-defined.AsStruct()StructExpr// RenumberIDs performs an in-place update of the expression and all of its descendents numeric ids.RenumberIDs(IDGenerator)// SetKindCase replaces the contents of the current expression with the contents of the other.//// The SetKindCase takes ownership of any expression instances references within the input Expr.// A shallow copy is made of the Expr value itself, but not a deep one.//// This method should only be used during AST rewrites using temporary Expr values.SetKindCase(Expr)// contains filtered or unexported methods}Expr represents the base expression node in a CEL abstract syntax tree.
Depending on the `Kind()` value, the Expr may be converted to a concrete expression typesas indicated by the `As<Kind>` methods.
typeExprFactory¶added inv0.17.2
type ExprFactory interface {// CopyExpr creates a deep copy of the input Expr value.CopyExpr(Expr)Expr// CopyEntryExpr creates a deep copy of the input EntryExpr value.CopyEntryExpr(EntryExpr)EntryExpr// NewCall creates an Expr value representing a global function call.NewCall(idint64, functionstring, args ...Expr)Expr// NewComprehension creates an Expr value representing a one-variable comprehension over a value range.NewComprehension(idint64, iterRangeExpr, iterVar, accuVarstring, accuInit, loopCondition, loopStep, resultExpr)Expr// NewComprehensionTwoVar creates an Expr value representing a two-variable comprehension over a value range.NewComprehensionTwoVar(idint64, iterRangeExpr, iterVar, iterVar2, accuVarstring, accuInit, loopCondition, loopStep, resultExpr)Expr// NewMemberCall creates an Expr value representing a member function call.NewMemberCall(idint64, functionstring, receiverExpr, args ...Expr)Expr// NewIdent creates an Expr value representing an identifier.NewIdent(idint64, namestring)Expr// NewAccuIdent creates an Expr value representing an accumulator identifier within a// comprehension.NewAccuIdent(idint64)Expr// AccuIdentName reports the name of the accumulator variable to be used within a comprehension.AccuIdentName()string// NewLiteral creates an Expr value representing a literal value, such as a string or integer.NewLiteral(idint64, valueref.Val)Expr// NewList creates an Expr value representing a list literal expression with optional indices.//// Optional indices will typically be empty unless the CEL optional types are enabled.NewList(idint64, elems []Expr, optIndices []int32)Expr// NewMap creates an Expr value representing a map literal expressionNewMap(idint64, entries []EntryExpr)Expr// NewMapEntry creates a MapEntry with a given key, value, and a flag indicating whether// the key is optionally set.NewMapEntry(idint64, key, valueExpr, isOptionalbool)EntryExpr// NewPresenceTest creates an Expr representing a field presence test on an operand expression.NewPresenceTest(idint64, operandExpr, fieldstring)Expr// NewSelect creates an Expr representing a field selection on an operand expression.NewSelect(idint64, operandExpr, fieldstring)Expr// NewStruct creates an Expr value representing a struct literal with a given type name and a// set of field initializers.NewStruct(idint64, typeNamestring, fields []EntryExpr)Expr// NewStructField creates a StructField with a given field name, value, and a flag indicating// whether the field is optionally set.NewStructField(idint64, fieldstring, valueExpr, isOptionalbool)EntryExpr// NewUnspecifiedExpr creates an empty expression node.NewUnspecifiedExpr(idint64)Expr// contains filtered or unexported methods}ExprFactory interfaces defines a set of methods necessary for building native expression values.
funcNewExprFactory¶added inv0.17.2
func NewExprFactory()ExprFactory
NewExprFactory creates an ExprFactory instance.
funcNewExprFactoryWithAccumulator¶added inv0.23.0
func NewExprFactoryWithAccumulator(idstring)ExprFactory
NewExprFactoryWithAccumulator creates an ExprFactory instance with a customaccumulator identifier name.
typeExprKind¶
type ExprKindint
ExprKind represents the expression node kind.
const (// UnspecifiedExprKind represents an unset expression with no specified properties.UnspecifiedExprKindExprKind =iota// CallKind represents a function call.CallKind// ComprehensionKind represents a comprehension expression generated by a macro.ComprehensionKind// IdentKind represents a simple variable, constant, or type identifier.IdentKind// ListKind represents a list literal expression.ListKind// LiteralKind represents a primitive scalar literal.LiteralKind// MapKind represents a map literal expression.MapKind// SelectKind represents a field selection expression.SelectKind// StructKind represents a struct literal expression.StructKind)
typeExprMatcher¶
type ExprMatcher func(NavigableExpr)bool
ExprMatcher takes a NavigableExpr in and indicates whether the value is a match.
This function type should be use with the `Match` and `MatchList` calls.
funcAllMatcher¶
func AllMatcher()ExprMatcher
AllMatcher returns true for all descendants of a NavigableExpr, effectively flattening them into a list.
Such a result would work well with subsequent MatchList calls.
funcConstantValueMatcher¶
func ConstantValueMatcher()ExprMatcher
ConstantValueMatcher returns an ExprMatcher which will return true if the input NavigableExpris comprised of all constant values, such as a simple literal or even list and map literal.
funcFunctionMatcher¶
func FunctionMatcher(funcNamestring)ExprMatcher
FunctionMatcher returns an ExprMatcher which will match NavigableExpr nodes of CallKind type whosefunction name is equal to `funcName`.
funcKindMatcher¶
func KindMatcher(kindExprKind)ExprMatcher
KindMatcher returns an ExprMatcher which will return true if the input NavigableExpr.Kind() matchesthe specified `kind`.
typeIDGenerator¶added inv0.17.2
IDGenerator produces unique ids suitable for tagging expression nodes
typeListExpr¶added inv0.17.2
type ListExpr interface {// Elements returns the list elements as navigable expressions.Elements() []Expr// OptionalIndicies returns the list of optional indices in the list literal.OptionalIndices() []int32// IsOptional indicates whether the given element index is optional.IsOptional(int32)bool// Size returns the number of elements in the list.Size()int// contains filtered or unexported methods}ListExpr defines an interface for inspecting a list literal expression.
typeMapEntry¶added inv0.17.2
type MapEntry interface {// Key returns the map entry key expression.Key()Expr// Value returns the map entry value expression.Value()Expr// IsOptional returns whether the entry is optional.IsOptional()bool// contains filtered or unexported methods}MapEntry defines an interface for inspecting a map entry.
typeMapExpr¶added inv0.17.2
type MapExpr interface {// Entries returns the map key value pairs as EntryExpr values.Entries() []EntryExpr// Size returns the number of entries in the map.Size()int// contains filtered or unexported methods}MapExpr defines an interface for inspecting a map expression.
typeNavigableExpr¶
type NavigableExpr interface {Expr// Type of the expression.//// If the expression is type-checked, the type check metadata is returned. If the expression// has not been type-checked, the types.DynType value is returned.Type() *types.Type// Parent returns the parent expression node, if one exists.Parent() (NavigableExpr,bool)// Children returns a list of child expression nodes.Children() []NavigableExpr// Depth indicates the depth in the expression tree.//// The root expression has depth 0.Depth()int}NavigableExpr represents the base navigable expression value with methods to inspect theparent and child expressions.
funcMatchDescendants¶
func MatchDescendants(exprNavigableExpr, matcherExprMatcher) []NavigableExpr
MatchDescendants takes a NavigableExpr and ExprMatcher and produces a list of NavigableExpr valuesmatching the input criteria in post-order (bottom up).
funcMatchSubset¶
func MatchSubset(exprs []NavigableExpr, matcherExprMatcher) []NavigableExpr
MatchSubset applies an ExprMatcher to a list of NavigableExpr values and their descendants, producing asubset of NavigableExpr values which match.
funcNavigateAST¶added inv0.17.2
func NavigateAST(ast *AST)NavigableExpr
NavigateAST converts an AST to a NavigableExpr
funcNavigateExpr¶added inv0.17.2
func NavigateExpr(ast *AST, exprExpr)NavigableExpr
NavigateExpr creates a NavigableExpr whose type information is backed by the input AST.
If the expression is already a NavigableExpr, the parent and depth information will bepropagated on the new NavigableExpr value; otherwise, the expr value will be treatedas though it is the root of the expression graph with a depth of 0.
typeOffsetRange¶added inv0.17.2
OffsetRange captures the start and stop positions of a section of text in the input expression.
typeReferenceInfo¶
ReferenceInfo contains a CEL native representation of an identifier reference which may refer toeither a qualified identifier name, a set of overload ids, or a constant value from an enum.
funcNewFunctionReference¶
func NewFunctionReference(overloads ...string) *ReferenceInfo
NewFunctionReference creates a ReferenceInfo instance for a set of function overloads.
funcNewIdentReference¶
func NewIdentReference(namestring, valueref.Val) *ReferenceInfo
NewIdentReference creates a ReferenceInfo instance for an identifier with an optional constant value.
funcProtoToReferenceInfo¶added inv0.17.2
func ProtoToReferenceInfo(ref *exprpb.Reference) (*ReferenceInfo,error)
ProtoToReferenceInfo converts a protobuf Reference into a CEL-native ReferenceInfo instance.
func (*ReferenceInfo)AddOverload¶
func (r *ReferenceInfo) AddOverload(overloadIDstring)
AddOverload appends a function overload ID to the ReferenceInfo.
func (*ReferenceInfo)Equals¶
func (r *ReferenceInfo) Equals(other *ReferenceInfo)bool
Equals returns whether two references are identical to each other.
typeSelectExpr¶added inv0.17.2
type SelectExpr interface {// Operand returns the selection operand expression.Operand()Expr// FieldName returns the field name being selected from the operand.FieldName()string// IsTestOnly indicates whether the select expression is a presence test generated by a macro.IsTestOnly()bool// contains filtered or unexported methods}SelectExpr defines an interface for inspecting a select expression.
typeSourceInfo¶added inv0.17.2
type SourceInfo struct {// contains filtered or unexported fields}SourceInfo records basic information about the expression as a textual input andas a parsed expression value.
funcCopySourceInfo¶added inv0.17.2
func CopySourceInfo(info *SourceInfo) *SourceInfo
CopySourceInfo creates a deep copy of the MacroCalls within the input SourceInfo.
Copies of macro Expr values are generated using an internal default ExprFactory.
funcNewSourceInfo¶added inv0.17.2
func NewSourceInfo(srccommon.Source) *SourceInfo
NewSourceInfo creates a simple SourceInfo object from an input common.Source value.
funcProtoToSourceInfo¶added inv0.17.2
func ProtoToSourceInfo(info *exprpb.SourceInfo) (*SourceInfo,error)
ProtoToSourceInfo deserializes the protobuf into a native SourceInfo value.
func (*SourceInfo)ClearMacroCall¶added inv0.18.0
func (s *SourceInfo) ClearMacroCall(idint64)
ClearMacroCall removes the macro call at the given expression id.
func (*SourceInfo)ClearOffsetRange¶added inv0.21.0
func (s *SourceInfo) ClearOffsetRange(idint64)
ClearOffsetRange removes the OffsetRange for the given expression id.
func (*SourceInfo)ComputeOffset¶added inv0.17.2
func (s *SourceInfo) ComputeOffset(line, colint32)int32
ComputeOffset calculates the 0-based character offset from a 1-based line and 0-based column.
func (*SourceInfo)Description¶added inv0.17.2
func (s *SourceInfo) Description()string
Description provides information about where the expression came from.
func (*SourceInfo)GetLocationByOffset¶added inv0.21.0
func (s *SourceInfo) GetLocationByOffset(offsetint32)common.Location
GetLocationByOffset returns the line and column information for a given character offset.
func (*SourceInfo)GetMacroCall¶added inv0.17.2
func (s *SourceInfo) GetMacroCall(idint64) (Expr,bool)
GetMacroCall returns the original ast.Expr value for the given expression if it was generated viaa macro replacement.
Note, parsing options must be enabled to track macro calls before this method will return a value.
func (*SourceInfo)GetOffsetRange¶added inv0.17.2
func (s *SourceInfo) GetOffsetRange(idint64) (OffsetRange,bool)
GetOffsetRange retrieves an OffsetRange for the given expression id if one exists.
func (*SourceInfo)GetStartLocation¶added inv0.17.2
func (s *SourceInfo) GetStartLocation(idint64)common.Location
GetStartLocation calculates the human-readable 1-based line and 0-based column of the first characterof the expression node at the id.
func (*SourceInfo)GetStopLocation¶added inv0.17.2
func (s *SourceInfo) GetStopLocation(idint64)common.Location
GetStopLocation calculates the human-readable 1-based line and 0-based column of the last character forthe expression node at the given id.
If the SourceInfo was generated from a serialized protobuf representation, the stop location willbe identical to the start location for the expression.
func (*SourceInfo)LineOffsets¶added inv0.17.2
func (s *SourceInfo) LineOffsets() []int32
LineOffsets returns a list of the 0-based character offsets in the input text where newlines appear.
func (*SourceInfo)MacroCalls¶added inv0.17.2
func (s *SourceInfo) MacroCalls() map[int64]Expr
MacroCalls returns a map of expression id to ast.Expr value where the id represents the expressionnode where the macro was inserted into the AST, and the ast.Expr value represents the original callsignature which was replaced.
func (*SourceInfo)OffsetRanges¶added inv0.17.2
func (s *SourceInfo) OffsetRanges() map[int64]OffsetRange
OffsetRanges returns a map of expression id to OffsetRange values where the range indicates either:the start and end position in the input stream where the expression occurs, or the start positiononly. If the range only captures start position, the stop position of the range will be equal tothe start.
func (*SourceInfo)SetMacroCall¶added inv0.17.2
func (s *SourceInfo) SetMacroCall(idint64, eExpr)
SetMacroCall records a macro call at a specific location.
func (*SourceInfo)SetOffsetRange¶added inv0.17.2
func (s *SourceInfo) SetOffsetRange(idint64, oOffsetRange)
SetOffsetRange sets the OffsetRange for the given expression id.
func (*SourceInfo)SyntaxVersion¶added inv0.17.2
func (s *SourceInfo) SyntaxVersion()string
SyntaxVersion returns the syntax version associated with the text expression.
typeStructExpr¶added inv0.17.2
type StructExpr interface {// TypeName returns the struct type name.TypeName()string// Fields returns the set of field initializers in the struct expression as EntryExpr values.Fields() []EntryExpr// contains filtered or unexported methods}StructExpr defines an interfaces for inspecting a struct and its field initializers.
typeStructField¶added inv0.17.2
type StructField interface {// Name returns the name of the field.Name()string// Value returns the field initialization expression.Value()Expr// IsOptional returns whether the field is optional.IsOptional()bool// contains filtered or unexported methods}StructField defines an interface for inspecting a struct field initialization.
typeVisitor¶added inv0.18.0
type Visitor interface {// VisitExpr visits the input expression.VisitExpr(Expr)// VisitEntryExpr visits the input entry expression, i.e. a struct field or map entry.VisitEntryExpr(EntryExpr)}Visitor defines an object for visiting Expr and EntryExpr nodes within an expression graph.
funcNewExprVisitor¶added inv0.18.0
NewExprVisitor creates a visitor which only visits expression nodes.