summary refs log tree commit diff
path: root/lisc/parse.c
diff options
context:
space:
mode:
authorQuentin Carbonneaux <quentin.carbonneaux@yale.edu>2015-09-07 23:06:13 -0400
committerQuentin Carbonneaux <quentin.carbonneaux@yale.edu>2015-09-15 23:01:33 -0400
commit0921f4b551b0c9768126e8c0b9c0e8de56e946c7 (patch)
tree63c26a3b12b335b95d0703c5482937e43b8d9258 /lisc/parse.c
parenta1b3e82dc9290b604151fed3682618bc09fca9cc (diff)
downloadroux-0921f4b551b0c9768126e8c0b9c0e8de56e946c7.tar.gz
fix minor type parsing bugs
Diffstat (limited to 'lisc/parse.c')
-rw-r--r--lisc/parse.c24
1 files changed, 13 insertions, 11 deletions
diff --git a/lisc/parse.c b/lisc/parse.c
index 43d40bb..5da8a69 100644
--- a/lisc/parse.c
+++ b/lisc/parse.c
@@ -273,9 +273,8 @@ nextnl()
 {
 	int t;
 
-	do
-		t = next();
-	while (t == TNL);
+	while ((t = next()) == TNL)
+		;
 	return t;
 }
 
@@ -542,7 +541,6 @@ parsefn()
 	ncon = 1; /* first constant must be 0 */
 	curi = insb;
 	curb = 0;
-	lnum = 1;
 	nblk = 0;
 	fn = alloc(sizeof *fn);
 	strcpy(fn->name, tokval.str);
@@ -576,6 +574,7 @@ parsety()
 	ty->align = -1;
 	if (nextnl() != TTyp ||  nextnl() != TEq)
 		err("type name, then = expected");
+	strcpy(ty->name, tokval.str);
 	t = nextnl();
 	if (t == TAlign) {
 		if (nextnl() != TNum)
@@ -599,9 +598,9 @@ parsety()
 		n = -1;
 		sz = 0;
 		al = 0;
-		do {
+		for (;;) {
 			flt = 0;
-			switch (nextnl()) {
+			switch (t) {
 			default: err("invalid size specifier");
 			case TD: flt = 1;
 			case TL: s = 8; a = 3; break;
@@ -627,14 +626,16 @@ parsety()
 			} else
 				c = 1;
 			while (c-- > 0) {
-				if (flt && ++n < NSeg) {
-					/* floating point segment */
-					ty->seg[n].flt = 1;
+				if (++n < NSeg) {
+					ty->seg[n].flt = flt;
 					ty->seg[n].len = s;
 				}
 				sz += a + s;
 			}
-		} while (t == TComma);
+			if (t != TComma)
+				break;
+			t = nextnl();
+		}
 		if (++n >= NSeg)
 			ty->dark = 1;
 		else
@@ -646,7 +647,7 @@ parsety()
 		a = (1 << al) - 1;
 		ty->size = (sz + a) & ~a;
 	}
-	if (t != TLBrace)
+	if (t != TRBrace)
 		err("expected closing }");
 }
 
@@ -657,6 +658,7 @@ parse(FILE *f)
 
 	fn = 0;
 	inf = f;
+	lnum = 1;
 	thead = TXXX;
 	for (;;)
 		switch (nextnl()) {