perl 5.003_01: lib/Carp.pm
[p5sagit/p5-mst-13.2.git] / x2p / a2p.y
index 13c68b8..961e2f2 100644 (file)
--- a/x2p/a2p.y
+++ b/x2p/a2p.y
@@ -1,21 +1,12 @@
 %{
-/* $Header: a2p.y,v 3.0.1.2 90/08/09 05:47:26 lwall Locked $
+/* $RCSfile: a2p.y,v $$Revision: 4.1 $$Date: 92/08/07 18:29:12 $
  *
- *    Copyright (c) 1989, Larry Wall
+ *    Copyright (c) 1991, Larry Wall
  *
- *    You may distribute under the terms of the GNU General Public License
- *    as specified in the README file that comes with the perl 3.0 kit.
+ *    You may distribute under the terms of either the GNU General Public
+ *    License or the Artistic License, as specified in the README file.
  *
  * $Log:       a2p.y,v $
- * Revision 3.0.1.2  90/08/09  05:47:26  lwall
- * patch19: a2p didn't handle {foo = (bar == 123)}
- * 
- * Revision 3.0.1.1  90/03/01  10:30:08  lwall
- * patch9: a2p didn't allow logical expressions everywhere it should
- * 
- * Revision 3.0  89/10/18  15:34:29  lwall
- * 3.0 baseline
- * 
  */
 
 #include "INTERN.h"
@@ -103,6 +94,8 @@ cond : expr
        | match
        | rel
        | compound_cond
+       | cond '?' expr ':' expr
+               { $$ = oper3(OCOND,$1,$3,$5); }
        ;
 
 compound_cond
@@ -169,7 +162,7 @@ term        : variable
                { $$ = oper2(OPOW,$1,$3); }
        | term IN VAR
                { $$ = oper2(ODEFINED,aryrefarg($3),$1); }
-       | term '?' term ':' term
+       | cond '?' expr ':' expr
                { $$ = oper3(OCOND,$1,$3,$5); }
        | variable INCR
                { $$ = oper1(OPOSTINCR,$1); }
@@ -187,18 +180,18 @@ term      : variable
                { $$ = oper1(OPAREN,$2); }
        | GETLINE
                { $$ = oper0(OGETLINE); }
-       | GETLINE VAR
+       | GETLINE variable
                { $$ = oper1(OGETLINE,$2); }
        | GETLINE '<' expr
                { $$ = oper3(OGETLINE,Nullop,string("<",1),$3);
                    if (ops[$3].ival != OSTR + (1<<8)) do_fancy_opens = TRUE; }
-       | GETLINE VAR '<' expr
+       | GETLINE variable '<' expr
                { $$ = oper3(OGETLINE,$2,string("<",1),$4);
                    if (ops[$4].ival != OSTR + (1<<8)) do_fancy_opens = TRUE; }
        | term 'p' GETLINE
                { $$ = oper3(OGETLINE,Nullop,string("|",1),$1);
                    if (ops[$1].ival != OSTR + (1<<8)) do_fancy_opens = TRUE; }
-       | term 'p' GETLINE VAR
+       | term 'p' GETLINE variable
                { $$ = oper3(OGETLINE,$4,string("|",1),$1);
                    if (ops[$1].ival != OSTR + (1<<8)) do_fancy_opens = TRUE; }
        | FUN1
@@ -219,6 +212,8 @@ term        : variable
                { $$ = oper2(OSUBSTR,$3,$5); }
        | SPLIT '(' expr ',' VAR ',' expr ')'
                { $$ = oper3(OSPLIT,$3,aryrefarg(numary($5)),$7); }
+       | SPLIT '(' expr ',' VAR ',' REGEX ')'
+               { $$ = oper3(OSPLIT,$3,aryrefarg(numary($5)),oper1(OREGEX,$7));}
        | SPLIT '(' expr ',' VAR ')'
                { $$ = oper2(OSPLIT,$3,aryrefarg(numary($5))); }
        | INDEX '(' expr ',' expr ')'
@@ -366,12 +361,12 @@ simple
                { $$ = oper0(ORETURN); }
        | RET expr
                { $$ = oper1(ORETURN,$2); }
-       | DELETE VAR '[' expr ']'
+       | DELETE VAR '[' expr_list ']'
                { $$ = oper2(ODELETE,aryrefarg($2),$4); }
        ;
 
 redir  : '>'   %prec FIELD
-               { $$ = oper1(OREDIR,$1); }
+               { $$ = oper1(OREDIR,string(">",1)); }
        | GRGR
                { $$ = oper1(OREDIR,string(">>",2)); }
        | '|'