Renamed internal variables for clarity.
This commit is contained in:
parent
95984f0447
commit
0285c1cbbb
@ -17,8 +17,8 @@ int main(int argc, char **argv)
|
|||||||
("help,h", "Display this help message")
|
("help,h", "Display this help message")
|
||||||
("version,v", "Display version information")
|
("version,v", "Display version information")
|
||||||
("input,i", po::value<std::vector<std::string>>(), "Input files")
|
("input,i", po::value<std::vector<std::string>>(), "Input files")
|
||||||
("simplify,s", po::bool_switch(&context.simplify), "Simplify the output")
|
("simplify,s", po::bool_switch(&context.performSimplification), "Simplify the output")
|
||||||
("complete,c", po::bool_switch(&context.complete), "Perform completion")
|
("complete,c", po::bool_switch(&context.performCompletion), "Perform completion")
|
||||||
("color", po::value<std::string>()->default_value("auto"), "Colorize output (always, never, auto)")
|
("color", po::value<std::string>()->default_value("auto"), "Colorize output (always, never, auto)")
|
||||||
("log-priority,p", po::value<std::string>()->default_value("warning"), "Log messages starting from this priority (debug, info, warning, error)");
|
("log-priority,p", po::value<std::string>()->default_value("warning"), "Log messages starting from this priority (debug, info, warning, error)");
|
||||||
|
|
||||||
|
@ -26,8 +26,8 @@ struct Context
|
|||||||
|
|
||||||
output::Logger logger;
|
output::Logger logger;
|
||||||
|
|
||||||
bool simplify = false;
|
bool performSimplification = false;
|
||||||
bool complete = false;
|
bool performCompletion = false;
|
||||||
|
|
||||||
std::experimental::optional<std::vector<ast::PredicateSignature>> visiblePredicateSignatures;
|
std::experimental::optional<std::vector<ast::PredicateSignature>> visiblePredicateSignatures;
|
||||||
};
|
};
|
||||||
|
@ -58,13 +58,13 @@ void translate(const char *fileName, std::istream &stream, Context &context)
|
|||||||
|
|
||||||
Clingo::parse_program(fileContent.c_str(), translateStatement, logger);
|
Clingo::parse_program(fileContent.c_str(), translateStatement, logger);
|
||||||
|
|
||||||
if (context.simplify)
|
if (context.performSimplification)
|
||||||
for (auto &scopedFormula : scopedFormulas)
|
for (auto &scopedFormula : scopedFormulas)
|
||||||
simplify(scopedFormula.formula);
|
simplify(scopedFormula.formula);
|
||||||
|
|
||||||
ast::PrintContext printContext;
|
ast::PrintContext printContext;
|
||||||
|
|
||||||
if (!context.complete)
|
if (!context.performCompletion)
|
||||||
{
|
{
|
||||||
if (context.visiblePredicateSignatures)
|
if (context.visiblePredicateSignatures)
|
||||||
context.logger.log(output::Priority::Warning) << "#show statements are ignored because completion is not enabled";
|
context.logger.log(output::Priority::Warning) << "#show statements are ignored because completion is not enabled";
|
||||||
@ -81,7 +81,7 @@ void translate(const char *fileName, std::istream &stream, Context &context)
|
|||||||
auto completedFormulas = complete(std::move(scopedFormulas), context);
|
auto completedFormulas = complete(std::move(scopedFormulas), context);
|
||||||
|
|
||||||
// TODO: rethink simplification steps
|
// TODO: rethink simplification steps
|
||||||
if (context.simplify)
|
if (context.performSimplification)
|
||||||
for (auto &completedFormula : completedFormulas)
|
for (auto &completedFormula : completedFormulas)
|
||||||
simplify(completedFormula);
|
simplify(completedFormula);
|
||||||
|
|
||||||
|
@ -16,8 +16,8 @@ TEST_CASE("[completion] Rules are completed", "[completion]")
|
|||||||
|
|
||||||
anthem::output::Logger logger(output, errors);
|
anthem::output::Logger logger(output, errors);
|
||||||
anthem::Context context(std::move(logger));
|
anthem::Context context(std::move(logger));
|
||||||
context.simplify = true;
|
context.performSimplification = true;
|
||||||
context.complete = true;
|
context.performCompletion = true;
|
||||||
|
|
||||||
SECTION("predicate in single rule head")
|
SECTION("predicate in single rule head")
|
||||||
{
|
{
|
||||||
|
@ -16,8 +16,8 @@ TEST_CASE("[hidden predicate elimination] Hidden predicates are correctly elimin
|
|||||||
|
|
||||||
anthem::output::Logger logger(output, errors);
|
anthem::output::Logger logger(output, errors);
|
||||||
anthem::Context context(std::move(logger));
|
anthem::Context context(std::move(logger));
|
||||||
context.simplify = true;
|
context.performSimplification = true;
|
||||||
context.complete = true;
|
context.performCompletion = true;
|
||||||
|
|
||||||
SECTION("simple example (positive 0-ary predicate)")
|
SECTION("simple example (positive 0-ary predicate)")
|
||||||
{
|
{
|
||||||
|
@ -16,8 +16,8 @@ TEST_CASE("[simplification] Rules are simplified correctly", "[simplification]")
|
|||||||
|
|
||||||
anthem::output::Logger logger(output, errors);
|
anthem::output::Logger logger(output, errors);
|
||||||
anthem::Context context(std::move(logger));
|
anthem::Context context(std::move(logger));
|
||||||
context.simplify = true;
|
context.performSimplification = true;
|
||||||
context.complete = false;
|
context.performCompletion = false;
|
||||||
|
|
||||||
SECTION("example 1")
|
SECTION("example 1")
|
||||||
{
|
{
|
||||||
|
@ -16,8 +16,8 @@ TEST_CASE("[translation] Rules are translated correctly", "[translation]")
|
|||||||
|
|
||||||
anthem::output::Logger logger(output, errors);
|
anthem::output::Logger logger(output, errors);
|
||||||
anthem::Context context(std::move(logger));
|
anthem::Context context(std::move(logger));
|
||||||
context.simplify = false;
|
context.performSimplification = false;
|
||||||
context.complete = false;
|
context.performCompletion = false;
|
||||||
|
|
||||||
SECTION("simple example 1")
|
SECTION("simple example 1")
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user