Skip to main content

parse_comprehension_text

Function parse_comprehension_text 

Source
pub fn parse_comprehension_text(text: &str) -> Result<Comprehension, String>
Expand description

Parse the full Polydat comprehension text grammar: <clause_list> [where <predicate>].

The clause list is a comma-separated sequence of var in expr clauses (paren-respecting; see parse_clause_list). The optional where keyword at top-paren-depth-0 ends the clause list and starts a single Polydat predicate expression that runs to end-of-string. The predicate is not parsed here — it’s stored as text and evaluated at iteration time against the per-tuple kernel.

Mode (Cartesian vs Union) is decided by comprehension_from_subspaces from the clause list. The filter, if present, attaches uniformly to both modes — one predicate per emitted tuple.

Examples:

k in 10,100, limit in 10,20,30
k in 10,100 where k > 5
k in 10,100, limit in 10,20,30,50,100,200,300 where k * limit < 1000