2020-05-19 15:39:20 +02:00
|
|
|
pub trait FunctionDeclaration
|
|
|
|
{
|
2020-05-21 23:19:18 +02:00
|
|
|
fn display_name(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result;
|
2020-05-19 15:39:20 +02:00
|
|
|
fn arity(&self) -> usize;
|
2020-05-21 23:19:18 +02:00
|
|
|
fn matches_signature(&self, other_name: &str, other_arity: usize) -> bool;
|
2020-05-19 15:39:20 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
impl FunctionDeclaration for crate::FunctionDeclaration
|
|
|
|
{
|
2020-05-21 23:19:18 +02:00
|
|
|
fn display_name(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result
|
2020-05-19 15:39:20 +02:00
|
|
|
{
|
2020-05-21 23:19:18 +02:00
|
|
|
write!(formatter, "{}", self.name)
|
2020-05-19 15:39:20 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
fn arity(&self) -> usize
|
|
|
|
{
|
|
|
|
self.arity
|
|
|
|
}
|
2020-05-21 23:19:18 +02:00
|
|
|
|
|
|
|
fn matches_signature(&self, other_name: &str, other_arity: usize) -> bool
|
|
|
|
{
|
|
|
|
self.name == other_name && self.arity == other_arity
|
|
|
|
}
|
2020-05-19 15:39:20 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
pub trait PredicateDeclaration
|
|
|
|
{
|
2020-05-21 23:19:18 +02:00
|
|
|
fn display_name(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result;
|
2020-05-19 15:39:20 +02:00
|
|
|
fn arity(&self) -> usize;
|
2020-05-21 23:19:18 +02:00
|
|
|
fn matches_signature(&self, other_name: &str, other_arity: usize) -> bool;
|
2020-05-19 15:39:20 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
impl PredicateDeclaration for crate::PredicateDeclaration
|
|
|
|
{
|
2020-05-21 23:19:18 +02:00
|
|
|
fn display_name(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result
|
2020-05-19 15:39:20 +02:00
|
|
|
{
|
2020-05-21 23:19:18 +02:00
|
|
|
write!(formatter, "{}", self.name)
|
2020-05-19 15:39:20 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
fn arity(&self) -> usize
|
|
|
|
{
|
|
|
|
self.arity
|
|
|
|
}
|
2020-05-21 23:19:18 +02:00
|
|
|
|
|
|
|
fn matches_signature(&self, other_name: &str, other_arity: usize) -> bool
|
|
|
|
{
|
|
|
|
self.name == other_name && self.arity == other_arity
|
|
|
|
}
|
2020-05-19 15:39:20 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
pub trait VariableDeclaration
|
|
|
|
{
|
2020-05-21 23:19:18 +02:00
|
|
|
fn display_name(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result;
|
|
|
|
fn matches_name(&self, other_name: &str) -> bool;
|
2020-05-19 15:39:20 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
impl VariableDeclaration for crate::VariableDeclaration
|
|
|
|
{
|
2020-05-21 23:19:18 +02:00
|
|
|
fn display_name(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result
|
|
|
|
{
|
|
|
|
write!(formatter, "{}", self.name)
|
|
|
|
}
|
|
|
|
|
|
|
|
fn matches_name(&self, other_name: &str) -> bool
|
2020-05-19 15:39:20 +02:00
|
|
|
{
|
2020-05-21 23:19:18 +02:00
|
|
|
self.name == other_name
|
2020-05-19 15:39:20 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
pub trait Flavor
|
|
|
|
{
|
|
|
|
type FunctionDeclaration: FunctionDeclaration + std::cmp::Eq + std::cmp::Ord + std::hash::Hash;
|
|
|
|
type PredicateDeclaration:
|
|
|
|
PredicateDeclaration + std::cmp::Eq + std::cmp::Ord + std::hash::Hash;
|
2020-05-21 23:19:18 +02:00
|
|
|
type VariableDeclaration: VariableDeclaration + std::cmp::Eq + std::cmp::Ord + std::hash::Hash;
|
2020-05-19 15:39:20 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
pub struct DefaultFlavor;
|
|
|
|
|
|
|
|
impl Flavor for DefaultFlavor
|
|
|
|
{
|
|
|
|
type FunctionDeclaration = crate::FunctionDeclaration;
|
|
|
|
type PredicateDeclaration = crate::PredicateDeclaration;
|
|
|
|
type VariableDeclaration = crate::VariableDeclaration;
|
|
|
|
}
|