use std::ops::Range;
pub use nibli_types::ast::{DeonticMood, Tense};
#[derive(Debug, Clone, PartialEq)]
pub struct Statement {
pub claim: Claim,
pub span: Range<usize>,
}
#[derive(Debug, Clone, PartialEq)]
pub enum Claim {
Prenex { vars: Vec<String>, body: Box<Claim> },
DetBlock {
det: Det,
restr: Restr,
var: String,
body: Box<Claim>,
},
Impl(Box<Claim>, Box<Claim>),
Iff(Box<Claim>, Box<Claim>),
Xor(Box<Claim>, Box<Claim>),
Or(Box<Claim>, Box<Claim>),
And(Box<Claim>, Box<Claim>),
Not(Box<Claim>),
Prefixed {
deontic: Option<DeonticMood>,
tense: Option<Tense>,
atom: Box<Claim>,
},
Equality(Term, Term),
Predication(Predication),
}
#[derive(Debug, Clone, PartialEq)]
pub struct Predication {
pub seq: PredSeq,
pub args: Vec<Arg>,
pub tags: Vec<Tag>,
pub span: Range<usize>,
}
#[derive(Debug, Clone, PartialEq)]
pub struct PredSeq(pub Vec<PredUnit>);
#[derive(Debug, Clone, PartialEq)]
pub enum PredUnit {
Word(Vec<String>),
Group(PredSeq),
}
impl PredSeq {
pub fn head_word(&self) -> &str {
match self.0.last().expect("pred_seq is non-empty") {
PredUnit::Word(parts) => parts.last().expect("pred_name is non-empty"),
PredUnit::Group(inner) => inner.head_word(),
}
}
}
#[derive(Debug, Clone, PartialEq)]
pub struct Tag {
pub pred: Vec<String>,
pub term: Term,
pub span: Range<usize>,
}
#[derive(Debug, Clone, PartialEq)]
pub struct Arg {
pub label: Option<String>,
pub term: Term,
pub span: Range<usize>,
}
#[derive(Debug, Clone, PartialEq)]
pub enum Term {
Unspecified,
Witness,
Number(f64),
Str(String),
Var(String),
Key(KeyTerm),
Name {
name: String,
rel_clauses: Vec<RelClause>,
},
Abstraction {
kind: AbsKind,
body: Box<Claim>,
},
Det {
det: Det,
restr: Restr,
},
}
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum AbsKind {
Event,
Fact,
Property,
Amount,
Concept,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum KeyTerm {
Me,
You,
We,
WeAll,
WeOthers,
YouAll,
This,
That,
Yonder,
ItA,
ItE,
ItI,
ItO,
ItU,
It,
Slot,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum Det {
Some,
The,
Every,
EveryThe,
Exactly(u32),
ExactlyThe(u32),
}
#[derive(Debug, Clone, PartialEq)]
pub struct Restr {
pub negated: bool,
pub kind: RestrKind,
pub rel_clauses: Vec<RelClause>,
pub span: Range<usize>,
}
#[derive(Debug, Clone, PartialEq)]
pub enum RestrKind {
Seq { seq: PredSeq, linked_args: Vec<Arg> },
Selected { pred: String, label: String },
}
#[derive(Debug, Clone, PartialEq)]
pub struct RelClause {
pub kind: RelKind,
pub body: ClauseBody,
pub span: Range<usize>,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum RelKind {
Where,
Also,
}
#[derive(Debug, Clone, PartialEq)]
pub enum ClauseBody {
Bare { negated: bool, seq: PredSeq },
Full(Box<Claim>),
}