summary refs log tree commit diff
path: root/parse.c
diff options
context:
space:
mode:
authorOri Bernstein <ori@eigenstate.org>2016-04-16 00:01:32 -0700
committerQuentin Carbonneaux <quentin.carbonneaux@yale.edu>2016-04-16 15:37:21 -0400
commit0cedf8e6cf8735b0de49b2bcbdbe43a65b88ab11 (patch)
tree90fb7e4327f8ef99408b3604a014edae99d5eaf7 /parse.c
parent42ecd05b7fe8512f1624873010b988e48d6431b5 (diff)
downloadroux-0cedf8e6cf8735b0de49b2bcbdbe43a65b88ab11.tar.gz
support trailing , in types/args/params
Diffstat (limited to 'parse.c')
-rw-r--r--parse.c19
1 files changed, 7 insertions, 12 deletions
diff --git a/parse.c b/parse.c
index 19575d9..fa4bd7d 100644
--- a/parse.c
+++ b/parse.c
@@ -439,15 +439,11 @@ parsecls(int *tyn)
 static void
 parserefl(int arg)
 {
-	int k, t, ty;
+	int k, ty;
 	Ref r;
 
 	expect(TLParen);
-	if (peek() == TRParen) {
-		next();
-		return;
-	}
-	for (;;) {
+	while (peek() != TRParen) {
 		if (curi - insb >= NIns)
 			err("too many instructions (1)");
 		k = parsecls(&ty);
@@ -467,12 +463,11 @@ parserefl(int arg)
 			else
 				*curi = (Ins){OPar, r, {R}, k};
 		curi++;
-		t = next();
-		if (t == TRParen)
+		if (peek() == TRParen)
 			break;
-		if (t != TComma)
-			err(", or ) expected");
+		expect(TComma);
 	}
+	next();
 }
 
 static Blk *
@@ -831,7 +826,7 @@ parsetyp()
 		n = -1;
 		sz = 0;
 		al = 0;
-		for (;;) {
+		while (t != TRBrace) {
 			flt = 0;
 			switch (t) {
 			default: err("invalid size specifier %c", tokval.chr);
@@ -882,7 +877,7 @@ parsetyp()
 		ty->size = (sz + a) & ~a;
 	}
 	if (t != TRBrace)
-		err("expected closing }");
+		err(", or } expected");
 }
 
 static void