implement basic namespacing for types, traits and commands
This commit is contained in:
parent
3cca2bc2cc
commit
b6b8c5085a
5 changed files with 287 additions and 6 deletions
|
@ -20,6 +20,10 @@ pub fn check(
|
|||
))
|
||||
}
|
||||
|
||||
if let Err(e_span) = check_missing_sink(&syntax) {
|
||||
errs.push(SyntaxError::MissingSink(vec![(file_id, e_span)]));
|
||||
}
|
||||
|
||||
if errs.is_empty() {
|
||||
Ok(syntax)
|
||||
} else {
|
||||
|
@ -44,11 +48,11 @@ fn check_missing_filters(syntax: &Vec<PipelineElement>) -> Result<(), Vec<logos:
|
|||
|
||||
for i in 0..syntax.len() {
|
||||
if let (
|
||||
Some(PipelineElement {
|
||||
Some(&PipelineElement {
|
||||
kind: PipelineElementKind::Pipe,
|
||||
ref span,
|
||||
}),
|
||||
Some(PipelineElement {
|
||||
Some(&PipelineElement {
|
||||
kind: PipelineElementKind::Pipe,
|
||||
span: ref span1,
|
||||
}),
|
||||
|
@ -64,3 +68,15 @@ fn check_missing_filters(syntax: &Vec<PipelineElement>) -> Result<(), Vec<logos:
|
|||
Err(missing_filter_locs)
|
||||
}
|
||||
}
|
||||
|
||||
fn check_missing_sink(syntax: &Vec<PipelineElement>) -> Result<(), logos::Span> {
|
||||
if let Some(&PipelineElement {
|
||||
kind: PipelineElementKind::Pipe,
|
||||
ref span,
|
||||
}) = syntax.last()
|
||||
{
|
||||
Err(span.clone())
|
||||
} else {
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
|
|
@ -13,11 +13,11 @@ pub enum SyntaxError {
|
|||
MissingSink(Vec<(FileId, logos::Span)>),
|
||||
/// This indicates a missing filter somewhere in the pipeline, meaning that there's 2 pipes after one another
|
||||
MissingFilter(Vec<(FileId, logos::Span)>),
|
||||
/// A literal cannot be a sink
|
||||
/// A literal cannot be a sink, TODO
|
||||
LiteralAsSink,
|
||||
/// A literal can't be a filter either
|
||||
/// A literal can't be a filter either, TODO
|
||||
LiteralAsFilter,
|
||||
/// A literal acting as streamer cannot take arguments
|
||||
/// A literal acting as streamer cannot take arguments, TODO
|
||||
LiteralWithArgs,
|
||||
}
|
||||
|
||||
|
@ -51,7 +51,16 @@ impl SyntaxError {
|
|||
})
|
||||
.collect(),
|
||||
),
|
||||
_ => todo!(),
|
||||
Self::MissingSink(locs) => Diagnostic::error()
|
||||
.with_message("pipelines cannot end on a pipe")
|
||||
.with_labels(
|
||||
locs.into_iter()
|
||||
.map(|(file_id, span)| {
|
||||
Label::primary(*file_id, span.clone()).with_message("no sink")
|
||||
})
|
||||
.collect(),
|
||||
),
|
||||
_ => unimplemented!(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue