Skip to main content

Module expr

Module expr 

Source
Expand description

SPARQL expression parser — precedence-climbing recursive descent over the token stream, producing Expression nodes into the SparqlQueryContext arena. Used for FILTER, BIND, and HAVING expressions.

Precedence (lowest → highest), per the SPARQL 1.1 grammar: || < && < (= != < <= > >=) < (+ -) < (* /) < unary < primary.

§Encoding note (matches the evaluator’s model)

ExpressionEvaluator maps both Variable and Literal to EvalResult::Numeric(u64), and comparisons require both operands to be the same EvalResult variant. So a constant used in an expression (IRI, string, number, boolean) is encoded as Expression::Literal(hash_or_value) — using exactly the same term encoding the triple-pattern parser (parse_term) uses — so ?x = <iri> / ?name = "Alice" / ?age >= 18 all compare correctly.

Functions§

parse_expression
Parse a full expression from tokens, allocating nodes into ctx. Returns the root ExpressionId. Errors on malformed syntax or arena overflow.
reset_parse_literals
Clear the parse-time literal table (call before parsing a query).
take_parse_literals
Take the literal table collected during the last parse.