Implementations based on `google/cel-go`'s unparser https://github.com/google/cel-go/blob/master/parser/unparser.go
(ast *cel.Ast)
| 17 | // https://github.com/google/cel-go/blob/master/parser/unparser.go |
| 18 | |
| 19 | func Convert(ast *cel.Ast) (string, error) { |
| 20 | checkedExpr, err := cel.AstToCheckedExpr(ast) |
| 21 | if err != nil { |
| 22 | return "", err |
| 23 | } |
| 24 | un := &converter{ |
| 25 | typeMap: checkedExpr.TypeMap, |
| 26 | } |
| 27 | if err := un.visit(checkedExpr.Expr); err != nil { |
| 28 | return "", err |
| 29 | } |
| 30 | return un.str.String(), nil |
| 31 | } |
| 32 | |
| 33 | type converter struct { |
| 34 | str strings.Builder |