Our parse trees are very unbalanced, so we cannot use a stack to implement parse tree visits. Instead, we use parent pointers and some hairy code in these two functions. */
| 1220 | ret = calc_inveclosure (dfa); |
| 1221 | } |
| 1222 | |
| 1223 | return ret; |
| 1224 | } |
| 1225 | |
| 1226 | /* Our parse trees are very unbalanced, so we cannot use a stack to |
| 1227 | implement parse tree visits. Instead, we use parent pointers and |
| 1228 | some hairy code in these two functions. */ |
| 1229 | static reg_errcode_t |
| 1230 | postorder (bin_tree_t *root, reg_errcode_t (fn (void *, bin_tree_t *)), |
| 1231 | void *extra) |
| 1232 | { |
| 1233 | bin_tree_t *node, *prev; |
| 1234 | |
| 1235 | for (node = root; ; ) |
| 1236 | { |
| 1237 | /* Descend down the tree, preferably to the left (or to the right |
| 1238 | if that's the only child). */ |
| 1239 | while (node->left || node->right) |
| 1240 | if (node->left) |
| 1241 | node = node->left; |
| 1242 | else |
| 1243 | node = node->right; |
| 1244 | |
| 1245 | do |
| 1246 | { |
| 1247 | reg_errcode_t err = fn (extra, node); |
| 1248 | if (BE (err != REG_NOERROR, 0)) |
| 1249 | return err; |
| 1250 | if (node->parent == NULL) |
| 1251 | return REG_NOERROR; |
| 1252 | prev = node; |
| 1253 | node = node->parent; |
| 1254 | } |
| 1255 | /* Go up while we have a node that is reached from the right. */ |
no outgoing calls
no test coverage detected