about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2015-07-24 18:30:02 -0700
committerKartik K. Agaram <vc@akkartik.com>2015-07-24 18:30:02 -0700
commit4ce90b39d0481f6bb9773ea904f10313af559a5b (patch)
tree5124feb0ef3d5369df8318d8695b505af771c28d
parenteefde1b934044bce32db4ee2dce7f9917d7c840d (diff)
downloadmu-4ce90b39d0481f6bb9773ea904f10313af559a5b.tar.gz
1837
Don't die on unbalanced '{'.
I won't bother adding more tests for warnings. Suffice it to say that we
need to gradually eliminate all asserts that check for illegal mu code.
-rw-r--r--040brace.cc8
1 files changed, 4 insertions, 4 deletions
diff --git a/040brace.cc b/040brace.cc
index de7b6b23..0ed25262 100644
--- a/040brace.cc
+++ b/040brace.cc
@@ -106,7 +106,7 @@ void transform_braces(const recipe_ordinal r) {
     else if (inst.name.find("loop") != string::npos)
       target.set_value(open_braces.top()-index);
     else  // break instruction
-      target.set_value(matching_brace(open_braces.top(), braces) - index - 1);
+      target.set_value(matching_brace(open_braces.top(), braces, r) - index - 1);
     inst.ingredients.push_back(target);
     // log computed target
     if (inst.name.find("-if") != string::npos)
@@ -120,15 +120,15 @@ void transform_braces(const recipe_ordinal r) {
 
 // returns a signed integer not just so that we can return -1 but also to
 // enable future signed arithmetic
-long long int matching_brace(long long int index, const list<pair<int, long long int> >& braces) {
+long long int matching_brace(long long int index, const list<pair<int, long long int> >& braces, recipe_ordinal r) {
   int stacksize = 0;
   for (list<pair<int, long long int> >::const_iterator p = braces.begin(); p != braces.end(); ++p) {
     if (p->second < index) continue;
     stacksize += (p->first ? 1 : -1);
     if (stacksize == 0) return p->second;
   }
-  assert(false);
-  return -1;
+  raise << Recipe[r].name << ": unbalanced '{'\n";
+  return SIZE(Recipe[r].steps);  // exit current routine
 }
 
 // temporarily suppress run