MCPcopy Index your code
hub / github.com/TomWright/dasel / binaryExprExecutor

Function binaryExprExecutor

execution/execute_binary.go:58–72  ·  view source on GitHub ↗
(e ast.BinaryExpr)

Source from the content-addressed store, hash-verified

56var binaryExpressionExecutors = map[lexer.TokenKind]binaryExpressionExecutorFn{}
57
58func binaryExprExecutor(e ast.BinaryExpr) (expressionExecutor, error) {
59 return func(ctx context.Context, options *Options, data *model.Value) (*model.Value, error) {
60 ctx = WithExecutorID(ctx, "binaryExpr")
61 if e.Left == nil || e.Right == nil {
62 return nil, fmt.Errorf("left and right expressions must be provided")
63 }
64
65 exec, ok := binaryExpressionExecutors[e.Operator.Kind]
66 if !ok {
67 return nil, fmt.Errorf("unhandled operator: %s", e.Operator.Value)
68 }
69
70 return exec(ctx, e, data, options)
71 }, nil
72}
73
74func init() {
75 binaryExpressionExecutors[lexer.Plus] = basicBinaryExpressionExecutorFn(func(ctx context.Context, left *model.Value, right *model.Value, _ ast.BinaryExpr) (*model.Value, error) {

Callers 1

exprExecutorFunction · 0.85

Calls 1

WithExecutorIDFunction · 0.85

Tested by

no test coverage detected