ref: a8acad8243a648e895baebf39b5672b8209a30c6
parent: 5e36187eb6fac0a74254d40302033d0f043f8e72
author: Roberto E. Vargas Caballero <[email protected]>
date: Tue Aug 28 16:43:56 EDT 2012
Added tree structure for continue
--- a/flow.c
+++ b/flow.c
@@ -159,6 +159,22 @@
}
static struct node *
+_continue(void)
+{
+ register unsigned char *bp;
+
+ expect(CONTINUE);
+ expect(';');
+
+ for (bp = blocks; bp < blockp && *bp == OSWITCH; ++bp)
+ ; /* nothing */
+ if (bp == blockp)
+ error("continue statement not within loop");
+
+ return node1(OCONT, NULL);
+}
+
+static struct node *
stmt(void)
{
register struct node *np;
@@ -170,7 +186,7 @@
case FOR: return _for();
case DO: return _do();
case WHILE: return _while();
- case CONTINUE:
+ case CONTINUE: return _continue();
case BREAK: return _break();
case RETURN:
case GOTO: return _goto();
--- a/syntax.h
+++ b/syntax.h
@@ -11,7 +11,7 @@
OBOR, OAND, OOR, OTERN, OASSIGN, OA_MUL, OA_DIV,
OA_MOD, OA_ADD, OA_SUB, OA_SHL, OA_SHR, OA_AND,
OA_XOR, OA_OR, OSYM, OCOMP, OSWITCH, OIF, OFOR,
- OFEXP, ODO, OWHILE, OLABEL, OGOTO, OBREAK,
+ OFEXP, ODO, OWHILE, OLABEL, OGOTO, OBREAK, OCONT
};
struct node;
--- a/tree.c
+++ b/tree.c
@@ -186,6 +186,7 @@
[OLABEL] = {2, "label"},
[OGOTO] = {1, "goto"},
[OBREAK] = {1, "break"},
+ [OCONT] = {1, "cont"},
};
if (!np) {
fputs(" nil", stdout);