pub type PredicateId = u32;
pub type ArgumentId = u32;
#[derive(Clone, Copy, Debug)]
pub struct ModalTag(pub PredicateId);
#[derive(Clone, Copy, Debug, Eq, Ord, PartialEq, PartialOrd)]
pub enum Conversion {
Swap12,
Swap13,
Swap14,
Swap15,
}
#[derive(Clone, Copy, Debug, Eq, Ord, PartialEq, PartialOrd)]
pub enum Connective {
And,
Or,
Iff,
Xor,
}
#[derive(Clone, Copy, Debug, Eq, Ord, PartialEq, PartialOrd)]
pub enum Determiner {
Indefinite,
Definite,
Every,
EveryThe,
}
#[derive(Clone, Copy, Debug, Eq, Ord, PartialEq, PartialOrd)]
pub enum AbstractionKind {
Event,
Fact,
Property,
Amount,
Concept,
}
#[derive(Clone, Copy, Debug, Eq, Ord, PartialEq, PartialOrd)]
pub enum RelClauseKind {
Restrictive,
Incidental,
}
#[derive(Clone, Debug)]
pub struct RelClause {
pub kind: RelClauseKind,
pub body_sentence: u32,
}
#[derive(Clone, Copy, Debug, Eq, Ord, PartialEq, PartialOrd)]
pub enum Marker {
It,
Slot,
Witness,
}
#[derive(Clone, Copy, Debug, Eq, Ord, PartialEq, PartialOrd)]
pub enum Pronoun {
Me,
You,
We,
WeAll,
WeOthers,
YouAll,
This,
That,
Yonder,
ItA,
ItE,
ItI,
ItO,
ItU,
}
impl Pronoun {
pub fn as_str(&self) -> &'static str {
match self {
Pronoun::Me => "me",
Pronoun::You => "you",
Pronoun::We => "we",
Pronoun::WeAll => "we_all",
Pronoun::WeOthers => "we_others",
Pronoun::YouAll => "you_all",
Pronoun::This => "this",
Pronoun::That => "that",
Pronoun::Yonder => "yonder",
Pronoun::ItA => "it_a",
Pronoun::ItE => "it_e",
Pronoun::ItI => "it_i",
Pronoun::ItO => "it_o",
Pronoun::ItU => "it_u",
}
}
pub const ALL: [Pronoun; 14] = [
Pronoun::Me,
Pronoun::You,
Pronoun::We,
Pronoun::WeAll,
Pronoun::WeOthers,
Pronoun::YouAll,
Pronoun::This,
Pronoun::That,
Pronoun::Yonder,
Pronoun::ItA,
Pronoun::ItE,
Pronoun::ItI,
Pronoun::ItO,
Pronoun::ItU,
];
}
#[derive(Clone, Debug)]
pub enum Argument {
Variable(String),
Marker(Marker),
Pronoun(Pronoun),
Description((Determiner, PredicateId)),
Name(String),
QuotedLiteral(String),
Unspecified,
Tagged((u8, ArgumentId)),
ModalTagged((ModalTag, ArgumentId)),
Restricted((ArgumentId, RelClause)),
Number(f64),
QuantifiedDescription((u32, Determiner, PredicateId)),
}
#[derive(Clone, Debug)]
pub enum Predicate {
Root(String),
Pair((PredicateId, PredicateId)),
Converted((Conversion, PredicateId)),
Negated(PredicateId),
Grouped(PredicateId),
WithArgs((PredicateId, Vec<ArgumentId>)),
Abstraction((AbstractionKind, u32)),
}
#[derive(Clone, Copy, Debug, Eq, Ord, PartialEq, PartialOrd)]
pub enum Tense {
Past,
Now,
Future,
}
#[derive(Clone, Copy, Debug, Eq, Ord, PartialEq, PartialOrd)]
pub enum DeonticMood {
Obligation,
Permission,
}
#[derive(Clone, Debug)]
pub struct Proposition {
pub relation: PredicateId,
pub terms: Vec<ArgumentId>,
pub x1_present: bool,
pub negated: bool,
pub tense: Option<Tense>,
pub deontic: Option<DeonticMood>,
}
#[derive(Clone, Debug)]
pub enum SentenceConnective {
Implies,
And,
Afterthought(Connective),
}
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
pub enum BlockQuant {
ExactCount(u32),
ExactCountDefinite(u32),
UniversalDefinite,
}
#[derive(Clone, Debug)]
pub enum Sentence {
Simple(Proposition),
Connected((SentenceConnective, u32, u32)),
Prenex((Vec<String>, u32)),
Quantified((BlockQuant, String, PredicateId, Option<u32>, u32)),
}
#[derive(Clone, Debug)]
pub struct AstBuffer {
pub predicates: Vec<Predicate>,
pub arguments: Vec<Argument>,
pub sentences: Vec<Sentence>,
pub roots: Vec<u32>,
}
#[derive(Clone, Debug)]
pub struct ParseError {
pub message: String,
pub line: u32,
pub column: u32,
}
#[derive(Clone, Debug)]
pub struct ParseResult {
pub buffer: AstBuffer,
pub errors: Vec<ParseError>,
}