Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

[perl #95546] Allow () after __FILE__, etc.

This commit makes the __FILE__, __LINE__ and __PACKAGE__ token parse
the same way as nullary functions.

It adds two extra rules to perly.y to allow the op to be created in
toke.c, instead of directly inside the parser.
  • Loading branch information...
commit 7eb971ee54c13db586d1afe434b0fa7d3fb759af 1 parent f4ef369
authored August 08, 2011
129  perly.act
@@ -1510,12 +1510,25 @@ case 2:
1510 1510
 
1511 1511
   case 188:
1512 1512
 #line 1236 "perly.y"
  1513
+    { (yyval.opval) = (ps[(1) - (1)].val.opval); ;}
  1514
+    break;
  1515
+
  1516
+  case 189:
  1517
+#line 1238 "perly.y"
  1518
+    { (yyval.opval) = (ps[(1) - (3)].val.opval);
  1519
+			  TOKEN_GETMAD((ps[(2) - (3)].val.i_tkval),(yyval.opval),'(');
  1520
+			  TOKEN_GETMAD((ps[(3) - (3)].val.i_tkval),(yyval.opval),')');
  1521
+			;}
  1522
+    break;
  1523
+
  1524
+  case 190:
  1525
+#line 1243 "perly.y"
1513 1526
     { (yyval.opval) = newUNOP(OP_ENTERSUB, OPf_STACKED,
1514 1527
 				scalar((ps[(1) - (1)].val.opval))); ;}
1515 1528
     break;
1516 1529
 
1517  
-  case 189:
1518  
-#line 1239 "perly.y"
  1530
+  case 191:
  1531
+#line 1246 "perly.y"
1519 1532
     { (yyval.opval) = (IVAL((ps[(1) - (3)].val.i_tkval)) == OP_NOT)
1520 1533
 			    ? newUNOP(IVAL((ps[(1) - (3)].val.i_tkval)), 0, newSVOP(OP_CONST, 0, newSViv(0)))
1521 1534
 			    : newOP(IVAL((ps[(1) - (3)].val.i_tkval)), OPf_SPECIAL);
@@ -1526,8 +1539,8 @@ case 2:
1526 1539
 			;}
1527 1540
     break;
1528 1541
 
1529  
-  case 190:
1530  
-#line 1248 "perly.y"
  1542
+  case 192:
  1543
+#line 1255 "perly.y"
1531 1544
     { (yyval.opval) = newUNOP(IVAL((ps[(1) - (4)].val.i_tkval)), 0, (ps[(3) - (4)].val.opval));
1532 1545
 			  TOKEN_GETMAD((ps[(1) - (4)].val.i_tkval),(yyval.opval),'o');
1533 1546
 			  TOKEN_GETMAD((ps[(2) - (4)].val.i_tkval),(yyval.opval),'(');
@@ -1535,16 +1548,16 @@ case 2:
1535 1548
 			;}
1536 1549
     break;
1537 1550
 
1538  
-  case 191:
1539  
-#line 1254 "perly.y"
  1551
+  case 193:
  1552
+#line 1261 "perly.y"
1540 1553
     { (yyval.opval) = pmruntime((ps[(1) - (4)].val.opval), (ps[(3) - (4)].val.opval), 1);
1541 1554
 			  TOKEN_GETMAD((ps[(2) - (4)].val.i_tkval),(yyval.opval),'(');
1542 1555
 			  TOKEN_GETMAD((ps[(4) - (4)].val.i_tkval),(yyval.opval),')');
1543 1556
 			;}
1544 1557
     break;
1545 1558
 
1546  
-  case 194:
1547  
-#line 1261 "perly.y"
  1559
+  case 196:
  1560
+#line 1268 "perly.y"
1548 1561
     {
1549 1562
 			  (yyval.opval) = newLISTOP(OP_DIE, 0, newOP(OP_PUSHMARK, 0),
1550 1563
 				newSVOP(OP_CONST, 0, newSVpvs("Unimplemented")));
@@ -1552,8 +1565,8 @@ case 2:
1552 1565
 			;}
1553 1566
     break;
1554 1567
 
1555  
-  case 196:
1556  
-#line 1271 "perly.y"
  1568
+  case 198:
  1569
+#line 1278 "perly.y"
1557 1570
     { (yyval.opval) = my_attrs((ps[(2) - (3)].val.opval),(ps[(3) - (3)].val.opval));
1558 1571
 			  DO_MAD(
1559 1572
 			      token_getmad((ps[(1) - (3)].val.i_tkval),(yyval.opval),'d');
@@ -1563,47 +1576,37 @@ case 2:
1563 1576
 			;}
1564 1577
     break;
1565 1578
 
1566  
-  case 197:
1567  
-#line 1279 "perly.y"
  1579
+  case 199:
  1580
+#line 1286 "perly.y"
1568 1581
     { (yyval.opval) = localize((ps[(2) - (2)].val.opval),IVAL((ps[(1) - (2)].val.i_tkval)));
1569 1582
 			  TOKEN_GETMAD((ps[(1) - (2)].val.i_tkval),(yyval.opval),'d');
1570 1583
 			;}
1571 1584
     break;
1572 1585
 
1573  
-  case 198:
1574  
-#line 1286 "perly.y"
  1586
+  case 200:
  1587
+#line 1293 "perly.y"
1575 1588
     { (yyval.opval) = sawparens((ps[(2) - (3)].val.opval));
1576 1589
 			  TOKEN_GETMAD((ps[(1) - (3)].val.i_tkval),(yyval.opval),'(');
1577 1590
 			  TOKEN_GETMAD((ps[(3) - (3)].val.i_tkval),(yyval.opval),')');
1578 1591
 			;}
1579 1592
     break;
1580 1593
 
1581  
-  case 199:
1582  
-#line 1291 "perly.y"
  1594
+  case 201:
  1595
+#line 1298 "perly.y"
1583 1596
     { (yyval.opval) = sawparens(newNULLLIST());
1584 1597
 			  TOKEN_GETMAD((ps[(1) - (2)].val.i_tkval),(yyval.opval),'(');
1585 1598
 			  TOKEN_GETMAD((ps[(2) - (2)].val.i_tkval),(yyval.opval),')');
1586 1599
 			;}
1587 1600
     break;
1588 1601
 
1589  
-  case 200:
1590  
-#line 1296 "perly.y"
1591  
-    { (yyval.opval) = (ps[(1) - (1)].val.opval); ;}
1592  
-    break;
1593  
-
1594  
-  case 201:
1595  
-#line 1298 "perly.y"
1596  
-    { (yyval.opval) = (ps[(1) - (1)].val.opval); ;}
1597  
-    break;
1598  
-
1599 1602
   case 202:
1600  
-#line 1300 "perly.y"
  1603
+#line 1303 "perly.y"
1601 1604
     { (yyval.opval) = (ps[(1) - (1)].val.opval); ;}
1602 1605
     break;
1603 1606
 
1604 1607
   case 203:
1605 1608
 #line 1305 "perly.y"
1606  
-    { (yyval.opval) = (OP*)NULL; ;}
  1609
+    { (yyval.opval) = (ps[(1) - (1)].val.opval); ;}
1607 1610
     break;
1608 1611
 
1609 1612
   case 204:
@@ -1612,94 +1615,104 @@ case 2:
1612 1615
     break;
1613 1616
 
1614 1617
   case 205:
1615  
-#line 1311 "perly.y"
  1618
+#line 1312 "perly.y"
1616 1619
     { (yyval.opval) = (OP*)NULL; ;}
1617 1620
     break;
1618 1621
 
1619 1622
   case 206:
1620  
-#line 1313 "perly.y"
  1623
+#line 1314 "perly.y"
1621 1624
     { (yyval.opval) = (ps[(1) - (1)].val.opval); ;}
1622 1625
     break;
1623 1626
 
1624 1627
   case 207:
1625  
-#line 1317 "perly.y"
1626  
-    { (yyval.i_tkval) = (ps[(1) - (1)].val.i_tkval); ;}
  1628
+#line 1318 "perly.y"
  1629
+    { (yyval.opval) = (OP*)NULL; ;}
1627 1630
     break;
1628 1631
 
1629 1632
   case 208:
1630  
-#line 1319 "perly.y"
1631  
-    { munge_qwlist_to_paren_list((ps[(1) - (1)].val.opval)); ;}
  1633
+#line 1320 "perly.y"
  1634
+    { (yyval.opval) = (ps[(1) - (1)].val.opval); ;}
1632 1635
     break;
1633 1636
 
1634 1637
   case 209:
1635  
-#line 1321 "perly.y"
1636  
-    { (yyval.i_tkval) = (ps[(3) - (3)].val.i_tkval); ;}
  1638
+#line 1324 "perly.y"
  1639
+    { (yyval.i_tkval) = (ps[(1) - (1)].val.i_tkval); ;}
1637 1640
     break;
1638 1641
 
1639 1642
   case 210:
1640  
-#line 1327 "perly.y"
1641  
-    { PL_parser->in_my = 0; (yyval.opval) = my((ps[(1) - (1)].val.opval)); ;}
  1643
+#line 1326 "perly.y"
  1644
+    { munge_qwlist_to_paren_list((ps[(1) - (1)].val.opval)); ;}
1642 1645
     break;
1643 1646
 
1644 1647
   case 211:
1645  
-#line 1331 "perly.y"
  1648
+#line 1328 "perly.y"
  1649
+    { (yyval.i_tkval) = (ps[(3) - (3)].val.i_tkval); ;}
  1650
+    break;
  1651
+
  1652
+  case 212:
  1653
+#line 1334 "perly.y"
  1654
+    { PL_parser->in_my = 0; (yyval.opval) = my((ps[(1) - (1)].val.opval)); ;}
  1655
+    break;
  1656
+
  1657
+  case 213:
  1658
+#line 1338 "perly.y"
1646 1659
     { (yyval.opval) = newCVREF(IVAL((ps[(1) - (2)].val.i_tkval)),(ps[(2) - (2)].val.opval));
1647 1660
 			  TOKEN_GETMAD((ps[(1) - (2)].val.i_tkval),(yyval.opval),'&');
1648 1661
 			;}
1649 1662
     break;
1650 1663
 
1651  
-  case 212:
1652  
-#line 1337 "perly.y"
  1664
+  case 214:
  1665
+#line 1344 "perly.y"
1653 1666
     { (yyval.opval) = newSVREF((ps[(2) - (2)].val.opval));
1654 1667
 			  TOKEN_GETMAD((ps[(1) - (2)].val.i_tkval),(yyval.opval),'$');
1655 1668
 			;}
1656 1669
     break;
1657 1670
 
1658  
-  case 213:
1659  
-#line 1343 "perly.y"
  1671
+  case 215:
  1672
+#line 1350 "perly.y"
1660 1673
     { (yyval.opval) = newAVREF((ps[(2) - (2)].val.opval));
1661 1674
 			  TOKEN_GETMAD((ps[(1) - (2)].val.i_tkval),(yyval.opval),'@');
1662 1675
 			;}
1663 1676
     break;
1664 1677
 
1665  
-  case 214:
1666  
-#line 1349 "perly.y"
  1678
+  case 216:
  1679
+#line 1356 "perly.y"
1667 1680
     { (yyval.opval) = newHVREF((ps[(2) - (2)].val.opval));
1668 1681
 			  TOKEN_GETMAD((ps[(1) - (2)].val.i_tkval),(yyval.opval),'%');
1669 1682
 			;}
1670 1683
     break;
1671 1684
 
1672  
-  case 215:
1673  
-#line 1355 "perly.y"
  1685
+  case 217:
  1686
+#line 1362 "perly.y"
1674 1687
     { (yyval.opval) = newAVREF((ps[(2) - (2)].val.opval));
1675 1688
 			  TOKEN_GETMAD((ps[(1) - (2)].val.i_tkval),(yyval.opval),'l');
1676 1689
 			;}
1677 1690
     break;
1678 1691
 
1679  
-  case 216:
1680  
-#line 1361 "perly.y"
  1692
+  case 218:
  1693
+#line 1368 "perly.y"
1681 1694
     { (yyval.opval) = newGVREF(0,(ps[(2) - (2)].val.opval));
1682 1695
 			  TOKEN_GETMAD((ps[(1) - (2)].val.i_tkval),(yyval.opval),'*');
1683 1696
 			;}
1684 1697
     break;
1685 1698
 
1686  
-  case 217:
1687  
-#line 1368 "perly.y"
  1699
+  case 219:
  1700
+#line 1375 "perly.y"
1688 1701
     { (yyval.opval) = scalar((ps[(1) - (1)].val.opval)); ;}
1689 1702
     break;
1690 1703
 
1691  
-  case 218:
1692  
-#line 1370 "perly.y"
  1704
+  case 220:
  1705
+#line 1377 "perly.y"
1693 1706
     { (yyval.opval) = scalar((ps[(1) - (1)].val.opval)); ;}
1694 1707
     break;
1695 1708
 
1696  
-  case 219:
1697  
-#line 1372 "perly.y"
  1709
+  case 221:
  1710
+#line 1379 "perly.y"
1698 1711
     { (yyval.opval) = op_scope((ps[(1) - (1)].val.opval)); ;}
1699 1712
     break;
1700 1713
 
1701  
-  case 220:
1702  
-#line 1375 "perly.y"
  1714
+  case 222:
  1715
+#line 1382 "perly.y"
1703 1716
     { (yyval.opval) = (ps[(1) - (1)].val.opval); ;}
1704 1717
     break;
1705 1718
 
@@ -1710,6 +1723,6 @@ case 2:
1710 1723
     
1711 1724
 
1712 1725
 /* Generated from:
1713  
- * 8bdd3d69bab2a9d77e0557f3b46a8845e8de190fafce0bc37841a105bbcacaa5 perly.y
  1726
+ * 7fb05fb0a9bd3f1c047696941084a07f2d9928ccde2dd343a19d32cf51669760 perly.y
1714 1727
  * 738ca60a0b4cb075902435e976a2f393d438e8e6e32ba81e037dd773b75c87b5 regen_perly.pl
1715 1728
  * ex: set ro: */
264  perly.h
@@ -59,71 +59,72 @@
59 59
      PMFUNC = 268,
60 60
      PRIVATEREF = 269,
61 61
      QWLIST = 270,
62  
-     FUNC0SUB = 271,
63  
-     UNIOPSUB = 272,
64  
-     LSTOPSUB = 273,
65  
-     PLUGEXPR = 274,
66  
-     PLUGSTMT = 275,
67  
-     LABEL = 276,
68  
-     FORMAT = 277,
69  
-     SUB = 278,
70  
-     ANONSUB = 279,
71  
-     PACKAGE = 280,
72  
-     USE = 281,
73  
-     WHILE = 282,
74  
-     UNTIL = 283,
75  
-     IF = 284,
76  
-     UNLESS = 285,
77  
-     ELSE = 286,
78  
-     ELSIF = 287,
79  
-     CONTINUE = 288,
80  
-     FOR = 289,
81  
-     GIVEN = 290,
82  
-     WHEN = 291,
83  
-     DEFAULT = 292,
84  
-     LOOPEX = 293,
85  
-     DOTDOT = 294,
86  
-     YADAYADA = 295,
87  
-     FUNC0 = 296,
88  
-     FUNC1 = 297,
89  
-     FUNC = 298,
90  
-     UNIOP = 299,
91  
-     LSTOP = 300,
92  
-     RELOP = 301,
93  
-     EQOP = 302,
94  
-     MULOP = 303,
95  
-     ADDOP = 304,
96  
-     DOLSHARP = 305,
97  
-     DO = 306,
98  
-     HASHBRACK = 307,
99  
-     NOAMP = 308,
100  
-     LOCAL = 309,
101  
-     MY = 310,
102  
-     MYSUB = 311,
103  
-     REQUIRE = 312,
104  
-     COLONATTR = 313,
105  
-     PREC_LOW = 314,
106  
-     DOROP = 315,
107  
-     OROP = 316,
108  
-     ANDOP = 317,
109  
-     NOTOP = 318,
110  
-     ASSIGNOP = 319,
111  
-     DORDOR = 320,
112  
-     OROR = 321,
113  
-     ANDAND = 322,
114  
-     BITOROP = 323,
115  
-     BITANDOP = 324,
116  
-     SHIFTOP = 325,
117  
-     MATCHOP = 326,
118  
-     REFGEN = 327,
119  
-     UMINUS = 328,
120  
-     POWOP = 329,
121  
-     POSTDEC = 330,
122  
-     POSTINC = 331,
123  
-     PREDEC = 332,
124  
-     PREINC = 333,
125  
-     ARROW = 334,
126  
-     PEG = 335
  62
+     FUNC0OP = 271,
  63
+     FUNC0SUB = 272,
  64
+     UNIOPSUB = 273,
  65
+     LSTOPSUB = 274,
  66
+     PLUGEXPR = 275,
  67
+     PLUGSTMT = 276,
  68
+     LABEL = 277,
  69
+     FORMAT = 278,
  70
+     SUB = 279,
  71
+     ANONSUB = 280,
  72
+     PACKAGE = 281,
  73
+     USE = 282,
  74
+     WHILE = 283,
  75
+     UNTIL = 284,
  76
+     IF = 285,
  77
+     UNLESS = 286,
  78
+     ELSE = 287,
  79
+     ELSIF = 288,
  80
+     CONTINUE = 289,
  81
+     FOR = 290,
  82
+     GIVEN = 291,
  83
+     WHEN = 292,
  84
+     DEFAULT = 293,
  85
+     LOOPEX = 294,
  86
+     DOTDOT = 295,
  87
+     YADAYADA = 296,
  88
+     FUNC0 = 297,
  89
+     FUNC1 = 298,
  90
+     FUNC = 299,
  91
+     UNIOP = 300,
  92
+     LSTOP = 301,
  93
+     RELOP = 302,
  94
+     EQOP = 303,
  95
+     MULOP = 304,
  96
+     ADDOP = 305,
  97
+     DOLSHARP = 306,
  98
+     DO = 307,
  99
+     HASHBRACK = 308,
  100
+     NOAMP = 309,
  101
+     LOCAL = 310,
  102
+     MY = 311,
  103
+     MYSUB = 312,
  104
+     REQUIRE = 313,
  105
+     COLONATTR = 314,
  106
+     PREC_LOW = 315,
  107
+     DOROP = 316,
  108
+     OROP = 317,
  109
+     ANDOP = 318,
  110
+     NOTOP = 319,
  111
+     ASSIGNOP = 320,
  112
+     DORDOR = 321,
  113
+     OROR = 322,
  114
+     ANDAND = 323,
  115
+     BITOROP = 324,
  116
+     BITANDOP = 325,
  117
+     SHIFTOP = 326,
  118
+     MATCHOP = 327,
  119
+     REFGEN = 328,
  120
+     UMINUS = 329,
  121
+     POWOP = 330,
  122
+     POSTDEC = 331,
  123
+     POSTINC = 332,
  124
+     PREDEC = 333,
  125
+     PREINC = 334,
  126
+     ARROW = 335,
  127
+     PEG = 336
127 128
    };
128 129
 #endif
129 130
 /* Tokens.  */
@@ -140,71 +141,72 @@
140 141
 #define PMFUNC 268
141 142
 #define PRIVATEREF 269
142 143
 #define QWLIST 270
143  
-#define FUNC0SUB 271
144  
-#define UNIOPSUB 272
145  
-#define LSTOPSUB 273
146  
-#define PLUGEXPR 274
147  
-#define PLUGSTMT 275
148  
-#define LABEL 276
149  
-#define FORMAT 277
150  
-#define SUB 278
151  
-#define ANONSUB 279
152  
-#define PACKAGE 280
153  
-#define USE 281
154  
-#define WHILE 282
155  
-#define UNTIL 283
156  
-#define IF 284
157  
-#define UNLESS 285
158  
-#define ELSE 286
159  
-#define ELSIF 287
160  
-#define CONTINUE 288
161  
-#define FOR 289
162  
-#define GIVEN 290
163  
-#define WHEN 291
164  
-#define DEFAULT 292
165  
-#define LOOPEX 293
166  
-#define DOTDOT 294
167  
-#define YADAYADA 295
168  
-#define FUNC0 296
169  
-#define FUNC1 297
170  
-#define FUNC 298
171  
-#define UNIOP 299
172  
-#define LSTOP 300
173  
-#define RELOP 301
174  
-#define EQOP 302
175  
-#define MULOP 303
176  
-#define ADDOP 304
177  
-#define DOLSHARP 305
178  
-#define DO 306
179  
-#define HASHBRACK 307
180  
-#define NOAMP 308
181  
-#define LOCAL 309
182  
-#define MY 310
183  
-#define MYSUB 311
184  
-#define REQUIRE 312
185  
-#define COLONATTR 313
186  
-#define PREC_LOW 314
187  
-#define DOROP 315
188  
-#define OROP 316
189  
-#define ANDOP 317
190  
-#define NOTOP 318
191  
-#define ASSIGNOP 319
192  
-#define DORDOR 320
193  
-#define OROR 321
194  
-#define ANDAND 322
195  
-#define BITOROP 323
196  
-#define BITANDOP 324
197  
-#define SHIFTOP 325
198  
-#define MATCHOP 326
199  
-#define REFGEN 327
200  
-#define UMINUS 328
201  
-#define POWOP 329
202  
-#define POSTDEC 330
203  
-#define POSTINC 331
204  
-#define PREDEC 332
205  
-#define PREINC 333
206  
-#define ARROW 334
207  
-#define PEG 335
  144
+#define FUNC0OP 271
  145
+#define FUNC0SUB 272
  146
+#define UNIOPSUB 273
  147
+#define LSTOPSUB 274
  148
+#define PLUGEXPR 275
  149
+#define PLUGSTMT 276
  150
+#define LABEL 277
  151
+#define FORMAT 278
  152
+#define SUB 279
  153
+#define ANONSUB 280
  154
+#define PACKAGE 281
  155
+#define USE 282
  156
+#define WHILE 283
  157
+#define UNTIL 284
  158
+#define IF 285
  159
+#define UNLESS 286
  160
+#define ELSE 287
  161
+#define ELSIF 288
  162
+#define CONTINUE 289
  163
+#define FOR 290
  164
+#define GIVEN 291
  165
+#define WHEN 292
  166
+#define DEFAULT 293
  167
+#define LOOPEX 294
  168
+#define DOTDOT 295
  169
+#define YADAYADA 296
  170
+#define FUNC0 297
  171
+#define FUNC1 298
  172
+#define FUNC 299
  173
+#define UNIOP 300
  174
+#define LSTOP 301
  175
+#define RELOP 302
  176
+#define EQOP 303
  177
+#define MULOP 304
  178
+#define ADDOP 305
  179
+#define DOLSHARP 306
  180
+#define DO 307
  181
+#define HASHBRACK 308
  182
+#define NOAMP 309
  183
+#define LOCAL 310
  184
+#define MY 311
  185
+#define MYSUB 312
  186
+#define REQUIRE 313
  187
+#define COLONATTR 314
  188
+#define PREC_LOW 315
  189
+#define DOROP 316
  190
+#define OROP 317
  191
+#define ANDOP 318
  192
+#define NOTOP 319
  193
+#define ASSIGNOP 320
  194
+#define DORDOR 321
  195
+#define OROR 322
  196
+#define ANDAND 323
  197
+#define BITOROP 324
  198
+#define BITANDOP 325
  199
+#define SHIFTOP 326
  200
+#define MATCHOP 327
  201
+#define REFGEN 328
  202
+#define UMINUS 329
  203
+#define POWOP 330
  204
+#define POSTDEC 331
  205
+#define POSTINC 332
  206
+#define PREDEC 333
  207
+#define PREINC 334
  208
+#define ARROW 335
  209
+#define PEG 336
208 210
 
209 211
 
210 212
 
@@ -240,6 +242,6 @@ typedef union YYSTYPE
240 242
 
241 243
 
242 244
 /* Generated from:
243  
- * 8bdd3d69bab2a9d77e0557f3b46a8845e8de190fafce0bc37841a105bbcacaa5 perly.y
  245
+ * 7fb05fb0a9bd3f1c047696941084a07f2d9928ccde2dd343a19d32cf51669760 perly.y
244 246
  * 738ca60a0b4cb075902435e976a2f393d438e8e6e32ba81e037dd773b75c87b5 regen_perly.pl
245 247
  * ex: set ro: */
1,601  perly.tab
810 additions, 791 deletions not shown
9  perly.y
@@ -74,7 +74,7 @@
74 74
 %token <i_tkval> '{' '}' '[' ']' '-' '+' '$' '@' '%' '*' '&' ';'
75 75
 
76 76
 %token <opval> WORD METHOD FUNCMETH THING PMFUNC PRIVATEREF QWLIST
77  
-%token <opval> FUNC0SUB UNIOPSUB LSTOPSUB
  77
+%token <opval> FUNC0OP FUNC0SUB UNIOPSUB LSTOPSUB
78 78
 %token <opval> PLUGEXPR PLUGSTMT
79 79
 %token <p_tkval> LABEL
80 80
 %token <i_tkval> FORMAT SUB ANONSUB PACKAGE USE
@@ -1232,6 +1232,13 @@ term	:	termbinop
1232 1232
 			  TOKEN_GETMAD($2,$$,'(');
1233 1233
 			  TOKEN_GETMAD($3,$$,')');
1234 1234
 			}
  1235
+	|	FUNC0OP       /* Same as above, but op created in toke.c */
  1236
+			{ $$ = $1; }
  1237
+	|	FUNC0OP '(' ')'
  1238
+			{ $$ = $1;
  1239
+			  TOKEN_GETMAD($2,$$,'(');
  1240
+			  TOKEN_GETMAD($3,$$,')');
  1241
+			}
1235 1242
 	|	FUNC0SUB                             /* Sub treated as nullop */
1236 1243
 			{ $$ = newUNOP(OP_ENTERSUB, OPf_STACKED,
1237 1244
 				scalar($1)); }
24  toke.c
@@ -224,6 +224,7 @@ static const char* const lex_state_names[] = {
224 224
  * LOOPX        : loop exiting command (goto, last, dump, etc)
225 225
  * FTST         : file test operator
226 226
  * FUN0         : zero-argument function
  227
+ * FUN0OP       : zero-argument function, with its op created in this file
227 228
  * FUN1         : not used, except for not, which isn't a UNIOP
228 229
  * BOop         : bitwise or or xor
229 230
  * BAop         : bitwise and
@@ -254,6 +255,7 @@ static const char* const lex_state_names[] = {
254 255
 #define LOOPX(f) return (pl_yylval.ival=f, PL_expect=XTERM, PL_bufptr=s, REPORT((int)LOOPEX))
255 256
 #define FTST(f)  return (pl_yylval.ival=f, PL_expect=XTERMORDORDOR, PL_bufptr=s, REPORT((int)UNIOP))
256 257
 #define FUN0(f)  return (pl_yylval.ival=f, PL_expect=XOPERATOR, PL_bufptr=s, REPORT((int)FUNC0))
  258
+#define FUN0OP(f)  return (pl_yylval.opval=f, CLINE, PL_expect=XOPERATOR, PL_bufptr=s, REPORT((int)FUNC0OP))
257 259
 #define FUN1(f)  return (pl_yylval.ival=f, PL_expect=XOPERATOR, PL_bufptr=s, REPORT((int)FUNC1))
258 260
 #define BOop(f)  return ao((pl_yylval.ival=f, PL_expect=XTERM, PL_bufptr=s, REPORT((int)BITOROP)))
259 261
 #define BAop(f)  return ao((pl_yylval.ival=f, PL_expect=XTERM, PL_bufptr=s, REPORT((int)BITANDOP)))
@@ -346,6 +348,7 @@ static struct debug_tokens {
346 348
     { FORMAT,		TOKENTYPE_NONE,		"FORMAT" },
347 349
     { FUNC,		TOKENTYPE_OPNUM,	"FUNC" },
348 350
     { FUNC0,		TOKENTYPE_OPNUM,	"FUNC0" },
  351
+    { FUNC0OP,		TOKENTYPE_OPVAL,	"FUNC0OP" },
349 352
     { FUNC0SUB,		TOKENTYPE_OPVAL,	"FUNC0SUB" },
350 353
     { FUNC1,		TOKENTYPE_OPNUM,	"FUNC1" },
351 354
     { FUNCMETH,		TOKENTYPE_OPVAL,	"FUNCMETH" },
@@ -6923,21 +6926,24 @@ Perl_yylex(pTHX)
6923 6926
 	    }
6924 6927
 
6925 6928
 	case KEY___FILE__:
6926  
-	    pl_yylval.opval = (OP*)newSVOP(OP_CONST, 0,
6927  
-					newSVpv(CopFILE(PL_curcop),0));
6928  
-	    TERM(THING);
  6929
+	    FUN0OP(
  6930
+		pl_yylval.opval = (OP*)newSVOP(OP_CONST, 0,
  6931
+					newSVpv(CopFILE(PL_curcop),0))
  6932
+	    );
6929 6933
 
6930 6934
 	case KEY___LINE__:
6931  
-            pl_yylval.opval = (OP*)newSVOP(OP_CONST, 0,
6932  
-                                    Perl_newSVpvf(aTHX_ "%"IVdf, (IV)CopLINE(PL_curcop)));
6933  
-	    TERM(THING);
  6935
+	    FUN0OP(
  6936
+        	(OP*)newSVOP(OP_CONST, 0,
  6937
+		    Perl_newSVpvf(aTHX_ "%"IVdf, (IV)CopLINE(PL_curcop)))
  6938
+	    );
6934 6939
 
6935 6940
 	case KEY___PACKAGE__:
6936  
-	    pl_yylval.opval = (OP*)newSVOP(OP_CONST, 0,
  6941
+	    FUN0OP(
  6942
+		(OP*)newSVOP(OP_CONST, 0,
6937 6943
 					(PL_curstash
6938 6944
 					 ? newSVhek(HvNAME_HEK(PL_curstash))
6939  
-					 : &PL_sv_undef));
6940  
-	    TERM(THING);
  6945
+					 : &PL_sv_undef))
  6946
+	    );
6941 6947
 
6942 6948
 	case KEY___DATA__:
6943 6949
 	case KEY___END__: {

0 notes on commit 7eb971e

Please sign in to comment.
Something went wrong with that request. Please try again.