Rename types for consistency
This commit is contained in:
parent
242435c698
commit
f0958b100e
30
src/ast.rs
30
src/ast.rs
@ -2,12 +2,12 @@
|
||||
|
||||
pub enum BinaryOperator
|
||||
{
|
||||
Addition,
|
||||
Subtraction,
|
||||
Multiplication,
|
||||
Division,
|
||||
Add,
|
||||
Subtract,
|
||||
Multiply,
|
||||
Divide,
|
||||
Modulo,
|
||||
Exponentiation,
|
||||
Exponentiate,
|
||||
}
|
||||
|
||||
pub enum ComparisonOperator
|
||||
@ -23,7 +23,7 @@ pub enum ComparisonOperator
|
||||
pub enum UnaryOperator
|
||||
{
|
||||
AbsoluteValue,
|
||||
Negation,
|
||||
Negative,
|
||||
}
|
||||
|
||||
// Primitives
|
||||
@ -153,13 +153,7 @@ pub struct Variable
|
||||
|
||||
// Formulas
|
||||
|
||||
pub struct Biconditional
|
||||
{
|
||||
pub left: Box<Formula>,
|
||||
pub right: Box<Formula>,
|
||||
}
|
||||
|
||||
pub struct Comparison
|
||||
pub struct Compare
|
||||
{
|
||||
pub operator: ComparisonOperator,
|
||||
pub left: Box<Term>,
|
||||
@ -178,6 +172,12 @@ pub struct ForAll
|
||||
pub argument: Box<Formula>,
|
||||
}
|
||||
|
||||
pub struct IfAndOnlyIf
|
||||
{
|
||||
pub left: Box<Formula>,
|
||||
pub right: Box<Formula>,
|
||||
}
|
||||
|
||||
pub struct Implies
|
||||
{
|
||||
pub antecedent: Box<Formula>,
|
||||
@ -210,11 +210,11 @@ pub type Terms = Vec<Box<Term>>;
|
||||
pub enum Formula
|
||||
{
|
||||
And(Formulas),
|
||||
Biconditional(Biconditional),
|
||||
Boolean(bool),
|
||||
Comparison(Comparison),
|
||||
Compare(Compare),
|
||||
Exists(Exists),
|
||||
ForAll(ForAll),
|
||||
IfAndOnlyIf(IfAndOnlyIf),
|
||||
Implies(Implies),
|
||||
Not(Box<Formula>),
|
||||
Or(Formulas),
|
||||
|
@ -48,16 +48,16 @@ impl Precedence for crate::Term
|
||||
| Self::String(_)
|
||||
| Self::Variable(_)
|
||||
=> 0,
|
||||
Self::UnaryOperation(crate::UnaryOperation{operator: crate::UnaryOperator::Negation, ..})
|
||||
Self::UnaryOperation(crate::UnaryOperation{operator: crate::UnaryOperator::Negative, ..})
|
||||
=> 1,
|
||||
Self::BinaryOperation(crate::BinaryOperation{operator: crate::BinaryOperator::Exponentiation, ..})
|
||||
Self::BinaryOperation(crate::BinaryOperation{operator: crate::BinaryOperator::Exponentiate, ..})
|
||||
=> 2,
|
||||
Self::BinaryOperation(crate::BinaryOperation{operator: crate::BinaryOperator::Multiplication, ..})
|
||||
| Self::BinaryOperation(crate::BinaryOperation{operator: crate::BinaryOperator::Division, ..})
|
||||
Self::BinaryOperation(crate::BinaryOperation{operator: crate::BinaryOperator::Multiply, ..})
|
||||
| Self::BinaryOperation(crate::BinaryOperation{operator: crate::BinaryOperator::Divide, ..})
|
||||
| Self::BinaryOperation(crate::BinaryOperation{operator: crate::BinaryOperator::Modulo, ..})
|
||||
=> 3,
|
||||
Self::BinaryOperation(crate::BinaryOperation{operator: crate::BinaryOperator::Addition, ..})
|
||||
| Self::BinaryOperation(crate::BinaryOperation{operator: crate::BinaryOperator::Subtraction, ..})
|
||||
Self::BinaryOperation(crate::BinaryOperation{operator: crate::BinaryOperator::Add, ..})
|
||||
| Self::BinaryOperation(crate::BinaryOperation{operator: crate::BinaryOperator::Subtract, ..})
|
||||
=> 4,
|
||||
Self::UnaryOperation(crate::UnaryOperation{operator: crate::UnaryOperator::AbsoluteValue, ..})
|
||||
=> 5,
|
||||
@ -73,7 +73,7 @@ impl Precedence for crate::Formula
|
||||
{
|
||||
Self::Predicate(_)
|
||||
| Self::Boolean(_)
|
||||
| Self::Comparison(_)
|
||||
| Self::Compare(_)
|
||||
=> 0,
|
||||
Self::Exists(_)
|
||||
| Self::ForAll(_)
|
||||
@ -86,7 +86,7 @@ impl Precedence for crate::Formula
|
||||
=> 4,
|
||||
Self::Implies(_)
|
||||
=> 5,
|
||||
Self::Biconditional(_)
|
||||
Self::IfAndOnlyIf(_)
|
||||
=> 6,
|
||||
}
|
||||
}
|
||||
@ -156,19 +156,19 @@ impl<'term> std::fmt::Debug for TermDisplay<'term>
|
||||
|
||||
Ok(())
|
||||
},
|
||||
crate::Term::BinaryOperation(crate::BinaryOperation{operator: crate::BinaryOperator::Addition, left, right})
|
||||
crate::Term::BinaryOperation(crate::BinaryOperation{operator: crate::BinaryOperator::Add, left, right})
|
||||
=> write!(format, "{:?} + {:?}", display_term(left, precedence), display_term(right, precedence)),
|
||||
crate::Term::BinaryOperation(crate::BinaryOperation{operator: crate::BinaryOperator::Subtraction, left, right})
|
||||
crate::Term::BinaryOperation(crate::BinaryOperation{operator: crate::BinaryOperator::Subtract, left, right})
|
||||
=> write!(format, "{:?} - {:?}", display_term(left, precedence), display_term(right, precedence)),
|
||||
crate::Term::BinaryOperation(crate::BinaryOperation{operator: crate::BinaryOperator::Multiplication, left, right})
|
||||
crate::Term::BinaryOperation(crate::BinaryOperation{operator: crate::BinaryOperator::Multiply, left, right})
|
||||
=> write!(format, "{:?} * {:?}", display_term(left, precedence), display_term(right, precedence)),
|
||||
crate::Term::BinaryOperation(crate::BinaryOperation{operator: crate::BinaryOperator::Division, left, right})
|
||||
crate::Term::BinaryOperation(crate::BinaryOperation{operator: crate::BinaryOperator::Divide, left, right})
|
||||
=> write!(format, "{:?} / {:?}", display_term(left, precedence), display_term(right, precedence)),
|
||||
crate::Term::BinaryOperation(crate::BinaryOperation{operator: crate::BinaryOperator::Modulo, left, right})
|
||||
=> write!(format, "{:?} % {:?}", display_term(left, precedence), display_term(right, precedence)),
|
||||
crate::Term::BinaryOperation(crate::BinaryOperation{operator: crate::BinaryOperator::Exponentiation, left, right})
|
||||
crate::Term::BinaryOperation(crate::BinaryOperation{operator: crate::BinaryOperator::Exponentiate, left, right})
|
||||
=> write!(format, "{:?} ** {:?}", display_term(left, precedence), display_term(right, precedence)),
|
||||
crate::Term::UnaryOperation(crate::UnaryOperation{operator: crate::UnaryOperator::Negation, argument})
|
||||
crate::Term::UnaryOperation(crate::UnaryOperation{operator: crate::UnaryOperator::Negative, argument})
|
||||
=> write!(format, "-{:?}", display_term(argument, precedence)),
|
||||
crate::Term::UnaryOperation(crate::UnaryOperation{operator: crate::UnaryOperator::AbsoluteValue, argument})
|
||||
=> write!(format, "|{:?}|", display_term(argument, precedence)),
|
||||
@ -260,19 +260,19 @@ impl<'formula> std::fmt::Debug for FormulaDisplay<'formula>
|
||||
},
|
||||
crate::Formula::Implies(crate::Implies{antecedent, implication})
|
||||
=> write!(format, "{:?} -> {:?}", display_formula(antecedent, precedence), display_formula(implication, precedence))?,
|
||||
crate::Formula::Biconditional(crate::Biconditional{left, right})
|
||||
crate::Formula::IfAndOnlyIf(crate::IfAndOnlyIf{left, right})
|
||||
=> write!(format, "{:?} <-> {:?}", display_formula(left, precedence), display_formula(right, precedence))?,
|
||||
crate::Formula::Comparison(crate::Comparison{operator: crate::ComparisonOperator::Less, left, right})
|
||||
crate::Formula::Compare(crate::Compare{operator: crate::ComparisonOperator::Less, left, right})
|
||||
=> write!(format, "{:?} < {:?}", display_term(left, 1000), display_term(right, 1000))?,
|
||||
crate::Formula::Comparison(crate::Comparison{operator: crate::ComparisonOperator::LessOrEqual, left, right})
|
||||
crate::Formula::Compare(crate::Compare{operator: crate::ComparisonOperator::LessOrEqual, left, right})
|
||||
=> write!(format, "{:?} <= {:?}", display_term(left, 1000), display_term(right, 1000))?,
|
||||
crate::Formula::Comparison(crate::Comparison{operator: crate::ComparisonOperator::Greater, left, right})
|
||||
crate::Formula::Compare(crate::Compare{operator: crate::ComparisonOperator::Greater, left, right})
|
||||
=> write!(format, "{:?} > {:?}", display_term(left, 1000), display_term(right, 1000))?,
|
||||
crate::Formula::Comparison(crate::Comparison{operator: crate::ComparisonOperator::GreaterOrEqual, left, right})
|
||||
crate::Formula::Compare(crate::Compare{operator: crate::ComparisonOperator::GreaterOrEqual, left, right})
|
||||
=> write!(format, "{:?} >= {:?}", display_term(left, 1000), display_term(right, 1000))?,
|
||||
crate::Formula::Comparison(crate::Comparison{operator: crate::ComparisonOperator::Equal, left, right})
|
||||
crate::Formula::Compare(crate::Compare{operator: crate::ComparisonOperator::Equal, left, right})
|
||||
=> write!(format, "{:?} = {:?}", display_term(left, 1000), display_term(right, 1000))?,
|
||||
crate::Formula::Comparison(crate::Comparison{operator: crate::ComparisonOperator::NotEqual, left, right})
|
||||
crate::Formula::Compare(crate::Compare{operator: crate::ComparisonOperator::NotEqual, left, right})
|
||||
=> write!(format, "{:?} != {:?}", display_term(left, 1000), display_term(right, 1000))?,
|
||||
crate::Formula::Boolean(true) => write!(format, "#true")?,
|
||||
crate::Formula::Boolean(false) => write!(format, "#false")?,
|
||||
|
Loading…
x
Reference in New Issue
Block a user