scc

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

commit bf42a6e903cc4c2e7968b4a1148d20923b1bc8b6
parent 8cd212d516410eb5c3403fc3d3c6e60387dd7d38
Author: Roberto E. Vargas Caballero <Roberto E. Vargas Caballero>
Date:   Mon, 18 Apr 2016 01:58:53 +0200

[cc2] Remove input dependecy from assign()

This function had a dependency with the input language in how it
was parsing the subop value.

Diffstat:
Mcc2/parser.c | 33+++++++++++++++++----------------
1 file changed, 17 insertions(+), 16 deletions(-)

diff --git a/cc2/parser.c b/cc2/parser.c @@ -232,29 +232,30 @@ constant(char *token, union tokenop u) static void assign(char *token, union tokenop u) { - int c, op = *token++; + int subop, op = u.op; Node *np = newnode(); - switch (*token) { - case ODIV: - case OMOD: - case OADD: - case OSUB: - case OSHL: - case OSHR: - case OBAND: - case OBXOR: - case OBOR: - case OINC: - case ODEC: - c = *token++; + switch (subop = *++token) { + case '/': + case '%': + case '+': + case '-': + case 'l': + case 'r': + case '&': + case '|': + case '^': + case 'i': + case 'd': + ++token; + subop = optbl[subop].u.op; break; default: - c = 0; + subop = 0; break; } - np->u.subop = c; + np->u.subop = subop; np->op = op; np->type = *gettype(token); np->right = pop();