Move comma operator parsing to ParseContext

This change is pure refactoring. It will help with fixing comma operator
return value qualifier bug.

BUG=angleproject:911
BUG=angleproject:1201

Change-Id: I481c337adbaf789cc959c8a1106f99ad7275e1e5
Reviewed-on: https://chromium-review.googlesource.com/311170
Reviewed-by: Jamie Madill <jmadill@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Tested-by: Olli Etuaho <oetuaho@nvidia.com>
diff --git a/src/compiler/translator/ParseContext.cpp b/src/compiler/translator/ParseContext.cpp
index 03a4fd3..8e145c6 100644
--- a/src/compiler/translator/ParseContext.cpp
+++ b/src/compiler/translator/ParseContext.cpp
@@ -3746,6 +3746,20 @@
     return node;
 }
 
+TIntermTyped *TParseContext::addComma(TIntermTyped *left,
+                                      TIntermTyped *right,
+                                      const TSourceLoc &loc)
+{
+    TIntermTyped *node = intermediate.addComma(left, right, loc);
+    if (node == nullptr)
+    {
+        binaryOpError(loc, ",", left->getCompleteString(), right->getCompleteString());
+        recover();
+        return right;
+    }
+    return node;
+}
+
 TIntermBranch *TParseContext::addBranch(TOperator op, const TSourceLoc &loc)
 {
     switch (op)
diff --git a/src/compiler/translator/ParseContext.h b/src/compiler/translator/ParseContext.h
index 3b02fa2..8625599 100644
--- a/src/compiler/translator/ParseContext.h
+++ b/src/compiler/translator/ParseContext.h
@@ -301,6 +301,8 @@
     TIntermTyped *addAssign(
         TOperator op, TIntermTyped *left, TIntermTyped *right, const TSourceLoc &loc);
 
+    TIntermTyped *addComma(TIntermTyped *left, TIntermTyped *right, const TSourceLoc &loc);
+
     TIntermBranch *addBranch(TOperator op, const TSourceLoc &loc);
     TIntermBranch *addBranch(TOperator op, TIntermTyped *returnValue, const TSourceLoc &loc);
 
diff --git a/src/compiler/translator/glslang.y b/src/compiler/translator/glslang.y
index 285c3c9..db0c53f 100644
--- a/src/compiler/translator/glslang.y
+++ b/src/compiler/translator/glslang.y
@@ -559,12 +559,7 @@
         $$ = $1;
     }
     | expression COMMA assignment_expression {
-        $$ = context->intermediate.addComma($1, $3, @2);
-        if ($$ == 0) {
-            context->binaryOpError(@2, ",", $1->getCompleteString(), $3->getCompleteString());
-            context->recover();
-            $$ = $3;
-        }
+        $$ = context->addComma($1, $3, @2);
     }
     ;
 
diff --git a/src/compiler/translator/glslang_tab.cpp b/src/compiler/translator/glslang_tab.cpp
index 1ecb940..aa37b05 100644
--- a/src/compiler/translator/glslang_tab.cpp
+++ b/src/compiler/translator/glslang_tab.cpp
@@ -702,26 +702,26 @@
      440,   443,   446,   449,   455,   456,   459,   465,   466,   473,
      474,   481,   482,   489,   490,   496,   497,   503,   504,   510,
      511,   517,   518,   526,   527,   528,   529,   533,   534,   535,
-     539,   543,   547,   551,   558,   561,   572,   580,   588,   616,
-     622,   633,   637,   641,   645,   652,   658,   661,   668,   676,
-     697,   724,   734,   762,   767,   777,   782,   792,   795,   798,
-     801,   807,   814,   817,   821,   825,   830,   835,   842,   846,
-     850,   854,   859,   864,   868,   875,   885,   891,   894,   900,
-     906,   913,   922,   932,   940,   943,   950,   954,   958,   963,
-     971,   974,   978,   982,   991,  1000,  1008,  1018,  1030,  1033,
-    1036,  1042,  1049,  1052,  1058,  1061,  1064,  1070,  1073,  1078,
-    1093,  1097,  1101,  1105,  1109,  1113,  1118,  1123,  1128,  1133,
-    1138,  1143,  1148,  1153,  1158,  1163,  1168,  1173,  1178,  1183,
-    1188,  1193,  1198,  1203,  1208,  1213,  1218,  1222,  1226,  1230,
-    1234,  1238,  1242,  1246,  1250,  1254,  1258,  1262,  1266,  1270,
-    1274,  1278,  1286,  1294,  1298,  1311,  1311,  1314,  1314,  1320,
-    1323,  1339,  1342,  1351,  1355,  1361,  1368,  1383,  1387,  1391,
-    1392,  1398,  1399,  1400,  1401,  1402,  1403,  1404,  1408,  1409,
-    1409,  1409,  1419,  1420,  1424,  1424,  1425,  1425,  1430,  1433,
-    1443,  1446,  1452,  1453,  1457,  1465,  1469,  1476,  1476,  1483,
-    1486,  1493,  1498,  1513,  1513,  1518,  1518,  1525,  1525,  1533,
-    1536,  1542,  1545,  1551,  1555,  1562,  1565,  1568,  1571,  1574,
-    1583,  1587,  1594,  1597,  1603,  1603
+     539,   543,   547,   551,   558,   561,   567,   575,   583,   611,
+     617,   628,   632,   636,   640,   647,   653,   656,   663,   671,
+     692,   719,   729,   757,   762,   772,   777,   787,   790,   793,
+     796,   802,   809,   812,   816,   820,   825,   830,   837,   841,
+     845,   849,   854,   859,   863,   870,   880,   886,   889,   895,
+     901,   908,   917,   927,   935,   938,   945,   949,   953,   958,
+     966,   969,   973,   977,   986,   995,  1003,  1013,  1025,  1028,
+    1031,  1037,  1044,  1047,  1053,  1056,  1059,  1065,  1068,  1073,
+    1088,  1092,  1096,  1100,  1104,  1108,  1113,  1118,  1123,  1128,
+    1133,  1138,  1143,  1148,  1153,  1158,  1163,  1168,  1173,  1178,
+    1183,  1188,  1193,  1198,  1203,  1208,  1213,  1217,  1221,  1225,
+    1229,  1233,  1237,  1241,  1245,  1249,  1253,  1257,  1261,  1265,
+    1269,  1273,  1281,  1289,  1293,  1306,  1306,  1309,  1309,  1315,
+    1318,  1334,  1337,  1346,  1350,  1356,  1363,  1378,  1382,  1386,
+    1387,  1393,  1394,  1395,  1396,  1397,  1398,  1399,  1403,  1404,
+    1404,  1404,  1414,  1415,  1419,  1419,  1420,  1420,  1425,  1428,
+    1438,  1441,  1447,  1448,  1452,  1460,  1464,  1471,  1471,  1478,
+    1481,  1488,  1493,  1508,  1508,  1513,  1513,  1520,  1520,  1528,
+    1531,  1537,  1540,  1546,  1550,  1557,  1560,  1563,  1566,  1569,
+    1578,  1582,  1589,  1592,  1598,  1598
 };
 #endif
 
@@ -3020,12 +3020,7 @@
   case 85:
 
     {
-        (yyval.interm.intermTypedNode) = context->intermediate.addComma((yyvsp[-2].interm.intermTypedNode), (yyvsp[0].interm.intermTypedNode), (yylsp[-1]));
-        if ((yyval.interm.intermTypedNode) == 0) {
-            context->binaryOpError((yylsp[-1]), ",", (yyvsp[-2].interm.intermTypedNode)->getCompleteString(), (yyvsp[0].interm.intermTypedNode)->getCompleteString());
-            context->recover();
-            (yyval.interm.intermTypedNode) = (yyvsp[0].interm.intermTypedNode);
-        }
+        (yyval.interm.intermTypedNode) = context->addComma((yyvsp[-2].interm.intermTypedNode), (yyvsp[0].interm.intermTypedNode), (yylsp[-1]));
     }
 
     break;