Expand description
Comprehension spec parser — text → AST.
The textual form is var in expr per clause, comma-separated
at clause boundaries, with paren-respecting splitting so
function-call argument commas and multi-value list commas
aren’t mistaken for clause separators.
§Two entry points
parse_clause_listturns one comma-separated string intoVec<Clause>. Each entry from the YAML’s array form, or the top-level entries of the YAML’s string form, calls this.comprehension_from_subspacestakes the parsed sub-spaces (each sub-space is aVec<Clause>— a Cartesian list) and decides betweenComprehensionMode::CartesianandComprehensionMode::Union. This is the structural detection rule: any variable name repeating across the sub-spaces’ flat clause set ⇒ Union; otherwise Cartesian over the flattened list.
YAML-shape detection (string vs list vs object) stays in
the host — it’s YAML-shaped, not GK-shaped. The
workload parser builds Vec<Vec<Clause>> from the YAML
using these primitives, then calls
comprehension_from_subspaces.
Functions§
- comprehension_
from_ subspaces - Build a
Comprehensionfrom a list of pre-parsed sub-spaces. Eachsubspaces[i]is one Cartesian clause list (the output ofparse_clause_listfor one of the YAML’s array-form entries, or one entry for the YAML’s map / string forms). - parse_
clause - Parse a single clause.
- parse_
clause_ list - Parse a comma-separated clause list — the textual content of one comprehension sub-space.
- parse_
comprehension_ text - Parse the full Polydat comprehension text grammar:
<clause_list> [where <predicate>]. - parse_
order_ spec - Parse an order spec string into a
TraversalOrder. - split_
at_ order - Split a comprehension text on the top-level
orderkeyword. Returns(head, Some(order_spec))if an order clause is present at paren-depth 0, or(text, None)otherwise. Theorderkeyword is consumed; the spec is trimmed. - split_
at_ where - Split a comprehension text on the top-level
wherekeyword. Returns(clause_text, Some(predicate))if awhereclause is present at paren-depth 0, or(text, None)otherwise. The predicate is trimmed; thewherekeyword itself is consumed. - split_
respecting_ parens - Split a comma-separated clause list on clause boundaries.
- validate_
order_ for_ mode Deprecated - Backward-compat shim — call
Comprehension::validateinstead. Kept so external host callers don’t need a same-day update; will be retired once those move.