about summary refs log tree commit diff stats
path: root/054dilated_reagent.cc
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2016-02-21 20:30:02 -0800
committerKartik K. Agaram <vc@akkartik.com>2016-02-21 20:40:06 -0800
commitc4e143d6ea0635cdb164cec1c62afd7461e605ad (patch)
tree06fbb672ce95f1d5152c113cdb40685148b57d0c /054dilated_reagent.cc
parentf22250a174d5ad5abf8bf99ad140ced52563aee2 (diff)
downloadmu-c4e143d6ea0635cdb164cec1c62afd7461e605ad.tar.gz
2681 - drop reagent types from reagent properties
All my attempts at staging this change failed with this humongous commit
that took all day and involved debugging three monstrous bugs. Two of
the bugs had to do with forgetting to check the type name in the
implementation of shape-shifting recipes. Bug #2 in particular would
cause core tests in layer 59 to fail -- only when I loaded up edit/! It
got me to just hack directly on mu.cc until I figured out the cause
(snapshot saved in mu.cc.modified). The problem turned out to be that I
accidentally saved a type ingredient in the Type table during
specialization. Now I know that that can be very bad.

I've checked the traces for any stray type numbers (rather than names).

I also found what might be a bug from last November (labeled TODO), but
we'll verify after this commit.
Diffstat (limited to '054dilated_reagent.cc')
-rw-r--r--054dilated_reagent.cc27
1 files changed, 17 insertions, 10 deletions
diff --git a/054dilated_reagent.cc b/054dilated_reagent.cc
index cab72cfb..f7b772a3 100644
--- a/054dilated_reagent.cc
+++ b/054dilated_reagent.cc
@@ -7,7 +7,7 @@
 recipe main [
   {1: number, foo: bar} <- copy 34
 ]
-+parse:   product: {"1": "number", "foo": "bar"}
++parse:   product: 1: "number", {"foo": "bar"}
 
 :(scenario load_trailing_space_after_curly_bracket)
 recipe main [
@@ -22,7 +22,7 @@ recipe main [
 recipe main [
   {1: number, foo: bar} <- copy 34  # test comment
 ]
-+parse:   product: {"1": "number", "foo": "bar"}
++parse:   product: 1: "number", {"foo": "bar"}
 $error: 0
 
 :(scenario dilated_reagent_with_comment_immediately_following)
@@ -97,6 +97,21 @@ if (s.at(0) == '{') {
   istringstream in(s);
   in >> std::noskipws;
   in.get();  // skip '{'
+  name = slurp_key(in);
+  if (name.empty()) {
+    raise_error << "invalid reagent " << s << " without a name\n";
+    return;
+  }
+  if (name == "}") {
+    raise_error << "invalid empty reagent " << s << '\n';
+    return;
+  }
+  {
+    string_tree* value = new string_tree(next_word(in));
+    // End Parsing Reagent Type Property(value)
+    type = new_type_tree(value);
+    delete value;
+  }
   while (has_data(in)) {
     string key = slurp_key(in);
     if (key.empty()) continue;
@@ -105,14 +120,6 @@ if (s.at(0) == '{') {
     // End Parsing Reagent Property(value)
     properties.push_back(pair<string, string_tree*>(key, value));
   }
-  // structures for the first row of properties
-  name = properties.at(0).first;
-  string type_name = properties.at(0).second->value;
-  if (!contains_key(Type_ordinal, type_name)) {
-      // this type can't be an integer literal
-    put(Type_ordinal, type_name, Next_type_ordinal++);
-  }
-  type = new_type_tree(properties.at(0).second);
   return;
 }