commit b93b0d2902bae928edd960ae4d373f5e0033e39e
parent 01c1734e42d49202aaa1362b18a428d0d7ae0c3f
Author: Quentin Carbonneaux <quentin.carbonneaux@yale.edu>
Date: Wed, 7 Oct 2015 18:30:19 -0400
start work on parsing data blocks
Diffstat:
| M | lisc/parse.c | | | 44 | +++++++++++++++++++++++++++++++++++++++++++- |
1 file changed, 43 insertions(+), 1 deletion(-)
diff --git a/lisc/parse.c b/lisc/parse.c
@@ -638,7 +638,7 @@ parsetyp()
t = nextnl();
if (t == TAlign) {
if (nextnl() != TNum)
- err("alignment value expected");
+ err("alignment expected");
for (al=0; tokval.num /= 2; al++)
;
ty->align = al;
@@ -711,6 +711,48 @@ parsetyp()
err("expected closing }");
}
+typedef struct Dat Dat;
+
+struct Dat {
+ enum {
+ DName,
+ DAlign,
+ DA,
+ DB,
+ DH,
+ DW,
+ DL
+ } type;
+ union {
+ long long num;
+ char *str;
+ } u;
+};
+
+static void
+parsedat(void cb(Dat *))
+{
+ int t;
+ Dat d;
+
+ if (nextnl() != TGlo || nextnl() != TEq)
+ err("data name, then = expected");
+ d.type = DName;
+ d.u.str = tokval.str;
+ cb(&d);
+ t = nextnl();
+ if (t == TAlign) {
+ if (nextnl() != TNum)
+ err("alignment expected");
+ d.type = DAlign;
+ d.u.num = tokval.num;
+ cb(&d);
+ t = nextnl();
+ }
+ if (t != TLBrace)
+ err("data contents must start with {");
+}
+
Fn *
parse(FILE *f)
{