about summary refs log tree commit diff stats
path: root/cpp
diff options
context:
space:
mode:
Diffstat (limited to 'cpp')
-rw-r--r--cpp/000organization22
-rw-r--r--cpp/001test10
-rw-r--r--cpp/012run15
3 files changed, 20 insertions, 27 deletions
diff --git a/cpp/000organization b/cpp/000organization
index f410fcd9..ab1cee79 100644
--- a/cpp/000organization
+++ b/cpp/000organization
@@ -95,28 +95,6 @@
 // End Globals
 
 int main(int argc, char* argv[]) {
-  if (argc > 1) {
-    // Commandline Options
-    if (!is_equal(argv[1], "test")) {
-      setup();
-      for (int i = 1; i < argc; ++i) {
-        ifstream fin(argv[i]);
-        while (!fin.eof()) add_recipe(fin);
-        fin.close();
-      }
-    }
-  }
-
-//?   setup();
-//?   for (unordered_map<string, int>::iterator p = Recipe_number.begin(); p != Recipe_number.end(); ++p) { //? 1
-//?     cout << p->first << ": " << p->second << '\n'; //? 1
-//?   } //? 1
-  recipe_number r = Recipe_number[string("main")];
-//?   cout << "recipe " << r << '\n'; //? 1
-//?   START_TRACING_UNTIL_END_OF_SCOPE //? 1
-//?   DUMP(""); //? 1
-  if (r) run(r);
-  dump_memory();
   return 0;  // End Main
 }
 
diff --git a/cpp/001test b/cpp/001test
index ed10e97e..32014689 100644
--- a/cpp/001test
+++ b/cpp/001test
@@ -39,11 +39,11 @@ long Num_failures = 0;
     return; \
   }
 
-:(after "Commandline Options")
-  if (is_equal(argv[1], "test")) {
-    run_tests();
-    return 0;
-  }
+:(before "End Main")
+if (argc > 1 && is_equal(argv[1], "test")) {
+  run_tests();
+  return 0;
+}
 
 :(code)
 void run_tests() {
diff --git a/cpp/012run b/cpp/012run
index 1e38c15a..bd914faa 100644
--- a/cpp/012run
+++ b/cpp/012run
@@ -84,6 +84,21 @@ void run(routine rr) {
 #undef instructions
 }
 
+:(before "End Main")
+if (argc > 1) {
+  setup();
+  for (int i = 1; i < argc; ++i) {
+    ifstream fin(argv[i]);
+    while (!fin.eof()) add_recipe(fin);
+    fin.close();
+  }
+
+  recipe_number r = Recipe_number[string("main")];
+  if (r) run(r);
+  dump_memory();
+}
+
+:(code)
 vector<int> read_memory(reagent x) {
 //?   cout << "read_memory: " << x.to_string() << '\n'; //? 1
   vector<int> result;