fe_analyzer/
lib.rs

1//! Fe semantic analysis.
2//!
3//! This library is used to analyze the semantics of a given Fe AST. It detects
4//! any semantic errors within a given AST and produces a `Context` instance
5//! that can be used to query contextual information attributed to AST nodes.
6
7pub mod builtins;
8pub mod constants;
9pub mod context;
10pub mod db;
11pub mod display;
12pub mod errors;
13pub mod namespace;
14
15mod operations;
16mod traversal;
17
18pub use db::{AnalyzerDb, TestDb};
19pub use traversal::pattern_analysis;
20
21use fe_common::diagnostics::Diagnostic;
22use namespace::items::{IngotId, ModuleId};
23
24pub fn analyze_ingot(db: &dyn AnalyzerDb, ingot_id: IngotId) -> Result<(), Vec<Diagnostic>> {
25    let diagnostics = ingot_id.diagnostics(db);
26
27    if diagnostics.is_empty() {
28        Ok(())
29    } else {
30        Err(diagnostics)
31    }
32}
33
34pub fn analyze_module(db: &dyn AnalyzerDb, module_id: ModuleId) -> Result<(), Vec<Diagnostic>> {
35    let diagnostics = module_id.diagnostics(db);
36
37    if diagnostics.is_empty() {
38        Ok(())
39    } else {
40        Err(diagnostics)
41    }
42}