MCPcopy Create free account
hub / github.com/ForestHubAI/edge-agents / parseAndEval

Function parseAndEval

go/engine/expr/parser.go:17–24  ·  view source on GitHub ↗

parseAndEval evaluates a simple expression string with literals and operators. Supports: +, -, *, /, %, ==, !=, <, >, <=, >=, &&, ||, !

(expr string, targetType workflow.DataType)

Source from the content-addressed store, hash-verified

15// parseAndEval evaluates a simple expression string with literals
16// and operators. Supports: +, -, *, /, %, ==, !=, <, >, <=, >=, &&, ||, !
17func parseAndEval(expr string, targetType workflowapi.DataType) (Value, error) {
18 p := &parser{input: expr, pos: 0}
19 val, err := p.parseOr()
20 if err != nil {
21 return Value{}, fmt.Errorf("evaluating %q: %w", expr, err)
22 }
23 return val.Cast(targetType), nil
24}
25
26// Minimal recursive-descent expression parser/evaluator.
27type parser struct {

Callers 1

evalCodeExprFunction · 0.85

Calls 2

parseOrMethod · 0.95
CastMethod · 0.80

Tested by

no test coverage detected