pub mod domain;
pub mod effects;
pub mod frontend;
pub mod interp;
pub mod ir;
pub mod limits;
pub mod models;
pub mod state;
use crate::rules::Dialect;
use effects::Effects;
use frontend::ParseError;
pub use interp::{Incomplete, ASSUMPTIONS};
#[derive(Debug, Clone)]
pub struct Analysis {
pub effects: Effects,
pub pipelines: Vec<(ir::Span, state::Tri)>,
pub incomplete: Option<Incomplete>,
}
impl Analysis {
pub fn pipefail_at(&self, at: usize) -> state::Tri {
self.pipelines
.iter()
.filter(|(span, _)| span.start <= at && at < span.end)
.min_by_key(|(span, _)| span.end - span.start)
.map_or(state::Tri::Maybe, |(_, t)| *t)
}
}
pub fn analyze(src: &str, dialect: Dialect) -> Analysis {
match frontend::parse(src) {
Ok(cmd) => {
let out = interp::run(&cmd, src, dialect);
Analysis {
effects: out.effects,
pipelines: out.pipelines,
incomplete: out.incomplete,
}
}
Err(e) => {
let (span, why) = match e {
ParseError::Syntax { why, span } => (span, why),
ParseError::Limit(x) => (0..src.len(), x.describe()),
};
Analysis {
effects: Effects {
contributions: Vec::new(),
unknown: vec![(span.clone(), why)],
},
pipelines: Vec::new(),
incomplete: Some(Incomplete { span, why }),
}
}
}
}