From 64bd1c17e329ed588e041677f9a22b5fb8b08fb6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Patrick=20L=C3=BChne?= Date: Fri, 2 Jun 2017 14:59:13 +0200 Subject: [PATCH] Improved debug output. --- include/anthem/StatementVisitor.h | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/include/anthem/StatementVisitor.h b/include/anthem/StatementVisitor.h index 1d16980..5671eb3 100644 --- a/include/anthem/StatementVisitor.h +++ b/include/anthem/StatementVisitor.h @@ -39,14 +39,19 @@ struct StatementVisitor { void visit(const Clingo::AST::Program &program, const Clingo::AST::Statement &statement, std::vector &, Context &context) { - context.logger.log(output::Priority::Debug) << "program “" << program.name << "”"; + context.logger.log(output::Priority::Debug, statement.location) << "reading program “" << program.name << "”"; + + if (std::strcmp(program.name, "base") != 0) + throw LogicException(statement.location, "program parts currently unsupported"); if (!program.parameters.empty()) throw LogicException(statement.location, "program parameters currently unsupported"); } - void visit(const Clingo::AST::Rule &rule, const Clingo::AST::Statement &, std::vector &scopedFormulas, Context &) + void visit(const Clingo::AST::Rule &rule, const Clingo::AST::Statement &statement, std::vector &scopedFormulas, Context &context) { + context.logger.log(output::Priority::Debug, statement.location) << "reading rule"; + RuleContext ruleContext; ast::VariableStack variableStack; variableStack.push(&ruleContext.freeVariables); @@ -164,9 +169,12 @@ struct StatementVisitor context.visiblePredicateSignatures.emplace(); if (std::strlen(signature.name()) == 0) + { + context.logger.log(output::Priority::Debug, statement.location) << "showing no predicates by default"; return; + } - context.logger.log(output::Priority::Debug) << "showing “" << signature.name() << "/" << signature.arity() << "”"; + context.logger.log(output::Priority::Debug, statement.location) << "showing “" << signature.name() << "/" << signature.arity() << "”"; context.visiblePredicateSignatures.value().emplace_back(std::string(signature.name()), signature.arity()); }