shithub: scc

Download patch

ref: 1886809da90d62f4c4929fa78f89f445348fe8a4
parent: bce263baaa569ae0a2eaa83e6483e456e172e56d
author: Roberto E. Vargas Caballero <[email protected]>
date: Fri Apr 11 12:16:51 EDT 2014

Add bit logical xor

--- a/cc.h
+++ b/cc.h
@@ -220,7 +220,8 @@
 enum {
 	OCAST, OPTR, OADD, OARY, OSIZE, OMUL, OSUB,
 	OINC, ODEC, OPINC, OPDEC, ODIV, OMOD, OSHL,
-	OSHR, OLT, OGT, OGE, OLE, OEQ, ONE, OBAND
+	OSHR, OLT, OGT, OGE, OLE, OEQ, ONE, OBAND,
+	OBXOR
 };
 
 extern void
--- a/code.c
+++ b/code.c
@@ -24,7 +24,8 @@
 	[OLE] =  "[",
 	[OEQ] = "=",
 	[ONE] = "!",
-	[OBAND] = "&"
+	[OBAND] = "&",
+	[OBXOR]  = "^"
 };
 
 Node *
--- a/expr.c
+++ b/expr.c
@@ -390,6 +390,19 @@
 	return np;
 }
 
+static Node *
+bit_xor(void)
+{
+	register Node *np;
+
+	np = bit_and();
+	while (yytoken == '^') {
+		next();
+		np = bitlogic(OBXOR,  np, bit_and());
+	}
+	return np;
+}
+
 Node *
 expr(void)
 {
@@ -396,7 +409,7 @@
 	register Node *np;
 
 	do
-		np = bit_and();
+		np = bit_xor();
 	while (yytoken == ',');
 	return np;
 }