| 14 | use crate::{Def, TestCatalog, try_parse_def, try_parse_mir}; |
| 15 | |
| 16 | pub fn handle_define(catalog: &mut TestCatalog, input: &str) -> String { |
| 17 | // Parse the relation, returning early on parse error. |
| 18 | let result = match try_parse_def(catalog, input) { |
| 19 | Ok(def) => match def { |
| 20 | Def::Source { name, cols, typ } => match catalog.insert(&name, cols, typ, true) { |
| 21 | Ok(id) => format!("Source defined as {id}"), |
| 22 | Err(err) => err, |
| 23 | }, |
| 24 | }, |
| 25 | Err(err) => err, |
| 26 | }; |
| 27 | result + "\n" |
| 28 | } |
| 29 | |
| 30 | pub fn handle_roundtrip(catalog: &TestCatalog, input: &str) -> String { |
| 31 | let output = match try_parse_mir(catalog, input) { |