Skip to main content

value_to_dexpr

Function value_to_dexpr 

Source
pub fn value_to_dexpr(v: &Value) -> Result<DExpr, String>
Expand description

Parse a Value::Struct { name: "DExpr", ... } into a DExpr.

The CJC language constructs DExpr values via helper builtins: col(“name”) → Struct { name: “DExpr”, kind: “col”, value: “name” } binop(“>”, l, r) → Struct { name: “DExpr”, kind: “binop”, op: “>”, left: l, right: r } lit_int(42) → Struct { name: “DExpr”, kind: “lit_int”, value: 42 } etc.

For ergonomic use, we also accept raw literals directly: Value::Int(42) → DExpr::LitInt(42) Value::Float(3.14) → DExpr::LitFloat(3.14) Value::Bool(true) → DExpr::LitBool(true) Value::String(“x”) → DExpr::Col(“x”) – shorthand for col(“x”)