ref: e9f3f4b6f347e80196c224028a80d48099495168
parent: 1886809da90d62f4c4929fa78f89f445348fe8a4
author: Roberto E. Vargas Caballero <[email protected]>
date: Fri Apr 11 12:21:38 EDT 2014
Add logical bit or
--- a/cc.h
+++ b/cc.h
@@ -221,7 +221,7 @@
OCAST, OPTR, OADD, OARY, OSIZE, OMUL, OSUB,
OINC, ODEC, OPINC, OPDEC, ODIV, OMOD, OSHL,
OSHR, OLT, OGT, OGE, OLE, OEQ, ONE, OBAND,
- OBXOR
+ OBXOR, OBOR
};
extern void
--- a/code.c
+++ b/code.c
@@ -25,7 +25,8 @@
[OEQ] = "=",
[ONE] = "!",
[OBAND] = "&",
- [OBXOR] = "^"
+ [OBXOR] = "^",
+ [OBOR] = "|"
};
Node *
--- a/expr.c
+++ b/expr.c
@@ -403,6 +403,19 @@
return np;
}
+static Node *
+bit_or(void)
+{
+ register Node *np;
+
+ np = bit_xor();
+ while (yytoken == '|') {
+ next();
+ np = bitlogic(OBOR, np, bit_xor());
+ }
+ return np;
+}
+
Node *
expr(void)
{
@@ -409,7 +422,7 @@
register Node *np;
do
- np = bit_xor();
+ np = bit_or();
while (yytoken == ',');
return np;
}