summaryrefslogtreecommitdiff
path: root/except.c
diff options
context:
space:
mode:
authorDrazen Borkovic <borkovic@users.noreply.github.com>2017-08-26 16:19:50 -0700
committerDrazen Borkovic <borkovic@users.noreply.github.com>2017-08-26 16:19:50 -0700
commit2325713c2f574aa08b5ad1bb91a3e4ee30b6b0b5 (patch)
tree9b19cfccfcc35ff74d513452f5b159d82cb9a0d0 /except.c
parent7dc3033c862c30d8998ed3e4c98c056286f31401 (diff)
Add "continue" builtin
Diffstat (limited to 'except.c')
-rw-r--r--except.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/except.c b/except.c
index 37696c4..aeb1da9 100644
--- a/except.c
+++ b/except.c
@@ -22,13 +22,14 @@ extern void except(ecodes e, Edata data, Estack *ex) {
estack = ex;
estack->e = e;
estack->data = data;
- if (e == eError || e == eBreak || e == eReturn)
+ if (e == eError || e == eBreak || e == eReturn || e == eContinue)
estack->interactive = interactive;
}
/* remove an exception, restore last interactive value */
-extern void unexcept() {
+extern void unexcept(ecodes e) {
+ assert(e == estack->e);
switch (estack->e) {
default:
break;
@@ -66,8 +67,10 @@ extern void rc_raise(ecodes e) {
exit(1); /* child processes exit on an error/signal */
for (; estack != NULL; estack = estack->prev)
if (estack->e != e) {
- if (e == eBreak && estack->e != eArena && estack->e != eVarstack)
+ if (e == eBreak && (estack->e != eArena && estack->e != eVarstack && estack->e != eContinue))
rc_error("break outside of loop");
+ else if (e == eContinue && (estack->e != eVarstack))
+ rc_error("continue outside of loop");
else if (e == eReturn && estack->e == eError) /* can return from loops inside functions */
rc_error("return outside of function");
switch (estack->e) {