From: Rafael Garcia-Suarez Date: Mon, 13 Nov 2006 11:17:10 +0000 (+0000) Subject: Parsing fix: it wasn't possible to call a function with a (_) prototype X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=3cd0a11a1a8c5cc6b632f666275eeafcb6f5c950;p=p5sagit%2Fp5-mst-13.2.git Parsing fix: it wasn't possible to call a function with a (_) prototype (that is, a function mimicing an unary op) without parentheses. Bug reported by Ævar Arnfjörð Bjarmason. p4raw-id: //depot/perl@29258 --- diff --git a/madly.act b/madly.act index d7d9936..319ce77 100644 --- a/madly.act +++ b/madly.act @@ -1310,19 +1310,24 @@ case 2: case 178: #line 1074 "madly.y" + { (yyval.opval) = newUNOP(OP_ENTERSUB, OPf_STACKED, scalar((yyvsp[0].opval))); ;} + break; + + case 179: +#line 1076 "madly.y" { (yyval.opval) = newUNOP(OP_ENTERSUB, OPf_STACKED, append_elem(OP_LIST, (yyvsp[0].opval), scalar((yyvsp[-1].opval)))); ;} break; - case 179: -#line 1077 "madly.y" + case 180: +#line 1079 "madly.y" { (yyval.opval) = newOP(((yyvsp[0].tkval))->tk_lval.ival, 0); token_getmad((yyvsp[0].tkval),(yyval.opval),'o'); ;} break; - case 180: -#line 1081 "madly.y" + case 181: +#line 1083 "madly.y" { (yyval.opval) = newOP(((yyvsp[-2].tkval))->tk_lval.ival, 0); token_getmad((yyvsp[-2].tkval),(yyval.opval),'o'); token_getmad((yyvsp[-1].tkval),(yyval.opval),'('); @@ -1330,14 +1335,14 @@ case 2: ;} break; - case 181: -#line 1087 "madly.y" + case 182: +#line 1089 "madly.y" { (yyval.opval) = newUNOP(OP_ENTERSUB, OPf_STACKED, scalar((yyvsp[0].opval))); ;} break; - case 182: -#line 1090 "madly.y" + case 183: +#line 1092 "madly.y" { (yyval.opval) = newOP(((yyvsp[-2].tkval))->tk_lval.ival, OPf_SPECIAL); token_getmad((yyvsp[-2].tkval),(yyval.opval),'o'); token_getmad((yyvsp[-1].tkval),(yyval.opval),'('); @@ -1345,8 +1350,8 @@ case 2: ;} break; - case 183: -#line 1096 "madly.y" + case 184: +#line 1098 "madly.y" { (yyval.opval) = newUNOP(((yyvsp[-3].tkval))->tk_lval.ival, 0, (yyvsp[-1].opval)); token_getmad((yyvsp[-3].tkval),(yyval.opval),'o'); token_getmad((yyvsp[-2].tkval),(yyval.opval),'('); @@ -1354,16 +1359,16 @@ case 2: ;} break; - case 184: -#line 1102 "madly.y" + case 185: +#line 1104 "madly.y" { (yyval.opval) = pmruntime((yyvsp[-3].opval), (yyvsp[-1].opval), 1); token_getmad((yyvsp[-2].tkval),(yyval.opval),'('); token_getmad((yyvsp[0].tkval),(yyval.opval),')'); ;} break; - case 187: -#line 1112 "madly.y" + case 188: +#line 1114 "madly.y" { (yyval.opval) = my_attrs((yyvsp[-1].opval),(yyvsp[0].opval)); token_getmad((yyvsp[-2].tkval),(yyval.opval),'d'); append_madprops((yyvsp[0].opval)->op_madprop, (yyval.opval), 'a'); @@ -1371,34 +1376,29 @@ case 2: ;} break; - case 188: -#line 1118 "madly.y" + case 189: +#line 1120 "madly.y" { (yyval.opval) = localize((yyvsp[0].opval),((yyvsp[-1].tkval))->tk_lval.ival); token_getmad((yyvsp[-1].tkval),(yyval.opval),'d'); ;} break; - case 189: -#line 1125 "madly.y" + case 190: +#line 1127 "madly.y" { (yyval.opval) = sawparens((yyvsp[-1].opval)); token_getmad((yyvsp[-2].tkval),(yyval.opval),'('); token_getmad((yyvsp[0].tkval),(yyval.opval),')'); ;} break; - case 190: -#line 1130 "madly.y" + case 191: +#line 1132 "madly.y" { (yyval.opval) = sawparens(newNULLLIST()); token_getmad((yyvsp[-1].tkval),(yyval.opval),'('); token_getmad((yyvsp[0].tkval),(yyval.opval),')'); ;} break; - case 191: -#line 1135 "madly.y" - { (yyval.opval) = (yyvsp[0].opval); ;} - break; - case 192: #line 1137 "madly.y" { (yyval.opval) = (yyvsp[0].opval); ;} @@ -1410,85 +1410,85 @@ case 2: break; case 194: -#line 1144 "madly.y" - { (yyval.opval) = Nullop; ;} +#line 1141 "madly.y" + { (yyval.opval) = (yyvsp[0].opval); ;} break; case 195: #line 1146 "madly.y" - { (yyval.opval) = (yyvsp[0].opval); ;} + { (yyval.opval) = Nullop; ;} break; case 196: -#line 1150 "madly.y" - { (yyval.opval) = Nullop; ;} +#line 1148 "madly.y" + { (yyval.opval) = (yyvsp[0].opval); ;} break; case 197: #line 1152 "madly.y" - { (yyval.opval) = (yyvsp[0].opval); ;} + { (yyval.opval) = Nullop; ;} break; case 198: #line 1154 "madly.y" + { (yyval.opval) = (yyvsp[0].opval); ;} + break; + + case 199: +#line 1156 "madly.y" { OP* op = newNULLLIST(); token_getmad((yyvsp[0].tkval),op,','); (yyval.opval) = append_elem(OP_LIST, (yyvsp[-1].opval), op); ;} break; - case 199: -#line 1163 "madly.y" + case 200: +#line 1165 "madly.y" { PL_in_my = 0; (yyval.opval) = my((yyvsp[0].opval)); ;} break; - case 200: -#line 1167 "madly.y" + case 201: +#line 1169 "madly.y" { (yyval.opval) = newCVREF(((yyvsp[-1].tkval))->tk_lval.ival,(yyvsp[0].opval)); token_getmad((yyvsp[-1].tkval),(yyval.opval),'&'); ;} break; - case 201: -#line 1173 "madly.y" + case 202: +#line 1175 "madly.y" { (yyval.opval) = newSVREF((yyvsp[0].opval)); token_getmad((yyvsp[-1].tkval),(yyval.opval),'$'); ;} break; - case 202: -#line 1179 "madly.y" + case 203: +#line 1181 "madly.y" { (yyval.opval) = newAVREF((yyvsp[0].opval)); token_getmad((yyvsp[-1].tkval),(yyval.opval),'@'); ;} break; - case 203: -#line 1185 "madly.y" + case 204: +#line 1187 "madly.y" { (yyval.opval) = newHVREF((yyvsp[0].opval)); token_getmad((yyvsp[-1].tkval),(yyval.opval),'%'); ;} break; - case 204: -#line 1191 "madly.y" + case 205: +#line 1193 "madly.y" { (yyval.opval) = newAVREF((yyvsp[0].opval)); token_getmad((yyvsp[-1].tkval),(yyval.opval),'l'); ;} break; - case 205: -#line 1197 "madly.y" + case 206: +#line 1199 "madly.y" { (yyval.opval) = newGVREF(0,(yyvsp[0].opval)); token_getmad((yyvsp[-1].tkval),(yyval.opval),'*'); ;} break; - case 206: -#line 1204 "madly.y" - { (yyval.opval) = scalar((yyvsp[0].opval)); ;} - break; - case 207: #line 1206 "madly.y" { (yyval.opval) = scalar((yyvsp[0].opval)); ;} @@ -1496,11 +1496,16 @@ case 2: case 208: #line 1208 "madly.y" - { (yyval.opval) = scope((yyvsp[0].opval)); ;} + { (yyval.opval) = scalar((yyvsp[0].opval)); ;} break; case 209: -#line 1211 "madly.y" +#line 1210 "madly.y" + { (yyval.opval) = scope((yyvsp[0].opval)); ;} + break; + + case 210: +#line 1213 "madly.y" { (yyval.opval) = (yyvsp[0].opval); ;} break; diff --git a/madly.tab b/madly.tab index ec58c14..32d11c9 100644 --- a/madly.tab +++ b/madly.tab @@ -7,7 +7,7 @@ /* YYNNTS -- Number of nonterminals. */ #define YYNNTS 66 /* YYNRULES -- Number of rules. */ -#define YYNRULES 209 +#define YYNRULES 210 /* YYNRULES -- Number of states. */ #define YYNSTATES 420 @@ -78,10 +78,11 @@ static const unsigned short int yyprhs[] = 520, 526, 529, 532, 537, 543, 548, 554, 556, 558, 560, 562, 568, 571, 573, 576, 580, 583, 585, 587, 589, 591, 593, 595, 600, 606, 608, 610, 614, 619, - 623, 625, 628, 631, 633, 636, 639, 641, 644, 647, - 649, 653, 655, 659, 664, 669, 671, 673, 677, 680, - 684, 687, 689, 691, 693, 694, 696, 697, 699, 702, - 704, 707, 710, 713, 716, 719, 722, 724, 726, 728 + 623, 625, 628, 631, 633, 636, 639, 641, 644, 646, + 649, 651, 655, 657, 661, 666, 671, 673, 675, 679, + 682, 686, 689, 691, 693, 695, 696, 698, 699, 701, + 704, 706, 709, 712, 715, 718, 721, 724, 726, 728, + 730 }; /* YYRHS -- A `-1'-separated list of the rules' RHS. */ @@ -151,15 +152,16 @@ static const short int yyrhs[] = 149, 88, 87, -1, 149, 88, 133, 87, -1, 53, 13, 146, -1, 39, -1, 39, 143, -1, 65, 134, -1, 44, -1, 44, 92, -1, 44, 143, -1, 57, - -1, 57, 143, -1, 20, 143, -1, 41, -1, 41, - 88, 87, -1, 19, -1, 42, 88, 87, -1, 42, - 88, 133, 87, -1, 17, 88, 134, 87, -1, 13, - -1, 135, -1, 55, 145, 128, -1, 55, 145, -1, - 88, 133, 87, -1, 88, 87, -1, 150, -1, 152, - -1, 151, -1, -1, 134, -1, -1, 133, -1, 133, - 66, -1, 150, -1, 59, 155, -1, 9, 155, -1, - 10, 155, -1, 11, 155, -1, 50, 155, -1, 12, - 155, -1, 13, -1, 150, -1, 92, -1, 18, -1 + -1, 57, 143, -1, 20, -1, 20, 143, -1, 41, + -1, 41, 88, 87, -1, 19, -1, 42, 88, 87, + -1, 42, 88, 133, 87, -1, 17, 88, 134, 87, + -1, 13, -1, 135, -1, 55, 145, 128, -1, 55, + 145, -1, 88, 133, 87, -1, 88, 87, -1, 150, + -1, 152, -1, 151, -1, -1, 134, -1, -1, 133, + -1, 133, 66, -1, 150, -1, 59, 155, -1, 9, + 155, -1, 10, 155, -1, 11, 155, -1, 50, 155, + -1, 12, 155, -1, 13, -1, 150, -1, 92, -1, + 18, -1 }; /* YYRLINE[YYN] -- source line where rule number YYN was defined. */ @@ -182,10 +184,11 @@ static const unsigned short int yyrline[] = 894, 905, 909, 913, 925, 938, 946, 958, 959, 960, 961, 962, 967, 971, 973, 977, 982, 987, 989, 991, 993, 995, 997, 999, 1008, 1019, 1021, 1023, 1028, 1039, - 1044, 1049, 1053, 1057, 1061, 1065, 1069, 1071, 1073, 1076, - 1080, 1086, 1089, 1095, 1101, 1106, 1107, 1111, 1117, 1124, - 1129, 1134, 1136, 1138, 1143, 1145, 1150, 1151, 1153, 1162, - 1166, 1172, 1178, 1184, 1190, 1196, 1203, 1205, 1207, 1210 + 1044, 1049, 1053, 1057, 1061, 1065, 1069, 1071, 1073, 1075, + 1078, 1082, 1088, 1091, 1097, 1103, 1108, 1109, 1113, 1119, + 1126, 1131, 1136, 1138, 1140, 1145, 1147, 1152, 1153, 1155, + 1164, 1168, 1174, 1180, 1186, 1192, 1198, 1205, 1207, 1209, + 1212 }; #endif @@ -257,9 +260,10 @@ static const unsigned char yyr1[] = 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, 143, - 143, 143, 143, 143, 143, 143, 143, 144, 144, 145, - 145, 145, 145, 145, 146, 146, 147, 147, 147, 148, - 149, 150, 151, 152, 153, 154, 155, 155, 155, 155 + 143, 143, 143, 143, 143, 143, 143, 143, 144, 144, + 145, 145, 145, 145, 145, 146, 146, 147, 147, 147, + 148, 149, 150, 151, 152, 153, 154, 155, 155, 155, + 155 }; /* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */ @@ -282,10 +286,11 @@ static const unsigned char yyr2[] = 5, 2, 2, 4, 5, 4, 5, 1, 1, 1, 1, 5, 2, 1, 2, 3, 2, 1, 1, 1, 1, 1, 1, 4, 5, 1, 1, 3, 4, 3, - 1, 2, 2, 1, 2, 2, 1, 2, 2, 1, - 3, 1, 3, 4, 4, 1, 1, 3, 2, 3, - 2, 1, 1, 1, 0, 1, 0, 1, 2, 1, - 2, 2, 2, 2, 2, 2, 1, 1, 1, 1 + 1, 2, 2, 1, 2, 2, 1, 2, 1, 2, + 1, 3, 1, 3, 4, 4, 1, 1, 3, 2, + 3, 2, 1, 1, 1, 0, 1, 0, 1, 2, + 1, 2, 2, 2, 2, 2, 2, 1, 1, 1, + 1 }; /* YYDEFACT[STATE-NAME] -- Default rule to reduce with in state @@ -297,37 +302,37 @@ static const unsigned char yydefact[] = 60, 52, 11, 59, 54, 56, 55, 57, 58, 63, 0, 0, 80, 0, 53, 12, 14, 15, 0, 62, 0, 69, 70, 79, 0, 70, 19, 4, 0, 0, - 0, 0, 0, 0, 0, 185, 0, 0, 165, 0, - 181, 0, 67, 67, 0, 0, 0, 0, 0, 0, - 0, 0, 170, 179, 0, 0, 173, 194, 0, 0, + 0, 0, 0, 0, 0, 186, 0, 0, 165, 0, + 182, 178, 67, 67, 0, 0, 0, 0, 0, 0, + 0, 0, 170, 180, 0, 0, 173, 195, 0, 0, 0, 0, 0, 0, 176, 0, 17, 0, 0, 0, 0, 0, 0, 0, 33, 0, 13, 16, 20, 85, - 186, 162, 147, 148, 149, 150, 88, 153, 166, 157, + 187, 162, 147, 148, 149, 150, 88, 153, 166, 157, 160, 159, 161, 158, 61, 71, 72, 0, 72, 10, - 137, 0, 128, 129, 206, 209, 208, 207, 201, 202, - 203, 205, 194, 0, 0, 178, 0, 70, 4, 4, + 137, 0, 128, 129, 207, 210, 209, 208, 202, 203, + 204, 206, 195, 0, 0, 179, 0, 70, 4, 4, 4, 4, 4, 4, 0, 4, 4, 32, 171, 0, - 0, 196, 174, 175, 206, 195, 95, 207, 0, 204, - 185, 142, 141, 157, 0, 0, 194, 154, 0, 188, - 191, 193, 192, 177, 200, 172, 130, 131, 152, 135, + 0, 197, 174, 175, 207, 196, 95, 208, 0, 205, + 186, 142, 141, 157, 0, 0, 195, 154, 0, 189, + 192, 194, 193, 177, 201, 172, 130, 131, 152, 135, 134, 156, 0, 0, 41, 18, 0, 0, 0, 0, 0, 0, 0, 0, 86, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 133, 132, 0, 0, 0, 0, 0, - 0, 0, 74, 0, 194, 0, 9, 136, 93, 196, + 0, 0, 74, 0, 195, 0, 9, 136, 93, 197, 0, 97, 72, 46, 0, 0, 0, 0, 0, 4, - 5, 0, 180, 182, 0, 197, 0, 0, 89, 0, - 0, 139, 0, 169, 190, 0, 76, 187, 0, 155, + 5, 0, 181, 183, 0, 198, 0, 0, 89, 0, + 0, 139, 0, 169, 191, 0, 76, 188, 0, 155, 34, 23, 24, 48, 21, 22, 25, 84, 83, 82, 87, 0, 0, 111, 0, 123, 119, 120, 116, 117, 114, 0, 126, 125, 124, 122, 121, 118, 127, 115, 0, 0, 99, 0, 92, 100, 167, 0, 0, 0, 0, 0, 0, 73, 78, 77, 65, 0, 64, 3, - 0, 184, 194, 0, 0, 47, 0, 0, 49, 51, - 0, 0, 199, 45, 50, 0, 0, 20, 0, 0, - 0, 183, 198, 96, 0, 143, 0, 145, 0, 138, - 189, 75, 0, 0, 0, 104, 110, 0, 0, 0, - 108, 0, 196, 168, 0, 102, 0, 163, 0, 81, + 0, 185, 195, 0, 0, 47, 0, 0, 49, 51, + 0, 0, 200, 45, 50, 0, 0, 20, 0, 0, + 0, 184, 199, 96, 0, 143, 0, 145, 0, 138, + 190, 75, 0, 0, 0, 104, 110, 0, 0, 0, + 108, 0, 197, 168, 0, 102, 0, 163, 0, 81, 94, 98, 140, 43, 43, 0, 0, 0, 0, 46, 0, 0, 0, 90, 144, 146, 113, 0, 107, 151, 0, 103, 109, 0, 105, 164, 101, 0, 0, 8, @@ -414,7 +419,7 @@ static const short int yypgoto[] = positive, shift that token. If negative, reduce the rule which number is the opposite. If zero, do what YYDEFACT says. If YYTABLE_NINF, syntax error. */ -#define YYTABLE_NINF -186 +#define YYTABLE_NINF -187 static const short int yytable[] = { 88, 216, 84, 300, 104, 218, -2, 215, 37, 145, @@ -463,7 +468,7 @@ static const short int yytable[] = 410, 63, 64, 65, 66, 67, 375, 413, 376, 385, 68, 69, 70, 71, 72, 73, 386, 74, 389, 75, -44, 198, 199, 200, 201, 77, 390, 398, 400, 202, - 203, 204, -186, -186, 205, 407, 205, 78, 79, 80, + 203, 204, -187, -187, 205, 407, 205, 78, 79, 80, 181, 182, 183, 36, 81, 82, 415, 38, 83, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 416, 50, 51, 52, 85, 364, 348, 53, 181, 182, @@ -476,7 +481,7 @@ static const short int yytable[] = 83, 37, 0, 38, 0, 39, 40, 41, 42, 43, 44, 144, 46, 47, 48, 49, 115, 50, 51, 52, 199, 200, 201, 53, 0, 0, 0, 202, 203, 204, - 0, -186, 205, 191, 192, 0, 0, 62, 0, 63, + 0, -187, 205, 191, 192, 0, 0, 62, 0, 63, 64, 65, 66, 67, 0, 0, 0, 0, 68, 69, 70, 71, 72, 73, 0, 74, 0, 75, 0, 0, 200, 201, 0, 77, 0, 0, 202, 203, 204, 0, @@ -484,7 +489,7 @@ static const short int yytable[] = 0, 0, 81, 82, 0, 37, 83, 38, 0, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 0, 50, 51, 52, 0, 0, 0, 53, 0, 0, - 0, 0, 201, 189, -186, 191, 192, 202, 203, 204, + 0, 0, 201, 189, -187, 191, 192, 202, 203, 204, 0, 62, 205, 63, 64, 65, 66, 67, 0, 0, 0, 0, 68, 69, 70, 71, 72, 73, 0, 74, 0, 75, 200, 201, 0, 0, 0, 77, 202, 203, @@ -593,15 +598,15 @@ static const short int yytable[] = 0, 53, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 62, 0, 63, 64, 65, 66, 67, 0, 0, 0, 0, 68, 69, 70, 71, - 72, 73, 0, 74, -185, 75, 0, 0, 0, 0, + 72, 73, 0, 74, -186, 75, 0, 0, 0, 0, 0, 77, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 78, 79, 80, -185, -185, -185, -185, - 81, 82, 0, -185, 83, 0, 0, 0, -185, 0, - 0, 0, 0, 0, -185, -185, -185, -185, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, -185, 0, - -185, -185, -185, 0, -185, -185, -185, -185, -185, -185, - -185, -185, -185, -185, -185, 0, 381, 0, 383, -185, - -185, -185, 387, 0, -185, -185, 0, 0, 0, 0, + 0, 0, 0, 78, 79, 80, -186, -186, -186, -186, + 81, 82, 0, -186, 83, 0, 0, 0, -186, 0, + 0, 0, 0, 0, -186, -186, -186, -186, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, -186, 0, + -186, -186, -186, 0, -186, -186, -186, -186, -186, -186, + -186, -186, -186, -186, -186, 0, 381, 0, 383, -186, + -186, -186, 387, 0, -186, -186, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 391, 392, 0, 0, 0, 0, 0, 0, 401, 402, 0, 0, 0, 0, 0, 0, 188, 406, 0, 0, 0, 408, 189, @@ -614,7 +619,7 @@ static const short int yytable[] = 189, 190, 191, 192, 193, 194, 0, 195, 196, 197, 198, 199, 200, 201, 0, 0, 0, 0, 202, 203, 204, 0, 194, 205, 195, 196, 197, 198, 199, 200, - 201, 0, 0, 0, 0, 202, 203, 204, -186, 0, + 201, 0, 0, 0, 0, 202, 203, 204, -187, 0, 205, 0, 0, 0, 189, 190, 191, 192, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 195, 196, diff --git a/madly.y b/madly.y index 86a4c5e..6021289 100644 --- a/madly.y +++ b/madly.y @@ -1070,6 +1070,8 @@ term : termbinop { $$ = newOP(OP_REQUIRE, $1 ? OPf_SPECIAL : 0); } | REQUIRE term /* require Foo *//* FIMXE for MAD needed? */ { $$ = newUNOP(OP_REQUIRE, $1 ? OPf_SPECIAL : 0, $2); } + | UNIOPSUB + { $$ = newUNOP(OP_ENTERSUB, OPf_STACKED, scalar($1)); } | UNIOPSUB term /* Sub treated as unop */ { $$ = newUNOP(OP_ENTERSUB, OPf_STACKED, append_elem(OP_LIST, $2, scalar($1))); } diff --git a/perly.act b/perly.act index d3e4eba..f1b9340 100644 --- a/perly.act +++ b/perly.act @@ -947,65 +947,65 @@ case 2: case 176: #line 715 "perly.y" - { (yyval.opval) = newUNOP(OP_ENTERSUB, OPf_STACKED, - append_elem(OP_LIST, (yyvsp[0].opval), scalar((yyvsp[-1].opval)))); ;} + { (yyval.opval) = newUNOP(OP_ENTERSUB, OPf_STACKED, scalar((yyvsp[0].opval))); ;} break; case 177: -#line 718 "perly.y" - { (yyval.opval) = newOP((yyvsp[0].ival), 0); ;} +#line 717 "perly.y" + { (yyval.opval) = newUNOP(OP_ENTERSUB, OPf_STACKED, + append_elem(OP_LIST, (yyvsp[0].opval), scalar((yyvsp[-1].opval)))); ;} break; case 178: #line 720 "perly.y" - { (yyval.opval) = newOP((yyvsp[-2].ival), 0); ;} + { (yyval.opval) = newOP((yyvsp[0].ival), 0); ;} break; case 179: #line 722 "perly.y" - { (yyval.opval) = newUNOP(OP_ENTERSUB, OPf_STACKED, - scalar((yyvsp[0].opval))); ;} + { (yyval.opval) = newOP((yyvsp[-2].ival), 0); ;} break; case 180: -#line 725 "perly.y" - { (yyval.opval) = (yyvsp[-2].ival) == OP_NOT ? newUNOP((yyvsp[-2].ival), 0, newSVOP(OP_CONST, 0, newSViv(0))) - : newOP((yyvsp[-2].ival), OPf_SPECIAL); ;} +#line 724 "perly.y" + { (yyval.opval) = newUNOP(OP_ENTERSUB, OPf_STACKED, + scalar((yyvsp[0].opval))); ;} break; case 181: -#line 728 "perly.y" - { (yyval.opval) = newUNOP((yyvsp[-3].ival), 0, (yyvsp[-1].opval)); ;} +#line 727 "perly.y" + { (yyval.opval) = (yyvsp[-2].ival) == OP_NOT ? newUNOP((yyvsp[-2].ival), 0, newSVOP(OP_CONST, 0, newSViv(0))) + : newOP((yyvsp[-2].ival), OPf_SPECIAL); ;} break; case 182: #line 730 "perly.y" - { (yyval.opval) = pmruntime((yyvsp[-3].opval), (yyvsp[-1].opval), 1); ;} + { (yyval.opval) = newUNOP((yyvsp[-3].ival), 0, (yyvsp[-1].opval)); ;} break; - case 185: -#line 737 "perly.y" - { (yyval.opval) = my_attrs((yyvsp[-1].opval),(yyvsp[0].opval)); ;} + case 183: +#line 732 "perly.y" + { (yyval.opval) = pmruntime((yyvsp[-3].opval), (yyvsp[-1].opval), 1); ;} break; case 186: #line 739 "perly.y" - { (yyval.opval) = localize((yyvsp[0].opval),(yyvsp[-1].ival)); ;} + { (yyval.opval) = my_attrs((yyvsp[-1].opval),(yyvsp[0].opval)); ;} break; case 187: -#line 744 "perly.y" - { (yyval.opval) = sawparens((yyvsp[-1].opval)); ;} +#line 741 "perly.y" + { (yyval.opval) = localize((yyvsp[0].opval),(yyvsp[-1].ival)); ;} break; case 188: #line 746 "perly.y" - { (yyval.opval) = sawparens(newNULLLIST()); ;} + { (yyval.opval) = sawparens((yyvsp[-1].opval)); ;} break; case 189: #line 748 "perly.y" - { (yyval.opval) = (yyvsp[0].opval); ;} + { (yyval.opval) = sawparens(newNULLLIST()); ;} break; case 190: @@ -1019,82 +1019,87 @@ case 2: break; case 192: -#line 757 "perly.y" - { (yyval.opval) = Nullop; ;} +#line 754 "perly.y" + { (yyval.opval) = (yyvsp[0].opval); ;} break; case 193: #line 759 "perly.y" - { (yyval.opval) = (yyvsp[0].opval); ;} + { (yyval.opval) = Nullop; ;} break; case 194: -#line 763 "perly.y" - { (yyval.opval) = Nullop; ;} +#line 761 "perly.y" + { (yyval.opval) = (yyvsp[0].opval); ;} break; case 195: #line 765 "perly.y" - { (yyval.opval) = (yyvsp[0].opval); ;} + { (yyval.opval) = Nullop; ;} break; case 196: #line 767 "perly.y" - { (yyval.opval) = (yyvsp[-1].opval); ;} + { (yyval.opval) = (yyvsp[0].opval); ;} break; case 197: -#line 773 "perly.y" - { PL_in_my = 0; (yyval.opval) = my((yyvsp[0].opval)); ;} +#line 769 "perly.y" + { (yyval.opval) = (yyvsp[-1].opval); ;} break; case 198: -#line 777 "perly.y" - { (yyval.opval) = newCVREF((yyvsp[-1].ival),(yyvsp[0].opval)); ;} +#line 775 "perly.y" + { PL_in_my = 0; (yyval.opval) = my((yyvsp[0].opval)); ;} break; case 199: -#line 781 "perly.y" - { (yyval.opval) = newSVREF((yyvsp[0].opval)); ;} +#line 779 "perly.y" + { (yyval.opval) = newCVREF((yyvsp[-1].ival),(yyvsp[0].opval)); ;} break; case 200: -#line 785 "perly.y" - { (yyval.opval) = newAVREF((yyvsp[0].opval)); ;} +#line 783 "perly.y" + { (yyval.opval) = newSVREF((yyvsp[0].opval)); ;} break; case 201: -#line 789 "perly.y" - { (yyval.opval) = newHVREF((yyvsp[0].opval)); ;} +#line 787 "perly.y" + { (yyval.opval) = newAVREF((yyvsp[0].opval)); ;} break; case 202: -#line 793 "perly.y" - { (yyval.opval) = newAVREF((yyvsp[0].opval)); ;} +#line 791 "perly.y" + { (yyval.opval) = newHVREF((yyvsp[0].opval)); ;} break; case 203: -#line 797 "perly.y" - { (yyval.opval) = newGVREF(0,(yyvsp[0].opval)); ;} +#line 795 "perly.y" + { (yyval.opval) = newAVREF((yyvsp[0].opval)); ;} break; case 204: -#line 802 "perly.y" - { (yyval.opval) = scalar((yyvsp[0].opval)); ;} +#line 799 "perly.y" + { (yyval.opval) = newGVREF(0,(yyvsp[0].opval)); ;} break; case 205: #line 804 "perly.y" - { (yyval.opval) = scalar((yyvsp[0].opval)); ;} + { (yyval.opval) = scalar((yyvsp[0].opval)); ;} break; case 206: #line 806 "perly.y" - { (yyval.opval) = scope((yyvsp[0].opval)); ;} + { (yyval.opval) = scalar((yyvsp[0].opval)); ;} break; case 207: -#line 809 "perly.y" +#line 808 "perly.y" + { (yyval.opval) = scope((yyvsp[0].opval)); ;} + break; + + case 208: +#line 811 "perly.y" { (yyval.opval) = (yyvsp[0].opval); ;} break; diff --git a/perly.tab b/perly.tab index 5e84c72..51fc317 100644 --- a/perly.tab +++ b/perly.tab @@ -7,7 +7,7 @@ /* YYNNTS -- Number of nonterminals. */ #define YYNNTS 65 /* YYNRULES -- Number of rules. */ -#define YYNRULES 207 +#define YYNRULES 208 /* YYNRULES -- Number of states. */ #define YYNSTATES 418 @@ -78,10 +78,10 @@ static const unsigned short int yyprhs[] = 525, 528, 533, 539, 544, 550, 552, 554, 556, 558, 564, 567, 569, 572, 576, 579, 581, 583, 585, 587, 589, 591, 596, 602, 604, 606, 610, 615, 619, 621, - 624, 627, 629, 632, 635, 637, 640, 643, 645, 649, - 651, 655, 660, 665, 667, 669, 673, 676, 680, 683, - 685, 687, 689, 690, 692, 693, 695, 698, 700, 703, - 706, 709, 712, 715, 718, 720, 722, 724 + 624, 627, 629, 632, 635, 637, 640, 642, 645, 647, + 651, 653, 657, 662, 667, 669, 671, 675, 678, 682, + 685, 687, 689, 691, 692, 694, 695, 697, 700, 702, + 705, 708, 711, 714, 717, 720, 722, 724, 726 }; /* YYRHS -- A `-1'-separated list of the rules' RHS. */ @@ -151,15 +151,15 @@ static const short int yyrhs[] = 148, 78, 132, 77, -1, 44, 4, 145, -1, 30, -1, 30, 142, -1, 55, 133, -1, 35, -1, 35, 92, -1, 35, 142, -1, 48, -1, 48, 142, -1, - 11, 142, -1, 32, -1, 32, 78, 77, -1, 10, - -1, 33, 78, 77, -1, 33, 78, 132, 77, -1, - 8, 78, 133, 77, -1, 4, -1, 134, -1, 46, - 144, 127, -1, 46, 144, -1, 78, 132, 77, -1, - 78, 77, -1, 149, -1, 151, -1, 150, -1, -1, - 133, -1, -1, 132, -1, 132, 56, -1, 149, -1, - 50, 154, -1, 86, 154, -1, 87, 154, -1, 88, - 154, -1, 41, 154, -1, 89, 154, -1, 4, -1, - 149, -1, 92, -1, 9, -1 + 11, -1, 11, 142, -1, 32, -1, 32, 78, 77, + -1, 10, -1, 33, 78, 77, -1, 33, 78, 132, + 77, -1, 8, 78, 133, 77, -1, 4, -1, 134, + -1, 46, 144, 127, -1, 46, 144, -1, 78, 132, + 77, -1, 78, 77, -1, 149, -1, 151, -1, 150, + -1, -1, 133, -1, -1, 132, -1, 132, 56, -1, + 149, -1, 50, 154, -1, 86, 154, -1, 87, 154, + -1, 88, 154, -1, 41, 154, -1, 89, 154, -1, + 4, -1, 149, -1, 92, -1, 9, -1 }; /* YYRLINE[YYN] -- source line where rule number YYN was defined. */ @@ -182,10 +182,10 @@ static const unsigned short int yyrline[] = 613, 615, 623, 632, 636, 644, 645, 646, 647, 648, 650, 652, 654, 656, 658, 660, 662, 664, 666, 668, 670, 672, 678, 685, 687, 689, 691, 694, 697, 700, - 702, 704, 706, 708, 710, 712, 714, 717, 719, 721, - 724, 727, 729, 731, 732, 736, 738, 743, 745, 747, - 749, 751, 756, 758, 763, 764, 766, 772, 776, 780, - 784, 788, 792, 796, 801, 803, 805, 808 + 702, 704, 706, 708, 710, 712, 714, 716, 719, 721, + 723, 726, 729, 731, 733, 734, 738, 740, 745, 747, + 749, 751, 753, 758, 760, 765, 766, 768, 774, 778, + 782, 786, 790, 794, 798, 803, 805, 807, 810 }; #endif @@ -257,9 +257,9 @@ static const unsigned char yyr1[] = 142, 142, 142, 142, 142, 142, 142, 142, 142, 142, 142, 142, 142, 142, 142, 142, 142, 142, 142, 142, 142, 142, 142, 142, 142, 142, 142, 142, 142, 142, - 142, 142, 142, 142, 142, 143, 143, 144, 144, 144, - 144, 144, 145, 145, 146, 146, 146, 147, 148, 149, - 150, 151, 152, 153, 154, 154, 154, 154 + 142, 142, 142, 142, 142, 142, 143, 143, 144, 144, + 144, 144, 144, 145, 145, 146, 146, 146, 147, 148, + 149, 150, 151, 152, 153, 154, 154, 154, 154 }; /* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */ @@ -282,10 +282,10 @@ static const unsigned char yyr2[] = 2, 4, 5, 4, 5, 1, 1, 1, 1, 5, 2, 1, 2, 3, 2, 1, 1, 1, 1, 1, 1, 4, 5, 1, 1, 3, 4, 3, 1, 2, - 2, 1, 2, 2, 1, 2, 2, 1, 3, 1, - 3, 4, 4, 1, 1, 3, 2, 3, 2, 1, - 1, 1, 0, 1, 0, 1, 2, 1, 2, 2, - 2, 2, 2, 2, 1, 1, 1, 1 + 2, 1, 2, 2, 1, 2, 1, 2, 1, 3, + 1, 3, 4, 4, 1, 1, 3, 2, 3, 2, + 1, 1, 1, 0, 1, 0, 1, 2, 1, 2, + 2, 2, 2, 2, 2, 1, 1, 1, 1 }; /* YYDEFACT[STATE-NAME] -- Default rule to reduce with in state @@ -296,38 +296,38 @@ static const unsigned char yydefact[] = 6, 0, 10, 1, 9, 66, 64, 0, 64, 64, 52, 11, 54, 56, 55, 57, 58, 61, 0, 0, 78, 0, 53, 12, 14, 15, 0, 60, 0, 67, - 68, 77, 0, 68, 19, 4, 183, 0, 0, 163, - 0, 179, 0, 65, 65, 0, 0, 0, 0, 0, - 0, 0, 0, 168, 177, 0, 0, 171, 192, 0, + 68, 77, 0, 68, 19, 4, 184, 0, 0, 163, + 0, 180, 176, 65, 65, 0, 0, 0, 0, 0, + 0, 0, 0, 168, 178, 0, 0, 171, 193, 0, 0, 0, 0, 0, 0, 174, 0, 0, 0, 0, 0, 0, 0, 0, 0, 17, 0, 0, 0, 0, - 0, 0, 33, 0, 13, 16, 20, 83, 184, 160, + 0, 0, 33, 0, 13, 16, 20, 83, 185, 160, 145, 146, 147, 148, 86, 151, 164, 155, 158, 157, - 159, 156, 59, 69, 70, 0, 70, 10, 204, 207, - 206, 205, 192, 0, 0, 176, 0, 68, 4, 4, + 159, 156, 59, 69, 70, 0, 70, 10, 205, 208, + 207, 206, 193, 0, 0, 177, 0, 68, 4, 4, 4, 4, 4, 4, 0, 4, 4, 32, 169, 0, - 0, 194, 172, 173, 204, 193, 93, 205, 0, 202, - 183, 140, 139, 155, 0, 0, 192, 152, 0, 186, - 189, 191, 190, 175, 198, 170, 128, 129, 150, 133, - 132, 154, 0, 135, 0, 126, 127, 199, 200, 201, - 203, 0, 41, 18, 0, 0, 0, 0, 0, 0, + 0, 195, 172, 173, 205, 194, 93, 206, 0, 203, + 184, 140, 139, 155, 0, 0, 193, 152, 0, 187, + 190, 192, 191, 175, 199, 170, 128, 129, 150, 133, + 132, 154, 0, 135, 0, 126, 127, 200, 201, 202, + 204, 0, 41, 18, 0, 0, 0, 0, 0, 0, 0, 0, 84, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 131, 130, 0, 0, 0, 0, 0, 0, 0, - 72, 0, 192, 0, 9, 91, 194, 0, 95, 70, - 46, 0, 0, 0, 0, 0, 4, 5, 0, 178, - 180, 0, 195, 0, 0, 87, 0, 0, 137, 0, - 167, 188, 0, 74, 185, 0, 153, 134, 34, 23, + 72, 0, 193, 0, 9, 91, 195, 0, 95, 70, + 46, 0, 0, 0, 0, 0, 4, 5, 0, 179, + 181, 0, 196, 0, 0, 87, 0, 0, 137, 0, + 167, 189, 0, 74, 186, 0, 153, 134, 34, 23, 24, 48, 21, 22, 25, 82, 81, 80, 85, 0, 109, 0, 0, 121, 117, 118, 114, 115, 112, 0, 124, 123, 122, 120, 119, 116, 125, 113, 0, 97, 0, 0, 90, 98, 165, 0, 0, 0, 0, 0, - 0, 71, 76, 75, 63, 0, 62, 3, 0, 182, - 192, 0, 0, 47, 0, 0, 49, 51, 0, 0, - 197, 45, 50, 0, 0, 20, 0, 0, 0, 181, - 196, 94, 0, 141, 0, 143, 0, 136, 187, 73, + 0, 71, 76, 75, 63, 0, 62, 3, 0, 183, + 193, 0, 0, 47, 0, 0, 49, 51, 0, 0, + 198, 45, 50, 0, 0, 20, 0, 0, 0, 182, + 197, 94, 0, 141, 0, 143, 0, 136, 188, 73, 0, 0, 0, 108, 102, 0, 0, 106, 0, 0, - 194, 166, 0, 100, 0, 161, 0, 79, 92, 96, + 195, 166, 0, 100, 0, 161, 0, 79, 92, 96, 138, 43, 43, 0, 0, 0, 0, 46, 0, 0, 0, 88, 142, 144, 111, 0, 105, 149, 0, 107, 101, 0, 103, 162, 99, 0, 0, 8, 26, 26, @@ -414,7 +414,7 @@ static const short int yypgoto[] = positive, shift that token. If negative, reduce the rule which number is the opposite. If zero, do what YYDEFACT says. If YYTABLE_NINF, syntax error. */ -#define YYTABLE_NINF -184 +#define YYTABLE_NINF -185 static const short int yytable[] = { 86, 214, 82, 298, 102, 313, 135, 213, 318, 35, @@ -433,7 +433,7 @@ static const short int yytable[] = 190, 146, 171, 78, 119, 380, 5, 6, 120, 7, 8, 179, 180, 181, 121, 297, 125, 248, 249, 251, 252, 253, 254, 255, 256, 257, 199, 259, 261, 262, - 135, 200, 201, 202, -184, -184, 203, 173, 203, 9, + 135, 200, 201, 202, -185, -185, 203, 173, 203, 9, 182, 126, 247, 209, 129, 316, 130, 131, 285, 286, 287, 288, 289, 290, 204, 410, 210, 293, 283, 293, 232, 179, 180, 181, 303, 251, 148, 251, -2, 315, @@ -477,7 +477,7 @@ static const short int yytable[] = 0, -44, 73, 74, 0, 0, 0, 0, 76, 77, 78, 79, 80, 81, 35, 134, 37, 38, 39, 40, 109, 41, 42, 43, 0, 370, 0, 44, 0, 179, - 180, 181, 0, 0, 187, -184, 189, 190, 0, 0, + 180, 181, 0, 0, 187, -185, 189, 190, 0, 0, 0, 53, 0, 54, 55, 56, 57, 58, 0, 0, 0, 0, 59, 60, 61, 62, 63, 64, 0, 65, 386, 66, 198, 199, 0, 0, 67, 0, 200, 201, @@ -494,7 +494,7 @@ static const short int yytable[] = 180, 181, 71, 72, 0, 0, 73, 74, 179, 180, 181, 0, 76, 77, 78, 79, 80, 81, 35, 140, 37, 38, 39, 40, 362, 41, 42, 43, 179, 180, - 181, 44, 0, 363, 0, 0, 0, 0, -184, 0, + 181, 44, 0, 363, 0, 0, 0, 0, -185, 0, 189, 190, 0, 0, 0, 53, 0, 54, 55, 56, 57, 58, 0, 369, 0, 0, 59, 60, 61, 62, 63, 64, 0, 65, 0, 66, 198, 199, 0, 0, @@ -602,14 +602,14 @@ static const short int yytable[] = 203, 0, 0, 0, 0, 0, -155, -155, -155, 0, -155, -155, -155, -155, -155, -155, -155, -155, -155, -155, -155, 0, 0, 0, 0, -155, -155, -155, 0, 0, - -155, -155, 0, 206, 0, 0, -155, -155, -183, -183, - -183, -183, 0, 0, 0, -183, 0, 0, 0, 0, - -183, 0, 0, 0, 0, 0, -183, -183, -183, -183, + -155, -155, 0, 206, 0, 0, -155, -155, -184, -184, + -184, -184, 0, 0, 0, -184, 0, 0, 0, 0, + -184, 0, 0, 0, 0, 0, -184, -184, -184, -184, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, -183, -183, -183, 0, -183, -183, -183, -183, -183, - -183, -183, -183, -183, -183, -183, 0, 0, 0, 0, - -183, -183, -183, 0, 0, -183, -183, 186, 0, 0, - 0, -183, -183, 187, 188, 189, 190, 0, 0, 0, + 0, -184, -184, -184, 0, -184, -184, -184, -184, -184, + -184, -184, -184, -184, -184, -184, 0, 0, 0, 0, + -184, -184, -184, 0, 0, -184, -184, 186, 0, 0, + 0, -184, -184, 187, 188, 189, 190, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 191, 192, 335, 193, 194, 195, 196, 197, 198, 199, 0, 0, 0, 0, 200, 201, 202, @@ -619,7 +619,7 @@ static const short int yytable[] = 194, 195, 196, 197, 198, 199, 0, 0, 0, 0, 200, 201, 202, 186, 0, 203, 0, 0, 0, 187, 188, 189, 190, 0, 0, 0, 0, 0, 0, 0, - -184, 0, 0, 0, 0, 0, 187, 188, 189, 190, + -185, 0, 0, 0, 0, 0, 187, 188, 189, 190, 192, 0, 193, 194, 195, 196, 197, 198, 199, 0, 0, 0, 0, 200, 201, 202, 0, 0, 203, 193, 194, 195, 196, 197, 198, 199, 0, 0, 0, 0, diff --git a/perly.y b/perly.y index 99493ce..77caeb6 100644 --- a/perly.y +++ b/perly.y @@ -711,6 +711,8 @@ term : termbinop { $$ = newOP(OP_REQUIRE, $1 ? OPf_SPECIAL : 0); } | REQUIRE term /* require Foo */ { $$ = newUNOP(OP_REQUIRE, $1 ? OPf_SPECIAL : 0, $2); } + | UNIOPSUB + { $$ = newUNOP(OP_ENTERSUB, OPf_STACKED, scalar($1)); } | UNIOPSUB term /* Sub treated as unop */ { $$ = newUNOP(OP_ENTERSUB, OPf_STACKED, append_elem(OP_LIST, $2, scalar($1))); } diff --git a/t/comp/uproto.t b/t/comp/uproto.t index b82a5a3..9b908eb 100644 --- a/t/comp/uproto.t +++ b/t/comp/uproto.t @@ -6,7 +6,7 @@ BEGIN { require "./test.pl"; } -plan(tests => 38); +plan(tests => 39); sub f($$_) { my $x = shift; is("@_", $x) } @@ -55,6 +55,7 @@ g("foo"); g($expected); $_ = $expected; g(); +g; undef $expected; &g; # $_ not passed { $expected = my $_ = "bar"; g() }