perl 3.0 patch #14 patch #13, continued
[p5sagit/p5-mst-13.2.git] / perl.y
diff --git a/perl.y b/perl.y
index 827448e..96ef414 100644 (file)
--- a/perl.y
+++ b/perl.y
@@ -1,4 +1,4 @@
-/* $Header: perl.y,v 3.0 89/10/18 15:22:04 lwall Locked $
+/* $Header: perl.y,v 3.0.1.5 90/03/12 16:55:56 lwall Locked $
  *
  *    Copyright (c) 1989, Larry Wall
  *
@@ -6,6 +6,26 @@
  *    as specified in the README file that comes with the perl 3.0 kit.
  *
  * $Log:       perl.y,v $
+ * Revision 3.0.1.5  90/03/12  16:55:56  lwall
+ * patch13: added list slice operator (LIST)[LIST]
+ * patch13: (LIST,) now legal
+ * 
+ * Revision 3.0.1.4  90/02/28  18:03:23  lwall
+ * patch9: line numbers were bogus during certain portions of foreach evaluation
+ * 
+ * Revision 3.0.1.3  89/12/21  20:13:41  lwall
+ * patch7: send() didn't allow a TO argument
+ * 
+ * Revision 3.0.1.2  89/11/11  04:49:04  lwall
+ * patch2: moved yydebug to where its type doesn't matter
+ * patch2: !$foo++ was unreasonably illegal
+ * patch2: local(@foo) didn't work
+ * patch2: default args to unary operators didn't work
+ * 
+ * Revision 3.0.1.1  89/10/26  23:20:41  lwall
+ * patch1: grandfathered "format stdout"
+ * patch1: operator(); is now normally equivalent to operator;
+ * 
  * Revision 3.0  89/10/18  15:22:04  lwall
  * 3.0 baseline
  * 
@@ -78,11 +98,17 @@ ARG *arg5;
 
 %% /* RULES */
 
-prog   :       lineseq
+prog   :       /* NULL */
+               {
+#if defined(YYDEBUG) && defined(DEBUGGING)
+                   yydebug = (debug & 1);
+#endif
+               }
+       /*CONTINUED*/   lineseq
                        { if (in_eval)
-                               eval_root = block_head($1);
+                               eval_root = block_head($2);
                            else
-                               main_root = block_head($1); }
+                               main_root = block_head($2); }
        ;
 
 compblock:     block CONTINUE block
@@ -210,6 +236,8 @@ loop        :       label WHILE '(' texpr ')' compblock
                                          stab2arg(A_STAB,scrstab),
                                          Nullarg,Nullarg ),
                                        $7)))));
+                               $$->c_line = $2;
+                               $$->c_head->c_line = $2;
                            }
                            else {
                                $$ = wopt(over($3,add_label($1,
@@ -235,6 +263,8 @@ loop        :       label WHILE '(' texpr ')' compblock
                                          stab2arg(A_STAB,scrstab),
                                          Nullarg,Nullarg ),
                                        $6)))));
+                               $$->c_line = $2;
+                               $$->c_head->c_line = $2;
                            }
                            else {      /* lisp, anyone? */
                                $$ = wopt(over(defstab,add_label($1,
@@ -276,7 +306,13 @@ decl       :       format
        ;
 
 format :       FORMAT WORD '=' FORMLIST
-                       { stab_form(stabent($2,TRUE)) = $4; Safefree($2);}
+                       { if (strEQ($2,"stdout"))
+                           stab_form(stabent("STDOUT",TRUE)) = $4;
+                         else if (strEQ($2,"stderr"))
+                           stab_form(stabent("STDERR",TRUE)) = $4;
+                         else
+                           stab_form(stabent($2,TRUE)) = $4;
+                         Safefree($2);}
        |       FORMAT '=' FORMLIST
                        { stab_form(stabent("STDOUT",TRUE)) = $3; }
        ;
@@ -369,18 +405,6 @@ sexpr      :       sexpr '=' sexpr
                        { $$ = mod_match(O_MATCH, $1, $3); }
        |       sexpr NMATCH sexpr
                        { $$ = mod_match(O_NMATCH, $1, $3); }
-       |       term INC
-                       { $$ = addflags(1, AF_POST|AF_UP,
-                           l(make_op(O_ITEM,1,$1,Nullarg,Nullarg))); }
-       |       term DEC
-                       { $$ = addflags(1, AF_POST,
-                           l(make_op(O_ITEM,1,$1,Nullarg,Nullarg))); }
-       |       INC term
-                       { $$ = addflags(1, AF_PRE|AF_UP,
-                           l(make_op(O_ITEM,1,$2,Nullarg,Nullarg))); }
-       |       DEC term
-                       { $$ = addflags(1, AF_PRE,
-                           l(make_op(O_ITEM,1,$2,Nullarg,Nullarg))); }
        |       term
                        { $$ = $1; }
        ;
@@ -393,6 +417,18 @@ term       :       '-' term %prec UMINUS
                        { $$ = make_op(O_NOT, 1, $2, Nullarg, Nullarg); }
        |       '~' term
                        { $$ = make_op(O_COMPLEMENT, 1, $2, Nullarg, Nullarg);}
+       |       term INC
+                       { $$ = addflags(1, AF_POST|AF_UP,
+                           l(make_op(O_ITEM,1,$1,Nullarg,Nullarg))); }
+       |       term DEC
+                       { $$ = addflags(1, AF_POST,
+                           l(make_op(O_ITEM,1,$1,Nullarg,Nullarg))); }
+       |       INC term
+                       { $$ = addflags(1, AF_PRE|AF_UP,
+                           l(make_op(O_ITEM,1,$2,Nullarg,Nullarg))); }
+       |       DEC term
+                       { $$ = addflags(1, AF_PRE,
+                           l(make_op(O_ITEM,1,$2,Nullarg,Nullarg))); }
        |       FILETEST WORD
                        { opargs[$1] = 0;       /* force it special */
                            $$ = make_op($1, 1,
@@ -409,9 +445,11 @@ term       :       '-' term %prec UMINUS
                                  $1 == O_FTTTY?stabent("STDIN",TRUE):defstab),
                                Nullarg, Nullarg); }
        |       LOCAL '(' expr ')'
-                       { $$ = l(make_op(O_ITEM, 1,
+                       { $$ = l(localize(make_op(O_ASSIGN, 1,
                                localize(listish(make_list($3))),
-                               Nullarg,Nullarg)); }
+                               Nullarg,Nullarg))); }
+       |       '(' expr ',' ')'
+                       { $$ = make_list(hide_ary($2)); }
        |       '(' expr ')'
                        { $$ = make_list(hide_ary($2)); }
        |       '(' ')'
@@ -442,6 +480,11 @@ term       :       '-' term %prec UMINUS
                                stab2arg(A_STAB,hadd($1)),
                                jmaybe($3),
                                Nullarg); }
+       |       '(' expr ')' '[' expr ']'       %prec '('
+                       { $$ = make_op(O_LSLICE, 3,
+                               Nullarg,
+                               listish(make_list($5)),
+                               listish(make_list($2))); }
        |       ARY '[' expr ']'        %prec '('
                        { $$ = make_op(O_ASLICE, 2,
                                stab2arg(A_STAB,aadd($1)),
@@ -523,7 +566,7 @@ term        :       '-' term %prec UMINUS
                        { $$ = make_op($1,1,cval_to_arg($2),
                            Nullarg,Nullarg); }
        |       UNIOP
-                       { $$ = make_op($1,1,Nullarg,Nullarg,Nullarg);
+                       { $$ = make_op($1,0,Nullarg,Nullarg,Nullarg);
                          if ($1 == O_EVAL || $1 == O_RESET)
                            $$ = fixeval($$); }
        |       UNIOP sexpr
@@ -574,7 +617,7 @@ term        :       '-' term %prec UMINUS
        |       FILOP2 '(' handle cexpr ')'
                        { $$ = make_op($1, 2, $3, $4, Nullarg); }
        |       FILOP3 '(' handle csexpr cexpr ')'
-                       { $$ = make_op($1, 3, $3, $4, $5); }
+                       { $$ = make_op($1, 3, $3, $4, make_list($5)); }
        |       FILOP22 '(' handle ',' handle ')'
                        { $$ = make_op($1, 2, $3, $5, Nullarg); }
        |       FILOP4 '(' handle csexpr csexpr cexpr ')'
@@ -632,6 +675,12 @@ term       :       '-' term %prec UMINUS
                            Nullarg, Nullarg)); }
        |       FUNC0
                        { $$ = make_op($1, 0, Nullarg, Nullarg, Nullarg); }
+       |       FUNC0 '(' ')'
+                       { $$ = make_op($1, 0, Nullarg, Nullarg, Nullarg); }
+       |       FUNC1 '(' ')'
+                       { $$ = make_op($1, 0, Nullarg, Nullarg, Nullarg);
+                         if ($1 == O_EVAL || $1 == O_RESET)
+                           $$ = fixeval($$); }
        |       FUNC1 '(' expr ')'
                        { $$ = make_op($1, 1, $3, Nullarg, Nullarg);
                          if ($1 == O_EVAL || $1 == O_RESET)