diff options
author | Quentin Carbonneaux <quentin.carbonneaux@yale.edu> | 2015-10-07 18:30:19 -0400 |
---|---|---|
committer | Quentin Carbonneaux <quentin.carbonneaux@yale.edu> | 2015-10-07 18:30:19 -0400 |
commit | b93b0d2902bae928edd960ae4d373f5e0033e39e (patch) | |
tree | c1b2d8b43378b9913c64e95ec85e8da5688a2e3a /lisc | |
parent | 01c1734e42d49202aaa1362b18a428d0d7ae0c3f (diff) | |
download | roux-b93b0d2902bae928edd960ae4d373f5e0033e39e.tar.gz |
start work on parsing data blocks
Diffstat (limited to 'lisc')
-rw-r--r-- | lisc/parse.c | 44 |
1 files changed, 43 insertions, 1 deletions
diff --git a/lisc/parse.c b/lisc/parse.c index 05cb32c..70cdb55 100644 --- 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) { |