Skip to main content

Module parse

Module parse 

Source
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_list turns one comma-separated string into Vec<Clause>. Each entry from the YAML’s array form, or the top-level entries of the YAML’s string form, calls this.
  • comprehension_from_subspaces takes the parsed sub-spaces (each sub-space is a Vec<Clause> — a Cartesian list) and decides between ComprehensionMode::Cartesian and ComprehensionMode::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 Comprehension from a list of pre-parsed sub-spaces. Each subspaces[i] is one Cartesian clause list (the output of parse_clause_list for 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 order keyword. Returns (head, Some(order_spec)) if an order clause is present at paren-depth 0, or (text, None) otherwise. The order keyword is consumed; the spec is trimmed.
split_at_where
Split a comprehension text on the top-level where keyword. Returns (clause_text, Some(predicate)) if a where clause is present at paren-depth 0, or (text, None) otherwise. The predicate is trimmed; the where keyword itself is consumed.
split_respecting_parens
Split a comma-separated clause list on clause boundaries.
validate_order_for_modeDeprecated
Backward-compat shim — call Comprehension::validate instead. Kept so external host callers don’t need a same-day update; will be retired once those move.