about summary refs log tree commit diff stats
path: root/cpp
diff options
context:
space:
mode:
Diffstat (limited to 'cpp')
-rw-r--r--cpp/.traces/parse_properties3
-rw-r--r--cpp/010vm20
-rw-r--r--cpp/011load6
3 files changed, 27 insertions, 2 deletions
diff --git a/cpp/.traces/parse_properties b/cpp/.traces/parse_properties
new file mode 100644
index 00000000..c8c059b4
--- /dev/null
+++ b/cpp/.traces/parse_properties
@@ -0,0 +1,3 @@
+parse/0: instruction: 1
+parse/0:   ingredient: {name: "23", type: 0}
+parse/0:   product: {name: "1", type: 1-2, property: deref:}
diff --git a/cpp/010vm b/cpp/010vm
index c5012c93..cf064581 100644
--- a/cpp/010vm
+++ b/cpp/010vm
@@ -141,7 +141,12 @@ void setup_recipes() {
       types.push_back(Type_number[t]);
     }
 //?     cout << types.size() << '\n'; //? 1
-    // todo: properties
+    // properties
+    while (!in.eof()) {
+      istringstream prop(slurp_until(in, '/'));
+      string name = slurp_until(prop, ':');
+      properties.push_back(pair<string, property>(name, property()));
+    }
   }
   string reagent::to_string() {
     ostringstream out;
@@ -150,7 +155,17 @@ void setup_recipes() {
       out << types[i];
       if (i < types.size()-1) out << "-";
     }
-    out << "}";  // todo: properties
+    if (!properties.empty()) {
+      out << ", property: ";
+      for (size_t i = 0; i < properties.size(); ++i) {
+        out << properties[i].first << ":";
+        for (size_t j = 0; j < properties[i].second.values.size(); ++j) {
+          out << properties[i].second.values[j];
+          if (j < properties[i].second.values.size()-1) out << ":";
+        }
+      }
+    }
+    out << "}";
     return out.str();
   }
 
@@ -159,6 +174,7 @@ string slurp_until(istream& in, char delim) {
   char c;
   while (in >> c) {
     if (c == delim) {
+      // drop the delim
       break;
     }
     out << c;
diff --git a/cpp/011load b/cpp/011load
index 4c019c1c..b7fa4a20 100644
--- a/cpp/011load
+++ b/cpp/011load
@@ -164,3 +164,9 @@ recipe main [
 +parse:   ingredient: {name: "4", type: 1}
 +parse:   product: {name: "1", type: 1}
 +parse:   product: {name: "2", type: 2-1}
+
+:(scenario parse_properties)
+recipe main [
+  1:integer:address/deref <- copy 23:literal
+]
++parse:   product: {name: "1", type: 1-2, property: deref:}