Skip to main content

normalize_condition_clause

Function normalize_condition_clause 

Source
pub fn normalize_condition_clause(s: &str) -> String
Expand description

Parse a YAML source into just the list of normalized ParsedOps. Normalise an op-level if: clause so callers can write expressions naturally. The downstream pipeline expects the condition to be either a binding-name reference ({name}) or an inline expression ({{expr}}). When the operator writes a bare expression like cql_dialect == 'cass', that doesn’t match either form and the conditional dispenser fails at init when it tries to look up a Polydat binding literally named cql_dialect == 'cass'.

Heuristic: if the trimmed value already starts with { (any braced form), or is a plain identifier ([A-Za-z_][A-Za-z0-9_]*), pass through unchanged. Otherwise treat as an inline expression and wrap with {{...}} so the existing inline-expression machinery in nmbrs-runtime::scope::build_scope synthesises a hidden binding (__expr_N := <expr>) and rewrites the condition to reference it.