From 4ce90b39d0481f6bb9773ea904f10313af559a5b Mon Sep 17 00:00:00 2001 From: "Kartik K. Agaram" Date: Fri, 24 Jul 2015 18:30:02 -0700 Subject: 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. --- 040brace.cc | 8 ++++---- 1 file 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 >& braces) { +long long int matching_brace(long long int index, const list >& braces, recipe_ordinal r) { int stacksize = 0; for (list >::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 -- cgit 1.4.1-2-gfad0