shithub: scc

Download patch

ref: fb65fca0b3c45ded10eaac0d5d0b1a83d7ab9c66
parent: da0ce9f484c0d744fed1e22af2651734c4830d73
author: Roberto E. Vargas Caballero <k0ga@shike2.com>
date: Tue Apr 15 13:27:05 EDT 2014

Implement comma operator

This operator was recognized but was not implemented

--- a/cc.h
+++ b/cc.h
@@ -224,6 +224,7 @@
 	OBAND, OBXOR, OBOR, OASSIGN, OA_MUL, OA_DIV,
 	OA_MOD, OA_ADD, OA_SUB, OA_SHL, OA_SHR,
 	OA_AND, OA_XOR, OA_OR, OADDR,ONEG, OCPL, OEXC,
+	OCOMMA,
 	/*
 	  * Complementary relational operators only differ in less
 	 * significant bit
--- a/code.c
+++ b/code.c
@@ -43,7 +43,8 @@
 	[ONEG] = "_",
 	[OCPL] = "~",
 	[OAND] = "m",
-	[OOR] = "s"
+	[OOR] = "s",
+	[OCOMMA] = ","
 };
 
 Node *
--- a/expr.c
+++ b/expr.c
@@ -707,10 +707,13 @@
 Node *
 expr(void)
 {
-	register Node *np;
+	register Node *np1, *np2;
 
-	do
-		np = assign();
-	while (yytoken == ',');
-	return np;
+	np1 = assign();
+	while (accept(',')) {
+		np2 = assign();
+		np1 = bincode(OCOMMA, np2->type, np1, np2);
+	}
+
+	return np1;
 }
--