%{
/* $RCSfile: a2p.y,v $$Revision: 4.1 $$Date: 92/08/07 18:29:12 $
*
- * Copyright (c) 1991, Larry Wall
+ * Copyright (c) 1991-1997, Larry Wall
*
* 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.1 92/08/07 18:29:12 lwall
- *
- * Revision 4.0.1.2 92/06/08 16:13:03 lwall
- * patch20: in a2p, getline should allow variable to be array element
- *
- * Revision 4.0.1.1 91/06/07 12:12:41 lwall
- * patch4: new copyright notice
- *
- * Revision 4.0 91/03/20 01:57:21 lwall
- * 4.0 baseline.
- *
*/
#include "INTERN.h"
%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
| match
| rel
| compound_cond
+ | cond '?' expr ':' expr
+ { $$ = oper3(OCOND,$1,$3,$5); }
;
compound_cond
{ $$ = $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)
}
;
+sprintf : SPRINTF_NEW
+ | SPRINTF_OLD ;
+
term : variable
{ $$ = $1; }
| NUMBER
{ $$ = 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
{ $$ = 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); }
{ $$ = oper0(ORETURN); }
| RET expr
{ $$ = oper1(ORETURN,$2); }
- | DELETE VAR '[' expr ']'
+ | DELETE VAR '[' expr_list ']'
{ $$ = oper2(ODELETE,aryrefarg($2),$4); }
;
;
%%
+
+int yyparse _((void));
+
#include "a2py.c"