scc

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

commit 2ea4d1165e7bd877f2e4e0f5b3ba16d727cce808
parent 9c6d70a63e38b5c92ae26e0e9ff19b585f7ff0e1
Author: Roberto E. Vargas Caballero <k0ga@shike2.com>
Date:   Mon, 11 Aug 2014 23:14:26 +0200

Add logical operators

Codification of these operators is also changed and now they are:

	- y (from spanish equivalent of 'and')
	- o (from or)

Diffstat:
Mcc1/expr.c | 3++-
Mcc2/cc2.h | 1-
Mcc2/cgen.c | 2++
Mcc2/parser.c | 2++
4 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/cc1/expr.c b/cc1/expr.c @@ -534,12 +534,13 @@ unary(void) next(); return incdec(unary(), op); case '!': op = 0; fun = negation; break; + /* FIXME: '-' and '+' can be applied to floats to */ case '+': op = OADD; fun = integeruop; break; case '-': op = ONEG; fun = integeruop; break; case '~': op = OCPL; fun = integeruop; break; case '&': op = OADDR; fun = address; break; case '*': op = OPTR; fun = content; break; - default: return postfix(); + default: return postfix(); } next(); diff --git a/cc2/cc2.h b/cc2/cc2.h @@ -86,7 +86,6 @@ enum nerrors { #define ONE '!' #define OOR 'o' #define OAND 'y' -#define ONEG '_' extern void error(unsigned nerror, ...); extern void genaddable(Node *list[]); diff --git a/cc2/cgen.c b/cc2/cgen.c @@ -124,6 +124,7 @@ xcgen(Node *np) } switch (np->op) { + case OOR: case OAND: case OPTR: case OADDR: case OINC: case OLT: case OGT: case OGE: case OLE: case OEQ: case ONE: @@ -197,6 +198,7 @@ xaddable(Node *np) case OPTR: case OADDR: xaddable(lp); break; + case OOR: case OAND: case OLT: case OGT: case OGE: case OLE: case OEQ: case ONE: case OINC: case OASSIG: case OADD: case OSUB: case OMOD: case ODIV: diff --git a/cc2/parser.c b/cc2/parser.c @@ -300,6 +300,8 @@ static void (*optbl[])(char *) = { ['['] = operator, ['='] = operator, ['!'] = operator, + ['y'] = operator, + ['o'] = operator, ['\177'] = NULL };