Skip to main content

parse_expression

Function parse_expression 

Source
pub fn parse_expression(tokens: Vec<Token>) -> Result<Expr, String>
Expand description

Parse a token stream as a single Polydat expression.

Used by string-interpolation desugaring to compile placeholder bodies ({ … } inside string literals) the same way any other binding right-hand side is compiled. Identifiers, nested function calls, infix arithmetic, and field access all work uniformly because this is the same parse_expr entry the compiler uses elsewhere.

// "{format_u64(hash(cycle), 10)}" → printf("{}", format_u64(hash(cycle), 10))
// "{a + b}"                       → printf("{}", a + b)

Returns an error if the tokens don’t form a single complete expression, or if there are trailing tokens after the expression ends.