mirror of
https://github.com/edg-l/edlang.git
synced 2024-11-09 17:48:24 +00:00
check
This commit is contained in:
parent
a1944fe1ce
commit
c68daa2d93
|
@ -1,4 +1,3 @@
|
||||||
let x = 2;
|
|
||||||
fn add(a: i64, b: i64) -> i64 {
|
fn add(a: i64, b: i64) -> i64 {
|
||||||
return a + b;
|
return a + b;
|
||||||
}
|
}
|
||||||
|
|
64
src/check.rs
64
src/check.rs
|
@ -50,8 +50,68 @@ pub fn check<'a>(data: &'a ProgramData, ast: &ast::Program) -> Vec<Check<'a>> {
|
||||||
let dl = DisplayList::from(snippet);
|
let dl = DisplayList::from(snippet);
|
||||||
errors.push(Check::Error(dl));
|
errors.push(Check::Error(dl));
|
||||||
}
|
}
|
||||||
Statement::Definition(_) => todo!(),
|
Statement::Definition(_) => {
|
||||||
Statement::Return(_) => unreachable!(),
|
// can't have a top level assignment yet.
|
||||||
|
let snippet = Snippet {
|
||||||
|
title: Some(Annotation {
|
||||||
|
id: None,
|
||||||
|
label: Some("unexpected definition at top level"),
|
||||||
|
annotation_type: AnnotationType::Error,
|
||||||
|
}),
|
||||||
|
footer: vec![],
|
||||||
|
slices: vec![Slice {
|
||||||
|
source: &data.source,
|
||||||
|
line_start: 1,
|
||||||
|
fold: true,
|
||||||
|
origin: Some(&data.filename),
|
||||||
|
annotations: vec![
|
||||||
|
SourceAnnotation {
|
||||||
|
label: "unexpected statement",
|
||||||
|
annotation_type: AnnotationType::Error,
|
||||||
|
range: statement.span.into(),
|
||||||
|
},
|
||||||
|
],
|
||||||
|
}],
|
||||||
|
opt: FormatOptions {
|
||||||
|
color: true,
|
||||||
|
..Default::default()
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
let dl = DisplayList::from(snippet);
|
||||||
|
errors.push(Check::Error(dl));
|
||||||
|
},
|
||||||
|
Statement::Return(_x) => {
|
||||||
|
// can't have a top level assignment yet.
|
||||||
|
let snippet = Snippet {
|
||||||
|
title: Some(Annotation {
|
||||||
|
id: None,
|
||||||
|
label: Some("unexpected return"),
|
||||||
|
annotation_type: AnnotationType::Error,
|
||||||
|
}),
|
||||||
|
footer: vec![],
|
||||||
|
slices: vec![Slice {
|
||||||
|
source: &data.source,
|
||||||
|
line_start: 1,
|
||||||
|
fold: true,
|
||||||
|
origin: Some(&data.filename),
|
||||||
|
annotations: vec![
|
||||||
|
SourceAnnotation {
|
||||||
|
label: "unexpected return",
|
||||||
|
annotation_type: AnnotationType::Error,
|
||||||
|
range: statement.span.into(),
|
||||||
|
},
|
||||||
|
],
|
||||||
|
}],
|
||||||
|
opt: FormatOptions {
|
||||||
|
color: true,
|
||||||
|
..Default::default()
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
let dl = DisplayList::from(snippet);
|
||||||
|
errors.push(Check::Error(dl));
|
||||||
|
},
|
||||||
Statement::Function(_function) => {}
|
Statement::Function(_function) => {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue