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

Function parse

src/testdrive/src/parser.rs:93–135  ·  view source on GitHub ↗
(line_reader: &mut LineReader)

Source from the content-addressed store, hash-verified

91}
92
93pub(crate) fn parse(line_reader: &mut LineReader) -> Result<Vec<PosCommand>, PosError> {
94 let mut out = Vec::new();
95 while let Some((pos, line)) = line_reader.peek() {
96 let pos = *pos;
97 let command = match line.chars().next() {
98 Some('$') => {
99 let version = parse_version_constraint(line_reader)?;
100 Command::Builtin(parse_builtin(line_reader)?, version)
101 }
102 Some('>') => {
103 let version = parse_version_constraint(line_reader)?;
104 Command::Sql(parse_sql(line_reader)?, version)
105 }
106 Some('?') => {
107 let version = parse_version_constraint(line_reader)?;
108 Command::Sql(parse_explain_sql(line_reader)?, version)
109 }
110 Some('!') => {
111 let version = parse_version_constraint(line_reader)?;
112 Command::FailSql(parse_fail_sql(line_reader)?, version)
113 }
114 Some('#') => {
115 // Comment line.
116 line_reader.next();
117 continue;
118 }
119 Some(x) => {
120 return Err(PosError {
121 source: anyhow!(format!("unexpected input line at beginning of file: {}", x)),
122 pos: Some(pos),
123 });
124 }
125 None => {
126 return Err(PosError {
127 source: anyhow!("unexpected input line at beginning of file"),
128 pos: Some(pos),
129 });
130 }
131 };
132 out.push(PosCommand { command, pos });
133 }
134 Ok(out)
135}
136
137fn parse_builtin(line_reader: &mut LineReader) -> Result<BuiltinCommand, PosError> {
138 let (pos, line) = line_reader.next().unwrap();

Callers 15

run_line_readerFunction · 0.70
reset_materializeMethod · 0.70
format.test.tsFile · 0.50
onStartDateChangeFunction · 0.50
onEndDateChangeFunction · 0.50
format.test.tsFile · 0.50
buildRowFunction · 0.50
buildProbeFunction · 0.50
buildRowFunction · 0.50
buildRowFunction · 0.50

Calls 10

parse_version_constraintFunction · 0.85
BuiltinEnum · 0.85
parse_builtinFunction · 0.85
SqlClass · 0.85
parse_explain_sqlFunction · 0.85
parse_fail_sqlFunction · 0.85
parse_sqlFunction · 0.70
peekMethod · 0.45
nextMethod · 0.45
pushMethod · 0.45

Tested by 12

buildRowFunction · 0.40
buildProbeFunction · 0.40
buildRowFunction · 0.40
buildRowFunction · 0.40
test_signatureFunction · 0.40
mainFunction · 0.40
test_version_stepFunction · 0.40
testcaseFunction · 0.40
test_parse_url_no_prefixFunction · 0.40