1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
pub(crate) mod graph_based_analysis;
pub mod naming;
use self::naming::NamingAnalysis;
use crate::ast;
use crate::ast::RTLolaAst;
use crate::reporting::Handler;
use crate::ty::check::TypeAnalysis;
use crate::FrontendConfig;
pub(crate) use self::graph_based_analysis::GraphAnalysisResult;
pub(crate) use self::naming::DeclarationTable;
pub(crate) use crate::ty::check::TypeTable;
pub(crate) struct Report {
pub(crate) declaration_table: DeclarationTable,
pub(crate) type_table: TypeTable,
pub(crate) graph_analysis_result: GraphAnalysisResult,
}
impl Report {
fn new(
declaration_table: DeclarationTable,
type_table: TypeTable,
graph_analysis_result: GraphAnalysisResult,
) -> Report {
Report { declaration_table, type_table, graph_analysis_result }
}
}
pub(crate) fn analyze(spec: &RTLolaAst, handler: &Handler, config: FrontendConfig) -> Result<Report, ()> {
ast::verify::Verifier::new(spec, handler).check();
if handler.contains_error() {
handler.error("aborting due to previous error");
return Err(());
}
let mut naming_analyzer = NamingAnalysis::new(&handler, config);
let mut decl_table = naming_analyzer.check(spec);
if handler.contains_error() {
handler.error("aborting due to previous error");
return Err(());
}
let mut type_analysis = TypeAnalysis::new(&handler, &mut decl_table);
let type_table = type_analysis.check(&spec);
assert_eq!(type_table.is_none(), handler.contains_error());
if handler.contains_error() {
handler.error("aborting due to previous error");
return Err(());
}
let tt = type_table.unwrap();
let graph_result = graph_based_analysis::analyze(spec, &decl_table, &tt, &handler);
if handler.contains_error() || graph_result.is_err() {
handler.error("aborting due to previous error");
return Err(());
}
let graph_res = graph_result.unwrap();
Ok(Report::new(decl_table, tt, graph_res))
}