X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=x2p%2Fa2p.y;h=b0da9df400e4ec86449f43c3d88e9a74bc188141;hb=9adaed53e8c5c02c21962f77d92b04411cd1a8b5;hp=8b3dc8ba4f326ea859b9c75c7a62c60591fe7817;hpb=fe14fcc35f78a371a174a1d14256c2f35ae4262b;p=p5sagit%2Fp5-mst-13.2.git diff --git a/x2p/a2p.y b/x2p/a2p.y index 8b3dc8b..b0da9df 100644 --- a/x2p/a2p.y +++ b/x2p/a2p.y @@ -1,15 +1,12 @@ %{ -/* $Header: a2p.y,v 4.0 91/03/20 01:57:21 lwall Locked $ +/* $RCSfile: a2p.y,v $$Revision: 4.1 $$Date: 92/08/07 18:29:12 $ * - * Copyright (c) 1989, Larry Wall + * Copyright (c) 1991-2002, 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 4.0 91/03/20 01:57:21 lwall - * 4.0 baseline. - * */ #include "INTERN.h" @@ -24,7 +21,7 @@ int ends = Nullop; %token REGEX %token SEMINEW NEWLINE COMMENT %token FUN1 FUNN GRGR -%token PRINT PRINTF SPRINTF SPLIT +%token PRINT PRINTF SPRINTF_OLD SPRINTF_NEW SPLIT %token IF ELSE WHILE FOR IN %token EXIT NEXT BREAK CONTINUE RET %token GETLINE DO SUB GSUB MATCH @@ -97,6 +94,8 @@ cond : expr | match | rel | compound_cond + | cond '?' expr ':' expr + { $$ = oper3(OCOND,$1,$3,$5); } ; compound_cond @@ -134,6 +133,8 @@ expr : term { $$ = $1; } | expr term { $$ = oper2(OCONCAT,$1,$2); } + | expr '?' expr ':' expr + { $$ = oper3(OCOND,$1,$3,$5); } | variable ASGNOP cond { $$ = oper3(OASSIGN,$2,$1,$3); if ((ops[$1].ival & 255) == OFLD) @@ -143,6 +144,9 @@ expr : term } ; +sprintf : SPRINTF_NEW + | SPRINTF_OLD ; + term : variable { $$ = $1; } | NUMBER @@ -163,8 +167,6 @@ term : variable { $$ = oper2(OPOW,$1,$3); } | term IN VAR { $$ = oper2(ODEFINED,aryrefarg($3),$1); } - | term '?' term ':' term - { $$ = oper3(OCOND,$1,$3,$5); } | variable INCR { $$ = oper1(OPOSTINCR,$1); } | variable DECR @@ -181,18 +183,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 @@ -205,7 +207,9 @@ term : variable { $$ = oper1($1,$3); } | USERFUN '(' expr_list ')' { $$ = oper2(OUSERFUN,$1,$3); } - | SPRINTF expr_list + | SPRINTF_NEW '(' expr_list ')' + { $$ = oper1(OSPRINTF,$3); } + | sprintf expr_list { $$ = oper1(OSPRINTF,$2); } | SUBSTR '(' expr ',' expr ',' expr ')' { $$ = oper3(OSUBSTR,$3,$5,$7); } @@ -362,7 +366,7 @@ simple { $$ = oper0(ORETURN); } | RET expr { $$ = oper1(ORETURN,$2); } - | DELETE VAR '[' expr ']' + | DELETE VAR '[' expr_list ']' { $$ = oper2(ODELETE,aryrefarg($2),$4); } ; @@ -394,4 +398,7 @@ compound ; %% + +int yyparse (void); + #include "a2py.c"