Improve parsing of pipelines, require pipes

At the moment the pipeline parser does not enforce
that there must be a pipe between each part of the pipeline,
which can lead to confusing behaviour or misleading errors.
This commit is contained in:
George Pollard
2019-09-05 03:30:51 +12:00
parent c6c4d4ddb1
commit 6034de641a
4 changed files with 20 additions and 21 deletions

View File

@ -147,6 +147,10 @@ fn paint_token_node(token_node: &TokenNode, line: &str) -> String {
fn paint_pipeline_element(pipeline_element: &PipelineElement, line: &str) -> String {
let mut styled = String::new();
if let Some(_) = pipeline_element.pipe {
styled.push_str(&Color::Purple.paint("|"));
}
if let Some(ws) = pipeline_element.pre_ws {
styled.push_str(&Color::White.normal().paint(ws.slice(line)));
}
@ -168,10 +172,6 @@ fn paint_pipeline_element(pipeline_element: &PipelineElement, line: &str) -> Str
styled.push_str(&Color::White.normal().paint(ws.slice(line)));
}
if let Some(_) = pipeline_element.post_pipe {
styled.push_str(&Color::Purple.paint("|"));
}
styled.to_string()
}