PageRenderTime 62ms CodeModel.GetById 31ms RepoModel.GetById 0ms app.codeStats 1ms

/opensource.apple.com/source/perl/perl-21/perl/perly.y

#
Happy | 759 lines | 677 code | 82 blank | 0 comment | 0 complexity | da4d5e8b863d9d07256a29d9fe14abf9 MD5 | raw file
Possible License(s): MPL-2.0-no-copyleft-exception, GPL-2.0, BSD-3-Clause, GPL-3.0, MPL-2.0, LGPL-2.0, LGPL-2.1, CC-BY-SA-3.0, IPL-1.0, ISC, AGPL-1.0, AGPL-3.0, JSON, Apache-2.0, 0BSD
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
  2. "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
  3. <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
  4. <head>
  5. <title>perly.y</title>
  6. <style type="text/css">
  7. .enscript-comment { font-style: italic; color: rgb(178,34,34); }
  8. .enscript-function-name { font-weight: bold; color: rgb(0,0,255); }
  9. .enscript-variable-name { font-weight: bold; color: rgb(184,134,11); }
  10. .enscript-keyword { font-weight: bold; color: rgb(160,32,240); }
  11. .enscript-reference { font-weight: bold; color: rgb(95,158,160); }
  12. .enscript-string { font-weight: bold; color: rgb(188,143,143); }
  13. .enscript-builtin { font-weight: bold; color: rgb(218,112,214); }
  14. .enscript-type { font-weight: bold; color: rgb(34,139,34); }
  15. .enscript-highlight { text-decoration: underline; color: 0; }
  16. </style>
  17. </head>
  18. <body id="top">
  19. <h1 style="margin:8px;" id="f1">perly.y&nbsp;&nbsp;&nbsp;<span style="font-weight: normal; font-size: 0.5em;">[<a href="?txt">plain text</a>]</span></h1>
  20. <hr/>
  21. <div></div>
  22. <pre>
  23. /* perly.y
  24. *
  25. * Copyright (c) 1991-2000, Larry Wall
  26. *
  27. * You may distribute under the terms of either the GNU General Public
  28. * License or the Artistic License, as specified in the README file.
  29. *
  30. */
  31. /*
  32. * 'I see,' laughed Strider. 'I look foul and feel fair. Is that it?
  33. * All that is gold does not glitter, not all those who wander are lost.'
  34. */
  35. %{
  36. #include &quot;EXTERN.h&quot;
  37. #define PERL_IN_PERLY_C
  38. #include &quot;perl.h&quot;
  39. #define dep() deprecate(&quot;\&quot;do\&quot; to call subroutines&quot;)
  40. /* stuff included here to make perly_c.diff apply better */
  41. #define yydebug PL_yydebug
  42. #define yynerrs PL_yynerrs
  43. #define yyerrflag PL_yyerrflag
  44. #define yychar PL_yychar
  45. #define yyval PL_yyval
  46. #define yylval PL_yylval
  47. struct ysv {
  48. short* yyss;
  49. YYSTYPE* yyvs;
  50. int oldyydebug;
  51. int oldyynerrs;
  52. int oldyyerrflag;
  53. int oldyychar;
  54. YYSTYPE oldyyval;
  55. YYSTYPE oldyylval;
  56. };
  57. static void yydestruct(pTHXo_ void *ptr);
  58. %}
  59. %start prog
  60. %{
  61. #if 0 /* get this from perly.h instead */
  62. %}
  63. %union {
  64. I32 ival;
  65. char *pval;
  66. OP *opval;
  67. GV *gvval;
  68. }
  69. %{
  70. #endif /* 0 */
  71. #ifdef USE_PURE_BISON
  72. #define YYLEX_PARAM (&amp;yychar)
  73. #endif
  74. %}
  75. %token &lt;ival&gt; '{'
  76. %token &lt;opval&gt; WORD METHOD FUNCMETH THING PMFUNC PRIVATEREF
  77. %token &lt;opval&gt; FUNC0SUB UNIOPSUB LSTOPSUB
  78. %token &lt;pval&gt; LABEL
  79. %token &lt;ival&gt; FORMAT SUB ANONSUB PACKAGE USE
  80. %token &lt;ival&gt; WHILE UNTIL IF UNLESS ELSE ELSIF CONTINUE FOR
  81. %token &lt;ival&gt; LOOPEX DOTDOT
  82. %token &lt;ival&gt; FUNC0 FUNC1 FUNC UNIOP LSTOP
  83. %token &lt;ival&gt; RELOP EQOP MULOP ADDOP
  84. %token &lt;ival&gt; DOLSHARP DO HASHBRACK NOAMP
  85. %token &lt;ival&gt; LOCAL MY MYSUB
  86. %token COLONATTR
  87. %type &lt;ival&gt; prog decl format startsub startanonsub startformsub
  88. %type &lt;ival&gt; remember mremember '&amp;'
  89. %type &lt;opval&gt; block mblock lineseq line loop cond else
  90. %type &lt;opval&gt; expr term subscripted scalar ary hsh arylen star amper sideff
  91. %type &lt;opval&gt; argexpr nexpr texpr iexpr mexpr mnexpr mtexpr miexpr
  92. %type &lt;opval&gt; listexpr listexprcom indirob listop method
  93. %type &lt;opval&gt; formname subname proto subbody cont my_scalar
  94. %type &lt;opval&gt; subattrlist myattrlist mysubrout myattrterm myterm
  95. %type &lt;pval&gt; label
  96. %nonassoc PREC_LOW
  97. %nonassoc LOOPEX
  98. %left &lt;ival&gt; OROP
  99. %left ANDOP
  100. %right NOTOP
  101. %nonassoc LSTOP LSTOPSUB
  102. %left ','
  103. %right &lt;ival&gt; ASSIGNOP
  104. %right '?' ':'
  105. %nonassoc DOTDOT
  106. %left OROR
  107. %left ANDAND
  108. %left &lt;ival&gt; BITOROP
  109. %left &lt;ival&gt; BITANDOP
  110. %nonassoc EQOP
  111. %nonassoc RELOP
  112. %nonassoc UNIOP UNIOPSUB
  113. %left &lt;ival&gt; SHIFTOP
  114. %left ADDOP
  115. %left MULOP
  116. %left &lt;ival&gt; MATCHOP
  117. %right '!' '~' UMINUS REFGEN
  118. %right &lt;ival&gt; POWOP
  119. %nonassoc PREINC PREDEC POSTINC POSTDEC
  120. %left ARROW
  121. %nonassoc &lt;ival&gt; ')'
  122. %left '('
  123. %left '[' '{'
  124. %% /* RULES */
  125. prog : /* NULL */
  126. {
  127. #if defined(YYDEBUG) &amp;&amp; defined(DEBUGGING)
  128. yydebug = (PL_debug &amp; 1);
  129. #endif
  130. PL_expect = XSTATE;
  131. }
  132. /*CONTINUED*/ lineseq
  133. { newPROG($2); }
  134. ;
  135. block : '{' remember lineseq '}'
  136. { if (PL_copline &gt; (line_t)$1)
  137. PL_copline = $1;
  138. $$ = block_end($2, $3); }
  139. ;
  140. remember: /* NULL */ /* start a full lexical scope */
  141. { $$ = block_start(TRUE); }
  142. ;
  143. mblock : '{' mremember lineseq '}'
  144. { if (PL_copline &gt; (line_t)$1)
  145. PL_copline = $1;
  146. $$ = block_end($2, $3); }
  147. ;
  148. mremember: /* NULL */ /* start a partial lexical scope */
  149. { $$ = block_start(FALSE); }
  150. ;
  151. lineseq : /* NULL */
  152. { $$ = Nullop; }
  153. | lineseq decl
  154. { $$ = $1; }
  155. | lineseq line
  156. { $$ = append_list(OP_LINESEQ,
  157. (LISTOP*)$1, (LISTOP*)$2);
  158. PL_pad_reset_pending = TRUE;
  159. if ($1 &amp;&amp; $2) PL_hints |= HINT_BLOCK_SCOPE; }
  160. ;
  161. line : label cond
  162. { $$ = newSTATEOP(0, $1, $2); }
  163. | loop /* loops add their own labels */
  164. | label ';'
  165. { if ($1 != Nullch) {
  166. $$ = newSTATEOP(0, $1, newOP(OP_NULL, 0));
  167. }
  168. else {
  169. $$ = Nullop;
  170. PL_copline = NOLINE;
  171. }
  172. PL_expect = XSTATE; }
  173. | label sideff ';'
  174. { $$ = newSTATEOP(0, $1, $2);
  175. PL_expect = XSTATE; }
  176. ;
  177. sideff : error
  178. { $$ = Nullop; }
  179. | expr
  180. { $$ = $1; }
  181. | expr IF expr
  182. { $$ = newLOGOP(OP_AND, 0, $3, $1); }
  183. | expr UNLESS expr
  184. { $$ = newLOGOP(OP_OR, 0, $3, $1); }
  185. | expr WHILE expr
  186. { $$ = newLOOPOP(OPf_PARENS, 1, scalar($3), $1); }
  187. | expr UNTIL iexpr
  188. { $$ = newLOOPOP(OPf_PARENS, 1, $3, $1);}
  189. | expr FOR expr
  190. { $$ = newFOROP(0, Nullch, $2,
  191. Nullop, $3, $1, Nullop); }
  192. ;
  193. else : /* NULL */
  194. { $$ = Nullop; }
  195. | ELSE mblock
  196. { ($2)-&gt;op_flags |= OPf_PARENS; $$ = scope($2); }
  197. | ELSIF '(' mexpr ')' mblock else
  198. { PL_copline = $1;
  199. $$ = newCONDOP(0, $3, scope($5), $6);
  200. PL_hints |= HINT_BLOCK_SCOPE; }
  201. ;
  202. cond : IF '(' remember mexpr ')' mblock else
  203. { PL_copline = $1;
  204. $$ = block_end($3,
  205. newCONDOP(0, $4, scope($6), $7)); }
  206. | UNLESS '(' remember miexpr ')' mblock else
  207. { PL_copline = $1;
  208. $$ = block_end($3,
  209. newCONDOP(0, $4, scope($6), $7)); }
  210. ;
  211. cont : /* NULL */
  212. { $$ = Nullop; }
  213. | CONTINUE block
  214. { $$ = scope($2); }
  215. ;
  216. loop : label WHILE '(' remember mtexpr ')' mblock cont
  217. { PL_copline = $2;
  218. $$ = block_end($4,
  219. newSTATEOP(0, $1,
  220. newWHILEOP(0, 1, (LOOP*)Nullop,
  221. $2, $5, $7, $8))); }
  222. | label UNTIL '(' remember miexpr ')' mblock cont
  223. { PL_copline = $2;
  224. $$ = block_end($4,
  225. newSTATEOP(0, $1,
  226. newWHILEOP(0, 1, (LOOP*)Nullop,
  227. $2, $5, $7, $8))); }
  228. | label FOR MY remember my_scalar '(' mexpr ')' mblock cont
  229. { $$ = block_end($4,
  230. newFOROP(0, $1, $2, $5, $7, $9, $10)); }
  231. | label FOR scalar '(' remember mexpr ')' mblock cont
  232. { $$ = block_end($5,
  233. newFOROP(0, $1, $2, mod($3, OP_ENTERLOOP),
  234. $6, $8, $9)); }
  235. | label FOR '(' remember mexpr ')' mblock cont
  236. { $$ = block_end($4,
  237. newFOROP(0, $1, $2, Nullop, $5, $7, $8)); }
  238. | label FOR '(' remember mnexpr ';' mtexpr ';' mnexpr ')' mblock
  239. /* basically fake up an initialize-while lineseq */
  240. { OP *forop = append_elem(OP_LINESEQ,
  241. scalar($5),
  242. newWHILEOP(0, 1, (LOOP*)Nullop,
  243. $2, scalar($7),
  244. $11, scalar($9)));
  245. PL_copline = $2;
  246. $$ = block_end($4, newSTATEOP(0, $1, forop)); }
  247. | label block cont /* a block is a loop that happens once */
  248. { $$ = newSTATEOP(0, $1,
  249. newWHILEOP(0, 1, (LOOP*)Nullop,
  250. NOLINE, Nullop, $2, $3)); }
  251. ;
  252. nexpr : /* NULL */
  253. { $$ = Nullop; }
  254. | sideff
  255. ;
  256. texpr : /* NULL means true */
  257. { (void)scan_num(&quot;1&quot;); $$ = yylval.opval; }
  258. | expr
  259. ;
  260. iexpr : expr
  261. { $$ = invert(scalar($1)); }
  262. ;
  263. mexpr : expr
  264. { $$ = $1; intro_my(); }
  265. ;
  266. mnexpr : nexpr
  267. { $$ = $1; intro_my(); }
  268. ;
  269. mtexpr : texpr
  270. { $$ = $1; intro_my(); }
  271. ;
  272. miexpr : iexpr
  273. { $$ = $1; intro_my(); }
  274. ;
  275. label : /* empty */
  276. { $$ = Nullch; }
  277. | LABEL
  278. ;
  279. decl : format
  280. { $$ = 0; }
  281. | subrout
  282. { $$ = 0; }
  283. | mysubrout
  284. { $$ = 0; }
  285. | package
  286. { $$ = 0; }
  287. | use
  288. { $$ = 0; }
  289. ;
  290. format : FORMAT startformsub formname block
  291. { newFORM($2, $3, $4); }
  292. ;
  293. formname: WORD { $$ = $1; }
  294. | /* NULL */ { $$ = Nullop; }
  295. ;
  296. mysubrout: MYSUB startsub subname proto subattrlist subbody
  297. { newMYSUB($2, $3, $4, $5, $6); }
  298. ;
  299. subrout : SUB startsub subname proto subattrlist subbody
  300. { newATTRSUB($2, $3, $4, $5, $6); }
  301. ;
  302. startsub: /* NULL */ /* start a regular subroutine scope */
  303. { $$ = start_subparse(FALSE, 0); }
  304. ;
  305. startanonsub: /* NULL */ /* start an anonymous subroutine scope */
  306. { $$ = start_subparse(FALSE, CVf_ANON); }
  307. ;
  308. startformsub: /* NULL */ /* start a format subroutine scope */
  309. { $$ = start_subparse(TRUE, 0); }
  310. ;
  311. subname : WORD { STRLEN n_a; char *name = SvPV(((SVOP*)$1)-&gt;op_sv,n_a);
  312. if (strEQ(name, &quot;BEGIN&quot;) || strEQ(name, &quot;END&quot;)
  313. || strEQ(name, &quot;INIT&quot;) || strEQ(name, &quot;CHECK&quot;))
  314. CvSPECIAL_on(PL_compcv);
  315. $$ = $1; }
  316. ;
  317. proto : /* NULL */
  318. { $$ = Nullop; }
  319. | THING
  320. ;
  321. subattrlist: /* NULL */
  322. { $$ = Nullop; }
  323. | COLONATTR THING
  324. { $$ = $2; }
  325. | COLONATTR
  326. { $$ = Nullop; }
  327. ;
  328. myattrlist: COLONATTR THING
  329. { $$ = $2; }
  330. | COLONATTR
  331. { $$ = Nullop; }
  332. ;
  333. subbody : block { $$ = $1; }
  334. | ';' { $$ = Nullop; PL_expect = XSTATE; }
  335. ;
  336. package : PACKAGE WORD ';'
  337. { package($2); }
  338. | PACKAGE ';'
  339. { package(Nullop); }
  340. ;
  341. use : USE startsub
  342. { CvSPECIAL_on(PL_compcv); /* It's a BEGIN {} */ }
  343. WORD WORD listexpr ';'
  344. { utilize($1, $2, $4, $5, $6); }
  345. ;
  346. expr : expr ANDOP expr
  347. { $$ = newLOGOP(OP_AND, 0, $1, $3); }
  348. | expr OROP expr
  349. { $$ = newLOGOP($2, 0, $1, $3); }
  350. | argexpr %prec PREC_LOW
  351. ;
  352. argexpr : argexpr ','
  353. { $$ = $1; }
  354. | argexpr ',' term
  355. { $$ = append_elem(OP_LIST, $1, $3); }
  356. | term %prec PREC_LOW
  357. ;
  358. listop : LSTOP indirob argexpr
  359. { $$ = convert($1, OPf_STACKED,
  360. prepend_elem(OP_LIST, newGVREF($1,$2), $3) ); }
  361. | FUNC '(' indirob expr ')'
  362. { $$ = convert($1, OPf_STACKED,
  363. prepend_elem(OP_LIST, newGVREF($1,$3), $4) ); }
  364. | term ARROW method '(' listexprcom ')'
  365. { $$ = convert(OP_ENTERSUB, OPf_STACKED,
  366. append_elem(OP_LIST,
  367. prepend_elem(OP_LIST, scalar($1), $5),
  368. newUNOP(OP_METHOD, 0, $3))); }
  369. | term ARROW method
  370. { $$ = convert(OP_ENTERSUB, OPf_STACKED,
  371. append_elem(OP_LIST, scalar($1),
  372. newUNOP(OP_METHOD, 0, $3))); }
  373. | METHOD indirob listexpr
  374. { $$ = convert(OP_ENTERSUB, OPf_STACKED,
  375. append_elem(OP_LIST,
  376. prepend_elem(OP_LIST, $2, $3),
  377. newUNOP(OP_METHOD, 0, $1))); }
  378. | FUNCMETH indirob '(' listexprcom ')'
  379. { $$ = convert(OP_ENTERSUB, OPf_STACKED,
  380. append_elem(OP_LIST,
  381. prepend_elem(OP_LIST, $2, $4),
  382. newUNOP(OP_METHOD, 0, $1))); }
  383. | LSTOP listexpr
  384. { $$ = convert($1, 0, $2); }
  385. | FUNC '(' listexprcom ')'
  386. { $$ = convert($1, 0, $3); }
  387. | LSTOPSUB startanonsub block
  388. { $3 = newANONATTRSUB($2, 0, Nullop, $3); }
  389. listexpr %prec LSTOP
  390. { $$ = newUNOP(OP_ENTERSUB, OPf_STACKED,
  391. append_elem(OP_LIST,
  392. prepend_elem(OP_LIST, $3, $5), $1)); }
  393. ;
  394. method : METHOD
  395. | scalar
  396. ;
  397. subscripted: star '{' expr ';' '}'
  398. { $$ = newBINOP(OP_GELEM, 0, $1, scalar($3)); }
  399. | scalar '[' expr ']'
  400. { $$ = newBINOP(OP_AELEM, 0, oopsAV($1), scalar($3)); }
  401. | term ARROW '[' expr ']'
  402. { $$ = newBINOP(OP_AELEM, 0,
  403. ref(newAVREF($1),OP_RV2AV),
  404. scalar($4));}
  405. | subscripted '[' expr ']'
  406. { $$ = newBINOP(OP_AELEM, 0,
  407. ref(newAVREF($1),OP_RV2AV),
  408. scalar($3));}
  409. | scalar '{' expr ';' '}'
  410. { $$ = newBINOP(OP_HELEM, 0, oopsHV($1), jmaybe($3));
  411. PL_expect = XOPERATOR; }
  412. | term ARROW '{' expr ';' '}'
  413. { $$ = newBINOP(OP_HELEM, 0,
  414. ref(newHVREF($1),OP_RV2HV),
  415. jmaybe($4));
  416. PL_expect = XOPERATOR; }
  417. | subscripted '{' expr ';' '}'
  418. { $$ = newBINOP(OP_HELEM, 0,
  419. ref(newHVREF($1),OP_RV2HV),
  420. jmaybe($3));
  421. PL_expect = XOPERATOR; }
  422. | term ARROW '(' ')'
  423. { $$ = newUNOP(OP_ENTERSUB, OPf_STACKED,
  424. newCVREF(0, scalar($1))); }
  425. | term ARROW '(' expr ')'
  426. { $$ = newUNOP(OP_ENTERSUB, OPf_STACKED,
  427. append_elem(OP_LIST, $4,
  428. newCVREF(0, scalar($1)))); }
  429. | subscripted '(' expr ')'
  430. { $$ = newUNOP(OP_ENTERSUB, OPf_STACKED,
  431. append_elem(OP_LIST, $3,
  432. newCVREF(0, scalar($1)))); }
  433. | subscripted '(' ')'
  434. { $$ = newUNOP(OP_ENTERSUB, OPf_STACKED,
  435. newCVREF(0, scalar($1))); }
  436. term : term ASSIGNOP term
  437. { $$ = newASSIGNOP(OPf_STACKED, $1, $2, $3); }
  438. | term POWOP term
  439. { $$ = newBINOP($2, 0, scalar($1), scalar($3)); }
  440. | term MULOP term
  441. { if ($2 != OP_REPEAT)
  442. scalar($1);
  443. $$ = newBINOP($2, 0, $1, scalar($3)); }
  444. | term ADDOP term
  445. { $$ = newBINOP($2, 0, scalar($1), scalar($3)); }
  446. | term SHIFTOP term
  447. { $$ = newBINOP($2, 0, scalar($1), scalar($3)); }
  448. | term RELOP term
  449. { $$ = newBINOP($2, 0, scalar($1), scalar($3)); }
  450. | term EQOP term
  451. { $$ = newBINOP($2, 0, scalar($1), scalar($3)); }
  452. | term BITANDOP term
  453. { $$ = newBINOP($2, 0, scalar($1), scalar($3)); }
  454. | term BITOROP term
  455. { $$ = newBINOP($2, 0, scalar($1), scalar($3)); }
  456. | term DOTDOT term
  457. { $$ = newRANGE($2, scalar($1), scalar($3));}
  458. | term ANDAND term
  459. { $$ = newLOGOP(OP_AND, 0, $1, $3); }
  460. | term OROR term
  461. { $$ = newLOGOP(OP_OR, 0, $1, $3); }
  462. | term '?' term ':' term
  463. { $$ = newCONDOP(0, $1, $3, $5); }
  464. | term MATCHOP term
  465. { $$ = bind_match($2, $1, $3); }
  466. | '-' term %prec UMINUS
  467. { $$ = newUNOP(OP_NEGATE, 0, scalar($2)); }
  468. | '+' term %prec UMINUS
  469. { $$ = $2; }
  470. | '!' term
  471. { $$ = newUNOP(OP_NOT, 0, scalar($2)); }
  472. | '~' term
  473. { $$ = newUNOP(OP_COMPLEMENT, 0, scalar($2));}
  474. | REFGEN term
  475. { $$ = newUNOP(OP_REFGEN, 0, mod($2,OP_REFGEN)); }
  476. | term POSTINC
  477. { $$ = newUNOP(OP_POSTINC, 0,
  478. mod(scalar($1), OP_POSTINC)); }
  479. | term POSTDEC
  480. { $$ = newUNOP(OP_POSTDEC, 0,
  481. mod(scalar($1), OP_POSTDEC)); }
  482. | PREINC term
  483. { $$ = newUNOP(OP_PREINC, 0,
  484. mod(scalar($2), OP_PREINC)); }
  485. | PREDEC term
  486. { $$ = newUNOP(OP_PREDEC, 0,
  487. mod(scalar($2), OP_PREDEC)); }
  488. | myattrterm %prec UNIOP
  489. { $$ = $1; }
  490. | LOCAL term %prec UNIOP
  491. { $$ = localize($2,$1); }
  492. | '(' expr ')'
  493. { $$ = sawparens($2); }
  494. | '(' ')'
  495. { $$ = sawparens(newNULLLIST()); }
  496. | '[' expr ']'
  497. { $$ = newANONLIST($2); }
  498. | '[' ']'
  499. { $$ = newANONLIST(Nullop); }
  500. | HASHBRACK expr ';' '}' %prec '('
  501. { $$ = newANONHASH($2); }
  502. | HASHBRACK ';' '}' %prec '('
  503. { $$ = newANONHASH(Nullop); }
  504. | ANONSUB startanonsub proto subattrlist block %prec '('
  505. { $$ = newANONATTRSUB($2, $3, $4, $5); }
  506. | scalar %prec '('
  507. { $$ = $1; }
  508. | star %prec '('
  509. { $$ = $1; }
  510. | hsh %prec '('
  511. { $$ = $1; }
  512. | ary %prec '('
  513. { $$ = $1; }
  514. | arylen %prec '('
  515. { $$ = newUNOP(OP_AV2ARYLEN, 0, ref($1, OP_AV2ARYLEN));}
  516. | subscripted
  517. { $$ = $1; }
  518. | '(' expr ')' '[' expr ']'
  519. { $$ = newSLICEOP(0, $5, $2); }
  520. | '(' ')' '[' expr ']'
  521. { $$ = newSLICEOP(0, $4, Nullop); }
  522. | ary '[' expr ']'
  523. { $$ = prepend_elem(OP_ASLICE,
  524. newOP(OP_PUSHMARK, 0),
  525. newLISTOP(OP_ASLICE, 0,
  526. list($3),
  527. ref($1, OP_ASLICE))); }
  528. | ary '{' expr ';' '}'
  529. { $$ = prepend_elem(OP_HSLICE,
  530. newOP(OP_PUSHMARK, 0),
  531. newLISTOP(OP_HSLICE, 0,
  532. list($3),
  533. ref(oopsHV($1), OP_HSLICE)));
  534. PL_expect = XOPERATOR; }
  535. | THING %prec '('
  536. { $$ = $1; }
  537. | amper
  538. { $$ = newUNOP(OP_ENTERSUB, 0, scalar($1)); }
  539. | amper '(' ')'
  540. { $$ = newUNOP(OP_ENTERSUB, OPf_STACKED, scalar($1)); }
  541. | amper '(' expr ')'
  542. { $$ = newUNOP(OP_ENTERSUB, OPf_STACKED,
  543. append_elem(OP_LIST, $3, scalar($1))); }
  544. | NOAMP WORD listexpr
  545. { $$ = newUNOP(OP_ENTERSUB, OPf_STACKED,
  546. append_elem(OP_LIST, $3, scalar($2))); }
  547. | DO term %prec UNIOP
  548. { $$ = dofile($2); }
  549. | DO block %prec '('
  550. { $$ = newUNOP(OP_NULL, OPf_SPECIAL, scope($2)); }
  551. | DO WORD '(' ')'
  552. { $$ = newUNOP(OP_ENTERSUB,
  553. OPf_SPECIAL|OPf_STACKED,
  554. prepend_elem(OP_LIST,
  555. scalar(newCVREF(
  556. (OPpENTERSUB_AMPER&lt;&lt;8),
  557. scalar($2)
  558. )),Nullop)); dep();}
  559. | DO WORD '(' expr ')'
  560. { $$ = newUNOP(OP_ENTERSUB,
  561. OPf_SPECIAL|OPf_STACKED,
  562. append_elem(OP_LIST,
  563. $4,
  564. scalar(newCVREF(
  565. (OPpENTERSUB_AMPER&lt;&lt;8),
  566. scalar($2)
  567. )))); dep();}
  568. | DO scalar '(' ')'
  569. { $$ = newUNOP(OP_ENTERSUB, OPf_SPECIAL|OPf_STACKED,
  570. prepend_elem(OP_LIST,
  571. scalar(newCVREF(0,scalar($2))), Nullop)); dep();}
  572. | DO scalar '(' expr ')'
  573. { $$ = newUNOP(OP_ENTERSUB, OPf_SPECIAL|OPf_STACKED,
  574. prepend_elem(OP_LIST,
  575. $4,
  576. scalar(newCVREF(0,scalar($2))))); dep();}
  577. | LOOPEX
  578. { $$ = newOP($1, OPf_SPECIAL);
  579. PL_hints |= HINT_BLOCK_SCOPE; }
  580. | LOOPEX term
  581. { $$ = newLOOPEX($1,$2); }
  582. | NOTOP argexpr
  583. { $$ = newUNOP(OP_NOT, 0, scalar($2)); }
  584. | UNIOP
  585. { $$ = newOP($1, 0); }
  586. | UNIOP block
  587. { $$ = newUNOP($1, 0, $2); }
  588. | UNIOP term
  589. { $$ = newUNOP($1, 0, $2); }
  590. | UNIOPSUB term
  591. { $$ = newUNOP(OP_ENTERSUB, OPf_STACKED,
  592. append_elem(OP_LIST, $2, scalar($1))); }
  593. | FUNC0
  594. { $$ = newOP($1, 0); }
  595. | FUNC0 '(' ')'
  596. { $$ = newOP($1, 0); }
  597. | FUNC0SUB
  598. { $$ = newUNOP(OP_ENTERSUB, OPf_STACKED,
  599. scalar($1)); }
  600. | FUNC1 '(' ')'
  601. { $$ = newOP($1, OPf_SPECIAL); }
  602. | FUNC1 '(' expr ')'
  603. { $$ = newUNOP($1, 0, $3); }
  604. | PMFUNC '(' term ')'
  605. { $$ = pmruntime($1, $3, Nullop); }
  606. | PMFUNC '(' term ',' term ')'
  607. { $$ = pmruntime($1, $3, $5); }
  608. | WORD
  609. | listop
  610. ;
  611. myattrterm: MY myterm myattrlist
  612. { $$ = my_attrs($2,$3); }
  613. | MY myterm
  614. { $$ = localize($2,$1); }
  615. ;
  616. myterm : '(' expr ')'
  617. { $$ = sawparens($2); }
  618. | '(' ')'
  619. { $$ = sawparens(newNULLLIST()); }
  620. | scalar %prec '('
  621. { $$ = $1; }
  622. | hsh %prec '('
  623. { $$ = $1; }
  624. | ary %prec '('
  625. { $$ = $1; }
  626. ;
  627. listexpr: /* NULL */ %prec PREC_LOW
  628. { $$ = Nullop; }
  629. | argexpr %prec PREC_LOW
  630. { $$ = $1; }
  631. ;
  632. listexprcom: /* NULL */
  633. { $$ = Nullop; }
  634. | expr
  635. { $$ = $1; }
  636. | expr ','
  637. { $$ = $1; }
  638. ;
  639. my_scalar: scalar
  640. { PL_in_my = 0; $$ = my($1); }
  641. ;
  642. amper : '&amp;' indirob
  643. { $$ = newCVREF($1,$2); }
  644. ;
  645. scalar : '$' indirob
  646. { $$ = newSVREF($2); }
  647. ;
  648. ary : '@' indirob
  649. { $$ = newAVREF($2); }
  650. ;
  651. hsh : '%' indirob
  652. { $$ = newHVREF($2); }
  653. ;
  654. arylen : DOLSHARP indirob
  655. { $$ = newAVREF($2); }
  656. ;
  657. star : '*' indirob
  658. { $$ = newGVREF(0,$2); }
  659. ;
  660. indirob : WORD
  661. { $$ = scalar($1); }
  662. | scalar %prec PREC_LOW
  663. { $$ = scalar($1); }
  664. | block
  665. { $$ = scope($1); }
  666. | PRIVATEREF
  667. { $$ = $1; }
  668. ;
  669. %% /* PROGRAM */
  670. /* more stuff added to make perly_c.diff easier to apply */
  671. #ifdef yyparse
  672. #undef yyparse
  673. #endif
  674. #define yyparse() Perl_yyparse(pTHX)
  675. </pre>
  676. <hr />
  677. </body></html>