ref: 2ea4d1165e7bd877f2e4e0f5b3ba16d727cce808
parent: 9c6d70a63e38b5c92ae26e0e9ff19b585f7ff0e1
author: Roberto E. Vargas Caballero <k0ga@shike2.com>
date: Mon Aug 11 19:14:26 EDT 2014
Add logical operators Codification of these operators is also changed and now they are: - y (from spanish equivalent of 'and') - o (from or)
--- a/cc1/expr.c
+++ b/cc1/expr.c
@@ -534,12 +534,13 @@
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();
--- a/cc2/cc2.h
+++ b/cc2/cc2.h
@@ -86,7 +86,6 @@
#define ONE '!'
#define OOR 'o'
#define OAND 'y'
-#define ONEG '_'
extern void error(unsigned nerror, ...);
extern void genaddable(Node *list[]);
--- a/cc2/cgen.c
+++ b/cc2/cgen.c
@@ -124,6 +124,7 @@
}
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 @@
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:
--- a/cc2/parser.c
+++ b/cc2/parser.c
@@ -300,6 +300,8 @@
['['] = operator,
['='] = operator,
['!'] = operator,
+ ['y'] = operator,
+ ['o'] = operator,
['\177'] = NULL
};
--
⑨