2020-02-04 16:45:06 +01:00
|
|
|
mod choose_value_in_term;
|
|
|
|
|
|
|
|
pub(crate) use choose_value_in_term::*;
|
2020-02-01 19:20:46 +01:00
|
|
|
|
2020-02-03 02:57:45 +01:00
|
|
|
pub(crate) trait AssignVariableDeclarationDomain
|
2020-02-01 21:59:36 +01:00
|
|
|
{
|
2020-02-03 02:57:45 +01:00
|
|
|
fn assign_variable_declaration_domain(&self,
|
2020-02-04 16:45:06 +01:00
|
|
|
variable_declaration: &std::rc::Rc<foliage::VariableDeclaration>, domain: crate::Domain);
|
2020-02-01 21:59:36 +01:00
|
|
|
}
|
2020-02-01 19:20:46 +01:00
|
|
|
|
2020-02-03 02:57:45 +01:00
|
|
|
pub(crate) trait VariableDeclarationDomain
|
2020-02-01 21:59:36 +01:00
|
|
|
{
|
2020-02-03 02:57:45 +01:00
|
|
|
fn variable_declaration_domain(&self,
|
2020-02-04 16:45:06 +01:00
|
|
|
variable_declaration: &std::rc::Rc<foliage::VariableDeclaration>) -> Option<crate::Domain>;
|
2020-02-01 21:59:36 +01:00
|
|
|
}
|
2020-02-01 19:20:46 +01:00
|
|
|
|
2020-02-03 02:57:45 +01:00
|
|
|
pub(crate) trait VariableDeclarationID
|
2020-02-01 19:20:46 +01:00
|
|
|
{
|
2020-02-03 02:57:45 +01:00
|
|
|
fn variable_declaration_id(&self,
|
|
|
|
variable_declaration: &std::rc::Rc<foliage::VariableDeclaration>) -> usize;
|
2020-02-01 19:20:46 +01:00
|
|
|
}
|
|
|
|
|
2020-02-03 02:57:45 +01:00
|
|
|
pub(crate) trait GetOrCreateFunctionDeclaration
|
2020-02-01 19:20:46 +01:00
|
|
|
{
|
2020-02-03 02:57:45 +01:00
|
|
|
fn get_or_create_function_declaration(&self, name: &str, arity: usize)
|
|
|
|
-> std::rc::Rc<foliage::FunctionDeclaration>;
|
2020-02-01 21:59:36 +01:00
|
|
|
}
|
|
|
|
|
2020-02-03 02:57:45 +01:00
|
|
|
pub(crate) trait GetOrCreatePredicateDeclaration
|
2020-02-01 21:59:36 +01:00
|
|
|
{
|
2020-02-03 02:57:45 +01:00
|
|
|
fn get_or_create_predicate_declaration(&self, name: &str, arity: usize)
|
|
|
|
-> std::rc::Rc<foliage::PredicateDeclaration>;
|
|
|
|
}
|
2020-02-01 19:20:46 +01:00
|
|
|
|
2020-02-03 02:57:45 +01:00
|
|
|
pub(crate) trait GetOrCreateVariableDeclaration
|
|
|
|
{
|
|
|
|
fn get_or_create_variable_declaration(&self, name: &str)
|
|
|
|
-> std::rc::Rc<foliage::VariableDeclaration>;
|
2020-02-01 21:59:36 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
pub(crate) fn translate_binary_operator(binary_operator: clingo::ast::BinaryOperator)
|
|
|
|
-> Result<foliage::BinaryOperator, crate::Error>
|
|
|
|
{
|
|
|
|
match binary_operator
|
|
|
|
{
|
|
|
|
clingo::ast::BinaryOperator::And
|
|
|
|
| clingo::ast::BinaryOperator::Or
|
|
|
|
| clingo::ast::BinaryOperator::Xor
|
|
|
|
=> return Err(crate::Error::new_unsupported_language_feature("binary logical operators")),
|
|
|
|
clingo::ast::BinaryOperator::Plus
|
2020-02-02 02:32:32 +01:00
|
|
|
=> Ok(foliage::BinaryOperator::Add),
|
2020-02-01 21:59:36 +01:00
|
|
|
clingo::ast::BinaryOperator::Minus
|
2020-02-02 02:32:32 +01:00
|
|
|
=> Ok(foliage::BinaryOperator::Subtract),
|
2020-02-01 21:59:36 +01:00
|
|
|
clingo::ast::BinaryOperator::Multiplication
|
2020-02-02 02:32:32 +01:00
|
|
|
=> Ok(foliage::BinaryOperator::Multiply),
|
2020-02-01 21:59:36 +01:00
|
|
|
clingo::ast::BinaryOperator::Division
|
2020-02-02 02:32:32 +01:00
|
|
|
=> Ok(foliage::BinaryOperator::Divide),
|
2020-02-01 21:59:36 +01:00
|
|
|
clingo::ast::BinaryOperator::Modulo
|
|
|
|
=> Ok(foliage::BinaryOperator::Modulo),
|
|
|
|
clingo::ast::BinaryOperator::Power
|
2020-02-02 02:32:32 +01:00
|
|
|
=> Ok(foliage::BinaryOperator::Exponentiate),
|
2020-02-01 19:20:46 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
pub(crate) fn translate_comparison_operator(comparison_operator: clingo::ast::ComparisonOperator)
|
2020-01-31 17:19:44 +01:00
|
|
|
-> foliage::ComparisonOperator
|
|
|
|
{
|
|
|
|
match comparison_operator
|
|
|
|
{
|
|
|
|
clingo::ast::ComparisonOperator::GreaterThan
|
|
|
|
=> foliage::ComparisonOperator::Greater,
|
|
|
|
clingo::ast::ComparisonOperator::LessThan
|
|
|
|
=> foliage::ComparisonOperator::Less,
|
|
|
|
clingo::ast::ComparisonOperator::LessEqual
|
|
|
|
=> foliage::ComparisonOperator::LessOrEqual,
|
|
|
|
clingo::ast::ComparisonOperator::GreaterEqual
|
|
|
|
=> foliage::ComparisonOperator::GreaterOrEqual,
|
|
|
|
clingo::ast::ComparisonOperator::NotEqual
|
|
|
|
=> foliage::ComparisonOperator::NotEqual,
|
|
|
|
clingo::ast::ComparisonOperator::Equal
|
|
|
|
=> foliage::ComparisonOperator::Equal,
|
|
|
|
}
|
|
|
|
}
|