MCPcopy Create free account
hub / github.com/cel-expr/cel-go / AstToString

Function AstToString

cel/io.go:142–147  ·  view source on GitHub ↗

AstToString converts an Ast back to a string if possible. Note, the conversion may not be an exact replica of the original expression, but will produce a string that is semantically equivalent and whose textual representation is stable.

(a *Ast, opts ...ASTFormatOption)

Source from the content-addressed store, hash-verified

140// Note, the conversion may not be an exact replica of the original expression, but will produce
141// a string that is semantically equivalent and whose textual representation is stable.
142func AstToString(a *Ast, opts ...ASTFormatOption) (string, error) {
143 if a == nil {
144 return "", errors.New("unsupported expr")
145 }
146 return ExprToString(a.NativeRep().Expr(), a.NativeRep().SourceInfo(), opts...)
147}
148
149// ExprToString converts an AST Expr node back to a string using macro call tracking metadata from
150// source info if any macros are encountered within the expression.

Calls 5

ExprToStringFunction · 0.85
NewMethod · 0.80
NativeRepMethod · 0.80
ExprMethod · 0.65
SourceInfoMethod · 0.45