[hackers] [scc] [cc2] Add format to the parse table || Roberto E. Vargas Caballero

From: <git_AT_suckless.org>
Date: Fri, 29 Jan 2016 10:03:47 +0100 (CET)

commit 3ff81f0b0e0ae86bf5401a358d7775038f348c69
Author: Roberto E. Vargas Caballero <k0ga_AT_shike2.com>
AuthorDate: Fri Jan 29 10:01:47 2016 +0100
Commit: Roberto E. Vargas Caballero <k0ga_AT_shike2.com>
CommitDate: Fri Jan 29 10:01:47 2016 +0100

    [cc2] Add format to the parse table

diff --git a/cc2/parser.c b/cc2/parser.c
index a9fc41d..5ec1f9c 100644
--- a/cc2/parser.c
+++ b/cc2/parser.c
_AT_@ -32,8 +32,8 @@ union tokenop {
 
 typedef void parsefun(char *, union tokenop);
 static parsefun type, symbol, getname, unary, binary, ternary, call,
- parameter, constant, composed, begininit, endinit,
- jump, oreturn, loop, assign, ocase, odefault, casetable;
+ parameter, constant, composed, binit, einit,
+ jump, oreturn, loop, assign, ocase, odefault, casetbl;
 
 typedef void evalfun(void);
 static evalfun vardecl, beginfun, endfun, endpars, stmt,
_AT_@ -43,91 +43,91 @@ static struct decoc {
         void (*eval)(void);
         void (*parse)(char *token, union tokenop);
         union tokenop u;
-} optbl[] = {
- [AUTO] = {vardecl, symbol, .u.op = AUTO},
- [REG] = {vardecl, symbol, .u.op = REG},
- [GLOB] = {vardecl, symbol, .u.op = MEM},
- [EXTRN] = {vardecl, symbol, .u.op = MEM},
- [PRIVAT] = {vardecl, symbol, .u.op = MEM},
- [LOCAL] = {vardecl, symbol, .u.op = MEM},
- [MEMBER] = {flddecl, symbol},
- [LABEL] = {labeldcl, symbol},
-
- [INT8] = {NULL, type, .u.arg = &int8type},
- [INT16] = {NULL, type, .u.arg = &int16type},
- [INT32] = {NULL, type, .u.arg = &int32type},
- [INT64] = {NULL, type, .u.arg = &int64type},
- [UINT8] = {NULL, type, .u.arg = &uint8type},
- [UINT16] = {NULL, type, .u.arg = &uint16type},
- [UINT32] = {NULL, type, .u.arg = &uint32type},
- [UINT64] = {NULL, type, .u.arg = &uint64type},
- [FLOAT] = {NULL, type, .u.arg = &float32type},
- [DOUBLE] = {NULL, type, .u.arg = &float64type},
- [LDOUBLE] = {NULL, type, .u.arg = &float80type},
- [VOID] = {NULL, type, .u.arg = &voidtype},
- [BOOL] = {NULL, type, .u.arg = &booltype},
- [POINTER] = {NULL, type, .u.arg = &ptrtype},
- [ELLIPSIS] = {NULL, type, .u.arg = &elipsistype},
-
- [FUNCTION] = {NULL, type, .u.arg = &funtype},
- [VECTOR] = {array, composed},
- [UNION] = {aggregate, composed},
- [STRUCT] = {aggregate, composed},
-
- [ONAME] = {NULL, getname},
- ['{'] = {beginfun},
- ['}'] = {endfun},
- ['('] = {NULL, begininit},
- [')'] = {NULL, endinit},
- [OEPARS] = {endpars},
- [OSTMT] = {stmt},
-
- [OCPL] = {NULL, unary},
- [ONEG] = {NULL, unary},
- [OADDR] = {NULL, unary},
- [OPTR] = {NULL, unary},
- [OCAST] = {NULL, unary},
- [OPAR ] = {NULL, unary},
-
- [OAND] = {NULL, binary},
- [OOR] = {NULL, binary},
- [OFIELD] = {NULL, binary},
- [OADD] = {NULL, binary},
- [OSUB] = {NULL, binary},
- [OMUL] = {NULL, binary},
- [OMOD] = {NULL, binary},
- [ODIV] = {NULL, binary},
- [OSHL] = {NULL, binary},
- [OSHR] = {NULL, binary},
- [OLT] = {NULL, binary},
- [OGT] = {NULL, binary},
- [OLE] = {NULL, binary},
- [OGE] = {NULL, binary},
- [OEQ] = {NULL, binary},
- [ONE] = {NULL, binary},
- [OBAND] = {NULL, binary},
- [OBOR] = {NULL, binary},
- [OBXOR] = {NULL, binary},
- [OCOMMA] = {NULL, binary},
-
- [OASSIG] = {NULL, assign},
- [OASK] = {NULL, ternary},
- [OCALL] = {NULL, call},
-
- [OCONST] = NULL, constant,
-
- [OJMP] = NULL, jump,
- [OBRANCH] = NULL, jump,
- [ORET] = NULL, oreturn,
-
- [OBLOOP] = NULL, loop,
- [OELOOP] = NULL, loop,
-
- [OCASE] = NULL, jump,
- [OSWITCH] = NULL, jump,
-
- [ODEFAULT] = NULL, odefault,
- [OTABLE] = NULL, casetable,
+} optbl[] = { /* eval parse args */
+ [AUTO] = { vardecl, symbol, .u.op = AUTO},
+ [REG] = { vardecl, symbol, .u.op = REG},
+ [GLOB] = { vardecl, symbol, .u.op = MEM},
+ [EXTRN] = { vardecl, symbol, .u.op = MEM},
+ [PRIVAT] = { vardecl, symbol, .u.op = MEM},
+ [LOCAL] = { vardecl, symbol, .u.op = MEM},
+ [MEMBER] = { flddecl, symbol, 0},
+ [LABEL] = { labeldcl, symbol, 0},
+
+ [INT8] = { NULL, type, .u.arg = &int8type},
+ [INT16] = { NULL, type, .u.arg = &int16type},
+ [INT32] = { NULL, type, .u.arg = &int32type},
+ [INT64] = { NULL, type, .u.arg = &int64type},
+ [UINT8] = { NULL, type, .u.arg = &uint8type},
+ [UINT16] = { NULL, type, .u.arg = &uint16type},
+ [UINT32] = { NULL, type, .u.arg = &uint32type},
+ [UINT64] = { NULL, type, .u.arg = &uint64type},
+ [FLOAT] = { NULL, type, .u.arg = &float32type},
+ [DOUBLE] = { NULL, type, .u.arg = &float64type},
+ [LDOUBLE] = { NULL, type, .u.arg = &float80type},
+ [VOID] = { NULL, type, .u.arg = &voidtype},
+ [BOOL] = { NULL, type, .u.arg = &booltype},
+ [POINTER] = { NULL, type, .u.arg = &ptrtype},
+ [ELLIPSIS] = { NULL, type, .u.arg = &elipsistype},
+
+ [FUNCTION] = { NULL, type, .u.arg = &funtype},
+ [VECTOR] = { array,composed, 0},
+ [UNION] = {aggregate,composed, 0},
+ [STRUCT] = {aggregate,composed, 0},
+
+ [ONAME] = { NULL, getname, 0},
+ ['{'] = { beginfun, NULL, 0},
+ ['}'] = { endfun, NULL, 0},
+ ['('] = { NULL, binit, 0},
+ [')'] = { NULL, einit, 0},
+ [OEPARS] = { endpars, NULL, 0},
+ [OSTMT] = { stmt, NULL, 0},
+
+ [OCPL] = { NULL, unary, 0},
+ [ONEG] = { NULL, unary, 0},
+ [OADDR] = { NULL, unary, 0},
+ [OPTR] = { NULL, unary, 0},
+ [OCAST] = { NULL, unary, 0},
+ [OPAR ] = { NULL, unary, 0},
+
+ [OAND] = { NULL, binary, 0},
+ [OOR] = { NULL, binary, 0},
+ [OFIELD] = { NULL, binary, 0},
+ [OADD] = { NULL, binary, 0},
+ [OSUB] = { NULL, binary, 0},
+ [OMUL] = { NULL, binary, 0},
+ [OMOD] = { NULL, binary, 0},
+ [ODIV] = { NULL, binary, 0},
+ [OSHL] = { NULL, binary, 0},
+ [OSHR] = { NULL, binary, 0},
+ [OLT] = { NULL, binary, 0},
+ [OGT] = { NULL, binary, 0},
+ [OLE] = { NULL, binary, 0},
+ [OGE] = { NULL, binary, 0},
+ [OEQ] = { NULL, binary, 0},
+ [ONE] = { NULL, binary, 0},
+ [OBAND] = { NULL, binary, 0},
+ [OBOR] = { NULL, binary, 0},
+ [OBXOR] = { NULL, binary, 0},
+ [OCOMMA] = { NULL, binary, 0},
+
+ [OASSIG] = { NULL, assign, 0},
+ [OASK] = { NULL, ternary, 0},
+ [OCALL] = { NULL, call, 0},
+
+ [OCONST] = { NULL,constant, 0},
+
+ [OJMP] = { NULL, jump, 0},
+ [OBRANCH] = { NULL, jump, 0},
+ [ORET] = { NULL, oreturn, 0},
+
+ [OBLOOP] = { NULL, loop, 0},
+ [OELOOP] = { NULL, loop, 0},
+
+ [OCASE] = { NULL, jump, 0},
+ [OSWITCH] = { NULL, jump, 0},
+
+ [ODEFAULT] = { NULL,odefault, 0},
+ [OTABLE] = { NULL, casetbl, 0}
 };
 
 static Symbol *curfun;
_AT_@ -355,7 +355,7 @@ jump(char *token, union tokenop u)
 }
 
 static void
-casetable(char *token, union tokenop u)
+casetbl(char *token, union tokenop u)
 {
         Node *np, *aux;
 
_AT_@ -432,13 +432,13 @@ binary(char *token, union tokenop u)
 }
 
 static void
-begininit(char *token, union tokenop u)
+binit(char *token, union tokenop u)
 {
         ininit = 1;
 }
 
 static void
-endinit(char *token, union tokenop u)
+einit(char *token, union tokenop u)
 {
         ininit = 0;
 }
Received on Fri Jan 29 2016 - 10:03:47 CET

This archive was generated by hypermail 2.3.0 : Fri Jan 29 2016 - 10:12:26 CET