scc

simple C compiler
git clone git://git.2f30.org/scc
Log | Files | Refs | README | LICENSE

commit 80065adc8365fd25c831018b6a5a5405cdce95ad
parent 088f60d8c93ae098a85b5d2b25cfd9143d7789b2
Author: Roberto E. Vargas Caballero <k0ga@shike2.com>
Date:   Fri, 13 Mar 2015 22:23:25 +0000

Move parser table in cc2 to the beginning of file

style change.

Diffstat:
Mcc2/parser.c | 108+++++++++++++++++++++++++++++++++++++++++--------------------------------------
1 file changed, 56 insertions(+), 52 deletions(-)

diff --git a/cc2/parser.c b/cc2/parser.c @@ -88,6 +88,62 @@ Type l_uint64 = { .flags = INTF }; +static void cast(char *), operator(char *), assignment(char *), increment(char *), + globvar(char *), localvar(char *), paramvar(char *), label(char *), + immediate(char *), unary(char *); + +static void (*optbl[])(char *) = { + [L_INT8] = cast, + [L_INT16] = cast, + [L_INT32] = cast, + [L_INT64] = cast, + [L_UINT8] = cast, + [L_UINT16] = cast, + [L_UINT32] = cast, + [L_UINT64] = cast, + [L_BOOL] = cast, + [L_FLOAT] = cast, + [L_DOUBLE] = cast, + [L_LDOUBLE] = cast, + [L_POINTER] = cast, + [L_VOID] = cast, + ['+'] = operator, + ['%'] = operator, + ['-'] = operator, + ['*'] = operator, + ['/'] = operator, + ['l'] = operator, + ['r'] = operator, + ['&'] = operator, + ['|'] = operator, + ['^'] = operator, + [':'] = assignment, + [';'] = increment, + ['Y'] = globvar, + ['A'] = localvar, + ['K'] = localvar, + ['T'] = localvar, + ['G'] = globvar, + ['P'] = paramvar, + ['L'] = label, + ['#'] = immediate, + ['@'] = unary, + ['a'] = unary, + ['<'] = operator, + ['>'] = operator, + [']'] = operator, + ['['] = operator, + ['='] = operator, + ['!'] = unary, + ['y'] = NULL, + ['j'] = NULL, + ['o'] = operator, + ['_'] = unary, + ['~'] = unary, + [','] = operator, + ['\177'] = NULL +}; + static void prnode(Node *np) @@ -348,58 +404,6 @@ cast(char *token) push(np); } -static void (*optbl[])(char *) = { - [L_INT8] = cast, - [L_INT16] = cast, - [L_INT32] = cast, - [L_INT64] = cast, - [L_UINT8] = cast, - [L_UINT16] = cast, - [L_UINT32] = cast, - [L_UINT64] = cast, - [L_BOOL] = cast, - [L_FLOAT] = cast, - [L_DOUBLE] = cast, - [L_LDOUBLE] = cast, - [L_POINTER] = cast, - [L_VOID] = cast, - ['+'] = operator, - ['%'] = operator, - ['-'] = operator, - ['*'] = operator, - ['/'] = operator, - ['l'] = operator, - ['r'] = operator, - ['&'] = operator, - ['|'] = operator, - ['^'] = operator, - [':'] = assignment, - [';'] = increment, - ['Y'] = globvar, - ['A'] = localvar, - ['K'] = localvar, - ['T'] = localvar, - ['G'] = globvar, - ['P'] = paramvar, - ['L'] = label, - ['#'] = immediate, - ['@'] = unary, - ['a'] = unary, - ['<'] = operator, - ['>'] = operator, - [']'] = operator, - ['['] = operator, - ['='] = operator, - ['!'] = unary, - ['y'] = NULL, - ['j'] = NULL, - ['o'] = operator, - ['_'] = unary, - ['~'] = unary, - [','] = operator, - ['\177'] = NULL -}; - static void expression(char *token) {