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
- experiment: rip out memory reclamation' href='/akkartik/mu/commit/037abandon.cc?h=hlt&id=acce384bcc88d5b300b913c14b9872081a182155'>acce384b ^
23d3a022 ^
3ecee22a ^


0be82cde ^
acce384b ^




3ecee22a ^



dc9afcbd ^

ce9b2b05 ^
3ecee22a ^
0be82cde ^
dc9afcbd ^

059def11 ^


23d3a022 ^
059def11 ^

9a6f8798 ^
dc9afcbd ^
a89c1bed ^
dc9afcbd ^
a89c1bed ^
3ecee22a ^

9a6f8798 ^
3ecee22a ^

6c96a437 ^
dc9afcbd ^




9a6f8798 ^
dc9afcbd ^



377b00b0 ^




ce9b2b05 ^
dc9afcbd ^

ce9b2b05 ^
dc9afcbd ^


23d3a022 ^





dc9afcbd ^
38f72faa ^
23d3a022 ^
3ecee22a ^









1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132