summaryrefslogtreecommitdiff
path: root/impl/main.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'impl/main.cpp')
-rw-r--r--impl/main.cpp35
1 files changed, 21 insertions, 14 deletions
diff --git a/impl/main.cpp b/impl/main.cpp
index 664fb6f..9e34071 100644
--- a/impl/main.cpp
+++ b/impl/main.cpp
@@ -1,7 +1,7 @@
+#include "Log.hpp"
#include <iostream>
#include <vector>
#include <sstream>
-#include "Log.hpp"
#include "Complete.hpp"
#include "Expression.hpp"
#include "Operator.hpp"
@@ -98,21 +98,27 @@ void treeToSystem(pANTLR3_BASE_TREE node, EquationSystem<T>& system) {
typedef Complete<int> ZBar;
int main (int argc, char* argv[]) {
if (argc <= 3) {
- cout << "Usage: " << argv[0] << " filename [fixpoint strategy log]" << endl
+ cout << "Usage: " << argv[0] << " filename fixpoint strategy [log]" << endl
<< " fixpoint: naive | smart" << endl
<< " strategy: naive | repeat | smart" << endl
- << " log: [section[,section[,section[...]]]]" << endl;
+ << " log: section[,section[,section[...]]]" << endl;
exit(1);
}
- for (int i = 4; i < argc; ++i) {
- if (!strcmp(argv[i], "trace")) {
- log::trace.enabled(true);
- } else if (!strcmp(argv[i], "strategy")) {
- log::strategy.enabled(true);
- } else if (!strcmp(argv[i], "debug")) {
- log::debug.enabled(true);
- }
+ map<string,log::Logger*> loggers;
+ loggers["info"] = &log::info;
+ loggers["trace"] = &log::trace;
+ loggers["strategy"] = &log::strategy;
+ loggers["fixpoint"] = &log::fixpoint;
+ loggers["debug"] = &log::debug;
+
+ if (argc > 3) {
+ char* arg = argv[4];
+ char* str = strtok(arg, ",");
+ do {
+ if (loggers[str])
+ loggers[str]->enabled(true);
+ } while ((str = strtok(NULL, ",")) != NULL);
}
auto input = antlr3FileStreamNew((pANTLR3_UINT8)argv[1], ANTLR3_ENC_8BIT);
@@ -156,7 +162,7 @@ int main (int argc, char* argv[]) {
exit(1);
}
- log::debug << system;
+ log::debug << system << std::endl;
system.indexMaxExpressions(); // make reverse-lookup O(1) instead of O(n)
StableVariableAssignment<ZBar> result(system.variableCount(), infinity<ZBar>());
ConcreteMaxStrategy<ZBar> strategy(system);
@@ -169,11 +175,11 @@ int main (int argc, char* argv[]) {
s1.clear();
algorithm->maxFixpoint(system, strategy, result, s2, s1);
- log::debug << result;
+ log::debug << result << std::endl;
s2.clear();
changed = improvement->improve(system, strategy, result, s1, s2);
- log::debug << (changed ? "true" : "false");
+ log::debug << "Changed: " << (changed ? "true" : "false") << std::endl;
} while(changed);
cout << endl;
@@ -194,3 +200,4 @@ int main (int argc, char* argv[]) {
return 0;
}
+