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 intoctx. Returns the rootExpressionId. 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.