about summary refs log tree commit diff stats
path: root/cpp
diff options
context:
space:
mode:
Diffstat (limited to 'cpp')
-rw-r--r--cpp/010vm99
-rw-r--r--cpp/makefile2
2 files changed, 50 insertions, 51 deletions
diff --git a/cpp/010vm b/cpp/010vm
index c233f127..032e1874 100644
--- a/cpp/010vm
+++ b/cpp/010vm
@@ -154,62 +154,61 @@ Next_recipe_number = 1000;  // consistent new numbers for each test
 //: Helpers
 
 :(code)
-// indent methods to avoid generating prototypes for them
-  instruction::instruction() :is_label(false), operation(IDLE) {}
-  void instruction::clear() { is_label=false; label.clear(); operation=IDLE; ingredients.clear(); products.clear(); }
+instruction::instruction() :is_label(false), operation(IDLE) {}
+void instruction::clear() { is_label=false; label.clear(); operation=IDLE; ingredients.clear(); products.clear(); }
 
-  // Reagents have the form <name>:<type>:<type>:.../<property>/<property>/...
-  reagent::reagent(string s) :value(0), initialized(false) {
-    istringstream in(s);
-    in >> std::noskipws;
-    // properties
-    while (!in.eof()) {
-      istringstream row(slurp_until(in, '/'));
-      row >> std::noskipws;
-      string name = slurp_until(row, ':');
-      vector<string> values;
-      while (!row.eof())
-        values.push_back(slurp_until(row, ':'));
-      properties.push_back(pair<string, vector<string> >(name, values));
-    }
-    // structures for the first row of properties
-    name = properties[0].first;
-    for (size_t i = 0; i < properties[0].second.size(); ++i) {
-      types.push_back(Type_number[properties[0].second[i]]);
-    }
-    if (name == "_" && types.empty()) {
-      types.push_back(0);
-      properties[0].second.push_back("dummy");
-    }
+// Reagents have the form <name>:<type>:<type>:.../<property>/<property>/...
+reagent::reagent(string s) :value(0), initialized(false) {
+  istringstream in(s);
+  in >> std::noskipws;
+  // properties
+  while (!in.eof()) {
+    istringstream row(slurp_until(in, '/'));
+    row >> std::noskipws;
+    string name = slurp_until(row, ':');
+    vector<string> values;
+    while (!row.eof())
+      values.push_back(slurp_until(row, ':'));
+    properties.push_back(pair<string, vector<string> >(name, values));
   }
-  reagent::reagent() :value(0), initialized(false) {
-    // The first property is special, so ensure we always have it.
-    // Other properties can be pushed back, but the first must always be
-    // assigned to.
-    properties.push_back(pair<string, vector<string> >("", vector<string>()));
+  // structures for the first row of properties
+  name = properties[0].first;
+  for (size_t i = 0; i < properties[0].second.size(); ++i) {
+    types.push_back(Type_number[properties[0].second[i]]);
   }
-  string reagent::to_string() const {
-    ostringstream out;
-    out << "{name: \"" << name << "\", value: " << value << ", type: ";
-    for (size_t i = 0; i < types.size(); ++i) {
-      out << types[i];
-      if (i < types.size()-1) out << "-";
-    }
-    if (!properties.empty()) {
-      out << ", properties: [";
-      for (size_t i = 0; i < properties.size(); ++i) {
-        out << "\"" << properties[i].first << "\": ";
-        for (size_t j = 0; j < properties[i].second.size(); ++j) {
-          out << "\"" << properties[i].second[j] << "\"";
-          if (j < properties[i].second.size()-1) out << ":";
-        }
-        if (i < properties.size()-1) out << ", ";
-        else out << "]";
+  if (name == "_" && types.empty()) {
+    types.push_back(0);
+    properties[0].second.push_back("dummy");
+  }
+}
+reagent::reagent() :value(0), initialized(false) {
+  // The first property is special, so ensure we always have it.
+  // Other properties can be pushed back, but the first must always be
+  // assigned to.
+  properties.push_back(pair<string, vector<string> >("", vector<string>()));
+}
+string reagent::to_string() const {
+  ostringstream out;
+  out << "{name: \"" << name << "\", value: " << value << ", type: ";
+  for (size_t i = 0; i < types.size(); ++i) {
+    out << types[i];
+    if (i < types.size()-1) out << "-";
+  }
+  if (!properties.empty()) {
+    out << ", properties: [";
+    for (size_t i = 0; i < properties.size(); ++i) {
+      out << "\"" << properties[i].first << "\": ";
+      for (size_t j = 0; j < properties[i].second.size(); ++j) {
+        out << "\"" << properties[i].second[j] << "\"";
+        if (j < properties[i].second.size()-1) out << ":";
       }
+      if (i < properties.size()-1) out << ", ";
+      else out << "]";
     }
-    out << "}";
-    return out.str();
   }
+  out << "}";
+  return out.str();
+}
 
 string slurp_until(istream& in, char delim) {
   ostringstream out;
diff --git a/cpp/makefile b/cpp/makefile
index 470c20c0..b062b288 100644
--- a/cpp/makefile
+++ b/cpp/makefile
@@ -22,7 +22,7 @@ test: mu
 	./mu test
 
 function_list: mu.cc
-	@grep -h "^[^ #].*) {" mu.cc |perl -pwe 's/ {.*/;/' > function_list
+	@grep -h "^[^ #].*) {" mu.cc |grep -v ":.*(" |perl -pwe 's/ {.*/;/' > function_list
 	@grep -h "^[[:space:]]*TEST(" mu.cc |perl -pwe 's/^\s*TEST\((.*)\)$$/void test_$$1();/' >> function_list
 
 test_list: mu.cc