MCPcopy Create free account
hub / github.com/MaterializeInc/materialize / try_parse_def

Function try_parse_def

src/expr-parser/src/parser.rs:53–67  ·  view source on GitHub ↗

Builds a source definition from a string.

(catalog: &TestCatalog, s: &str)

Source from the content-addressed store, hash-verified

51
52/// Builds a source definition from a string.
53pub 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].
70mod relation {

Callers 1

handle_defineFunction · 0.85

Calls 3

parse_defFunction · 0.85
spanMethod · 0.80
startMethod · 0.45

Tested by

no test coverage detected