From 038ea2d0a34fb362f577e6c9884c710ebaf4042e Mon Sep 17 00:00:00 2001 From: Nicholas Noll Date: Fri, 29 May 2020 17:18:16 -0700 Subject: feat: cc parser prototype finished --- sys/cmd/cc/cc.h | 48 ++++++++++++++++++++++++++++++++---------------- 1 file changed, 32 insertions(+), 16 deletions(-) (limited to 'sys/cmd/cc/cc.h') diff --git a/sys/cmd/cc/cc.h b/sys/cmd/cc/cc.h index 44b0037..cf97233 100644 --- a/sys/cmd/cc/cc.h +++ b/sys/cmd/cc/cc.h @@ -361,7 +361,7 @@ enum Xref, Xstar, Xplus, Xminus, Xneg, Xnot, Xsizeof, Xalignof, Xpreinc, Xpredec, Xcast, /* unary postfix ops */ - Xpostinc, Xpostdec, Xindex, Xcall, Xselp, Xself, Xcmpdlit, + Xpostinc, Xpostdec, Xindex, Xcall, Xselp, Xself, Xinitlist, /* binary ops */ Xoror, Xandand, Xor, Xxor, Xand, Xneq, Xeql, Xgt, Xlt, Xgteq, Xlteq, Xlsft, Xrsft, Xadd, Xsub, Xmul, Xdiv, Xmod, @@ -383,14 +383,16 @@ enum }; /* expressions */ +enum +{ + Keynil, + Keyidx, + Keysel, +}; + struct Key { - /* - * NOTE: bitpacked - * lower 32 -> index into designator array - * upper 32 -> type - */ - uint64 kind; + uint kind : 2; union { Expr *x; string s; @@ -400,17 +402,18 @@ struct Key struct Expr { struct Node; - int32 type; + uint32 qual; + uint32 type; union { struct { uint64 kind; union Val; } val; struct { - int n; - struct Key *key; - Expr *val; - } cmpd; + int n; + struct Key *k; + Expr *v; + } init; Expr *x; struct { Expr *l; @@ -436,10 +439,23 @@ struct Expr union { Expr *pre; Expr *post; - } unary; + } unary; struct { - int32 to; - Expr *x; + int type : 1; + union { + struct { + uint32 qual; + uint32 type; + } of; + Expr *x; + }; + } info; + struct { + struct { + uint32 qual; + uint32 type; + } to; + Expr *x; } cast; struct { Expr *l; @@ -677,7 +693,7 @@ struct Type /* platform specific */ extern Type pointer; -extern Type basetypes[22]; +extern Type basetypes[23]; /* mandated by C standard */ extern uint64 validtypespec[40]; extern int indextypespec[40]; -- cgit v1.2.1