Builds a source definition from a string.
(catalog: &TestCatalog, s: &str)
| 51 | |
| 52 | /// Builds a source definition from a string. |
| 53 | pub fn try_parse_def(catalog: &TestCatalog, s: &str) -> Result<Def, String> { |
| 54 | // Define a Parser that constructs a (read-only) parsing context `ctx` and |
| 55 | // delegates to `relation::parse_expr` by passing a `ctx` as a shared ref. |
| 56 | let parser = move |input: ParseStream| { |
| 57 | let ctx = Ctx { catalog }; |
| 58 | def::parse_def(&ctx, input) |
| 59 | }; |
| 60 | // Call the parser with the given input string. |
| 61 | let def = parser.parse_str(s).map_err(|err| { |
| 62 | let (line, column) = (err.span().start().line, err.span().start().column); |
| 63 | format!("parse error at {line}:{column}:\n{err}\n") |
| 64 | })?; |
| 65 | // Return the parsed, post-processed expression. |
| 66 | Ok(def) |
| 67 | } |
| 68 | |
| 69 | /// Support for parsing [mz_expr::MirRelationExpr]. |
| 70 | mod relation { |
no test coverage detected