commit 0921f4b551b0c9768126e8c0b9c0e8de56e946c7
parent a1b3e82dc9290b604151fed3682618bc09fca9cc
Author: Quentin Carbonneaux <quentin.carbonneaux@yale.edu>
Date: Mon, 7 Sep 2015 23:06:13 -0400
fix minor type parsing bugs
Diffstat:
2 files changed, 14 insertions(+), 11 deletions(-)
diff --git a/lisc/lisc.h b/lisc/lisc.h
@@ -230,6 +230,7 @@ struct Fn {
};
struct Type {
+ char name[NString];
int dark;
int size;
int align;
diff --git 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()) {