mirror of
https://forge.katzen.cafe/katzen-cafe/iowo.git
synced 2025-09-25 16:01:30 +02:00
implement better checking and errors
This commit is contained in:
parent
3f4846744b
commit
344afa22b5
4 changed files with 125 additions and 52 deletions
34
src/syntax/check.rs
Normal file
34
src/syntax/check.rs
Normal file
|
@ -0,0 +1,34 @@
|
|||
use super::{
|
||||
error::{FileId, SyntaxError},
|
||||
PipelineElement, PipelineElementKind,
|
||||
};
|
||||
|
||||
pub fn check(
|
||||
syntax: Vec<PipelineElement>,
|
||||
raw_source: &str,
|
||||
file_id: FileId,
|
||||
) -> Result<Vec<PipelineElement>, Vec<SyntaxError>> {
|
||||
let mut errs = Vec::new();
|
||||
|
||||
if let Err(e_span) = check_missing_streamer(&syntax) {
|
||||
errs.push(SyntaxError::MissingStreamer(vec![(file_id, e_span)]));
|
||||
}
|
||||
|
||||
if errs.is_empty() {
|
||||
Ok(syntax)
|
||||
} else {
|
||||
Err(errs)
|
||||
}
|
||||
}
|
||||
|
||||
fn check_missing_streamer(syntax: &Vec<PipelineElement>) -> Result<(), logos::Span> {
|
||||
if let Some(&PipelineElement {
|
||||
kind: PipelineElementKind::Pipe,
|
||||
ref span,
|
||||
}) = syntax.first()
|
||||
{
|
||||
Err(span.clone())
|
||||
} else {
|
||||
Ok(())
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue