Support exponentiation operator
Because of a bug in the Clingo API, the exponentation operator was not properly exposed to anthem. This updates Clingo to a version with a fixed API and adds proper support for exponentation within anthem along with a matching unit test.
This commit is contained in:
@@ -32,7 +32,8 @@ struct BinaryOperation
|
||||
Minus,
|
||||
Multiplication,
|
||||
Division,
|
||||
Modulo
|
||||
Modulo,
|
||||
Power
|
||||
};
|
||||
|
||||
explicit BinaryOperation(Operator operator_, Term &&left, Term &&right)
|
||||
|
@@ -23,6 +23,12 @@ ast::BinaryOperation::Operator translate(Clingo::AST::BinaryOperator binaryOpera
|
||||
{
|
||||
switch (binaryOperator)
|
||||
{
|
||||
case Clingo::AST::BinaryOperator::XOr:
|
||||
throw TranslationException(term.location, "binary operation “xor” currently unsupported");
|
||||
case Clingo::AST::BinaryOperator::Or:
|
||||
throw TranslationException(term.location, "binary operation “or” currently unsupported");
|
||||
case Clingo::AST::BinaryOperator::And:
|
||||
throw TranslationException(term.location, "binary operation “and” currently unsupported");
|
||||
case Clingo::AST::BinaryOperator::Plus:
|
||||
return ast::BinaryOperation::Operator::Plus;
|
||||
case Clingo::AST::BinaryOperator::Minus:
|
||||
@@ -33,11 +39,11 @@ ast::BinaryOperation::Operator translate(Clingo::AST::BinaryOperator binaryOpera
|
||||
return ast::BinaryOperation::Operator::Division;
|
||||
case Clingo::AST::BinaryOperator::Modulo:
|
||||
return ast::BinaryOperation::Operator::Modulo;
|
||||
default:
|
||||
throw TranslationException(term.location, "“binary operation” terms currently unsupported");
|
||||
case Clingo::AST::BinaryOperator::Power:
|
||||
return ast::BinaryOperation::Operator::Power;
|
||||
}
|
||||
|
||||
return ast::BinaryOperation::Operator::Plus;
|
||||
throw TranslationException(term.location, "unknown binary operation");
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
@@ -85,6 +85,8 @@ inline output::ColorStream &print(output::ColorStream &stream, BinaryOperation::
|
||||
return (stream << output::Operator("/"));
|
||||
case BinaryOperation::Operator::Modulo:
|
||||
return (stream << output::Operator("%"));
|
||||
case BinaryOperation::Operator::Power:
|
||||
return (stream << output::Operator("**"));
|
||||
}
|
||||
|
||||
return stream;
|
||||
|
Reference in New Issue
Block a user