ref: ec3805a1ef3e6d851ecc3e6b0b3ea4135dbaf3ab
parent: 0806fd87e7bb0f60a0acc1600b84d1a74351f5d1
author: Roberto E. Vargas Caballero <k0ga@shike2.com>
date: Sat Aug 25 13:54:45 EDT 2012
Added tree struct for do/while statement
--- a/flow.c
+++ b/flow.c
@@ -29,13 +29,17 @@
static struct node *
do_do(void)
{+ register struct node *cond, *body;
+
expect(DO);
- stmt();
+ body = stmt();
expect(WHILE);
expect('(');- expr();
+ cond = expr();
expect(')');- return NULL;
+ expect(';');+
+ return node2(ODO, body, cond);
}
static struct node *
--- 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
+ OFEXP, ODO
};
struct node;
--- a/tree.c
+++ b/tree.c
@@ -180,7 +180,8 @@
[OSWITCH] = {2, "switch"}, [OIF] = {3, "if"}, [OFOR] = {2, "for"},- [OFEXP] = {3, "efor"}+ [OFEXP] = {3, "efor"},+ [ODO] = {2, "do"}};
if (!np) { fputs(" nil", stdout);--
⑨