test: Reduce code size of ops table.

This commit is contained in:
Jilles Tjoelker 2011-11-25 23:45:29 +00:00
parent 7a98470824
commit ba22f6c693

View File

@ -119,7 +119,7 @@ enum token_types {
}; };
static struct t_op { static struct t_op {
const char *op_text; char op_text[4];
short op_num, op_type; short op_num, op_type;
} const ops [] = { } const ops [] = {
{"-r", FILRD, UNOP}, {"-r", FILRD, UNOP},
@ -162,7 +162,7 @@ static struct t_op {
{"-o", BOR, BBINOP}, {"-o", BOR, BBINOP},
{"(", LPAREN, PAREN}, {"(", LPAREN, PAREN},
{")", RPAREN, PAREN}, {")", RPAREN, PAREN},
{0, 0, 0} {"", 0, 0}
}; };
static struct t_op const *t_wp_op; static struct t_op const *t_wp_op;
@ -427,7 +427,7 @@ t_lex(char *s)
t_wp_op = NULL; t_wp_op = NULL;
return EOI; return EOI;
} }
while (op->op_text) { while (*op->op_text) {
if (strcmp(s, op->op_text) == 0) { if (strcmp(s, op->op_text) == 0) {
if (((op->op_type == UNOP || op->op_type == BUNOP) if (((op->op_type == UNOP || op->op_type == BUNOP)
&& isunopoperand()) || && isunopoperand()) ||
@ -456,7 +456,7 @@ isunopoperand(void)
if (nargc == 2) if (nargc == 2)
return parenlevel == 1 && strcmp(s, ")") == 0; return parenlevel == 1 && strcmp(s, ")") == 0;
t = *(t_wp + 2); t = *(t_wp + 2);
while (op->op_text) { while (*op->op_text) {
if (strcmp(s, op->op_text) == 0) if (strcmp(s, op->op_text) == 0)
return op->op_type == BINOP && return op->op_type == BINOP &&
(parenlevel == 0 || t[0] != ')' || t[1] != '\0'); (parenlevel == 0 || t[0] != ')' || t[1] != '\0');
@ -478,7 +478,7 @@ islparenoperand(void)
return parenlevel == 1 && strcmp(s, ")") == 0; return parenlevel == 1 && strcmp(s, ")") == 0;
if (nargc != 3) if (nargc != 3)
return 0; return 0;
while (op->op_text) { while (*op->op_text) {
if (strcmp(s, op->op_text) == 0) if (strcmp(s, op->op_text) == 0)
return op->op_type == BINOP; return op->op_type == BINOP;
op++; op++;