diff options
author | gclarkii <gclarkii@FreeBSD.org> | 1994-09-10 06:27:55 +0000 |
---|---|---|
committer | gclarkii <gclarkii@FreeBSD.org> | 1994-09-10 06:27:55 +0000 |
commit | bd9f08584221a6bacbfeaebf19d4c3e21fa94a83 (patch) | |
tree | 8e0cf41774fd52d25f63363297782b383c4ad1f7 /gnu/usr.bin/perl/x2p | |
download | FreeBSD-src-bd9f08584221a6bacbfeaebf19d4c3e21fa94a83.zip FreeBSD-src-bd9f08584221a6bacbfeaebf19d4c3e21fa94a83.tar.gz |
Initial import of Perl 4.046 bmaked
Diffstat (limited to 'gnu/usr.bin/perl/x2p')
-rw-r--r-- | gnu/usr.bin/perl/x2p/EXTERN.h | 26 | ||||
-rw-r--r-- | gnu/usr.bin/perl/x2p/INTERN.h | 26 | ||||
-rw-r--r-- | gnu/usr.bin/perl/x2p/Makefile | 17 | ||||
-rw-r--r-- | gnu/usr.bin/perl/x2p/a2p.1 | 199 | ||||
-rw-r--r-- | gnu/usr.bin/perl/x2p/a2p.c | 2715 | ||||
-rw-r--r-- | gnu/usr.bin/perl/x2p/a2p.h | 341 | ||||
-rw-r--r-- | gnu/usr.bin/perl/x2p/a2p.y | 406 | ||||
-rw-r--r-- | gnu/usr.bin/perl/x2p/a2py.c | 1301 | ||||
-rwxr-xr-x | gnu/usr.bin/perl/x2p/find2perl | 568 | ||||
-rwxr-xr-x | gnu/usr.bin/perl/x2p/h2ph | 253 | ||||
-rwxr-xr-x | gnu/usr.bin/perl/x2p/h2ph.1 | 253 | ||||
-rw-r--r-- | gnu/usr.bin/perl/x2p/handy.h | 46 | ||||
-rw-r--r-- | gnu/usr.bin/perl/x2p/hash.c | 250 | ||||
-rw-r--r-- | gnu/usr.bin/perl/x2p/hash.h | 60 | ||||
-rw-r--r-- | gnu/usr.bin/perl/x2p/malloc.c | 513 | ||||
-rwxr-xr-x | gnu/usr.bin/perl/x2p/s2p | 766 | ||||
-rw-r--r-- | gnu/usr.bin/perl/x2p/s2p.1 | 108 | ||||
-rw-r--r-- | gnu/usr.bin/perl/x2p/str.c | 467 | ||||
-rw-r--r-- | gnu/usr.bin/perl/x2p/str.h | 46 | ||||
-rw-r--r-- | gnu/usr.bin/perl/x2p/util.c | 268 | ||||
-rw-r--r-- | gnu/usr.bin/perl/x2p/util.h | 53 | ||||
-rw-r--r-- | gnu/usr.bin/perl/x2p/walk.c | 2086 |
22 files changed, 10768 insertions, 0 deletions
diff --git a/gnu/usr.bin/perl/x2p/EXTERN.h b/gnu/usr.bin/perl/x2p/EXTERN.h new file mode 100644 index 0000000..f3048ed --- /dev/null +++ b/gnu/usr.bin/perl/x2p/EXTERN.h @@ -0,0 +1,26 @@ +/* $RCSfile: EXTERN.h,v $$Revision: 1.1.1.1 $$Date: 1993/08/23 21:30:11 $ + * + * Copyright (c) 1991, 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: EXTERN.h,v $ + * Revision 1.1.1.1 1993/08/23 21:30:11 nate + * PERL! + * + * Revision 4.0.1.1 91/06/07 12:11:15 lwall + * patch4: new copyright notice + * + * Revision 4.0 91/03/20 01:56:53 lwall + * 4.0 baseline. + * + */ + +#undef EXT +#define EXT extern + +#undef INIT +#define INIT(x) + +#undef DOINIT diff --git a/gnu/usr.bin/perl/x2p/INTERN.h b/gnu/usr.bin/perl/x2p/INTERN.h new file mode 100644 index 0000000..e1967d2 --- /dev/null +++ b/gnu/usr.bin/perl/x2p/INTERN.h @@ -0,0 +1,26 @@ +/* $RCSfile: INTERN.h,v $$Revision: 1.1.1.1 $$Date: 1993/08/23 21:30:11 $ + * + * Copyright (c) 1991, 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: INTERN.h,v $ + * Revision 1.1.1.1 1993/08/23 21:30:11 nate + * PERL! + * + * Revision 4.0.1.1 91/06/07 12:11:20 lwall + * patch4: new copyright notice + * + * Revision 4.0 91/03/20 01:56:58 lwall + * 4.0 baseline. + * + */ + +#undef EXT +#define EXT + +#undef INIT +#define INIT(x) = x + +#define DOINIT diff --git a/gnu/usr.bin/perl/x2p/Makefile b/gnu/usr.bin/perl/x2p/Makefile new file mode 100644 index 0000000..d7e383d --- /dev/null +++ b/gnu/usr.bin/perl/x2p/Makefile @@ -0,0 +1,17 @@ + +PROG= a2p + +SRCS+= a2p.c hash.c str.c walk.c util.c +CFLAGS+= -I${.CURDIR}/../perl + +LDADD= -lm +DPADD= ${LIBM} + +MAN1+= a2p.1 s2p.1 h2ph.1 + +beforeinstall: + install -c -o ${BINOWN} -g ${BINGRP} -m 555 s2p ${BINDIR} + install -c -o ${BINOWN} -g ${BINGRP} -m 555 h2ph ${BINDIR} + +.include <bsd.prog.mk> + diff --git a/gnu/usr.bin/perl/x2p/a2p.1 b/gnu/usr.bin/perl/x2p/a2p.1 new file mode 100644 index 0000000..58d8c07 --- /dev/null +++ b/gnu/usr.bin/perl/x2p/a2p.1 @@ -0,0 +1,199 @@ +.rn '' }` +''' $Header: /home/cvs/386BSD/ports/lang/perl/x2p/a2p.man,v 1.1.1.1 1993/08/23 21:30:10 nate Exp $ +''' +''' $Log: a2p.man,v $ +.\" Revision 1.1.1.1 1993/08/23 21:30:10 nate +.\" PERL! +.\" +''' Revision 4.0 91/03/20 01:57:11 lwall +''' 4.0 baseline. +''' +''' Revision 3.0 89/10/18 15:34:22 lwall +''' 3.0 baseline +''' +''' Revision 2.0.1.1 88/07/11 23:16:25 root +''' patch2: changes related to 1985 awk +''' +''' Revision 2.0 88/06/05 00:15:36 root +''' Baseline version 2.0. +''' +''' +.de Sh +.br +.ne 5 +.PP +\fB\\$1\fR +.PP +.. +.de Sp +.if t .sp .5v +.if n .sp +.. +.de Ip +.br +.ie \\n.$>=3 .ne \\$3 +.el .ne 3 +.IP "\\$1" \\$2 +.. +''' +''' Set up \*(-- to give an unbreakable dash; +''' string Tr holds user defined translation string. +''' Bell System Logo is used as a dummy character. +''' +.tr \(*W-|\(bv\*(Tr +.ie n \{\ +.ds -- \(*W- +.if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch +.if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch +.ds L" "" +.ds R" "" +.ds L' ' +.ds R' ' +'br\} +.el\{\ +.ds -- \(em\| +.tr \*(Tr +.ds L" `` +.ds R" '' +.ds L' ` +.ds R' ' +'br\} +.TH A2P 1 LOCAL +.SH NAME +a2p - Awk to Perl translator +.SH SYNOPSIS +.B a2p [options] filename +.SH DESCRIPTION +.I A2p +takes an awk script specified on the command line (or from standard input) +and produces a comparable +.I perl +script on the standard output. +.Sh "Options" +Options include: +.TP 5 +.B \-D<number> +sets debugging flags. +.TP 5 +.B \-F<character> +tells a2p that this awk script is always invoked with this -F switch. +.TP 5 +.B \-n<fieldlist> +specifies the names of the input fields if input does not have to be split into +an array. +If you were translating an awk script that processes the password file, you +might say: +.sp + a2p -7 -nlogin.password.uid.gid.gcos.shell.home +.sp +Any delimiter can be used to separate the field names. +.TP 5 +.B \-<number> +causes a2p to assume that input will always have that many fields. +.Sh "Considerations" +A2p cannot do as good a job translating as a human would, but it usually +does pretty well. +There are some areas where you may want to examine the perl script produced +and tweak it some. +Here are some of them, in no particular order. +.PP +There is an awk idiom of putting int() around a string expression to force +numeric interpretation, even though the argument is always integer anyway. +This is generally unneeded in perl, but a2p can't tell if the argument +is always going to be integer, so it leaves it in. +You may wish to remove it. +.PP +Perl differentiates numeric comparison from string comparison. +Awk has one operator for both that decides at run time which comparison +to do. +A2p does not try to do a complete job of awk emulation at this point. +Instead it guesses which one you want. +It's almost always right, but it can be spoofed. +All such guesses are marked with the comment \*(L"#???\*(R". +You should go through and check them. +You might want to run at least once with the \-w switch to perl, which +will warn you if you use == where you should have used eq. +.PP +Perl does not attempt to emulate the behavior of awk in which nonexistent +array elements spring into existence simply by being referenced. +If somehow you are relying on this mechanism to create null entries for +a subsequent for...in, they won't be there in perl. +.PP +If a2p makes a split line that assigns to a list of variables that looks +like (Fld1, Fld2, Fld3...) you may want +to rerun a2p using the \-n option mentioned above. +This will let you name the fields throughout the script. +If it splits to an array instead, the script is probably referring to the number +of fields somewhere. +.PP +The exit statement in awk doesn't necessarily exit; it goes to the END +block if there is one. +Awk scripts that do contortions within the END block to bypass the block under +such circumstances can be simplified by removing the conditional +in the END block and just exiting directly from the perl script. +.PP +Perl has two kinds of array, numerically-indexed and associative. +Awk arrays are usually translated to associative arrays, but if you happen +to know that the index is always going to be numeric you could change +the {...} to [...]. +Iteration over an associative array is done using the keys() function, but +iteration over a numeric array is NOT. +You might need to modify any loop that is iterating over the array in question. +.PP +Awk starts by assuming OFMT has the value %.6g. +Perl starts by assuming its equivalent, $#, to have the value %.20g. +You'll want to set $# explicitly if you use the default value of OFMT. +.PP +Near the top of the line loop will be the split operation that is implicit in +the awk script. +There are times when you can move this down past some conditionals that +test the entire record so that the split is not done as often. +.PP +For aesthetic reasons you may wish to change the array base $[ from 1 back +to perl's default of 0, but remember to change all array subscripts AND +all substr() and index() operations to match. +.PP +Cute comments that say "# Here is a workaround because awk is dumb" are passed +through unmodified. +.PP +Awk scripts are often embedded in a shell script that pipes stuff into and +out of awk. +Often the shell script wrapper can be incorporated into the perl script, since +perl can start up pipes into and out of itself, and can do other things that +awk can't do by itself. +.PP +Scripts that refer to the special variables RSTART and RLENGTH can often +be simplified by referring to the variables $`, $& and $', as long as they +are within the scope of the pattern match that sets them. +.PP +The produced perl script may have subroutines defined to deal with awk's +semantics regarding getline and print. +Since a2p usually picks correctness over efficiency. +it is almost always possible to rewrite such code to be more efficient by +discarding the semantic sugar. +.PP +For efficiency, you may wish to remove the keyword from any return statement +that is the last statement executed in a subroutine. +A2p catches the most common case, but doesn't analyze embedded blocks for +subtler cases. +.PP +ARGV[0] translates to $ARGV0, but ARGV[n] translates to $ARGV[$n]. +A loop that tries to iterate over ARGV[0] won't find it. +.SH ENVIRONMENT +A2p uses no environment variables. +.SH AUTHOR +Larry Wall <lwall@jpl-devvax.Jpl.Nasa.Gov> +.SH FILES +.SH SEE ALSO +perl The perl compiler/interpreter +.br +s2p sed to perl translator +.SH DIAGNOSTICS +.SH BUGS +It would be possible to emulate awk's behavior in selecting string versus +numeric operations at run time by inspection of the operands, but it would +be gross and inefficient. +Besides, a2p almost always guesses right. +.PP +Storage for the awk syntax tree is currently static, and can run out. +.rn }` '' diff --git a/gnu/usr.bin/perl/x2p/a2p.c b/gnu/usr.bin/perl/x2p/a2p.c new file mode 100644 index 0000000..c441634 --- /dev/null +++ b/gnu/usr.bin/perl/x2p/a2p.c @@ -0,0 +1,2715 @@ +#ifndef lint +static char yysccsid[] = "@(#)yaccpar 1.9 (Berkeley) 02/21/93"; +#endif +#define YYBYACC 1 +#define YYMAJOR 1 +#define YYMINOR 9 +#define yyclearin (yychar=(-1)) +#define yyerrok (yyerrflag=0) +#define YYRECOVERING (yyerrflag!=0) +#define YYPREFIX "yy" +#line 2 "a2p.y" +/* $RCSfile: a2p.y,v $$Revision: 1.1.1.1 $$Date: 1993/08/23 21:30:09 $ + * + * Copyright (c) 1991, 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 1.1.1.1 1993/08/23 21:30:09 nate + * PERL! + * + * 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" +#include "a2p.h" + +int root; +int begins = Nullop; +int ends = Nullop; + +#line 42 "y.tab.c" +#define BEGIN 257 +#define END 258 +#define REGEX 259 +#define SEMINEW 260 +#define NEWLINE 261 +#define COMMENT 262 +#define FUN1 263 +#define FUNN 264 +#define GRGR 265 +#define PRINT 266 +#define PRINTF 267 +#define SPRINTF 268 +#define SPLIT 269 +#define IF 270 +#define ELSE 271 +#define WHILE 272 +#define FOR 273 +#define IN 274 +#define EXIT 275 +#define NEXT 276 +#define BREAK 277 +#define CONTINUE 278 +#define RET 279 +#define GETLINE 280 +#define DO 281 +#define SUB 282 +#define GSUB 283 +#define MATCH 284 +#define FUNCTION 285 +#define USERFUN 286 +#define DELETE 287 +#define ASGNOP 288 +#define OROR 289 +#define ANDAND 290 +#define NUMBER 291 +#define VAR 292 +#define SUBSTR 293 +#define INDEX 294 +#define MATCHOP 295 +#define RELOP 296 +#define OR 297 +#define STRING 298 +#define UMINUS 299 +#define NOT 300 +#define INCR 301 +#define DECR 302 +#define FIELD 303 +#define VFIELD 304 +#define YYERRCODE 256 +short yylhs[] = { -1, + 0, 3, 6, 6, 2, 2, 7, 7, 7, 7, + 7, 7, 9, 8, 8, 11, 11, 11, 11, 15, + 15, 15, 15, 14, 14, 14, 14, 13, 13, 13, + 13, 12, 12, 12, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 17, 17, 17, 17, 10, 10, 10, 18, 18, 18, + 1, 1, 19, 19, 19, 19, 4, 4, 20, 20, + 21, 21, 21, 21, 5, 5, 22, 22, 22, 22, + 25, 25, 23, 23, 23, 23, 23, 23, 23, 23, + 23, 23, 23, 23, 23, 26, 26, 26, 24, 24, + 24, 24, 24, 24, 24, 24, +}; +short yylen[] = { 2, + 2, 6, 5, 2, 3, 0, 1, 5, 10, 4, + 1, 1, 1, 1, 3, 1, 1, 1, 1, 3, + 4, 4, 2, 3, 3, 3, 3, 3, 3, 1, + 3, 1, 2, 3, 1, 1, 1, 3, 3, 3, + 3, 3, 3, 3, 5, 2, 2, 2, 2, 2, + 2, 3, 1, 2, 3, 4, 3, 4, 1, 3, + 4, 4, 4, 2, 8, 6, 8, 8, 6, 6, + 6, 6, 6, 6, 6, 6, 8, 8, 8, 8, + 1, 4, 1, 2, 1, 1, 0, 4, 4, 3, + 2, 0, 1, 1, 1, 1, 2, 0, 1, 1, + 2, 2, 2, 2, 2, 0, 3, 2, 2, 1, + 1, 0, 1, 4, 2, 4, 2, 1, 1, 1, + 2, 1, 1, 2, 5, 1, 1, 1, 6, 9, + 6, 7, 10, 9, 6, 5, +}; +short yydefred[] = { 92, + 0, 0, 94, 95, 96, 93, 0, 91, 0, 0, + 30, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 36, 0, 0, 0, 37, 0, 0, 0, 0, + 0, 83, 0, 98, 0, 11, 0, 92, 0, 0, + 0, 17, 18, 19, 0, 0, 98, 98, 0, 0, + 0, 64, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 23, + 48, 49, 0, 0, 0, 0, 0, 0, 4, 0, + 98, 98, 98, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 46, + 47, 0, 0, 60, 0, 0, 0, 0, 0, 98, + 98, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 99, 100, 0, 97, 52, 31, + 27, 20, 0, 0, 0, 0, 29, 0, 0, 0, + 0, 44, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 61, 62, 90, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 13, 63, 82, 0, + 0, 98, 0, 0, 0, 0, 0, 0, 119, 118, + 122, 0, 98, 0, 98, 10, 98, 0, 105, 0, + 110, 0, 0, 21, 0, 58, 92, 3, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 98, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 98, 98, 98, 98, 98, 8, 0, 0, + 69, 0, 74, 0, 73, 0, 76, 0, 75, 0, + 71, 72, 0, 66, 0, 70, 127, 126, 128, 0, + 0, 0, 0, 0, 111, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 98, 0, 0, 0, 98, 98, 98, 0, 0, 0, + 98, 68, 67, 78, 77, 80, 79, 0, 65, 0, + 0, 0, 0, 0, 0, 125, 0, 0, 0, 131, + 135, 0, 0, 0, 9, 98, 98, 0, 132, 0, + 0, 98, 130, 134, 0, 133, +}; +short yydgoto[] = { 1, + 2, 7, 36, 74, 127, 37, 38, 39, 166, 52, + 75, 188, 42, 43, 44, 45, 46, 54, 8, 128, + 227, 189, 190, 191, 256, 250, +}; +short yysindex[] = { 0, + 0, -45, 0, 0, 0, 0, 4961, 0, -114, -98, + 0, -11, 7, 7279, 10, 6, 17, 25, 45, -195, + 62, 0, 5, 77, 83, 0, 7332, 7332, 5086, -252, + -252, 0, 7332, 0, 5086, 0, -154, 0, 8, -41, + 1605, 0, 0, 0, 118, -234, 0, 0, 6059, 7279, + 5487, 0, 5843, 85, 7332, 7332, 75, 6108, 6154, 7332, + 97, 7279, 7279, 7332, 7332, 5086, -73, -266, -73, 0, + 0, 0, 26, -183, -39, 102, 106, 116, 0, -45, + 0, 0, 0, 5086, 6219, 7332, 7332, 7332, 118, -133, + 7332, 7332, 7332, 7332, 7332, 7332, 7332, -116, 5086, 0, + 0, -183, -183, 0, 6289, 125, 5487, 166, 29, 0, + 0, 6335, 1522, 7332, 128, 6381, 134, 6423, 6484, 7279, + 141, 90, 6534, 6580, 0, 0, 5197, 0, 0, 0, + 0, 0, -183, 5362, 5362, -206, 0, 1522, 1522, 1522, + 1522, 0, -32, 395, 395, -73, -73, -73, -73, -252, + -206, 5242, 5288, 0, 0, 0, 3391, 3391, -108, 1522, + 7332, 7332, 7332, 7332, 6626, 145, 0, 0, 0, 7332, + 7332, 0, 7279, 7279, 147, 148, 149, 7332, 0, 0, + 0, 7332, 0, -102, 0, 0, 0, 7332, 0, -42, + 0, 5553, -99, 0, 7332, 0, 0, 0, 7332, 7332, + 31, 2565, 3715, 3794, 5752, 153, 6688, 0, 6017, 6749, + -183, -38, -38, 5086, 5086, 2408, 7332, 7332, 4312, 104, + -183, -183, 0, 0, 0, 0, 0, 0, 118, -45, + 0, 6802, 0, 7332, 0, 7332, 0, 7332, 0, 7332, + 0, 0, -86, 0, 7332, 0, 0, 0, 0, 7332, + 7332, -37, -35, 6856, 0, 137, -74, 7332, 5598, -183, + -183, -183, -183, -183, 156, 6898, 6953, 7014, 7067, 7128, + 0, 7170, 7332, 7332, 0, 0, 0, 2698, 159, 7218, + 0, 0, 0, 0, 0, 0, 0, -183, 0, 4312, + 4312, 4312, 2408, -52, 5086, 0, -183, 5643, -71, 0, + 0, 160, 2408, -33, 0, 0, 0, 161, 0, 4312, + 4312, 0, 0, 0, 4312, 0, +}; +short yyrindex[] = { 0, + 0, 2363, 0, 0, 0, 0, 203, 0, 0, 0, + 0, 56, 0, 3556, 0, 2835, 0, 0, 0, 0, + 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 2231, 0, 2279, 1209, + 3881, 0, 0, 0, 1818, 1664, 0, 0, 0, 173, + 0, 0, 3764, 111, 0, 0, 381, 0, 0, 0, + 0, 173, 129, 0, 0, 0, 564, 834, 889, 0, + 0, 0, 436, 5689, 0, -200, -180, -156, 0, 2462, + 0, 0, 0, 0, 0, 0, 0, 0, 2084, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 5689, 5689, 0, 0, 0, 0, -22, 0, 0, + 0, 0, 2883, 0, 0, 0, 0, 0, 0, 173, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 5689, 0, 0, 2181, 0, 3122, 3167, 3212, + 3281, 0, 0, 1719, 1770, 943, 1016, 1286, 1340, 2780, + 1394, 0, 0, 0, 0, 0, 0, 0, 0, 3489, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 12, 12, 0, 0, 0, -29, 0, 0, + 0, 46, 0, 0, 0, 0, 0, 67, 0, 0, + 0, 0, 491, 0, 0, 0, 0, 0, 3604, 3676, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 4374, 71, 103, 0, 0, 162, 126, 241, 0, 0, + 5689, 4441, 0, 0, 0, 0, 0, 0, 2132, 2510, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 165, 0, 0, 0, 0, 0, 4486, + 4751, 4796, 4841, 4887, 0, 0, 0, 0, 0, 0, + 0, 0, 296, 357, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 5689, 0, 0, + 0, 0, 184, 0, 0, 0, 5152, 0, 5954, 0, + 0, 0, 184, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, +}; +short yygindex[] = { 0, + -20, 0, 0, 4150, -75, 0, 0, 0, 0, 19, + -7, 4065, -19, -3, -1, 7551, 4353, -31, 0, 0, + 0, -170, -161, 0, -270, 16, +}; +#define YYTABLESIZE 7831 +short yytable[] = { 40, + 81, 129, 84, 275, 96, 276, 303, 309, 47, 94, + 92, 120, 93, 6, 95, 76, 226, 80, 16, 109, + 97, 70, 302, 248, 48, 195, 152, 153, 49, 120, + 91, 77, 308, 78, 100, 101, 271, 81, 98, 23, + 81, 81, 81, 81, 81, 81, 50, 81, 257, 55, + 32, 33, 87, 99, 255, 59, 58, 192, 81, 81, + 81, 97, 81, 81, 59, 56, 100, 101, 106, 156, + 87, 231, 111, 87, 232, 109, 136, 125, 126, 98, + 121, 122, 82, 83, 60, 249, 123, 76, 17, 17, + 61, 151, 59, 81, 81, 63, 59, 59, 59, 59, + 59, 62, 59, 77, 123, 78, 79, 113, 18, 18, + 86, 115, 81, 59, 59, 59, 64, 59, 59, 299, + 300, 301, 65, 81, 81, 113, 193, 194, 111, 115, + 81, 255, 19, 19, 114, 87, 120, 98, 167, 313, + 314, 255, 130, 117, 316, 259, 131, 86, 59, 59, + 86, 86, 86, 86, 96, 86, 132, 86, 142, 94, + 92, 117, 93, 150, 95, 155, 121, 59, 86, 86, + 86, 161, 86, 86, 125, 126, 230, 163, 59, 59, + 91, 168, 169, 201, 121, 208, 214, 215, 216, 220, + 83, 212, 213, 241, 258, 278, 282, 279, 295, 306, + 307, 312, 1, 86, 86, 66, 252, 253, 27, 110, + 28, 97, 298, 87, 3, 4, 5, 223, 224, 225, + 112, 87, 86, 113, 112, 87, 247, 88, 251, 98, + 120, 120, 120, 86, 86, 0, 82, 83, 0, 0, + 0, 90, 0, 0, 0, 0, 0, 82, 83, 82, + 83, 82, 83, 82, 83, 82, 83, 81, 81, 81, + 81, 81, 81, 81, 81, 81, 16, 16, 81, 81, + 294, 87, 87, 87, 81, 0, 87, 0, 0, 0, + 81, 124, 81, 81, 81, 81, 81, 304, 81, 81, + 81, 81, 81, 81, 81, 81, 81, 23, 81, 124, + 81, 81, 81, 81, 81, 123, 123, 123, 32, 33, + 0, 0, 59, 59, 59, 59, 59, 59, 59, 59, + 59, 0, 0, 59, 59, 0, 113, 113, 113, 59, + 115, 115, 115, 0, 0, 59, 114, 59, 59, 59, + 59, 59, 0, 59, 59, 59, 59, 59, 59, 59, + 59, 59, 0, 59, 114, 59, 59, 59, 59, 59, + 0, 0, 117, 117, 117, 0, 0, 86, 86, 86, + 86, 86, 86, 86, 86, 86, 0, 0, 86, 86, + 54, 0, 0, 0, 86, 121, 121, 121, 0, 0, + 86, 90, 86, 86, 86, 86, 86, 116, 86, 86, + 86, 86, 86, 86, 86, 86, 86, 0, 86, 0, + 86, 86, 86, 86, 86, 116, 0, 54, 0, 0, + 54, 54, 54, 54, 54, 54, 0, 54, 12, 13, + 0, 96, 0, 14, 15, 84, 94, 0, 54, 54, + 0, 95, 54, 54, 0, 16, 0, 17, 18, 19, + 0, 21, 0, 0, 0, 0, 22, 23, 24, 25, + 85, 86, 0, 26, 0, 0, 30, 31, 32, 33, + 0, 0, 84, 54, 54, 84, 84, 84, 84, 84, + 84, 0, 84, 0, 0, 0, 0, 0, 97, 0, + 22, 0, 54, 84, 84, 84, 0, 84, 84, 0, + 124, 124, 124, 54, 54, 0, 98, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 22, 84, 84, + 22, 22, 22, 22, 22, 22, 0, 22, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 22, 22, + 22, 0, 22, 22, 0, 114, 114, 114, 84, 84, + 0, 0, 0, 51, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 22, 22, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 51, 0, 22, 51, 51, 51, 51, 51, 51, 0, + 51, 0, 0, 22, 22, 0, 116, 116, 116, 0, + 0, 51, 51, 51, 0, 51, 51, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 54, 54, 54, + 54, 54, 54, 54, 54, 54, 0, 0, 54, 54, + 0, 0, 0, 0, 54, 0, 51, 0, 0, 0, + 54, 0, 54, 54, 54, 54, 54, 0, 54, 54, + 54, 54, 54, 54, 54, 54, 54, 0, 54, 0, + 54, 54, 54, 54, 54, 0, 51, 51, 0, 0, + 0, 0, 84, 84, 84, 84, 84, 84, 84, 84, + 84, 0, 0, 84, 84, 0, 0, 0, 0, 84, + 0, 0, 0, 0, 0, 84, 0, 84, 84, 84, + 84, 84, 0, 84, 84, 84, 84, 84, 84, 84, + 84, 84, 0, 84, 0, 84, 84, 84, 84, 84, + 0, 0, 0, 0, 0, 0, 0, 22, 22, 22, + 22, 22, 22, 22, 22, 22, 0, 0, 22, 22, + 0, 0, 0, 0, 22, 0, 0, 0, 0, 0, + 22, 0, 22, 22, 22, 22, 22, 0, 22, 22, + 0, 22, 22, 22, 22, 22, 22, 0, 22, 0, + 22, 22, 22, 22, 22, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 51, 51, 51, 51, 51, 51, 51, 51, 51, 0, + 0, 51, 51, 35, 0, 0, 0, 51, 0, 0, + 0, 0, 0, 51, 0, 51, 51, 51, 51, 51, + 0, 51, 51, 51, 51, 51, 51, 51, 51, 51, + 0, 51, 0, 51, 51, 51, 51, 51, 0, 0, + 35, 0, 0, 35, 35, 35, 35, 35, 35, 0, + 35, 0, 0, 0, 0, 0, 0, 0, 50, 0, + 0, 35, 35, 35, 0, 35, 35, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 50, 35, 35, 50, 50, + 50, 50, 50, 50, 0, 50, 0, 0, 0, 0, + 0, 0, 40, 0, 0, 35, 50, 50, 50, 0, + 50, 50, 0, 0, 0, 0, 35, 35, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 40, + 0, 50, 40, 40, 40, 40, 40, 40, 0, 40, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 40, 40, 40, 0, 40, 40, 0, 0, 0, 0, + 0, 50, 50, 0, 0, 41, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 40, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 41, 0, 0, 41, 41, 41, 41, 41, + 41, 0, 41, 0, 0, 40, 40, 0, 0, 0, + 0, 0, 0, 41, 41, 41, 0, 41, 41, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 35, 35, 35, 35, 35, 35, 35, 35, 35, 0, + 0, 35, 35, 0, 0, 0, 0, 35, 41, 0, + 0, 0, 0, 35, 0, 35, 35, 35, 35, 35, + 0, 35, 35, 35, 35, 35, 35, 35, 35, 35, + 0, 35, 0, 35, 0, 0, 35, 35, 41, 41, + 0, 0, 0, 0, 0, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 0, 0, 50, 50, 0, 0, + 0, 0, 50, 0, 0, 0, 0, 0, 50, 0, + 50, 50, 50, 50, 50, 0, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 0, 50, 0, 50, 50, + 50, 50, 50, 0, 0, 0, 0, 0, 0, 40, + 40, 40, 40, 40, 40, 40, 40, 40, 14, 0, + 40, 40, 0, 0, 0, 0, 40, 0, 0, 0, + 0, 0, 40, 0, 40, 40, 40, 40, 40, 0, + 40, 40, 40, 40, 40, 40, 40, 40, 40, 0, + 40, 0, 40, 40, 40, 40, 40, 0, 14, 0, + 0, 14, 0, 14, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 14, 0, 0, + 0, 0, 41, 41, 41, 41, 41, 41, 41, 41, + 41, 0, 0, 41, 41, 42, 0, 0, 0, 41, + 0, 0, 0, 0, 0, 41, 0, 41, 41, 41, + 41, 41, 0, 41, 41, 41, 41, 41, 41, 41, + 41, 41, 0, 41, 0, 41, 41, 41, 41, 41, + 0, 0, 42, 0, 0, 42, 42, 42, 42, 42, + 42, 14, 42, 0, 0, 0, 0, 0, 0, 43, + 0, 0, 0, 42, 42, 42, 0, 42, 42, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 43, 0, 42, 43, + 43, 43, 43, 43, 43, 0, 43, 0, 0, 0, + 0, 0, 0, 34, 0, 0, 0, 43, 43, 43, + 0, 43, 43, 0, 0, 0, 0, 0, 42, 42, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 34, 0, 43, 34, 34, 34, 34, 34, 34, 0, + 34, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 34, 34, 34, 0, 34, 34, 0, 0, 0, + 0, 0, 43, 43, 0, 14, 14, 14, 14, 14, + 14, 14, 14, 0, 0, 0, 14, 14, 0, 0, + 0, 0, 0, 0, 0, 0, 34, 34, 14, 0, + 14, 14, 14, 14, 14, 0, 0, 0, 0, 14, + 14, 14, 14, 0, 0, 34, 14, 0, 14, 14, + 14, 14, 14, 0, 0, 0, 34, 34, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 42, 42, 42, 42, 42, 42, 42, 42, + 42, 0, 0, 42, 42, 0, 0, 0, 0, 42, + 0, 66, 0, 0, 27, 42, 28, 42, 42, 42, + 42, 42, 0, 42, 42, 42, 42, 42, 42, 42, + 42, 42, 0, 42, 0, 42, 42, 42, 42, 42, + 0, 0, 0, 0, 0, 0, 43, 43, 43, 43, + 43, 43, 43, 43, 43, 0, 0, 43, 43, 0, + 0, 0, 0, 43, 0, 0, 0, 0, 0, 43, + 0, 43, 43, 43, 43, 43, 0, 43, 43, 43, + 43, 43, 43, 43, 43, 43, 0, 43, 0, 43, + 43, 43, 43, 43, 66, 0, 0, 27, 0, 28, + 34, 34, 34, 34, 34, 34, 34, 34, 34, 0, + 0, 34, 34, 35, 87, 0, 88, 34, 0, 0, + 0, 0, 0, 34, 0, 34, 34, 34, 34, 34, + 0, 34, 0, 0, 34, 34, 34, 34, 34, 34, + 0, 34, 0, 34, 34, 34, 34, 34, 0, 0, + 35, 0, 0, 35, 35, 35, 35, 35, 35, 0, + 35, 0, 0, 0, 0, 0, 0, 0, 38, 0, + 0, 35, 35, 35, 0, 35, 35, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 35, 35, 38, 38, + 0, 38, 38, 38, 0, 0, 0, 0, 0, 39, + 0, 0, 0, 0, 0, 35, 38, 38, 38, 0, + 38, 38, 0, 0, 12, 13, 35, 35, 0, 14, + 15, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 16, 0, 17, 18, 19, 0, 21, 0, 39, + 39, 38, 39, 39, 39, 0, 0, 32, 0, 26, + 0, 0, 30, 31, 32, 33, 0, 39, 39, 39, + 0, 39, 39, 0, 0, 0, 0, 0, 0, 0, + 0, 38, 38, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 32, 32, 0, + 0, 32, 39, 0, 0, 0, 0, 12, 13, 0, + 0, 0, 14, 15, 0, 32, 32, 32, 0, 32, + 0, 0, 0, 0, 16, 0, 17, 18, 19, 0, + 21, 0, 39, 39, 0, 22, 23, 24, 25, 85, + 86, 0, 26, 0, 0, 30, 31, 32, 33, 0, + 32, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 35, 35, 35, 35, 35, 35, 35, 35, 35, 0, + 0, 35, 35, 0, 0, 0, 0, 35, 0, 0, + 32, 32, 0, 35, 0, 35, 35, 35, 35, 35, + 0, 0, 35, 35, 35, 35, 35, 35, 35, 35, + 0, 35, 0, 35, 0, 0, 35, 35, 0, 0, + 0, 0, 0, 0, 0, 38, 38, 38, 38, 38, + 38, 38, 38, 38, 0, 0, 38, 38, 0, 0, + 0, 0, 38, 0, 0, 0, 0, 0, 38, 0, + 38, 38, 38, 38, 38, 0, 38, 38, 38, 38, + 38, 38, 38, 38, 38, 0, 38, 0, 38, 38, + 38, 38, 38, 0, 0, 0, 39, 39, 39, 39, + 39, 39, 39, 39, 39, 0, 0, 39, 39, 0, + 0, 0, 0, 39, 0, 0, 0, 0, 0, 39, + 0, 39, 39, 39, 39, 39, 0, 39, 39, 39, + 39, 39, 39, 39, 39, 39, 0, 39, 0, 39, + 39, 39, 39, 39, 32, 32, 32, 32, 32, 32, + 32, 32, 32, 33, 0, 32, 32, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 32, 0, 32, + 32, 32, 32, 32, 0, 32, 32, 32, 32, 32, + 32, 32, 32, 32, 0, 32, 0, 32, 32, 32, + 32, 32, 0, 33, 33, 0, 0, 33, 0, 0, + 0, 45, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 33, 33, 33, 0, 33, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 45, 45, 0, 0, 45, 33, 0, 0, 0, + 15, 0, 0, 0, 0, 0, 0, 0, 0, 45, + 45, 45, 0, 45, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 33, 33, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 15, 0, 0, 15, 45, 15, 0, 0, 0, 0, + 12, 0, 0, 0, 0, 0, 0, 0, 0, 15, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 45, 45, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 12, 0, 0, 12, 0, 12, 0, 0, 7, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 12, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 15, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 7, 0, + 0, 7, 0, 7, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 7, 0, 0, + 33, 33, 33, 33, 33, 33, 33, 33, 33, 0, + 0, 33, 33, 12, 0, 0, 0, 0, 0, 0, + 0, 0, 6, 33, 0, 33, 33, 33, 33, 33, + 0, 33, 33, 33, 33, 33, 33, 33, 33, 33, + 0, 33, 0, 33, 33, 33, 33, 33, 45, 45, + 45, 45, 45, 45, 45, 45, 45, 0, 0, 45, + 45, 0, 6, 0, 0, 6, 0, 6, 0, 0, + 0, 45, 0, 45, 45, 45, 45, 45, 0, 45, + 45, 45, 45, 45, 45, 45, 45, 45, 0, 45, + 0, 45, 45, 45, 45, 45, 0, 15, 15, 15, + 15, 15, 15, 15, 15, 0, 0, 66, 15, 15, + 27, 0, 28, 0, 0, 0, 0, 0, 0, 0, + 15, 5, 15, 15, 15, 15, 15, 0, 0, 0, + 0, 15, 15, 15, 15, 0, 0, 0, 15, 0, + 15, 15, 15, 15, 15, 6, 0, 12, 12, 12, + 12, 0, 12, 12, 12, 0, 0, 0, 12, 12, + 0, 5, 0, 0, 5, 0, 5, 0, 0, 2, + 12, 0, 12, 12, 12, 12, 12, 0, 0, 0, + 0, 12, 12, 12, 12, 0, 0, 0, 12, 0, + 12, 12, 12, 12, 12, 7, 7, 7, 7, 7, + 7, 7, 7, 0, 0, 0, 7, 7, 0, 2, + 0, 0, 2, 0, 2, 0, 0, 0, 7, 0, + 7, 7, 7, 7, 7, 0, 0, 0, 0, 7, + 7, 7, 7, 0, 0, 0, 7, 0, 7, 7, + 7, 7, 7, 0, 5, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 66, 233, 0, 27, 234, 28, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 6, + 6, 6, 0, 0, 0, 6, 6, 0, 0, 0, + 6, 6, 2, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 6, 0, 6, 6, 6, 6, 6, 0, + 0, 0, 0, 6, 6, 6, 6, 0, 0, 0, + 6, 0, 6, 6, 6, 6, 6, 0, 0, 0, + 12, 13, 0, 173, 174, 14, 15, 0, 0, 0, + 0, 0, 178, 179, 180, 181, 182, 16, 0, 17, + 18, 19, 0, 21, 184, 0, 0, 0, 22, 23, + 24, 25, 0, 0, 0, 26, 0, 0, 30, 31, + 32, 33, 0, 0, 0, 0, 0, 0, 5, 5, + 5, 0, 0, 0, 5, 5, 0, 0, 0, 5, + 5, 0, 0, 0, 0, 0, 0, 35, 0, 0, + 27, 5, 28, 5, 5, 5, 5, 5, 0, 0, + 0, 0, 5, 5, 5, 5, 293, 0, 0, 5, + 0, 5, 5, 5, 5, 5, 2, 2, 2, 0, + 0, 0, 2, 2, 0, 0, 0, 2, 2, 57, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, + 0, 2, 2, 2, 2, 2, 0, 0, 0, 0, + 2, 2, 2, 2, 0, 0, 0, 2, 0, 2, + 2, 2, 2, 2, 0, 0, 57, 0, 0, 57, + 57, 57, 57, 57, 57, 0, 57, 12, 13, 0, + 0, 0, 14, 15, 53, 0, 0, 57, 57, 57, + 0, 57, 57, 0, 16, 0, 17, 18, 19, 0, + 21, 0, 0, 0, 0, 22, 23, 24, 25, 0, + 0, 0, 26, 0, 0, 30, 31, 32, 33, 0, + 0, 53, 57, 57, 53, 53, 53, 53, 53, 53, + 0, 53, 55, 0, 0, 0, 0, 0, 0, 0, + 0, 57, 53, 53, 0, 0, 53, 53, 0, 0, + 0, 0, 57, 57, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 55, + 0, 0, 0, 55, 55, 0, 55, 53, 53, 55, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 55, 55, 55, 0, 55, 55, 53, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 11, 53, 53, 0, + 12, 13, 0, 0, 0, 14, 15, 0, 0, 0, + 0, 0, 0, 0, 0, 55, 55, 16, 0, 17, + 18, 19, 0, 21, 0, 0, 0, 0, 22, 23, + 24, 25, 0, 0, 55, 26, 0, 29, 30, 31, + 32, 33, 0, 0, 0, 55, 55, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 57, 57, 57, 57, + 57, 57, 57, 57, 57, 0, 0, 57, 57, 0, + 0, 0, 0, 57, 0, 0, 0, 0, 0, 57, + 0, 57, 57, 57, 57, 57, 0, 57, 57, 57, + 57, 0, 57, 57, 57, 57, 0, 57, 0, 57, + 57, 57, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 53, 53, 53, 53, 53, 53, 53, 53, 53, + 0, 0, 53, 53, 0, 0, 0, 0, 53, 0, + 0, 0, 0, 0, 53, 0, 53, 53, 53, 53, + 53, 28, 53, 53, 53, 53, 0, 53, 53, 53, + 53, 0, 53, 0, 53, 53, 53, 0, 0, 55, + 55, 55, 55, 55, 55, 0, 0, 55, 0, 0, + 0, 0, 0, 0, 0, 0, 55, 0, 28, 0, + 0, 0, 28, 28, 0, 28, 24, 55, 28, 0, + 55, 55, 55, 55, 55, 55, 55, 55, 55, 28, + 28, 28, 55, 28, 28, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 24, 0, 0, 0, 24, 24, 0, + 24, 26, 0, 24, 28, 28, 0, 0, 0, 0, + 0, 0, 0, 0, 24, 24, 24, 0, 24, 24, + 0, 0, 0, 28, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 28, 28, 0, 0, 26, 0, + 0, 0, 26, 26, 0, 26, 0, 0, 26, 24, + 24, 0, 0, 0, 0, 0, 0, 0, 0, 26, + 26, 26, 0, 26, 26, 0, 0, 0, 24, 0, + 25, 0, 0, 0, 0, 0, 0, 0, 0, 24, + 24, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 26, 26, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 25, 0, 0, + 0, 25, 25, 26, 25, 0, 0, 25, 0, 0, + 0, 0, 0, 0, 26, 26, 0, 0, 25, 25, + 25, 0, 25, 25, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 25, 25, 0, 0, 0, 28, 28, + 28, 28, 28, 28, 0, 0, 28, 0, 0, 0, + 0, 0, 25, 0, 0, 28, 0, 0, 0, 0, + 0, 0, 0, 25, 25, 0, 28, 0, 0, 28, + 28, 28, 28, 28, 28, 28, 28, 28, 0, 0, + 0, 28, 0, 24, 24, 24, 24, 24, 24, 0, + 66, 24, 0, 27, 0, 28, 0, 0, 0, 0, + 24, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 24, 0, 0, 24, 24, 24, 24, 24, 24, + 24, 24, 24, 0, 0, 0, 24, 0, 26, 26, + 26, 26, 26, 26, 0, 0, 26, 0, 0, 0, + 0, 0, 0, 0, 0, 26, 0, 0, 56, 0, + 0, 0, 0, 0, 0, 0, 26, 0, 0, 26, + 26, 26, 26, 26, 26, 26, 26, 26, 0, 0, + 0, 26, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 56, 0, 0, 0, 56, + 56, 0, 56, 0, 0, 56, 0, 25, 25, 25, + 25, 25, 25, 0, 0, 25, 56, 56, 56, 0, + 56, 56, 0, 0, 25, 87, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 25, 0, 0, 25, 25, + 25, 25, 25, 25, 25, 25, 25, 0, 0, 0, + 25, 56, 56, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 87, 0, 0, 0, 87, 87, 0, 87, + 56, 0, 87, 88, 0, 0, 0, 0, 0, 0, + 0, 56, 56, 87, 87, 87, 0, 87, 87, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 88, 0, 0, 0, 88, 88, 0, 88, 87, 87, + 88, 125, 126, 12, 13, 0, 0, 0, 14, 15, + 0, 88, 88, 88, 0, 88, 88, 87, 0, 0, + 16, 0, 17, 18, 19, 89, 21, 0, 87, 87, + 0, 22, 23, 24, 25, 0, 0, 0, 26, 0, + 0, 30, 31, 32, 33, 0, 88, 88, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 89, 0, 0, 88, 89, 89, 0, 89, + 0, 0, 89, 0, 0, 0, 88, 88, 0, 0, + 0, 0, 0, 89, 89, 89, 0, 89, 89, 0, + 0, 0, 0, 0, 0, 56, 56, 56, 56, 56, + 56, 0, 0, 56, 66, 235, 0, 27, 236, 28, + 0, 0, 56, 85, 0, 0, 0, 0, 89, 89, + 0, 0, 0, 56, 0, 0, 56, 56, 56, 56, + 56, 56, 56, 56, 56, 0, 0, 89, 56, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 89, 89, + 85, 0, 0, 0, 85, 85, 0, 0, 0, 0, + 85, 0, 87, 87, 87, 87, 87, 87, 0, 0, + 87, 85, 85, 85, 0, 85, 85, 0, 0, 87, + 0, 0, 0, 66, 237, 0, 27, 238, 28, 0, + 87, 0, 0, 87, 87, 87, 0, 0, 0, 0, + 87, 87, 0, 0, 0, 87, 85, 85, 0, 0, + 88, 88, 88, 88, 88, 88, 0, 0, 88, 0, + 0, 0, 0, 0, 0, 85, 0, 88, 0, 0, + 16, 0, 0, 0, 0, 0, 85, 85, 88, 0, + 0, 88, 88, 88, 0, 0, 0, 0, 88, 88, + 0, 0, 0, 88, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 16, 0, 0, + 0, 16, 16, 0, 16, 0, 0, 16, 0, 0, + 0, 0, 89, 89, 89, 89, 89, 89, 16, 16, + 89, 0, 0, 16, 0, 0, 0, 0, 0, 89, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 89, 0, 0, 89, 89, 89, 0, 0, 0, 0, + 89, 89, 0, 16, 16, 89, 0, 12, 13, 0, + 0, 0, 14, 15, 0, 0, 0, 0, 0, 0, + 0, 0, 16, 0, 16, 0, 17, 18, 19, 0, + 21, 0, 0, 16, 16, 22, 23, 24, 25, 0, + 0, 0, 26, 0, 0, 30, 31, 32, 33, 0, + 85, 85, 85, 85, 85, 85, 0, 0, 85, 0, + 0, 0, 0, 0, 0, 0, 0, 85, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 85, 0, + 0, 85, 85, 85, 0, 0, 12, 13, 85, 85, + 0, 14, 15, 85, 0, 0, 0, 0, 0, 0, + 0, 41, 0, 16, 0, 17, 18, 19, 53, 21, + 0, 0, 0, 0, 22, 23, 24, 25, 0, 0, + 0, 26, 0, 41, 30, 31, 32, 33, 0, 41, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 105, 53, 108, 0, 0, 0, 112, + 113, 0, 116, 118, 119, 0, 53, 53, 123, 124, + 41, 0, 0, 0, 0, 0, 0, 16, 16, 16, + 16, 16, 16, 0, 0, 16, 0, 0, 41, 138, + 139, 140, 141, 0, 16, 0, 0, 0, 0, 0, + 0, 0, 0, 41, 0, 16, 0, 0, 16, 16, + 16, 108, 0, 0, 0, 0, 0, 0, 160, 0, + 16, 0, 0, 0, 53, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 102, 103, 41, 41, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 199, 200, 0, 0, 202, 203, 204, 205, 207, + 133, 134, 135, 0, 209, 210, 0, 53, 53, 0, + 0, 0, 217, 0, 0, 0, 218, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 157, + 158, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 41, 41, + 254, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 266, 0, 267, 0, + 268, 0, 269, 0, 270, 0, 0, 0, 0, 272, + 0, 0, 0, 0, 273, 274, 0, 0, 0, 0, + 0, 211, 280, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 219, 0, 221, 0, 222, 0, 0, 0, + 0, 0, 41, 0, 0, 0, 0, 0, 0, 0, + 0, 66, 0, 0, 27, 0, 28, 243, 0, 41, + 0, 0, 0, 0, 0, 0, 0, 0, 57, 0, + 187, 0, 260, 261, 262, 263, 264, 0, 0, 68, + 68, 0, 71, 72, 0, 68, 0, 0, 0, 0, + 0, 0, 0, 68, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 68, 0, 0, 0, 0, + 0, 0, 0, 109, 0, 0, 109, 0, 109, 0, + 288, 0, 0, 0, 290, 291, 292, 0, 0, 0, + 297, 0, 109, 0, 185, 0, 0, 0, 0, 0, + 0, 0, 0, 68, 68, 68, 68, 68, 68, 68, + 0, 0, 0, 0, 0, 310, 311, 68, 0, 0, + 68, 315, 0, 0, 68, 68, 0, 0, 68, 0, + 68, 68, 0, 0, 0, 68, 68, 0, 0, 0, + 108, 0, 0, 108, 0, 108, 0, 0, 0, 0, + 68, 68, 68, 68, 0, 0, 109, 0, 109, 108, + 0, 0, 196, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 68, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 102, 0, 0, 102, 0, + 102, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 68, 0, 0, 0, 102, 0, 0, 68, 0, 0, + 0, 68, 68, 0, 68, 68, 68, 68, 0, 68, + 0, 68, 68, 108, 0, 108, 0, 0, 0, 68, + 68, 172, 125, 126, 12, 13, 0, 173, 174, 14, + 15, 175, 0, 176, 177, 0, 178, 179, 180, 181, + 182, 16, 183, 17, 18, 19, 0, 21, 184, 0, + 0, 0, 22, 23, 24, 25, 68, 0, 102, 26, + 102, 0, 30, 31, 32, 33, 0, 0, 68, 68, + 68, 68, 68, 0, 68, 68, 68, 0, 0, 0, + 0, 0, 68, 109, 0, 0, 109, 109, 0, 109, + 109, 109, 109, 109, 109, 109, 109, 0, 109, 109, + 109, 109, 109, 109, 109, 109, 109, 109, 0, 109, + 109, 0, 0, 0, 109, 109, 109, 109, 0, 0, + 0, 109, 0, 0, 109, 109, 109, 109, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 108, 0, 0, 108, 108, 0, 108, 108, 108, 108, + 108, 108, 108, 108, 0, 108, 108, 108, 108, 108, + 108, 108, 108, 108, 108, 0, 108, 108, 0, 0, + 0, 108, 108, 108, 108, 0, 0, 0, 108, 0, + 0, 108, 108, 108, 108, 102, 0, 0, 102, 102, + 0, 102, 102, 102, 102, 102, 102, 102, 102, 0, + 102, 102, 102, 102, 102, 102, 102, 102, 102, 102, + 0, 102, 102, 0, 0, 0, 102, 102, 102, 102, + 0, 0, 0, 102, 0, 0, 102, 102, 102, 102, + 103, 0, 0, 103, 0, 103, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 103, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 104, 0, 0, 104, 0, + 104, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 104, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 103, 0, 103, 0, 0, 0, 0, + 101, 0, 0, 101, 0, 101, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 101, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 104, 0, + 104, 0, 0, 0, 0, 0, 107, 0, 0, 107, + 0, 107, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 107, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 101, 0, 101, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 35, 0, 0, 27, 0, 28, 0, 0, 0, 107, + 103, 107, 0, 103, 103, 0, 103, 103, 103, 103, + 103, 103, 103, 103, 0, 103, 103, 103, 103, 103, + 103, 103, 103, 103, 103, 0, 103, 103, 0, 0, + 0, 103, 103, 103, 103, 0, 0, 0, 103, 0, + 0, 103, 103, 103, 103, 104, 0, 0, 104, 104, + 0, 104, 104, 104, 104, 104, 104, 104, 104, 0, + 104, 104, 104, 104, 104, 104, 104, 104, 104, 104, + 0, 104, 104, 34, 0, 0, 104, 104, 104, 104, + 0, 0, 0, 104, 0, 0, 104, 104, 104, 104, + 101, 0, 0, 101, 101, 0, 101, 101, 101, 101, + 101, 101, 101, 101, 0, 101, 101, 101, 101, 101, + 101, 101, 101, 101, 101, 35, 101, 101, 27, 0, + 28, 101, 101, 101, 101, 0, 0, 0, 101, 0, + 0, 101, 101, 101, 101, 0, 107, 0, 0, 107, + 107, 0, 107, 107, 107, 107, 107, 107, 107, 107, + 0, 107, 107, 107, 107, 107, 107, 107, 107, 107, + 107, 0, 107, 107, 0, 0, 0, 107, 107, 107, + 107, 0, 0, 0, 107, 0, 0, 107, 107, 107, + 107, 136, 0, 0, 136, 0, 136, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 136, 0, 0, 0, 0, 0, 0, 9, 10, 11, + 0, 0, 0, 12, 13, 0, 0, 0, 14, 15, + 0, 0, 0, 0, 0, 0, 66, 0, 0, 27, + 16, 28, 17, 18, 19, 20, 21, 0, 0, 0, + 0, 22, 23, 24, 25, 187, 0, 0, 26, 0, + 29, 30, 31, 32, 33, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 136, 0, 136, 0, 0, 0, + 0, 66, 0, 0, 27, 0, 28, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 187, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 185, + 0, 186, 0, 0, 0, 0, 0, 66, 0, 0, + 27, 0, 28, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 11, 0, 187, 0, 12, 13, + 0, 0, 0, 14, 15, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 185, 16, 197, 17, 18, 19, + 0, 21, 0, 0, 0, 0, 22, 23, 24, 25, + 0, 0, 0, 26, 0, 29, 30, 31, 32, 33, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 35, 0, 0, 27, 0, 28, 0, 0, 0, + 185, 136, 198, 0, 136, 136, 0, 136, 136, 136, + 136, 136, 136, 136, 136, 0, 136, 136, 136, 136, + 136, 136, 136, 136, 136, 136, 0, 136, 136, 0, + 0, 0, 136, 136, 136, 136, 0, 0, 0, 136, + 0, 0, 136, 136, 136, 136, 172, 0, 0, 12, + 13, 0, 173, 174, 14, 15, 175, 0, 176, 177, + 0, 178, 179, 180, 181, 182, 16, 183, 17, 18, + 19, 0, 21, 184, 0, 0, 0, 22, 23, 24, + 25, 0, 0, 0, 26, 0, 0, 30, 31, 32, + 33, 172, 0, 0, 12, 13, 0, 173, 174, 14, + 15, 175, 0, 176, 177, 0, 178, 179, 180, 181, + 182, 16, 183, 17, 18, 19, 107, 21, 184, 27, + 0, 28, 22, 23, 24, 25, 0, 0, 0, 26, + 0, 0, 30, 31, 32, 33, 0, 172, 0, 0, + 12, 13, 0, 173, 174, 14, 15, 175, 0, 176, + 177, 0, 178, 179, 180, 181, 182, 16, 183, 17, + 18, 19, 0, 21, 184, 0, 0, 0, 22, 23, + 24, 25, 0, 0, 0, 26, 0, 0, 30, 31, + 32, 33, 66, 0, 0, 27, 0, 28, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 187, 0, 0, 0, 0, 0, 0, 0, 0, + 11, 0, 125, 126, 12, 13, 0, 0, 0, 14, + 15, 0, 0, 0, 0, 0, 0, 66, 0, 0, + 27, 16, 28, 17, 18, 19, 0, 21, 0, 0, + 0, 0, 22, 23, 24, 25, 187, 0, 0, 26, + 0, 29, 30, 31, 32, 33, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 185, 0, 228, 0, 0, + 0, 0, 66, 0, 0, 27, 0, 28, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 187, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 185, 0, 281, 0, 0, 0, 0, 0, 106, 0, + 0, 106, 0, 106, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 11, 0, 106, 0, 12, + 13, 0, 0, 0, 14, 15, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 185, 16, 305, 17, 18, + 19, 0, 21, 0, 0, 0, 0, 22, 23, 24, + 25, 0, 0, 0, 26, 0, 29, 30, 31, 32, + 33, 66, 239, 0, 27, 240, 28, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 106, 172, 106, 0, 12, 13, 0, 173, 174, + 14, 15, 175, 0, 176, 177, 0, 178, 179, 180, + 181, 182, 16, 183, 17, 18, 19, 0, 21, 184, + 0, 0, 0, 22, 23, 24, 25, 0, 0, 0, + 26, 0, 0, 30, 31, 32, 33, 172, 0, 0, + 12, 13, 0, 173, 174, 14, 15, 175, 0, 176, + 177, 0, 178, 179, 180, 181, 182, 16, 183, 17, + 18, 19, 66, 21, 184, 27, 110, 28, 22, 23, + 24, 25, 0, 0, 0, 26, 0, 0, 30, 31, + 32, 33, 172, 0, 0, 12, 13, 0, 173, 174, + 14, 15, 175, 0, 176, 177, 0, 178, 179, 180, + 181, 182, 16, 183, 17, 18, 19, 0, 21, 184, + 0, 0, 0, 22, 23, 24, 25, 0, 0, 0, + 26, 0, 0, 30, 31, 32, 33, 0, 106, 0, + 0, 106, 106, 0, 106, 106, 106, 106, 106, 0, + 106, 106, 0, 106, 106, 106, 106, 106, 106, 106, + 106, 106, 106, 0, 106, 106, 0, 0, 0, 106, + 106, 106, 106, 0, 0, 0, 106, 0, 0, 106, + 106, 106, 106, 129, 0, 0, 129, 0, 129, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 129, 0, 12, 13, 0, 0, 0, 14, + 15, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 16, 0, 17, 18, 19, 0, 21, 0, 0, + 0, 0, 22, 23, 24, 25, 0, 0, 0, 26, + 0, 0, 30, 31, 32, 33, 66, 244, 0, 27, + 245, 28, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 129, 0, 129, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 66, 104, + 0, 27, 0, 28, 0, 12, 13, 0, 0, 0, + 14, 15, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 16, 0, 17, 18, 19, 0, 21, 0, + 0, 0, 0, 22, 23, 24, 25, 0, 0, 0, + 26, 0, 0, 30, 31, 32, 33, 66, 0, 0, + 27, 0, 28, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 66, 0, 0, 27, 0, 28, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 129, 0, 0, 129, 129, 0, 129, + 129, 129, 129, 129, 0, 129, 129, 0, 129, 129, + 129, 129, 129, 129, 129, 129, 129, 129, 0, 129, + 129, 0, 0, 0, 129, 129, 129, 129, 0, 0, + 0, 129, 0, 0, 129, 129, 129, 129, 66, 0, + 0, 27, 0, 28, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 12, + 13, 0, 0, 0, 14, 15, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 16, 0, 17, 18, + 19, 0, 21, 0, 0, 0, 0, 22, 23, 24, + 25, 0, 0, 0, 26, 0, 0, 30, 31, 32, + 33, 12, 13, 0, 0, 0, 14, 15, 66, 154, + 0, 27, 0, 28, 0, 0, 0, 0, 16, 0, + 17, 18, 19, 0, 21, 0, 0, 0, 0, 22, + 23, 24, 25, 0, 0, 0, 26, 0, 0, 30, + 31, 32, 33, 0, 0, 0, 115, 0, 0, 0, + 12, 13, 0, 0, 66, 14, 15, 27, 159, 28, + 0, 0, 0, 0, 0, 0, 0, 16, 0, 17, + 18, 19, 0, 21, 0, 0, 0, 0, 22, 23, + 24, 25, 0, 0, 0, 26, 0, 0, 30, 31, + 32, 33, 117, 0, 0, 0, 12, 13, 0, 0, + 66, 14, 15, 27, 162, 28, 0, 0, 0, 0, + 0, 0, 0, 16, 0, 17, 18, 19, 0, 21, + 0, 0, 0, 0, 22, 23, 24, 25, 0, 0, + 0, 26, 0, 0, 30, 31, 32, 33, 0, 0, + 0, 0, 66, 0, 0, 27, 164, 28, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 137, 0, 0, + 0, 12, 13, 0, 0, 0, 14, 15, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 16, 0, + 17, 18, 19, 0, 21, 0, 0, 0, 0, 22, + 23, 24, 25, 0, 0, 0, 26, 0, 0, 30, + 31, 32, 33, 66, 0, 0, 27, 165, 28, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 12, 13, 0, 0, 0, 14, 15, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 16, 0, + 17, 18, 19, 66, 21, 0, 27, 170, 28, 22, + 23, 24, 25, 0, 0, 0, 26, 0, 0, 30, + 31, 32, 33, 0, 0, 0, 0, 12, 13, 0, + 0, 0, 14, 15, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 16, 0, 17, 18, 19, 66, + 21, 0, 27, 171, 28, 22, 23, 24, 25, 0, + 0, 0, 26, 0, 0, 30, 31, 32, 33, 0, + 0, 0, 0, 12, 13, 0, 0, 0, 14, 15, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 16, 0, 17, 18, 19, 66, 21, 0, 27, 0, + 28, 22, 23, 24, 25, 0, 0, 0, 26, 0, + 0, 30, 31, 32, 33, 12, 13, 0, 0, 0, + 14, 15, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 16, 0, 17, 18, 19, 0, 21, 0, + 0, 0, 0, 22, 23, 24, 25, 0, 0, 0, + 26, 0, 0, 30, 31, 32, 33, 66, 242, 0, + 27, 0, 28, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 12, 13, 0, 0, + 0, 14, 15, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 16, 0, 17, 18, 19, 0, 21, + 0, 0, 0, 0, 22, 23, 24, 25, 0, 0, + 0, 26, 0, 0, 30, 31, 32, 33, 66, 246, + 0, 27, 0, 28, 0, 0, 12, 13, 0, 0, + 0, 14, 15, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 16, 0, 17, 18, 19, 0, 21, + 0, 0, 0, 0, 22, 23, 24, 25, 0, 0, + 0, 26, 0, 0, 30, 31, 32, 33, 0, 0, + 0, 66, 12, 13, 27, 0, 28, 14, 15, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 16, + 0, 17, 18, 19, 0, 21, 0, 0, 0, 0, + 22, 23, 24, 25, 0, 0, 0, 26, 0, 0, + 30, 31, 32, 33, 206, 0, 0, 0, 12, 13, + 0, 0, 0, 14, 15, 66, 277, 0, 27, 0, + 28, 0, 0, 0, 0, 16, 0, 17, 18, 19, + 0, 21, 0, 0, 0, 0, 22, 23, 24, 25, + 0, 0, 0, 26, 0, 0, 30, 31, 32, 33, + 0, 0, 0, 0, 0, 0, 0, 66, 283, 0, + 27, 0, 28, 0, 0, 0, 0, 0, 0, 0, + 12, 13, 0, 0, 0, 14, 15, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 16, 0, 17, + 18, 19, 0, 21, 0, 0, 0, 0, 22, 23, + 24, 25, 0, 0, 0, 26, 0, 0, 30, 31, + 32, 33, 66, 284, 0, 27, 0, 28, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 12, 13, 0, 0, 0, 14, 15, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 16, 0, + 17, 18, 19, 0, 21, 0, 0, 0, 0, 22, + 23, 24, 25, 0, 0, 0, 26, 0, 0, 30, + 31, 32, 33, 66, 285, 0, 27, 0, 28, 0, + 265, 0, 0, 0, 12, 13, 0, 0, 0, 14, + 15, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 16, 0, 17, 18, 19, 0, 21, 0, 0, + 0, 0, 22, 23, 24, 25, 0, 0, 0, 26, + 0, 0, 30, 31, 32, 33, 66, 286, 0, 27, + 0, 28, 0, 0, 0, 0, 0, 0, 12, 13, + 0, 0, 0, 14, 15, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 16, 0, 17, 18, 19, + 0, 21, 0, 0, 0, 0, 22, 23, 24, 25, + 0, 0, 0, 26, 0, 0, 30, 31, 32, 33, + 12, 13, 0, 0, 0, 14, 15, 66, 287, 0, + 27, 0, 28, 0, 0, 0, 0, 16, 0, 17, + 18, 19, 0, 21, 0, 0, 0, 0, 22, 23, + 24, 25, 0, 0, 0, 26, 0, 0, 30, 31, + 32, 33, 0, 0, 0, 0, 0, 0, 0, 66, + 289, 0, 27, 0, 28, 12, 13, 0, 0, 0, + 14, 15, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 16, 0, 17, 18, 19, 0, 21, 0, + 0, 0, 0, 22, 23, 24, 25, 0, 0, 0, + 26, 0, 0, 30, 31, 32, 33, 66, 0, 0, + 27, 0, 28, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 12, 13, 0, 0, + 0, 14, 15, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 16, 0, 17, 18, 19, 0, 21, + 0, 0, 0, 0, 22, 23, 24, 25, 0, 0, + 296, 26, 0, 0, 30, 31, 32, 33, 51, 0, + 0, 27, 0, 28, 0, 0, 0, 0, 0, 12, + 13, 0, 0, 0, 14, 15, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 16, 0, 17, 18, + 19, 0, 21, 0, 0, 0, 0, 22, 23, 24, + 25, 0, 0, 0, 26, 0, 0, 30, 31, 32, + 33, 66, 0, 0, 27, 0, 28, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 12, 13, 0, 0, 0, 14, 15, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 16, 0, 17, + 18, 19, 0, 21, 0, 0, 0, 0, 22, 23, + 24, 25, 0, 0, 0, 26, 0, 0, 30, 31, + 32, 33, 12, 13, 0, 0, 0, 14, 15, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 16, + 0, 17, 18, 19, 0, 21, 0, 0, 0, 0, + 22, 23, 24, 25, 0, 0, 0, 26, 0, 0, + 30, 31, 32, 33, 0, 0, 0, 0, 0, 0, + 12, 13, 0, 0, 0, 14, 15, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 16, 0, 17, + 18, 19, 0, 21, 0, 0, 0, 0, 22, 23, + 24, 25, 0, 0, 0, 26, 0, 0, 30, 31, + 32, 33, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 12, 13, 0, 0, 0, 14, 15, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 16, 0, + 17, 18, 19, 0, 21, 0, 0, 0, 0, 22, + 23, 24, 25, 0, 0, 0, 26, 67, 69, 30, + 31, 32, 33, 73, 0, 0, 0, 0, 0, 0, + 0, 89, 0, 0, 12, 13, 0, 0, 0, 14, + 15, 0, 0, 89, 0, 0, 0, 0, 0, 0, + 0, 16, 0, 17, 18, 19, 0, 21, 0, 0, + 0, 0, 22, 23, 24, 25, 0, 0, 0, 26, + 0, 0, 30, 31, 32, 33, 0, 0, 0, 0, + 0, 143, 144, 145, 146, 147, 148, 149, 0, 0, + 0, 0, 0, 0, 0, 89, 0, 0, 89, 0, + 0, 0, 89, 89, 0, 0, 89, 0, 89, 89, + 0, 0, 0, 89, 89, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 89, 89, + 89, 89, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 89, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 89, 0, + 0, 0, 0, 0, 0, 229, 0, 0, 0, 89, + 89, 0, 89, 89, 89, 89, 0, 89, 0, 89, + 89, 0, 0, 0, 0, 0, 0, 89, 89, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 89, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 89, 89, 89, 89, + 89, 0, 89, 89, 89, 0, 0, 0, 0, 0, + 89, +}; +short yycheck[] = { 7, + 0, 41, 44, 41, 37, 41, 59, 41, 123, 42, + 43, 41, 45, 59, 47, 35, 59, 38, 41, 51, + 94, 29, 293, 62, 123, 58, 102, 103, 40, 59, + 63, 35, 303, 35, 301, 302, 123, 37, 112, 292, + 40, 41, 42, 43, 44, 45, 40, 47, 219, 40, + 303, 304, 41, 288, 216, 0, 40, 133, 58, 59, + 60, 94, 62, 63, 40, 60, 301, 302, 50, 41, + 59, 41, 44, 62, 44, 107, 84, 261, 262, 112, + 62, 63, 289, 290, 40, 124, 41, 107, 289, 290, + 286, 99, 37, 93, 94, 91, 41, 42, 43, 44, + 45, 40, 47, 107, 59, 107, 261, 41, 289, 290, + 0, 41, 112, 58, 59, 60, 40, 62, 63, 290, + 291, 292, 40, 123, 124, 59, 134, 135, 44, 59, + 123, 293, 289, 290, 60, 124, 40, 112, 120, 310, + 311, 303, 41, 41, 315, 221, 41, 37, 93, 94, + 40, 41, 42, 43, 37, 45, 41, 47, 292, 42, + 43, 59, 45, 280, 47, 41, 41, 112, 58, 59, + 60, 44, 62, 63, 261, 262, 197, 44, 123, 124, + 63, 41, 93, 292, 59, 41, 40, 40, 40, 292, + 290, 173, 174, 41, 91, 59, 41, 272, 40, 271, + 41, 41, 0, 93, 94, 40, 214, 215, 43, 44, + 45, 94, 288, 41, 260, 261, 262, 260, 261, 262, + 59, 93, 112, 59, 41, 60, 265, 62, 213, 112, + 260, 261, 262, 123, 124, -1, 289, 290, -1, -1, + -1, 274, -1, -1, -1, -1, -1, 289, 290, 289, + 290, 289, 290, 289, 290, 289, 290, 257, 258, 259, + 260, 261, 262, 263, 264, 265, 289, 290, 268, 269, + 278, 260, 261, 262, 274, -1, 265, -1, -1, -1, + 280, 41, 282, 283, 284, 285, 286, 295, 288, 289, + 290, 291, 292, 293, 294, 295, 296, 292, 298, 59, + 300, 301, 302, 303, 304, 260, 261, 262, 303, 304, + -1, -1, 257, 258, 259, 260, 261, 262, 263, 264, + 265, -1, -1, 268, 269, -1, 260, 261, 262, 274, + 260, 261, 262, -1, -1, 280, 41, 282, 283, 284, + 285, 286, -1, 288, 289, 290, 291, 292, 293, 294, + 295, 296, -1, 298, 59, 300, 301, 302, 303, 304, + -1, -1, 260, 261, 262, -1, -1, 257, 258, 259, + 260, 261, 262, 263, 264, 265, -1, -1, 268, 269, + 0, -1, -1, -1, 274, 260, 261, 262, -1, -1, + 280, 274, 282, 283, 284, 285, 286, 41, 288, 289, + 290, 291, 292, 293, 294, 295, 296, -1, 298, -1, + 300, 301, 302, 303, 304, 59, -1, 37, -1, -1, + 40, 41, 42, 43, 44, 45, -1, 47, 263, 264, + -1, 37, -1, 268, 269, 0, 42, -1, 58, 59, + -1, 47, 62, 63, -1, 280, -1, 282, 283, 284, + -1, 286, -1, -1, -1, -1, 291, 292, 293, 294, + 295, 296, -1, 298, -1, -1, 301, 302, 303, 304, + -1, -1, 37, 93, 94, 40, 41, 42, 43, 44, + 45, -1, 47, -1, -1, -1, -1, -1, 94, -1, + 0, -1, 112, 58, 59, 60, -1, 62, 63, -1, + 260, 261, 262, 123, 124, -1, 112, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, 37, 93, 94, + 40, 41, 42, 43, 44, 45, -1, 47, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, 58, 59, + 60, -1, 62, 63, -1, 260, 261, 262, 123, 124, + -1, -1, -1, 0, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, 93, 94, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + 37, -1, 112, 40, 41, 42, 43, 44, 45, -1, + 47, -1, -1, 123, 124, -1, 260, 261, 262, -1, + -1, 58, 59, 60, -1, 62, 63, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, 257, 258, 259, + 260, 261, 262, 263, 264, 265, -1, -1, 268, 269, + -1, -1, -1, -1, 274, -1, 93, -1, -1, -1, + 280, -1, 282, 283, 284, 285, 286, -1, 288, 289, + 290, 291, 292, 293, 294, 295, 296, -1, 298, -1, + 300, 301, 302, 303, 304, -1, 123, 124, -1, -1, + -1, -1, 257, 258, 259, 260, 261, 262, 263, 264, + 265, -1, -1, 268, 269, -1, -1, -1, -1, 274, + -1, -1, -1, -1, -1, 280, -1, 282, 283, 284, + 285, 286, -1, 288, 289, 290, 291, 292, 293, 294, + 295, 296, -1, 298, -1, 300, 301, 302, 303, 304, + -1, -1, -1, -1, -1, -1, -1, 257, 258, 259, + 260, 261, 262, 263, 264, 265, -1, -1, 268, 269, + -1, -1, -1, -1, 274, -1, -1, -1, -1, -1, + 280, -1, 282, 283, 284, 285, 286, -1, 288, 289, + -1, 291, 292, 293, 294, 295, 296, -1, 298, -1, + 300, 301, 302, 303, 304, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + 257, 258, 259, 260, 261, 262, 263, 264, 265, -1, + -1, 268, 269, 0, -1, -1, -1, 274, -1, -1, + -1, -1, -1, 280, -1, 282, 283, 284, 285, 286, + -1, 288, 289, 290, 291, 292, 293, 294, 295, 296, + -1, 298, -1, 300, 301, 302, 303, 304, -1, -1, + 37, -1, -1, 40, 41, 42, 43, 44, 45, -1, + 47, -1, -1, -1, -1, -1, -1, -1, 0, -1, + -1, 58, 59, 60, -1, 62, 63, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, 37, 93, 94, 40, 41, + 42, 43, 44, 45, -1, 47, -1, -1, -1, -1, + -1, -1, 0, -1, -1, 112, 58, 59, 60, -1, + 62, 63, -1, -1, -1, -1, 123, 124, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, 37, + -1, 93, 40, 41, 42, 43, 44, 45, -1, 47, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + 58, 59, 60, -1, 62, 63, -1, -1, -1, -1, + -1, 123, 124, -1, -1, 0, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, 93, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, 37, -1, -1, 40, 41, 42, 43, 44, + 45, -1, 47, -1, -1, 123, 124, -1, -1, -1, + -1, -1, -1, 58, 59, 60, -1, 62, 63, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + 257, 258, 259, 260, 261, 262, 263, 264, 265, -1, + -1, 268, 269, -1, -1, -1, -1, 274, 93, -1, + -1, -1, -1, 280, -1, 282, 283, 284, 285, 286, + -1, 288, 289, 290, 291, 292, 293, 294, 295, 296, + -1, 298, -1, 300, -1, -1, 303, 304, 123, 124, + -1, -1, -1, -1, -1, 257, 258, 259, 260, 261, + 262, 263, 264, 265, -1, -1, 268, 269, -1, -1, + -1, -1, 274, -1, -1, -1, -1, -1, 280, -1, + 282, 283, 284, 285, 286, -1, 288, 289, 290, 291, + 292, 293, 294, 295, 296, -1, 298, -1, 300, 301, + 302, 303, 304, -1, -1, -1, -1, -1, -1, 257, + 258, 259, 260, 261, 262, 263, 264, 265, 0, -1, + 268, 269, -1, -1, -1, -1, 274, -1, -1, -1, + -1, -1, 280, -1, 282, 283, 284, 285, 286, -1, + 288, 289, 290, 291, 292, 293, 294, 295, 296, -1, + 298, -1, 300, 301, 302, 303, 304, -1, 40, -1, + -1, 43, -1, 45, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, 59, -1, -1, + -1, -1, 257, 258, 259, 260, 261, 262, 263, 264, + 265, -1, -1, 268, 269, 0, -1, -1, -1, 274, + -1, -1, -1, -1, -1, 280, -1, 282, 283, 284, + 285, 286, -1, 288, 289, 290, 291, 292, 293, 294, + 295, 296, -1, 298, -1, 300, 301, 302, 303, 304, + -1, -1, 37, -1, -1, 40, 41, 42, 43, 44, + 45, 123, 47, -1, -1, -1, -1, -1, -1, 0, + -1, -1, -1, 58, 59, 60, -1, 62, 63, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, 37, -1, 93, 40, + 41, 42, 43, 44, 45, -1, 47, -1, -1, -1, + -1, -1, -1, 0, -1, -1, -1, 58, 59, 60, + -1, 62, 63, -1, -1, -1, -1, -1, 123, 124, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + 37, -1, 93, 40, 41, 42, 43, 44, 45, -1, + 47, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, 58, 59, 60, -1, 62, 63, -1, -1, -1, + -1, -1, 123, 124, -1, 257, 258, 259, 260, 261, + 262, 263, 264, -1, -1, -1, 268, 269, -1, -1, + -1, -1, -1, -1, -1, -1, 93, 94, 280, -1, + 282, 283, 284, 285, 286, -1, -1, -1, -1, 291, + 292, 293, 294, -1, -1, 112, 298, -1, 300, 301, + 302, 303, 304, -1, -1, -1, 123, 124, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, 257, 258, 259, 260, 261, 262, 263, 264, + 265, -1, -1, 268, 269, -1, -1, -1, -1, 274, + -1, 40, -1, -1, 43, 280, 45, 282, 283, 284, + 285, 286, -1, 288, 289, 290, 291, 292, 293, 294, + 295, 296, -1, 298, -1, 300, 301, 302, 303, 304, + -1, -1, -1, -1, -1, -1, 257, 258, 259, 260, + 261, 262, 263, 264, 265, -1, -1, 268, 269, -1, + -1, -1, -1, 274, -1, -1, -1, -1, -1, 280, + -1, 282, 283, 284, 285, 286, -1, 288, 289, 290, + 291, 292, 293, 294, 295, 296, -1, 298, -1, 300, + 301, 302, 303, 304, 40, -1, -1, 43, -1, 45, + 257, 258, 259, 260, 261, 262, 263, 264, 265, -1, + -1, 268, 269, 0, 60, -1, 62, 274, -1, -1, + -1, -1, -1, 280, -1, 282, 283, 284, 285, 286, + -1, 288, -1, -1, 291, 292, 293, 294, 295, 296, + -1, 298, -1, 300, 301, 302, 303, 304, -1, -1, + 37, -1, -1, 40, 41, 42, 43, 44, 45, -1, + 47, -1, -1, -1, -1, -1, -1, -1, 0, -1, + -1, 58, 59, 60, -1, 62, 63, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, 93, 94, 40, 41, + -1, 43, 44, 45, -1, -1, -1, -1, -1, 0, + -1, -1, -1, -1, -1, 112, 58, 59, 60, -1, + 62, 63, -1, -1, 263, 264, 123, 124, -1, 268, + 269, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, 280, -1, 282, 283, 284, -1, 286, -1, 40, + 41, 93, 43, 44, 45, -1, -1, 0, -1, 298, + -1, -1, 301, 302, 303, 304, -1, 58, 59, 60, + -1, 62, 63, -1, -1, -1, -1, -1, -1, -1, + -1, 123, 124, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, 40, 41, -1, + -1, 44, 93, -1, -1, -1, -1, 263, 264, -1, + -1, -1, 268, 269, -1, 58, 59, 60, -1, 62, + -1, -1, -1, -1, 280, -1, 282, 283, 284, -1, + 286, -1, 123, 124, -1, 291, 292, 293, 294, 295, + 296, -1, 298, -1, -1, 301, 302, 303, 304, -1, + 93, -1, -1, -1, -1, -1, -1, -1, -1, -1, + 257, 258, 259, 260, 261, 262, 263, 264, 265, -1, + -1, 268, 269, -1, -1, -1, -1, 274, -1, -1, + 123, 124, -1, 280, -1, 282, 283, 284, 285, 286, + -1, -1, 289, 290, 291, 292, 293, 294, 295, 296, + -1, 298, -1, 300, -1, -1, 303, 304, -1, -1, + -1, -1, -1, -1, -1, 257, 258, 259, 260, 261, + 262, 263, 264, 265, -1, -1, 268, 269, -1, -1, + -1, -1, 274, -1, -1, -1, -1, -1, 280, -1, + 282, 283, 284, 285, 286, -1, 288, 289, 290, 291, + 292, 293, 294, 295, 296, -1, 298, -1, 300, 301, + 302, 303, 304, -1, -1, -1, 257, 258, 259, 260, + 261, 262, 263, 264, 265, -1, -1, 268, 269, -1, + -1, -1, -1, 274, -1, -1, -1, -1, -1, 280, + -1, 282, 283, 284, 285, 286, -1, 288, 289, 290, + 291, 292, 293, 294, 295, 296, -1, 298, -1, 300, + 301, 302, 303, 304, 257, 258, 259, 260, 261, 262, + 263, 264, 265, 0, -1, 268, 269, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, 280, -1, 282, + 283, 284, 285, 286, -1, 288, 289, 290, 291, 292, + 293, 294, 295, 296, -1, 298, -1, 300, 301, 302, + 303, 304, -1, 40, 41, -1, -1, 44, -1, -1, + -1, 0, -1, -1, -1, -1, -1, -1, -1, -1, + -1, 58, 59, 60, -1, 62, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, 40, 41, -1, -1, 44, 93, -1, -1, -1, + 0, -1, -1, -1, -1, -1, -1, -1, -1, 58, + 59, 60, -1, 62, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, 123, 124, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + 40, -1, -1, 43, 93, 45, -1, -1, -1, -1, + 0, -1, -1, -1, -1, -1, -1, -1, -1, 59, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, 123, 124, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + 40, -1, -1, 43, -1, 45, -1, -1, 0, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, 59, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, 123, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, 40, -1, + -1, 43, -1, 45, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, 59, -1, -1, + 257, 258, 259, 260, 261, 262, 263, 264, 265, -1, + -1, 268, 269, 123, -1, -1, -1, -1, -1, -1, + -1, -1, 0, 280, -1, 282, 283, 284, 285, 286, + -1, 288, 289, 290, 291, 292, 293, 294, 295, 296, + -1, 298, -1, 300, 301, 302, 303, 304, 257, 258, + 259, 260, 261, 262, 263, 264, 265, -1, -1, 268, + 269, -1, 40, -1, -1, 43, -1, 45, -1, -1, + -1, 280, -1, 282, 283, 284, 285, 286, -1, 288, + 289, 290, 291, 292, 293, 294, 295, 296, -1, 298, + -1, 300, 301, 302, 303, 304, -1, 257, 258, 259, + 260, 261, 262, 263, 264, -1, -1, 40, 268, 269, + 43, -1, 45, -1, -1, -1, -1, -1, -1, -1, + 280, 0, 282, 283, 284, 285, 286, -1, -1, -1, + -1, 291, 292, 293, 294, -1, -1, -1, 298, -1, + 300, 301, 302, 303, 304, 123, -1, 257, 258, 259, + 260, -1, 262, 263, 264, -1, -1, -1, 268, 269, + -1, 40, -1, -1, 43, -1, 45, -1, -1, 0, + 280, -1, 282, 283, 284, 285, 286, -1, -1, -1, + -1, 291, 292, 293, 294, -1, -1, -1, 298, -1, + 300, 301, 302, 303, 304, 257, 258, 259, 260, 261, + 262, 263, 264, -1, -1, -1, 268, 269, -1, 40, + -1, -1, 43, -1, 45, -1, -1, -1, 280, -1, + 282, 283, 284, 285, 286, -1, -1, -1, -1, 291, + 292, 293, 294, -1, -1, -1, 298, -1, 300, 301, + 302, 303, 304, -1, 123, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, 40, 41, -1, 43, 44, 45, + -1, -1, -1, -1, -1, -1, -1, -1, -1, 257, + 258, 259, -1, -1, -1, 263, 264, -1, -1, -1, + 268, 269, 123, -1, -1, -1, -1, -1, -1, -1, + -1, -1, 280, -1, 282, 283, 284, 285, 286, -1, + -1, -1, -1, 291, 292, 293, 294, -1, -1, -1, + 298, -1, 300, 301, 302, 303, 304, -1, -1, -1, + 263, 264, -1, 266, 267, 268, 269, -1, -1, -1, + -1, -1, 275, 276, 277, 278, 279, 280, -1, 282, + 283, 284, -1, 286, 287, -1, -1, -1, 291, 292, + 293, 294, -1, -1, -1, 298, -1, -1, 301, 302, + 303, 304, -1, -1, -1, -1, -1, -1, 257, 258, + 259, -1, -1, -1, 263, 264, -1, -1, -1, 268, + 269, -1, -1, -1, -1, -1, -1, 40, -1, -1, + 43, 280, 45, 282, 283, 284, 285, 286, -1, -1, + -1, -1, 291, 292, 293, 294, 59, -1, -1, 298, + -1, 300, 301, 302, 303, 304, 257, 258, 259, -1, + -1, -1, 263, 264, -1, -1, -1, 268, 269, 0, + -1, -1, -1, -1, -1, -1, -1, -1, -1, 280, + -1, 282, 283, 284, 285, 286, -1, -1, -1, -1, + 291, 292, 293, 294, -1, -1, -1, 298, -1, 300, + 301, 302, 303, 304, -1, -1, 37, -1, -1, 40, + 41, 42, 43, 44, 45, -1, 47, 263, 264, -1, + -1, -1, 268, 269, 0, -1, -1, 58, 59, 60, + -1, 62, 63, -1, 280, -1, 282, 283, 284, -1, + 286, -1, -1, -1, -1, 291, 292, 293, 294, -1, + -1, -1, 298, -1, -1, 301, 302, 303, 304, -1, + -1, 37, 93, 94, 40, 41, 42, 43, 44, 45, + -1, 47, 0, -1, -1, -1, -1, -1, -1, -1, + -1, 112, 58, 59, -1, -1, 62, 63, -1, -1, + -1, -1, 123, 124, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, 37, + -1, -1, -1, 41, 42, -1, 44, 93, 94, 47, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + 58, 59, 60, -1, 62, 63, 112, -1, -1, -1, + -1, -1, -1, -1, -1, -1, 259, 123, 124, -1, + 263, 264, -1, -1, -1, 268, 269, -1, -1, -1, + -1, -1, -1, -1, -1, 93, 94, 280, -1, 282, + 283, 284, -1, 286, -1, -1, -1, -1, 291, 292, + 293, 294, -1, -1, 112, 298, -1, 300, 301, 302, + 303, 304, -1, -1, -1, 123, 124, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, 257, 258, 259, 260, + 261, 262, 263, 264, 265, -1, -1, 268, 269, -1, + -1, -1, -1, 274, -1, -1, -1, -1, -1, 280, + -1, 282, 283, 284, 285, 286, -1, 288, 289, 290, + 291, -1, 293, 294, 295, 296, -1, 298, -1, 300, + 301, 302, -1, -1, -1, -1, -1, -1, -1, -1, + -1, 257, 258, 259, 260, 261, 262, 263, 264, 265, + -1, -1, 268, 269, -1, -1, -1, -1, 274, -1, + -1, -1, -1, -1, 280, -1, 282, 283, 284, 285, + 286, 0, 288, 289, 290, 291, -1, 293, 294, 295, + 296, -1, 298, -1, 300, 301, 302, -1, -1, 257, + 258, 259, 260, 261, 262, -1, -1, 265, -1, -1, + -1, -1, -1, -1, -1, -1, 274, -1, 37, -1, + -1, -1, 41, 42, -1, 44, 0, 285, 47, -1, + 288, 289, 290, 291, 292, 293, 294, 295, 296, 58, + 59, 60, 300, 62, 63, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, 37, -1, -1, -1, 41, 42, -1, + 44, 0, -1, 47, 93, 94, -1, -1, -1, -1, + -1, -1, -1, -1, 58, 59, 60, -1, 62, 63, + -1, -1, -1, 112, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, 123, 124, -1, -1, 37, -1, + -1, -1, 41, 42, -1, 44, -1, -1, 47, 93, + 94, -1, -1, -1, -1, -1, -1, -1, -1, 58, + 59, 60, -1, 62, 63, -1, -1, -1, 112, -1, + 0, -1, -1, -1, -1, -1, -1, -1, -1, 123, + 124, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, 93, 94, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, 37, -1, -1, + -1, 41, 42, 112, 44, -1, -1, 47, -1, -1, + -1, -1, -1, -1, 123, 124, -1, -1, 58, 59, + 60, -1, 62, 63, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, 93, 94, -1, -1, -1, 257, 258, + 259, 260, 261, 262, -1, -1, 265, -1, -1, -1, + -1, -1, 112, -1, -1, 274, -1, -1, -1, -1, + -1, -1, -1, 123, 124, -1, 285, -1, -1, 288, + 289, 290, 291, 292, 293, 294, 295, 296, -1, -1, + -1, 300, -1, 257, 258, 259, 260, 261, 262, -1, + 40, 265, -1, 43, -1, 45, -1, -1, -1, -1, + 274, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, 285, -1, -1, 288, 289, 290, 291, 292, 293, + 294, 295, 296, -1, -1, -1, 300, -1, 257, 258, + 259, 260, 261, 262, -1, -1, 265, -1, -1, -1, + -1, -1, -1, -1, -1, 274, -1, -1, 0, -1, + -1, -1, -1, -1, -1, -1, 285, -1, -1, 288, + 289, 290, 291, 292, 293, 294, 295, 296, -1, -1, + -1, 300, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, 37, -1, -1, -1, 41, + 42, -1, 44, -1, -1, 47, -1, 257, 258, 259, + 260, 261, 262, -1, -1, 265, 58, 59, 60, -1, + 62, 63, -1, -1, 274, 0, -1, -1, -1, -1, + -1, -1, -1, -1, -1, 285, -1, -1, 288, 289, + 290, 291, 292, 293, 294, 295, 296, -1, -1, -1, + 300, 93, 94, -1, -1, -1, -1, -1, -1, -1, + -1, -1, 37, -1, -1, -1, 41, 42, -1, 44, + 112, -1, 47, 0, -1, -1, -1, -1, -1, -1, + -1, 123, 124, 58, 59, 60, -1, 62, 63, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + 37, -1, -1, -1, 41, 42, -1, 44, 93, 94, + 47, 261, 262, 263, 264, -1, -1, -1, 268, 269, + -1, 58, 59, 60, -1, 62, 63, 112, -1, -1, + 280, -1, 282, 283, 284, 0, 286, -1, 123, 124, + -1, 291, 292, 293, 294, -1, -1, -1, 298, -1, + -1, 301, 302, 303, 304, -1, 93, 94, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, 37, -1, -1, 112, 41, 42, -1, 44, + -1, -1, 47, -1, -1, -1, 123, 124, -1, -1, + -1, -1, -1, 58, 59, 60, -1, 62, 63, -1, + -1, -1, -1, -1, -1, 257, 258, 259, 260, 261, + 262, -1, -1, 265, 40, 41, -1, 43, 44, 45, + -1, -1, 274, 0, -1, -1, -1, -1, 93, 94, + -1, -1, -1, 285, -1, -1, 288, 289, 290, 291, + 292, 293, 294, 295, 296, -1, -1, 112, 300, -1, + -1, -1, -1, -1, -1, -1, -1, -1, 123, 124, + 37, -1, -1, -1, 41, 42, -1, -1, -1, -1, + 47, -1, 257, 258, 259, 260, 261, 262, -1, -1, + 265, 58, 59, 60, -1, 62, 63, -1, -1, 274, + -1, -1, -1, 40, 41, -1, 43, 44, 45, -1, + 285, -1, -1, 288, 289, 290, -1, -1, -1, -1, + 295, 296, -1, -1, -1, 300, 93, 94, -1, -1, + 257, 258, 259, 260, 261, 262, -1, -1, 265, -1, + -1, -1, -1, -1, -1, 112, -1, 274, -1, -1, + 0, -1, -1, -1, -1, -1, 123, 124, 285, -1, + -1, 288, 289, 290, -1, -1, -1, -1, 295, 296, + -1, -1, -1, 300, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, 37, -1, -1, + -1, 41, 42, -1, 44, -1, -1, 47, -1, -1, + -1, -1, 257, 258, 259, 260, 261, 262, 58, 59, + 265, -1, -1, 63, -1, -1, -1, -1, -1, 274, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + 285, -1, -1, 288, 289, 290, -1, -1, -1, -1, + 295, 296, -1, 93, 94, 300, -1, 263, 264, -1, + -1, -1, 268, 269, -1, -1, -1, -1, -1, -1, + -1, -1, 112, -1, 280, -1, 282, 283, 284, -1, + 286, -1, -1, 123, 124, 291, 292, 293, 294, -1, + -1, -1, 298, -1, -1, 301, 302, 303, 304, -1, + 257, 258, 259, 260, 261, 262, -1, -1, 265, -1, + -1, -1, -1, -1, -1, -1, -1, 274, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, 285, -1, + -1, 288, 289, 290, -1, -1, 263, 264, 295, 296, + -1, 268, 269, 300, -1, -1, -1, -1, -1, -1, + -1, 7, -1, 280, -1, 282, 283, 284, 14, 286, + -1, -1, -1, -1, 291, 292, 293, 294, -1, -1, + -1, 298, -1, 29, 301, 302, 303, 304, -1, 35, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, 49, 50, 51, -1, -1, -1, 55, + 56, -1, 58, 59, 60, -1, 62, 63, 64, 65, + 66, -1, -1, -1, -1, -1, -1, 257, 258, 259, + 260, 261, 262, -1, -1, 265, -1, -1, 84, 85, + 86, 87, 88, -1, 274, -1, -1, -1, -1, -1, + -1, -1, -1, 99, -1, 285, -1, -1, 288, 289, + 290, 107, -1, -1, -1, -1, -1, -1, 114, -1, + 300, -1, -1, -1, 120, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, 47, 48, 134, 135, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, 157, 158, -1, -1, 161, 162, 163, 164, 165, + 81, 82, 83, -1, 170, 171, -1, 173, 174, -1, + -1, -1, 178, -1, -1, -1, 182, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, 110, + 111, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, 214, 215, + 216, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, 232, -1, 234, -1, + 236, -1, 238, -1, 240, -1, -1, -1, -1, 245, + -1, -1, -1, -1, 250, 251, -1, -1, -1, -1, + -1, 172, 258, -1, -1, -1, -1, -1, -1, -1, + -1, -1, 183, -1, 185, -1, 187, -1, -1, -1, + -1, -1, 278, -1, -1, -1, -1, -1, -1, -1, + -1, 40, -1, -1, 43, -1, 45, 208, -1, 295, + -1, -1, -1, -1, -1, -1, -1, -1, 16, -1, + 59, -1, 223, 224, 225, 226, 227, -1, -1, 27, + 28, -1, 30, 31, -1, 33, -1, -1, -1, -1, + -1, -1, -1, 41, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, 53, -1, -1, -1, -1, + -1, -1, -1, 40, -1, -1, 43, -1, 45, -1, + 271, -1, -1, -1, 275, 276, 277, -1, -1, -1, + 281, -1, 59, -1, 123, -1, -1, -1, -1, -1, + -1, -1, -1, 91, 92, 93, 94, 95, 96, 97, + -1, -1, -1, -1, -1, 306, 307, 105, -1, -1, + 108, 312, -1, -1, 112, 113, -1, -1, 116, -1, + 118, 119, -1, -1, -1, 123, 124, -1, -1, -1, + 40, -1, -1, 43, -1, 45, -1, -1, -1, -1, + 138, 139, 140, 141, -1, -1, 123, -1, 125, 59, + -1, -1, 150, -1, -1, -1, -1, -1, -1, -1, + -1, -1, 160, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, 40, -1, -1, 43, -1, + 45, -1, -1, -1, -1, -1, -1, -1, -1, -1, + 188, -1, -1, -1, 59, -1, -1, 195, -1, -1, + -1, 199, 200, -1, 202, 203, 204, 205, -1, 207, + -1, 209, 210, 123, -1, 125, -1, -1, -1, 217, + 218, 260, 261, 262, 263, 264, -1, 266, 267, 268, + 269, 270, -1, 272, 273, -1, 275, 276, 277, 278, + 279, 280, 281, 282, 283, 284, -1, 286, 287, -1, + -1, -1, 291, 292, 293, 294, 254, -1, 123, 298, + 125, -1, 301, 302, 303, 304, -1, -1, 266, 267, + 268, 269, 270, -1, 272, 273, 274, -1, -1, -1, + -1, -1, 280, 260, -1, -1, 263, 264, -1, 266, + 267, 268, 269, 270, 271, 272, 273, -1, 275, 276, + 277, 278, 279, 280, 281, 282, 283, 284, -1, 286, + 287, -1, -1, -1, 291, 292, 293, 294, -1, -1, + -1, 298, -1, -1, 301, 302, 303, 304, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + 260, -1, -1, 263, 264, -1, 266, 267, 268, 269, + 270, 271, 272, 273, -1, 275, 276, 277, 278, 279, + 280, 281, 282, 283, 284, -1, 286, 287, -1, -1, + -1, 291, 292, 293, 294, -1, -1, -1, 298, -1, + -1, 301, 302, 303, 304, 260, -1, -1, 263, 264, + -1, 266, 267, 268, 269, 270, 271, 272, 273, -1, + 275, 276, 277, 278, 279, 280, 281, 282, 283, 284, + -1, 286, 287, -1, -1, -1, 291, 292, 293, 294, + -1, -1, -1, 298, -1, -1, 301, 302, 303, 304, + 40, -1, -1, 43, -1, 45, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, 59, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, 40, -1, -1, 43, -1, + 45, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, 59, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, 123, -1, 125, -1, -1, -1, -1, + 40, -1, -1, 43, -1, 45, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, 59, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, 123, -1, + 125, -1, -1, -1, -1, -1, 40, -1, -1, 43, + -1, 45, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, 59, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, 123, -1, 125, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + 40, -1, -1, 43, -1, 45, -1, -1, -1, 123, + 260, 125, -1, 263, 264, -1, 266, 267, 268, 269, + 270, 271, 272, 273, -1, 275, 276, 277, 278, 279, + 280, 281, 282, 283, 284, -1, 286, 287, -1, -1, + -1, 291, 292, 293, 294, -1, -1, -1, 298, -1, + -1, 301, 302, 303, 304, 260, -1, -1, 263, 264, + -1, 266, 267, 268, 269, 270, 271, 272, 273, -1, + 275, 276, 277, 278, 279, 280, 281, 282, 283, 284, + -1, 286, 287, 123, -1, -1, 291, 292, 293, 294, + -1, -1, -1, 298, -1, -1, 301, 302, 303, 304, + 260, -1, -1, 263, 264, -1, 266, 267, 268, 269, + 270, 271, 272, 273, -1, 275, 276, 277, 278, 279, + 280, 281, 282, 283, 284, 40, 286, 287, 43, -1, + 45, 291, 292, 293, 294, -1, -1, -1, 298, -1, + -1, 301, 302, 303, 304, -1, 260, -1, -1, 263, + 264, -1, 266, 267, 268, 269, 270, 271, 272, 273, + -1, 275, 276, 277, 278, 279, 280, 281, 282, 283, + 284, -1, 286, 287, -1, -1, -1, 291, 292, 293, + 294, -1, -1, -1, 298, -1, -1, 301, 302, 303, + 304, 40, -1, -1, 43, -1, 45, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + 59, -1, -1, -1, -1, -1, -1, 257, 258, 259, + -1, -1, -1, 263, 264, -1, -1, -1, 268, 269, + -1, -1, -1, -1, -1, -1, 40, -1, -1, 43, + 280, 45, 282, 283, 284, 285, 286, -1, -1, -1, + -1, 291, 292, 293, 294, 59, -1, -1, 298, -1, + 300, 301, 302, 303, 304, -1, -1, -1, -1, -1, + -1, -1, -1, -1, 123, -1, 125, -1, -1, -1, + -1, 40, -1, -1, 43, -1, 45, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + 59, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, 123, + -1, 125, -1, -1, -1, -1, -1, 40, -1, -1, + 43, -1, 45, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, 259, -1, 59, -1, 263, 264, + -1, -1, -1, 268, 269, -1, -1, -1, -1, -1, + -1, -1, -1, -1, 123, 280, 125, 282, 283, 284, + -1, 286, -1, -1, -1, -1, 291, 292, 293, 294, + -1, -1, -1, 298, -1, 300, 301, 302, 303, 304, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, 40, -1, -1, 43, -1, 45, -1, -1, -1, + 123, 260, 125, -1, 263, 264, -1, 266, 267, 268, + 269, 270, 271, 272, 273, -1, 275, 276, 277, 278, + 279, 280, 281, 282, 283, 284, -1, 286, 287, -1, + -1, -1, 291, 292, 293, 294, -1, -1, -1, 298, + -1, -1, 301, 302, 303, 304, 260, -1, -1, 263, + 264, -1, 266, 267, 268, 269, 270, -1, 272, 273, + -1, 275, 276, 277, 278, 279, 280, 281, 282, 283, + 284, -1, 286, 287, -1, -1, -1, 291, 292, 293, + 294, -1, -1, -1, 298, -1, -1, 301, 302, 303, + 304, 260, -1, -1, 263, 264, -1, 266, 267, 268, + 269, 270, -1, 272, 273, -1, 275, 276, 277, 278, + 279, 280, 281, 282, 283, 284, 40, 286, 287, 43, + -1, 45, 291, 292, 293, 294, -1, -1, -1, 298, + -1, -1, 301, 302, 303, 304, -1, 260, -1, -1, + 263, 264, -1, 266, 267, 268, 269, 270, -1, 272, + 273, -1, 275, 276, 277, 278, 279, 280, 281, 282, + 283, 284, -1, 286, 287, -1, -1, -1, 291, 292, + 293, 294, -1, -1, -1, 298, -1, -1, 301, 302, + 303, 304, 40, -1, -1, 43, -1, 45, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, 59, -1, -1, -1, -1, -1, -1, -1, -1, + 259, -1, 261, 262, 263, 264, -1, -1, -1, 268, + 269, -1, -1, -1, -1, -1, -1, 40, -1, -1, + 43, 280, 45, 282, 283, 284, -1, 286, -1, -1, + -1, -1, 291, 292, 293, 294, 59, -1, -1, 298, + -1, 300, 301, 302, 303, 304, -1, -1, -1, -1, + -1, -1, -1, -1, -1, 123, -1, 125, -1, -1, + -1, -1, 40, -1, -1, 43, -1, 45, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, 59, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + 123, -1, 125, -1, -1, -1, -1, -1, 40, -1, + -1, 43, -1, 45, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, 259, -1, 59, -1, 263, + 264, -1, -1, -1, 268, 269, -1, -1, -1, -1, + -1, -1, -1, -1, -1, 123, 280, 125, 282, 283, + 284, -1, 286, -1, -1, -1, -1, 291, 292, 293, + 294, -1, -1, -1, 298, -1, 300, 301, 302, 303, + 304, 40, 41, -1, 43, 44, 45, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, 123, 260, 125, -1, 263, 264, -1, 266, 267, + 268, 269, 270, -1, 272, 273, -1, 275, 276, 277, + 278, 279, 280, 281, 282, 283, 284, -1, 286, 287, + -1, -1, -1, 291, 292, 293, 294, -1, -1, -1, + 298, -1, -1, 301, 302, 303, 304, 260, -1, -1, + 263, 264, -1, 266, 267, 268, 269, 270, -1, 272, + 273, -1, 275, 276, 277, 278, 279, 280, 281, 282, + 283, 284, 40, 286, 287, 43, 44, 45, 291, 292, + 293, 294, -1, -1, -1, 298, -1, -1, 301, 302, + 303, 304, 260, -1, -1, 263, 264, -1, 266, 267, + 268, 269, 270, -1, 272, 273, -1, 275, 276, 277, + 278, 279, 280, 281, 282, 283, 284, -1, 286, 287, + -1, -1, -1, 291, 292, 293, 294, -1, -1, -1, + 298, -1, -1, 301, 302, 303, 304, -1, 260, -1, + -1, 263, 264, -1, 266, 267, 268, 269, 270, -1, + 272, 273, -1, 275, 276, 277, 278, 279, 280, 281, + 282, 283, 284, -1, 286, 287, -1, -1, -1, 291, + 292, 293, 294, -1, -1, -1, 298, -1, -1, 301, + 302, 303, 304, 40, -1, -1, 43, -1, 45, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, 59, -1, 263, 264, -1, -1, -1, 268, + 269, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, 280, -1, 282, 283, 284, -1, 286, -1, -1, + -1, -1, 291, 292, 293, 294, -1, -1, -1, 298, + -1, -1, 301, 302, 303, 304, 40, 41, -1, 43, + 44, 45, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, 123, -1, 125, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, 40, 41, + -1, 43, -1, 45, -1, 263, 264, -1, -1, -1, + 268, 269, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, 280, -1, 282, 283, 284, -1, 286, -1, + -1, -1, -1, 291, 292, 293, 294, -1, -1, -1, + 298, -1, -1, 301, 302, 303, 304, 40, -1, -1, + 43, -1, 45, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, 40, -1, -1, 43, -1, 45, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, 260, -1, -1, 263, 264, -1, 266, + 267, 268, 269, 270, -1, 272, 273, -1, 275, 276, + 277, 278, 279, 280, 281, 282, 283, 284, -1, 286, + 287, -1, -1, -1, 291, 292, 293, 294, -1, -1, + -1, 298, -1, -1, 301, 302, 303, 304, 40, -1, + -1, 43, -1, 45, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, 263, + 264, -1, -1, -1, 268, 269, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, 280, -1, 282, 283, + 284, -1, 286, -1, -1, -1, -1, 291, 292, 293, + 294, -1, -1, -1, 298, -1, -1, 301, 302, 303, + 304, 263, 264, -1, -1, -1, 268, 269, 40, 41, + -1, 43, -1, 45, -1, -1, -1, -1, 280, -1, + 282, 283, 284, -1, 286, -1, -1, -1, -1, 291, + 292, 293, 294, -1, -1, -1, 298, -1, -1, 301, + 302, 303, 304, -1, -1, -1, 259, -1, -1, -1, + 263, 264, -1, -1, 40, 268, 269, 43, 44, 45, + -1, -1, -1, -1, -1, -1, -1, 280, -1, 282, + 283, 284, -1, 286, -1, -1, -1, -1, 291, 292, + 293, 294, -1, -1, -1, 298, -1, -1, 301, 302, + 303, 304, 259, -1, -1, -1, 263, 264, -1, -1, + 40, 268, 269, 43, 44, 45, -1, -1, -1, -1, + -1, -1, -1, 280, -1, 282, 283, 284, -1, 286, + -1, -1, -1, -1, 291, 292, 293, 294, -1, -1, + -1, 298, -1, -1, 301, 302, 303, 304, -1, -1, + -1, -1, 40, -1, -1, 43, 44, 45, -1, -1, + -1, -1, -1, -1, -1, -1, -1, 259, -1, -1, + -1, 263, 264, -1, -1, -1, 268, 269, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, 280, -1, + 282, 283, 284, -1, 286, -1, -1, -1, -1, 291, + 292, 293, 294, -1, -1, -1, 298, -1, -1, 301, + 302, 303, 304, 40, -1, -1, 43, 44, 45, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, 263, 264, -1, -1, -1, 268, 269, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, 280, -1, + 282, 283, 284, 40, 286, -1, 43, 44, 45, 291, + 292, 293, 294, -1, -1, -1, 298, -1, -1, 301, + 302, 303, 304, -1, -1, -1, -1, 263, 264, -1, + -1, -1, 268, 269, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, 280, -1, 282, 283, 284, 40, + 286, -1, 43, 44, 45, 291, 292, 293, 294, -1, + -1, -1, 298, -1, -1, 301, 302, 303, 304, -1, + -1, -1, -1, 263, 264, -1, -1, -1, 268, 269, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + 280, -1, 282, 283, 284, 40, 286, -1, 43, -1, + 45, 291, 292, 293, 294, -1, -1, -1, 298, -1, + -1, 301, 302, 303, 304, 263, 264, -1, -1, -1, + 268, 269, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, 280, -1, 282, 283, 284, -1, 286, -1, + -1, -1, -1, 291, 292, 293, 294, -1, -1, -1, + 298, -1, -1, 301, 302, 303, 304, 40, 41, -1, + 43, -1, 45, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, 263, 264, -1, -1, + -1, 268, 269, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, 280, -1, 282, 283, 284, -1, 286, + -1, -1, -1, -1, 291, 292, 293, 294, -1, -1, + -1, 298, -1, -1, 301, 302, 303, 304, 40, 41, + -1, 43, -1, 45, -1, -1, 263, 264, -1, -1, + -1, 268, 269, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, 280, -1, 282, 283, 284, -1, 286, + -1, -1, -1, -1, 291, 292, 293, 294, -1, -1, + -1, 298, -1, -1, 301, 302, 303, 304, -1, -1, + -1, 40, 263, 264, 43, -1, 45, 268, 269, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, 280, + -1, 282, 283, 284, -1, 286, -1, -1, -1, -1, + 291, 292, 293, 294, -1, -1, -1, 298, -1, -1, + 301, 302, 303, 304, 259, -1, -1, -1, 263, 264, + -1, -1, -1, 268, 269, 40, 41, -1, 43, -1, + 45, -1, -1, -1, -1, 280, -1, 282, 283, 284, + -1, 286, -1, -1, -1, -1, 291, 292, 293, 294, + -1, -1, -1, 298, -1, -1, 301, 302, 303, 304, + -1, -1, -1, -1, -1, -1, -1, 40, 41, -1, + 43, -1, 45, -1, -1, -1, -1, -1, -1, -1, + 263, 264, -1, -1, -1, 268, 269, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, 280, -1, 282, + 283, 284, -1, 286, -1, -1, -1, -1, 291, 292, + 293, 294, -1, -1, -1, 298, -1, -1, 301, 302, + 303, 304, 40, 41, -1, 43, -1, 45, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, 263, 264, -1, -1, -1, 268, 269, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, 280, -1, + 282, 283, 284, -1, 286, -1, -1, -1, -1, 291, + 292, 293, 294, -1, -1, -1, 298, -1, -1, 301, + 302, 303, 304, 40, 41, -1, 43, -1, 45, -1, + 259, -1, -1, -1, 263, 264, -1, -1, -1, 268, + 269, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, 280, -1, 282, 283, 284, -1, 286, -1, -1, + -1, -1, 291, 292, 293, 294, -1, -1, -1, 298, + -1, -1, 301, 302, 303, 304, 40, 41, -1, 43, + -1, 45, -1, -1, -1, -1, -1, -1, 263, 264, + -1, -1, -1, 268, 269, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, 280, -1, 282, 283, 284, + -1, 286, -1, -1, -1, -1, 291, 292, 293, 294, + -1, -1, -1, 298, -1, -1, 301, 302, 303, 304, + 263, 264, -1, -1, -1, 268, 269, 40, 41, -1, + 43, -1, 45, -1, -1, -1, -1, 280, -1, 282, + 283, 284, -1, 286, -1, -1, -1, -1, 291, 292, + 293, 294, -1, -1, -1, 298, -1, -1, 301, 302, + 303, 304, -1, -1, -1, -1, -1, -1, -1, 40, + 41, -1, 43, -1, 45, 263, 264, -1, -1, -1, + 268, 269, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, 280, -1, 282, 283, 284, -1, 286, -1, + -1, -1, -1, 291, 292, 293, 294, -1, -1, -1, + 298, -1, -1, 301, 302, 303, 304, 40, -1, -1, + 43, -1, 45, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, 263, 264, -1, -1, + -1, 268, 269, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, 280, -1, 282, 283, 284, -1, 286, + -1, -1, -1, -1, 291, 292, 293, 294, -1, -1, + 93, 298, -1, -1, 301, 302, 303, 304, 40, -1, + -1, 43, -1, 45, -1, -1, -1, -1, -1, 263, + 264, -1, -1, -1, 268, 269, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, 280, -1, 282, 283, + 284, -1, 286, -1, -1, -1, -1, 291, 292, 293, + 294, -1, -1, -1, 298, -1, -1, 301, 302, 303, + 304, 40, -1, -1, 43, -1, 45, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + 263, 264, -1, -1, -1, 268, 269, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, 280, -1, 282, + 283, 284, -1, 286, -1, -1, -1, -1, 291, 292, + 293, 294, -1, -1, -1, 298, -1, -1, 301, 302, + 303, 304, 263, 264, -1, -1, -1, 268, 269, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, 280, + -1, 282, 283, 284, -1, 286, -1, -1, -1, -1, + 291, 292, 293, 294, -1, -1, -1, 298, -1, -1, + 301, 302, 303, 304, -1, -1, -1, -1, -1, -1, + 263, 264, -1, -1, -1, 268, 269, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, 280, -1, 282, + 283, 284, -1, 286, -1, -1, -1, -1, 291, 292, + 293, 294, -1, -1, -1, 298, -1, -1, 301, 302, + 303, 304, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, 263, 264, -1, -1, -1, 268, 269, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, 280, -1, + 282, 283, 284, -1, 286, -1, -1, -1, -1, 291, + 292, 293, 294, -1, -1, -1, 298, 27, 28, 301, + 302, 303, 304, 33, -1, -1, -1, -1, -1, -1, + -1, 41, -1, -1, 263, 264, -1, -1, -1, 268, + 269, -1, -1, 53, -1, -1, -1, -1, -1, -1, + -1, 280, -1, 282, 283, 284, -1, 286, -1, -1, + -1, -1, 291, 292, 293, 294, -1, -1, -1, 298, + -1, -1, 301, 302, 303, 304, -1, -1, -1, -1, + -1, 91, 92, 93, 94, 95, 96, 97, -1, -1, + -1, -1, -1, -1, -1, 105, -1, -1, 108, -1, + -1, -1, 112, 113, -1, -1, 116, -1, 118, 119, + -1, -1, -1, 123, 124, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, 138, 139, + 140, 141, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + 160, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, 188, -1, + -1, -1, -1, -1, -1, 195, -1, -1, -1, 199, + 200, -1, 202, 203, 204, 205, -1, 207, -1, 209, + 210, -1, -1, -1, -1, -1, -1, 217, 218, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, 254, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, 266, 267, 268, 269, + 270, -1, 272, 273, 274, -1, -1, -1, -1, -1, + 280, +}; +#define YYFINAL 1 +#ifndef YYDEBUG +#define YYDEBUG 0 +#endif +#define YYMAXTOKEN 304 +#if YYDEBUG +char *yyname[] = { +"end-of-file",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,"'%'",0,0,"'('","')'","'*'","'+'","','","'-'",0,"'/'",0,0,0,0,0,0,0,0,0,0, +"':'","';'","'<'",0,"'>'","'?'",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,"'['",0,"']'","'^'",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,"'p'",0,0,0,0,0,0,0, +0,0,0,"'{'","'|'","'}'",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,"BEGIN","END","REGEX","SEMINEW", +"NEWLINE","COMMENT","FUN1","FUNN","GRGR","PRINT","PRINTF","SPRINTF","SPLIT", +"IF","ELSE","WHILE","FOR","IN","EXIT","NEXT","BREAK","CONTINUE","RET","GETLINE", +"DO","SUB","GSUB","MATCH","FUNCTION","USERFUN","DELETE","ASGNOP","OROR", +"ANDAND","NUMBER","VAR","SUBSTR","INDEX","MATCHOP","RELOP","OR","STRING", +"UMINUS","NOT","INCR","DECR","FIELD","VFIELD", +}; +char *yyrule[] = { +"$accept : program", +"program : junk hunks", +"begin : BEGIN '{' maybe states '}' junk", +"end : END '{' maybe states '}'", +"end : end NEWLINE", +"hunks : hunks hunk junk", +"hunks :", +"hunk : patpat", +"hunk : patpat '{' maybe states '}'", +"hunk : FUNCTION USERFUN '(' arg_list ')' maybe '{' maybe states '}'", +"hunk : '{' maybe states '}'", +"hunk : begin", +"hunk : end", +"arg_list : expr_list", +"patpat : cond", +"patpat : cond ',' cond", +"cond : expr", +"cond : match", +"cond : rel", +"cond : compound_cond", +"compound_cond : '(' compound_cond ')'", +"compound_cond : cond ANDAND maybe cond", +"compound_cond : cond OROR maybe cond", +"compound_cond : NOT cond", +"rel : expr RELOP expr", +"rel : expr '>' expr", +"rel : expr '<' expr", +"rel : '(' rel ')'", +"match : expr MATCHOP expr", +"match : expr MATCHOP REGEX", +"match : REGEX", +"match : '(' match ')'", +"expr : term", +"expr : expr term", +"expr : variable ASGNOP cond", +"term : variable", +"term : NUMBER", +"term : STRING", +"term : term '+' term", +"term : term '-' term", +"term : term '*' term", +"term : term '/' term", +"term : term '%' term", +"term : term '^' term", +"term : term IN VAR", +"term : term '?' term ':' term", +"term : variable INCR", +"term : variable DECR", +"term : INCR variable", +"term : DECR variable", +"term : '-' term", +"term : '+' term", +"term : '(' cond ')'", +"term : GETLINE", +"term : GETLINE variable", +"term : GETLINE '<' expr", +"term : GETLINE variable '<' expr", +"term : term 'p' GETLINE", +"term : term 'p' GETLINE variable", +"term : FUN1", +"term : FUN1 '(' ')'", +"term : FUN1 '(' expr ')'", +"term : FUNN '(' expr_list ')'", +"term : USERFUN '(' expr_list ')'", +"term : SPRINTF expr_list", +"term : SUBSTR '(' expr ',' expr ',' expr ')'", +"term : SUBSTR '(' expr ',' expr ')'", +"term : SPLIT '(' expr ',' VAR ',' expr ')'", +"term : SPLIT '(' expr ',' VAR ',' REGEX ')'", +"term : SPLIT '(' expr ',' VAR ')'", +"term : INDEX '(' expr ',' expr ')'", +"term : MATCH '(' expr ',' REGEX ')'", +"term : MATCH '(' expr ',' expr ')'", +"term : SUB '(' expr ',' expr ')'", +"term : SUB '(' REGEX ',' expr ')'", +"term : GSUB '(' expr ',' expr ')'", +"term : GSUB '(' REGEX ',' expr ')'", +"term : SUB '(' expr ',' expr ',' expr ')'", +"term : SUB '(' REGEX ',' expr ',' expr ')'", +"term : GSUB '(' expr ',' expr ',' expr ')'", +"term : GSUB '(' REGEX ',' expr ',' expr ')'", +"variable : VAR", +"variable : VAR '[' expr_list ']'", +"variable : FIELD", +"variable : VFIELD term", +"expr_list : expr", +"expr_list : clist", +"expr_list :", +"clist : expr ',' maybe expr", +"clist : clist ',' maybe expr", +"clist : '(' clist ')'", +"junk : junk hunksep", +"junk :", +"hunksep : ';'", +"hunksep : SEMINEW", +"hunksep : NEWLINE", +"hunksep : COMMENT", +"maybe : maybe nlstuff", +"maybe :", +"nlstuff : NEWLINE", +"nlstuff : COMMENT", +"separator : ';' maybe", +"separator : SEMINEW maybe", +"separator : NEWLINE maybe", +"separator : COMMENT maybe", +"states : states statement", +"states :", +"statement : simple separator maybe", +"statement : ';' maybe", +"statement : SEMINEW maybe", +"statement : compound", +"simpnull : simple", +"simpnull :", +"simple : expr", +"simple : PRINT expr_list redir expr", +"simple : PRINT expr_list", +"simple : PRINTF expr_list redir expr", +"simple : PRINTF expr_list", +"simple : BREAK", +"simple : NEXT", +"simple : EXIT", +"simple : EXIT expr", +"simple : CONTINUE", +"simple : RET", +"simple : RET expr", +"simple : DELETE VAR '[' expr ']'", +"redir : '>'", +"redir : GRGR", +"redir : '|'", +"compound : IF '(' cond ')' maybe statement", +"compound : IF '(' cond ')' maybe statement ELSE maybe statement", +"compound : WHILE '(' cond ')' maybe statement", +"compound : DO maybe statement WHILE '(' cond ')'", +"compound : FOR '(' simpnull ';' cond ';' simpnull ')' maybe statement", +"compound : FOR '(' simpnull ';' ';' simpnull ')' maybe statement", +"compound : FOR '(' expr ')' maybe statement", +"compound : '{' maybe states '}' maybe", +}; +#endif +#ifndef YYSTYPE +typedef int YYSTYPE; +#endif +#ifdef YYSTACKSIZE +#undef YYMAXDEPTH +#define YYMAXDEPTH YYSTACKSIZE +#else +#ifdef YYMAXDEPTH +#define YYSTACKSIZE YYMAXDEPTH +#else +#define YYSTACKSIZE 500 +#define YYMAXDEPTH 500 +#endif +#endif +int yydebug; +int yynerrs; +int yyerrflag; +int yychar; +short *yyssp; +YYSTYPE *yyvsp; +YYSTYPE yyval; +YYSTYPE yylval; +short yyss[YYSTACKSIZE]; +YYSTYPE yyvs[YYSTACKSIZE]; +#define yystacksize YYSTACKSIZE +#line 406 "a2p.y" +#include "a2py.c" +#line 1997 "y.tab.c" +#define YYABORT goto yyabort +#define YYREJECT goto yyabort +#define YYACCEPT goto yyaccept +#define YYERROR goto yyerrlab +int +yyparse() +{ + register int yym, yyn, yystate; +#if YYDEBUG + register char *yys; + extern char *getenv(); + + if (yys = getenv("YYDEBUG")) + { + yyn = *yys; + if (yyn >= '0' && yyn <= '9') + yydebug = yyn - '0'; + } +#endif + + yynerrs = 0; + yyerrflag = 0; + yychar = (-1); + + yyssp = yyss; + yyvsp = yyvs; + *yyssp = yystate = 0; + +yyloop: + if (yyn = yydefred[yystate]) goto yyreduce; + if (yychar < 0) + { + if ((yychar = yylex()) < 0) yychar = 0; +#if YYDEBUG + if (yydebug) + { + yys = 0; + if (yychar <= YYMAXTOKEN) yys = yyname[yychar]; + if (!yys) yys = "illegal-symbol"; + printf("%sdebug: state %d, reading %d (%s)\n", + YYPREFIX, yystate, yychar, yys); + } +#endif + } + if ((yyn = yysindex[yystate]) && (yyn += yychar) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == yychar) + { +#if YYDEBUG + if (yydebug) + printf("%sdebug: state %d, shifting to state %d\n", + YYPREFIX, yystate, yytable[yyn]); +#endif + if (yyssp >= yyss + yystacksize - 1) + { + goto yyoverflow; + } + *++yyssp = yystate = yytable[yyn]; + *++yyvsp = yylval; + yychar = (-1); + if (yyerrflag > 0) --yyerrflag; + goto yyloop; + } + if ((yyn = yyrindex[yystate]) && (yyn += yychar) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == yychar) + { + yyn = yytable[yyn]; + goto yyreduce; + } + if (yyerrflag) goto yyinrecovery; +#ifdef lint + goto yynewerror; +#endif +yynewerror: + yyerror("syntax error"); +#ifdef lint + goto yyerrlab; +#endif +yyerrlab: + ++yynerrs; +yyinrecovery: + if (yyerrflag < 3) + { + yyerrflag = 3; + for (;;) + { + if ((yyn = yysindex[*yyssp]) && (yyn += YYERRCODE) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == YYERRCODE) + { +#if YYDEBUG + if (yydebug) + printf("%sdebug: state %d, error recovery shifting\ + to state %d\n", YYPREFIX, *yyssp, yytable[yyn]); +#endif + if (yyssp >= yyss + yystacksize - 1) + { + goto yyoverflow; + } + *++yyssp = yystate = yytable[yyn]; + *++yyvsp = yylval; + goto yyloop; + } + else + { +#if YYDEBUG + if (yydebug) + printf("%sdebug: error recovery discarding state %d\n", + YYPREFIX, *yyssp); +#endif + if (yyssp <= yyss) goto yyabort; + --yyssp; + --yyvsp; + } + } + } + else + { + if (yychar == 0) goto yyabort; +#if YYDEBUG + if (yydebug) + { + yys = 0; + if (yychar <= YYMAXTOKEN) yys = yyname[yychar]; + if (!yys) yys = "illegal-symbol"; + printf("%sdebug: state %d, error recovery discards token %d (%s)\n", + YYPREFIX, yystate, yychar, yys); + } +#endif + yychar = (-1); + goto yyloop; + } +yyreduce: +#if YYDEBUG + if (yydebug) + printf("%sdebug: state %d, reducing by rule %d (%s)\n", + YYPREFIX, yystate, yyn, yyrule[yyn]); +#endif + yym = yylen[yyn]; + yyval = yyvsp[1-yym]; + switch (yyn) + { +case 1: +#line 63 "a2p.y" +{ root = oper4(OPROG,yyvsp[-1],begins,yyvsp[0],ends); } +break; +case 2: +#line 67 "a2p.y" +{ begins = oper4(OJUNK,begins,yyvsp[-3],yyvsp[-2],yyvsp[0]); in_begin = FALSE; + yyval = Nullop; } +break; +case 3: +#line 72 "a2p.y" +{ ends = oper3(OJUNK,ends,yyvsp[-2],yyvsp[-1]); yyval = Nullop; } +break; +case 4: +#line 74 "a2p.y" +{ yyval = yyvsp[-1]; } +break; +case 5: +#line 78 "a2p.y" +{ yyval = oper3(OHUNKS,yyvsp[-2],yyvsp[-1],yyvsp[0]); } +break; +case 6: +#line 80 "a2p.y" +{ yyval = Nullop; } +break; +case 7: +#line 84 "a2p.y" +{ yyval = oper1(OHUNK,yyvsp[0]); need_entire = TRUE; } +break; +case 8: +#line 86 "a2p.y" +{ yyval = oper2(OHUNK,yyvsp[-4],oper2(OJUNK,yyvsp[-2],yyvsp[-1])); } +break; +case 9: +#line 88 "a2p.y" +{ fixfargs(yyvsp[-8],yyvsp[-6],0); yyval = oper5(OUSERDEF,yyvsp[-8],yyvsp[-6],yyvsp[-4],yyvsp[-2],yyvsp[-1]); } +break; +case 10: +#line 90 "a2p.y" +{ yyval = oper2(OHUNK,Nullop,oper2(OJUNK,yyvsp[-2],yyvsp[-1])); } +break; +case 13: +#line 96 "a2p.y" +{ yyval = rememberargs(yyval); } +break; +case 14: +#line 100 "a2p.y" +{ yyval = oper1(OPAT,yyvsp[0]); } +break; +case 15: +#line 102 "a2p.y" +{ yyval = oper2(ORANGE,yyvsp[-2],yyvsp[0]); } +break; +case 20: +#line 113 "a2p.y" +{ yyval = oper1(OCPAREN,yyvsp[-1]); } +break; +case 21: +#line 115 "a2p.y" +{ yyval = oper3(OCANDAND,yyvsp[-3],yyvsp[-1],yyvsp[0]); } +break; +case 22: +#line 117 "a2p.y" +{ yyval = oper3(OCOROR,yyvsp[-3],yyvsp[-1],yyvsp[0]); } +break; +case 23: +#line 119 "a2p.y" +{ yyval = oper1(OCNOT,yyvsp[0]); } +break; +case 24: +#line 123 "a2p.y" +{ yyval = oper3(ORELOP,yyvsp[-1],yyvsp[-2],yyvsp[0]); } +break; +case 25: +#line 125 "a2p.y" +{ yyval = oper3(ORELOP,string(">",1),yyvsp[-2],yyvsp[0]); } +break; +case 26: +#line 127 "a2p.y" +{ yyval = oper3(ORELOP,string("<",1),yyvsp[-2],yyvsp[0]); } +break; +case 27: +#line 129 "a2p.y" +{ yyval = oper1(ORPAREN,yyvsp[-1]); } +break; +case 28: +#line 133 "a2p.y" +{ yyval = oper3(OMATCHOP,yyvsp[-1],yyvsp[-2],yyvsp[0]); } +break; +case 29: +#line 135 "a2p.y" +{ yyval = oper3(OMATCHOP,yyvsp[-1],yyvsp[-2],oper1(OREGEX,yyvsp[0])); } +break; +case 30: +#line 137 "a2p.y" +{ yyval = oper1(OREGEX,yyvsp[0]); } +break; +case 31: +#line 139 "a2p.y" +{ yyval = oper1(OMPAREN,yyvsp[-1]); } +break; +case 32: +#line 143 "a2p.y" +{ yyval = yyvsp[0]; } +break; +case 33: +#line 145 "a2p.y" +{ yyval = oper2(OCONCAT,yyvsp[-1],yyvsp[0]); } +break; +case 34: +#line 147 "a2p.y" +{ yyval = oper3(OASSIGN,yyvsp[-1],yyvsp[-2],yyvsp[0]); + if ((ops[yyvsp[-2]].ival & 255) == OFLD) + lval_field = TRUE; + if ((ops[yyvsp[-2]].ival & 255) == OVFLD) + lval_field = TRUE; + } +break; +case 35: +#line 156 "a2p.y" +{ yyval = yyvsp[0]; } +break; +case 36: +#line 158 "a2p.y" +{ yyval = oper1(ONUM,yyvsp[0]); } +break; +case 37: +#line 160 "a2p.y" +{ yyval = oper1(OSTR,yyvsp[0]); } +break; +case 38: +#line 162 "a2p.y" +{ yyval = oper2(OADD,yyvsp[-2],yyvsp[0]); } +break; +case 39: +#line 164 "a2p.y" +{ yyval = oper2(OSUBTRACT,yyvsp[-2],yyvsp[0]); } +break; +case 40: +#line 166 "a2p.y" +{ yyval = oper2(OMULT,yyvsp[-2],yyvsp[0]); } +break; +case 41: +#line 168 "a2p.y" +{ yyval = oper2(ODIV,yyvsp[-2],yyvsp[0]); } +break; +case 42: +#line 170 "a2p.y" +{ yyval = oper2(OMOD,yyvsp[-2],yyvsp[0]); } +break; +case 43: +#line 172 "a2p.y" +{ yyval = oper2(OPOW,yyvsp[-2],yyvsp[0]); } +break; +case 44: +#line 174 "a2p.y" +{ yyval = oper2(ODEFINED,aryrefarg(yyvsp[0]),yyvsp[-2]); } +break; +case 45: +#line 176 "a2p.y" +{ yyval = oper3(OCOND,yyvsp[-4],yyvsp[-2],yyvsp[0]); } +break; +case 46: +#line 178 "a2p.y" +{ yyval = oper1(OPOSTINCR,yyvsp[-1]); } +break; +case 47: +#line 180 "a2p.y" +{ yyval = oper1(OPOSTDECR,yyvsp[-1]); } +break; +case 48: +#line 182 "a2p.y" +{ yyval = oper1(OPREINCR,yyvsp[0]); } +break; +case 49: +#line 184 "a2p.y" +{ yyval = oper1(OPREDECR,yyvsp[0]); } +break; +case 50: +#line 186 "a2p.y" +{ yyval = oper1(OUMINUS,yyvsp[0]); } +break; +case 51: +#line 188 "a2p.y" +{ yyval = oper1(OUPLUS,yyvsp[0]); } +break; +case 52: +#line 190 "a2p.y" +{ yyval = oper1(OPAREN,yyvsp[-1]); } +break; +case 53: +#line 192 "a2p.y" +{ yyval = oper0(OGETLINE); } +break; +case 54: +#line 194 "a2p.y" +{ yyval = oper1(OGETLINE,yyvsp[0]); } +break; +case 55: +#line 196 "a2p.y" +{ yyval = oper3(OGETLINE,Nullop,string("<",1),yyvsp[0]); + if (ops[yyvsp[0]].ival != OSTR + (1<<8)) do_fancy_opens = TRUE; } +break; +case 56: +#line 199 "a2p.y" +{ yyval = oper3(OGETLINE,yyvsp[-2],string("<",1),yyvsp[0]); + if (ops[yyvsp[0]].ival != OSTR + (1<<8)) do_fancy_opens = TRUE; } +break; +case 57: +#line 202 "a2p.y" +{ yyval = oper3(OGETLINE,Nullop,string("|",1),yyvsp[-2]); + if (ops[yyvsp[-2]].ival != OSTR + (1<<8)) do_fancy_opens = TRUE; } +break; +case 58: +#line 205 "a2p.y" +{ yyval = oper3(OGETLINE,yyvsp[0],string("|",1),yyvsp[-3]); + if (ops[yyvsp[-3]].ival != OSTR + (1<<8)) do_fancy_opens = TRUE; } +break; +case 59: +#line 208 "a2p.y" +{ yyval = oper0(yyvsp[0]); need_entire = do_chop = TRUE; } +break; +case 60: +#line 210 "a2p.y" +{ yyval = oper1(yyvsp[-2],Nullop); need_entire = do_chop = TRUE; } +break; +case 61: +#line 212 "a2p.y" +{ yyval = oper1(yyvsp[-3],yyvsp[-1]); } +break; +case 62: +#line 214 "a2p.y" +{ yyval = oper1(yyvsp[-3],yyvsp[-1]); } +break; +case 63: +#line 216 "a2p.y" +{ yyval = oper2(OUSERFUN,yyvsp[-3],yyvsp[-1]); } +break; +case 64: +#line 218 "a2p.y" +{ yyval = oper1(OSPRINTF,yyvsp[0]); } +break; +case 65: +#line 220 "a2p.y" +{ yyval = oper3(OSUBSTR,yyvsp[-5],yyvsp[-3],yyvsp[-1]); } +break; +case 66: +#line 222 "a2p.y" +{ yyval = oper2(OSUBSTR,yyvsp[-3],yyvsp[-1]); } +break; +case 67: +#line 224 "a2p.y" +{ yyval = oper3(OSPLIT,yyvsp[-5],aryrefarg(numary(yyvsp[-3])),yyvsp[-1]); } +break; +case 68: +#line 226 "a2p.y" +{ yyval = oper3(OSPLIT,yyvsp[-5],aryrefarg(numary(yyvsp[-3])),oper1(OREGEX,yyvsp[-1]));} +break; +case 69: +#line 228 "a2p.y" +{ yyval = oper2(OSPLIT,yyvsp[-3],aryrefarg(numary(yyvsp[-1]))); } +break; +case 70: +#line 230 "a2p.y" +{ yyval = oper2(OINDEX,yyvsp[-3],yyvsp[-1]); } +break; +case 71: +#line 232 "a2p.y" +{ yyval = oper2(OMATCH,yyvsp[-3],oper1(OREGEX,yyvsp[-1])); } +break; +case 72: +#line 234 "a2p.y" +{ yyval = oper2(OMATCH,yyvsp[-3],yyvsp[-1]); } +break; +case 73: +#line 236 "a2p.y" +{ yyval = oper2(OSUB,yyvsp[-3],yyvsp[-1]); } +break; +case 74: +#line 238 "a2p.y" +{ yyval = oper2(OSUB,oper1(OREGEX,yyvsp[-3]),yyvsp[-1]); } +break; +case 75: +#line 240 "a2p.y" +{ yyval = oper2(OGSUB,yyvsp[-3],yyvsp[-1]); } +break; +case 76: +#line 242 "a2p.y" +{ yyval = oper2(OGSUB,oper1(OREGEX,yyvsp[-3]),yyvsp[-1]); } +break; +case 77: +#line 244 "a2p.y" +{ yyval = oper3(OSUB,yyvsp[-5],yyvsp[-3],yyvsp[-1]); } +break; +case 78: +#line 246 "a2p.y" +{ yyval = oper3(OSUB,oper1(OREGEX,yyvsp[-5]),yyvsp[-3],yyvsp[-1]); } +break; +case 79: +#line 248 "a2p.y" +{ yyval = oper3(OGSUB,yyvsp[-5],yyvsp[-3],yyvsp[-1]); } +break; +case 80: +#line 250 "a2p.y" +{ yyval = oper3(OGSUB,oper1(OREGEX,yyvsp[-5]),yyvsp[-3],yyvsp[-1]); } +break; +case 81: +#line 254 "a2p.y" +{ yyval = oper1(OVAR,yyvsp[0]); } +break; +case 82: +#line 256 "a2p.y" +{ yyval = oper2(OVAR,aryrefarg(yyvsp[-3]),yyvsp[-1]); } +break; +case 83: +#line 258 "a2p.y" +{ yyval = oper1(OFLD,yyvsp[0]); } +break; +case 84: +#line 260 "a2p.y" +{ yyval = oper1(OVFLD,yyvsp[0]); } +break; +case 87: +#line 267 "a2p.y" +{ yyval = Nullop; } +break; +case 88: +#line 271 "a2p.y" +{ yyval = oper3(OCOMMA,yyvsp[-3],yyvsp[-1],yyvsp[0]); } +break; +case 89: +#line 273 "a2p.y" +{ yyval = oper3(OCOMMA,yyvsp[-3],yyvsp[-1],yyvsp[0]); } +break; +case 90: +#line 275 "a2p.y" +{ yyval = yyvsp[-1]; } +break; +case 91: +#line 279 "a2p.y" +{ yyval = oper2(OJUNK,yyvsp[-1],yyvsp[0]); } +break; +case 92: +#line 281 "a2p.y" +{ yyval = Nullop; } +break; +case 93: +#line 285 "a2p.y" +{ yyval = oper2(OJUNK,oper0(OSEMICOLON),oper0(ONEWLINE)); } +break; +case 94: +#line 287 "a2p.y" +{ yyval = oper2(OJUNK,oper0(OSEMICOLON),oper0(ONEWLINE)); } +break; +case 95: +#line 289 "a2p.y" +{ yyval = oper0(ONEWLINE); } +break; +case 96: +#line 291 "a2p.y" +{ yyval = oper1(OCOMMENT,yyvsp[0]); } +break; +case 97: +#line 295 "a2p.y" +{ yyval = oper2(OJUNK,yyvsp[-1],yyvsp[0]); } +break; +case 98: +#line 297 "a2p.y" +{ yyval = Nullop; } +break; +case 99: +#line 301 "a2p.y" +{ yyval = oper0(ONEWLINE); } +break; +case 100: +#line 303 "a2p.y" +{ yyval = oper1(OCOMMENT,yyvsp[0]); } +break; +case 101: +#line 308 "a2p.y" +{ yyval = oper2(OJUNK,oper0(OSEMICOLON),yyvsp[0]); } +break; +case 102: +#line 310 "a2p.y" +{ yyval = oper2(OJUNK,oper0(OSNEWLINE),yyvsp[0]); } +break; +case 103: +#line 312 "a2p.y" +{ yyval = oper2(OJUNK,oper0(OSNEWLINE),yyvsp[0]); } +break; +case 104: +#line 314 "a2p.y" +{ yyval = oper2(OJUNK,oper1(OSCOMMENT,yyvsp[-1]),yyvsp[0]); } +break; +case 105: +#line 318 "a2p.y" +{ yyval = oper2(OSTATES,yyvsp[-1],yyvsp[0]); } +break; +case 106: +#line 320 "a2p.y" +{ yyval = Nullop; } +break; +case 107: +#line 325 "a2p.y" +{ yyval = oper2(OJUNK,oper2(OSTATE,yyvsp[-2],yyvsp[-1]),yyvsp[0]); } +break; +case 108: +#line 327 "a2p.y" +{ yyval = oper2(OSTATE,Nullop,oper2(OJUNK,oper0(OSEMICOLON),yyvsp[0])); } +break; +case 109: +#line 329 "a2p.y" +{ yyval = oper2(OSTATE,Nullop,oper2(OJUNK,oper0(OSNEWLINE),yyvsp[0])); } +break; +case 112: +#line 335 "a2p.y" +{ yyval = Nullop; } +break; +case 114: +#line 341 "a2p.y" +{ yyval = oper3(OPRINT,yyvsp[-2],yyvsp[-1],yyvsp[0]); + do_opens = TRUE; + saw_ORS = saw_OFS = TRUE; + if (!yyvsp[-2]) need_entire = TRUE; + if (ops[yyvsp[0]].ival != OSTR + (1<<8)) do_fancy_opens = TRUE; } +break; +case 115: +#line 347 "a2p.y" +{ yyval = oper1(OPRINT,yyvsp[0]); + if (!yyvsp[0]) need_entire = TRUE; + saw_ORS = saw_OFS = TRUE; + } +break; +case 116: +#line 352 "a2p.y" +{ yyval = oper3(OPRINTF,yyvsp[-2],yyvsp[-1],yyvsp[0]); + do_opens = TRUE; + if (!yyvsp[-2]) need_entire = TRUE; + if (ops[yyvsp[0]].ival != OSTR + (1<<8)) do_fancy_opens = TRUE; } +break; +case 117: +#line 357 "a2p.y" +{ yyval = oper1(OPRINTF,yyvsp[0]); + if (!yyvsp[0]) need_entire = TRUE; + } +break; +case 118: +#line 361 "a2p.y" +{ yyval = oper0(OBREAK); } +break; +case 119: +#line 363 "a2p.y" +{ yyval = oper0(ONEXT); } +break; +case 120: +#line 365 "a2p.y" +{ yyval = oper0(OEXIT); } +break; +case 121: +#line 367 "a2p.y" +{ yyval = oper1(OEXIT,yyvsp[0]); } +break; +case 122: +#line 369 "a2p.y" +{ yyval = oper0(OCONTINUE); } +break; +case 123: +#line 371 "a2p.y" +{ yyval = oper0(ORETURN); } +break; +case 124: +#line 373 "a2p.y" +{ yyval = oper1(ORETURN,yyvsp[0]); } +break; +case 125: +#line 375 "a2p.y" +{ yyval = oper2(ODELETE,aryrefarg(yyvsp[-3]),yyvsp[-1]); } +break; +case 126: +#line 379 "a2p.y" +{ yyval = oper1(OREDIR,string(">",1)); } +break; +case 127: +#line 381 "a2p.y" +{ yyval = oper1(OREDIR,string(">>",2)); } +break; +case 128: +#line 383 "a2p.y" +{ yyval = oper1(OREDIR,string("|",1)); } +break; +case 129: +#line 388 "a2p.y" +{ yyval = oper2(OIF,yyvsp[-3],bl(yyvsp[0],yyvsp[-1])); } +break; +case 130: +#line 390 "a2p.y" +{ yyval = oper3(OIF,yyvsp[-6],bl(yyvsp[-3],yyvsp[-4]),bl(yyvsp[0],yyvsp[-1])); } +break; +case 131: +#line 392 "a2p.y" +{ yyval = oper2(OWHILE,yyvsp[-3],bl(yyvsp[0],yyvsp[-1])); } +break; +case 132: +#line 394 "a2p.y" +{ yyval = oper2(ODO,bl(yyvsp[-4],yyvsp[-5]),yyvsp[-1]); } +break; +case 133: +#line 396 "a2p.y" +{ yyval = oper4(OFOR,yyvsp[-7],yyvsp[-5],yyvsp[-3],bl(yyvsp[0],yyvsp[-1])); } +break; +case 134: +#line 398 "a2p.y" +{ yyval = oper4(OFOR,yyvsp[-6],string("",0),yyvsp[-3],bl(yyvsp[0],yyvsp[-1])); } +break; +case 135: +#line 400 "a2p.y" +{ yyval = oper2(OFORIN,yyvsp[-3],bl(yyvsp[0],yyvsp[-1])); } +break; +case 136: +#line 402 "a2p.y" +{ yyval = oper3(OBLOCK,oper2(OJUNK,yyvsp[-3],yyvsp[-2]),Nullop,yyvsp[0]); } +break; +#line 2660 "y.tab.c" + } + yyssp -= yym; + yystate = *yyssp; + yyvsp -= yym; + yym = yylhs[yyn]; + if (yystate == 0 && yym == 0) + { +#if YYDEBUG + if (yydebug) + printf("%sdebug: after reduction, shifting from state 0 to\ + state %d\n", YYPREFIX, YYFINAL); +#endif + yystate = YYFINAL; + *++yyssp = YYFINAL; + *++yyvsp = yyval; + if (yychar < 0) + { + if ((yychar = yylex()) < 0) yychar = 0; +#if YYDEBUG + if (yydebug) + { + yys = 0; + if (yychar <= YYMAXTOKEN) yys = yyname[yychar]; + if (!yys) yys = "illegal-symbol"; + printf("%sdebug: state %d, reading %d (%s)\n", + YYPREFIX, YYFINAL, yychar, yys); + } +#endif + } + if (yychar == 0) goto yyaccept; + goto yyloop; + } + if ((yyn = yygindex[yym]) && (yyn += yystate) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == yystate) + yystate = yytable[yyn]; + else + yystate = yydgoto[yym]; +#if YYDEBUG + if (yydebug) + printf("%sdebug: after reduction, shifting from state %d \ +to state %d\n", YYPREFIX, *yyssp, yystate); +#endif + if (yyssp >= yyss + yystacksize - 1) + { + goto yyoverflow; + } + *++yyssp = yystate; + *++yyvsp = yyval; + goto yyloop; +yyoverflow: + yyerror("yacc stack overflow"); +yyabort: + return (1); +yyaccept: + return (0); +} diff --git a/gnu/usr.bin/perl/x2p/a2p.h b/gnu/usr.bin/perl/x2p/a2p.h new file mode 100644 index 0000000..7c6a66dd --- /dev/null +++ b/gnu/usr.bin/perl/x2p/a2p.h @@ -0,0 +1,341 @@ +/* $RCSfile: a2p.h,v $$Revision: 1.1.1.1 $$Date: 1993/08/23 21:30:09 $ + * + * Copyright (c) 1991, 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.h,v $ + * Revision 1.1.1.1 1993/08/23 21:30:09 nate + * PERL! + * + * Revision 4.0.1.2 92/06/08 16:12:23 lwall + * patch20: hash tables now split only if the memory is available to do so + * + * Revision 4.0.1.1 91/06/07 12:12:27 lwall + * patch4: new copyright notice + * + * Revision 4.0 91/03/20 01:57:07 lwall + * 4.0 baseline. + * + */ + +#define VOIDUSED 1 +#include "config.h" + +#ifndef HAS_BCOPY +# define bcopy(s1,s2,l) memcpy(s2,s1,l) +#endif +#ifndef HAS_BZERO +# define bzero(s,l) memset(s,0,l) +#endif + +#include "handy.h" +#define Nullop 0 + +#define OPROG 1 +#define OJUNK 2 +#define OHUNKS 3 +#define ORANGE 4 +#define OPAT 5 +#define OHUNK 6 +#define OPPAREN 7 +#define OPANDAND 8 +#define OPOROR 9 +#define OPNOT 10 +#define OCPAREN 11 +#define OCANDAND 12 +#define OCOROR 13 +#define OCNOT 14 +#define ORELOP 15 +#define ORPAREN 16 +#define OMATCHOP 17 +#define OMPAREN 18 +#define OCONCAT 19 +#define OASSIGN 20 +#define OADD 21 +#define OSUBTRACT 22 +#define OMULT 23 +#define ODIV 24 +#define OMOD 25 +#define OPOSTINCR 26 +#define OPOSTDECR 27 +#define OPREINCR 28 +#define OPREDECR 29 +#define OUMINUS 30 +#define OUPLUS 31 +#define OPAREN 32 +#define OGETLINE 33 +#define OSPRINTF 34 +#define OSUBSTR 35 +#define OSTRING 36 +#define OSPLIT 37 +#define OSNEWLINE 38 +#define OINDEX 39 +#define ONUM 40 +#define OSTR 41 +#define OVAR 42 +#define OFLD 43 +#define ONEWLINE 44 +#define OCOMMENT 45 +#define OCOMMA 46 +#define OSEMICOLON 47 +#define OSCOMMENT 48 +#define OSTATES 49 +#define OSTATE 50 +#define OPRINT 51 +#define OPRINTF 52 +#define OBREAK 53 +#define ONEXT 54 +#define OEXIT 55 +#define OCONTINUE 56 +#define OREDIR 57 +#define OIF 58 +#define OWHILE 59 +#define OFOR 60 +#define OFORIN 61 +#define OVFLD 62 +#define OBLOCK 63 +#define OREGEX 64 +#define OLENGTH 65 +#define OLOG 66 +#define OEXP 67 +#define OSQRT 68 +#define OINT 69 +#define ODO 70 +#define OPOW 71 +#define OSUB 72 +#define OGSUB 73 +#define OMATCH 74 +#define OUSERFUN 75 +#define OUSERDEF 76 +#define OCLOSE 77 +#define OATAN2 78 +#define OSIN 79 +#define OCOS 80 +#define ORAND 81 +#define OSRAND 82 +#define ODELETE 83 +#define OSYSTEM 84 +#define OCOND 85 +#define ORETURN 86 +#define ODEFINED 87 +#define OSTAR 88 + +#ifdef DOINIT +char *opname[] = { + "0", + "PROG", + "JUNK", + "HUNKS", + "RANGE", + "PAT", + "HUNK", + "PPAREN", + "PANDAND", + "POROR", + "PNOT", + "CPAREN", + "CANDAND", + "COROR", + "CNOT", + "RELOP", + "RPAREN", + "MATCHOP", + "MPAREN", + "CONCAT", + "ASSIGN", + "ADD", + "SUBTRACT", + "MULT", + "DIV", + "MOD", + "POSTINCR", + "POSTDECR", + "PREINCR", + "PREDECR", + "UMINUS", + "UPLUS", + "PAREN", + "GETLINE", + "SPRINTF", + "SUBSTR", + "STRING", + "SPLIT", + "SNEWLINE", + "INDEX", + "NUM", + "STR", + "VAR", + "FLD", + "NEWLINE", + "COMMENT", + "COMMA", + "SEMICOLON", + "SCOMMENT", + "STATES", + "STATE", + "PRINT", + "PRINTF", + "BREAK", + "NEXT", + "EXIT", + "CONTINUE", + "REDIR", + "IF", + "WHILE", + "FOR", + "FORIN", + "VFLD", + "BLOCK", + "REGEX", + "LENGTH", + "LOG", + "EXP", + "SQRT", + "INT", + "DO", + "POW", + "SUB", + "GSUB", + "MATCH", + "USERFUN", + "USERDEF", + "CLOSE", + "ATAN2", + "SIN", + "COS", + "RAND", + "SRAND", + "DELETE", + "SYSTEM", + "COND", + "RETURN", + "DEFINED", + "STAR", + "89" +}; +#else +extern char *opname[]; +#endif + +EXT int mop INIT(1); + +union u_ops { + int ival; + char *cval; +}; +#if defined(iAPX286) || defined(M_I286) || defined(I80286) /* 80286 hack */ +#define OPSMAX (64000/sizeof(union u_ops)) /* approx. max segment size */ +#else +#define OPSMAX 50000 +#endif /* 80286 hack */ +union u_ops ops[OPSMAX]; + +#include <stdio.h> +#include <ctype.h> + +typedef struct string STR; +typedef struct htbl HASH; + +#include "str.h" +#include "hash.h" + +/* A string is TRUE if not "" or "0". */ +#define True(val) (tmps = (val), (*tmps && !(*tmps == '0' && !tmps[1]))) +EXT char *Yes INIT("1"); +EXT char *No INIT(""); + +#define str_true(str) (Str = (str), (Str->str_pok ? True(Str->str_ptr) : (Str->str_nok ? (Str->str_nval != 0.0) : 0 ))) + +#define str_peek(str) (Str = (str), (Str->str_pok ? Str->str_ptr : (Str->str_nok ? (sprintf(buf,"num(%g)",Str->str_nval),buf) : "" ))) +#define str_get(str) (Str = (str), (Str->str_pok ? Str->str_ptr : str_2ptr(Str))) +#define str_gnum(str) (Str = (str), (Str->str_nok ? Str->str_nval : str_2num(Str))) +EXT STR *Str; + +#define GROWSTR(pp,lp,len) if (*(lp) < (len)) growstr(pp,lp,len) + +STR *str_new(); + +char *scanpat(); +char *scannum(); + +void str_free(); + +EXT int line INIT(0); + +EXT FILE *rsfp; +EXT char buf[2048]; +EXT char *bufptr INIT(buf); + +EXT STR *linestr INIT(Nullstr); + +EXT char tokenbuf[2048]; +EXT int expectterm INIT(TRUE); + +#ifdef DEBUGGING +EXT int debug INIT(0); +EXT int dlevel INIT(0); +#define YYDEBUG 1 +extern int yydebug; +#endif + +EXT STR *freestrroot INIT(Nullstr); + +EXT STR str_no; +EXT STR str_yes; + +EXT bool do_split INIT(FALSE); +EXT bool split_to_array INIT(FALSE); +EXT bool set_array_base INIT(FALSE); +EXT bool saw_RS INIT(FALSE); +EXT bool saw_OFS INIT(FALSE); +EXT bool saw_ORS INIT(FALSE); +EXT bool saw_line_op INIT(FALSE); +EXT bool in_begin INIT(TRUE); +EXT bool do_opens INIT(FALSE); +EXT bool do_fancy_opens INIT(FALSE); +EXT bool lval_field INIT(FALSE); +EXT bool do_chop INIT(FALSE); +EXT bool need_entire INIT(FALSE); +EXT bool absmaxfld INIT(FALSE); +EXT bool saw_altinput INIT(FALSE); + +EXT bool nomemok INIT(FALSE); + +EXT char const_FS INIT(0); +EXT char *namelist INIT(Nullch); +EXT char fswitch INIT(0); + +EXT int saw_FS INIT(0); +EXT int maxfld INIT(0); +EXT int arymax INIT(0); +char *nameary[100]; + +EXT STR *opens; + +EXT HASH *symtab; +EXT HASH *curarghash; + +#define P_MIN 0 +#define P_LISTOP 5 +#define P_COMMA 10 +#define P_ASSIGN 15 +#define P_COND 20 +#define P_DOTDOT 25 +#define P_OROR 30 +#define P_ANDAND 35 +#define P_OR 40 +#define P_AND 45 +#define P_EQ 50 +#define P_REL 55 +#define P_UNI 60 +#define P_FILETEST 65 +#define P_SHIFT 70 +#define P_ADD 75 +#define P_MUL 80 +#define P_MATCH 85 +#define P_UNARY 90 +#define P_POW 95 +#define P_AUTO 100 +#define P_MAX 999 diff --git a/gnu/usr.bin/perl/x2p/a2p.y b/gnu/usr.bin/perl/x2p/a2p.y new file mode 100644 index 0000000..bc86632 --- /dev/null +++ b/gnu/usr.bin/perl/x2p/a2p.y @@ -0,0 +1,406 @@ +%{ +/* $RCSfile: a2p.y,v $$Revision: 1.1.1.1 $$Date: 1993/08/23 21:30:09 $ + * + * Copyright (c) 1991, 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 1.1.1.1 1993/08/23 21:30:09 nate + * PERL! + * + * 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" +#include "a2p.h" + +int root; +int begins = Nullop; +int ends = Nullop; + +%} +%token BEGIN END +%token REGEX +%token SEMINEW NEWLINE COMMENT +%token FUN1 FUNN GRGR +%token PRINT PRINTF SPRINTF SPLIT +%token IF ELSE WHILE FOR IN +%token EXIT NEXT BREAK CONTINUE RET +%token GETLINE DO SUB GSUB MATCH +%token FUNCTION USERFUN DELETE + +%right ASGNOP +%right '?' ':' +%left OROR +%left ANDAND +%left IN +%left NUMBER VAR SUBSTR INDEX +%left MATCHOP +%left RELOP '<' '>' +%left OR +%left STRING +%left '+' '-' +%left '*' '/' '%' +%right UMINUS +%left NOT +%right '^' +%left INCR DECR +%left FIELD VFIELD + +%% + +program : junk hunks + { root = oper4(OPROG,$1,begins,$2,ends); } + ; + +begin : BEGIN '{' maybe states '}' junk + { begins = oper4(OJUNK,begins,$3,$4,$6); in_begin = FALSE; + $$ = Nullop; } + ; + +end : END '{' maybe states '}' + { ends = oper3(OJUNK,ends,$3,$4); $$ = Nullop; } + | end NEWLINE + { $$ = $1; } + ; + +hunks : hunks hunk junk + { $$ = oper3(OHUNKS,$1,$2,$3); } + | /* NULL */ + { $$ = Nullop; } + ; + +hunk : patpat + { $$ = oper1(OHUNK,$1); need_entire = TRUE; } + | patpat '{' maybe states '}' + { $$ = oper2(OHUNK,$1,oper2(OJUNK,$3,$4)); } + | FUNCTION USERFUN '(' arg_list ')' maybe '{' maybe states '}' + { fixfargs($2,$4,0); $$ = oper5(OUSERDEF,$2,$4,$6,$8,$9); } + | '{' maybe states '}' + { $$ = oper2(OHUNK,Nullop,oper2(OJUNK,$2,$3)); } + | begin + | end + ; + +arg_list: expr_list + { $$ = rememberargs($$); } + ; + +patpat : cond + { $$ = oper1(OPAT,$1); } + | cond ',' cond + { $$ = oper2(ORANGE,$1,$3); } + ; + +cond : expr + | match + | rel + | compound_cond + ; + +compound_cond + : '(' compound_cond ')' + { $$ = oper1(OCPAREN,$2); } + | cond ANDAND maybe cond + { $$ = oper3(OCANDAND,$1,$3,$4); } + | cond OROR maybe cond + { $$ = oper3(OCOROR,$1,$3,$4); } + | NOT cond + { $$ = oper1(OCNOT,$2); } + ; + +rel : expr RELOP expr + { $$ = oper3(ORELOP,$2,$1,$3); } + | expr '>' expr + { $$ = oper3(ORELOP,string(">",1),$1,$3); } + | expr '<' expr + { $$ = oper3(ORELOP,string("<",1),$1,$3); } + | '(' rel ')' + { $$ = oper1(ORPAREN,$2); } + ; + +match : expr MATCHOP expr + { $$ = oper3(OMATCHOP,$2,$1,$3); } + | expr MATCHOP REGEX + { $$ = oper3(OMATCHOP,$2,$1,oper1(OREGEX,$3)); } + | REGEX %prec MATCHOP + { $$ = oper1(OREGEX,$1); } + | '(' match ')' + { $$ = oper1(OMPAREN,$2); } + ; + +expr : term + { $$ = $1; } + | expr term + { $$ = oper2(OCONCAT,$1,$2); } + | variable ASGNOP cond + { $$ = oper3(OASSIGN,$2,$1,$3); + if ((ops[$1].ival & 255) == OFLD) + lval_field = TRUE; + if ((ops[$1].ival & 255) == OVFLD) + lval_field = TRUE; + } + ; + +term : variable + { $$ = $1; } + | NUMBER + { $$ = oper1(ONUM,$1); } + | STRING + { $$ = oper1(OSTR,$1); } + | term '+' term + { $$ = oper2(OADD,$1,$3); } + | term '-' term + { $$ = oper2(OSUBTRACT,$1,$3); } + | term '*' term + { $$ = oper2(OMULT,$1,$3); } + | term '/' term + { $$ = oper2(ODIV,$1,$3); } + | term '%' term + { $$ = oper2(OMOD,$1,$3); } + | term '^' term + { $$ = 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(OPOSTDECR,$1); } + | INCR variable + { $$ = oper1(OPREINCR,$2); } + | DECR variable + { $$ = oper1(OPREDECR,$2); } + | '-' term %prec UMINUS + { $$ = oper1(OUMINUS,$2); } + | '+' term %prec UMINUS + { $$ = oper1(OUPLUS,$2); } + | '(' cond ')' + { $$ = oper1(OPAREN,$2); } + | GETLINE + { $$ = oper0(OGETLINE); } + | 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 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 variable + { $$ = oper3(OGETLINE,$4,string("|",1),$1); + if (ops[$1].ival != OSTR + (1<<8)) do_fancy_opens = TRUE; } + | FUN1 + { $$ = oper0($1); need_entire = do_chop = TRUE; } + | FUN1 '(' ')' + { $$ = oper1($1,Nullop); need_entire = do_chop = TRUE; } + | FUN1 '(' expr ')' + { $$ = oper1($1,$3); } + | FUNN '(' expr_list ')' + { $$ = oper1($1,$3); } + | USERFUN '(' expr_list ')' + { $$ = oper2(OUSERFUN,$1,$3); } + | SPRINTF expr_list + { $$ = oper1(OSPRINTF,$2); } + | SUBSTR '(' expr ',' expr ',' expr ')' + { $$ = oper3(OSUBSTR,$3,$5,$7); } + | SUBSTR '(' expr ',' expr ')' + { $$ = 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 ')' + { $$ = oper2(OINDEX,$3,$5); } + | MATCH '(' expr ',' REGEX ')' + { $$ = oper2(OMATCH,$3,oper1(OREGEX,$5)); } + | MATCH '(' expr ',' expr ')' + { $$ = oper2(OMATCH,$3,$5); } + | SUB '(' expr ',' expr ')' + { $$ = oper2(OSUB,$3,$5); } + | SUB '(' REGEX ',' expr ')' + { $$ = oper2(OSUB,oper1(OREGEX,$3),$5); } + | GSUB '(' expr ',' expr ')' + { $$ = oper2(OGSUB,$3,$5); } + | GSUB '(' REGEX ',' expr ')' + { $$ = oper2(OGSUB,oper1(OREGEX,$3),$5); } + | SUB '(' expr ',' expr ',' expr ')' + { $$ = oper3(OSUB,$3,$5,$7); } + | SUB '(' REGEX ',' expr ',' expr ')' + { $$ = oper3(OSUB,oper1(OREGEX,$3),$5,$7); } + | GSUB '(' expr ',' expr ',' expr ')' + { $$ = oper3(OGSUB,$3,$5,$7); } + | GSUB '(' REGEX ',' expr ',' expr ')' + { $$ = oper3(OGSUB,oper1(OREGEX,$3),$5,$7); } + ; + +variable: VAR + { $$ = oper1(OVAR,$1); } + | VAR '[' expr_list ']' + { $$ = oper2(OVAR,aryrefarg($1),$3); } + | FIELD + { $$ = oper1(OFLD,$1); } + | VFIELD term + { $$ = oper1(OVFLD,$2); } + ; + +expr_list + : expr + | clist + | /* NULL */ + { $$ = Nullop; } + ; + +clist : expr ',' maybe expr + { $$ = oper3(OCOMMA,$1,$3,$4); } + | clist ',' maybe expr + { $$ = oper3(OCOMMA,$1,$3,$4); } + | '(' clist ')' /* these parens are invisible */ + { $$ = $2; } + ; + +junk : junk hunksep + { $$ = oper2(OJUNK,$1,$2); } + | /* NULL */ + { $$ = Nullop; } + ; + +hunksep : ';' + { $$ = oper2(OJUNK,oper0(OSEMICOLON),oper0(ONEWLINE)); } + | SEMINEW + { $$ = oper2(OJUNK,oper0(OSEMICOLON),oper0(ONEWLINE)); } + | NEWLINE + { $$ = oper0(ONEWLINE); } + | COMMENT + { $$ = oper1(OCOMMENT,$1); } + ; + +maybe : maybe nlstuff + { $$ = oper2(OJUNK,$1,$2); } + | /* NULL */ + { $$ = Nullop; } + ; + +nlstuff : NEWLINE + { $$ = oper0(ONEWLINE); } + | COMMENT + { $$ = oper1(OCOMMENT,$1); } + ; + +separator + : ';' maybe + { $$ = oper2(OJUNK,oper0(OSEMICOLON),$2); } + | SEMINEW maybe + { $$ = oper2(OJUNK,oper0(OSNEWLINE),$2); } + | NEWLINE maybe + { $$ = oper2(OJUNK,oper0(OSNEWLINE),$2); } + | COMMENT maybe + { $$ = oper2(OJUNK,oper1(OSCOMMENT,$1),$2); } + ; + +states : states statement + { $$ = oper2(OSTATES,$1,$2); } + | /* NULL */ + { $$ = Nullop; } + ; + +statement + : simple separator maybe + { $$ = oper2(OJUNK,oper2(OSTATE,$1,$2),$3); } + | ';' maybe + { $$ = oper2(OSTATE,Nullop,oper2(OJUNK,oper0(OSEMICOLON),$2)); } + | SEMINEW maybe + { $$ = oper2(OSTATE,Nullop,oper2(OJUNK,oper0(OSNEWLINE),$2)); } + | compound + ; + +simpnull: simple + | /* NULL */ + { $$ = Nullop; } + ; + +simple + : expr + | PRINT expr_list redir expr + { $$ = oper3(OPRINT,$2,$3,$4); + do_opens = TRUE; + saw_ORS = saw_OFS = TRUE; + if (!$2) need_entire = TRUE; + if (ops[$4].ival != OSTR + (1<<8)) do_fancy_opens = TRUE; } + | PRINT expr_list + { $$ = oper1(OPRINT,$2); + if (!$2) need_entire = TRUE; + saw_ORS = saw_OFS = TRUE; + } + | PRINTF expr_list redir expr + { $$ = oper3(OPRINTF,$2,$3,$4); + do_opens = TRUE; + if (!$2) need_entire = TRUE; + if (ops[$4].ival != OSTR + (1<<8)) do_fancy_opens = TRUE; } + | PRINTF expr_list + { $$ = oper1(OPRINTF,$2); + if (!$2) need_entire = TRUE; + } + | BREAK + { $$ = oper0(OBREAK); } + | NEXT + { $$ = oper0(ONEXT); } + | EXIT + { $$ = oper0(OEXIT); } + | EXIT expr + { $$ = oper1(OEXIT,$2); } + | CONTINUE + { $$ = oper0(OCONTINUE); } + | RET + { $$ = oper0(ORETURN); } + | RET expr + { $$ = oper1(ORETURN,$2); } + | DELETE VAR '[' expr ']' + { $$ = oper2(ODELETE,aryrefarg($2),$4); } + ; + +redir : '>' %prec FIELD + { $$ = oper1(OREDIR,string(">",1)); } + | GRGR + { $$ = oper1(OREDIR,string(">>",2)); } + | '|' + { $$ = oper1(OREDIR,string("|",1)); } + ; + +compound + : IF '(' cond ')' maybe statement + { $$ = oper2(OIF,$3,bl($6,$5)); } + | IF '(' cond ')' maybe statement ELSE maybe statement + { $$ = oper3(OIF,$3,bl($6,$5),bl($9,$8)); } + | WHILE '(' cond ')' maybe statement + { $$ = oper2(OWHILE,$3,bl($6,$5)); } + | DO maybe statement WHILE '(' cond ')' + { $$ = oper2(ODO,bl($3,$2),$6); } + | FOR '(' simpnull ';' cond ';' simpnull ')' maybe statement + { $$ = oper4(OFOR,$3,$5,$7,bl($10,$9)); } + | FOR '(' simpnull ';' ';' simpnull ')' maybe statement + { $$ = oper4(OFOR,$3,string("",0),$6,bl($9,$8)); } + | FOR '(' expr ')' maybe statement + { $$ = oper2(OFORIN,$3,bl($6,$5)); } + | '{' maybe states '}' maybe + { $$ = oper3(OBLOCK,oper2(OJUNK,$2,$3),Nullop,$5); } + ; + +%% +#include "a2py.c" diff --git a/gnu/usr.bin/perl/x2p/a2py.c b/gnu/usr.bin/perl/x2p/a2py.c new file mode 100644 index 0000000..1558f99 --- /dev/null +++ b/gnu/usr.bin/perl/x2p/a2py.c @@ -0,0 +1,1301 @@ +/* $RCSfile: a2py.c,v $$Revision: 1.1.1.1 $$Date: 1993/08/23 21:30:10 $ + * + * Copyright (c) 1991, 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: a2py.c,v $ + * Revision 1.1.1.1 1993/08/23 21:30:10 nate + * PERL! + * + * Revision 4.0.1.2 92/06/08 16:15:16 lwall + * patch20: in a2p, now warns about spurious backslashes + * patch20: in a2p, now allows [ to be backslashed in pattern + * patch20: in a2p, now allows numbers of the form 2. + * + * Revision 4.0.1.1 91/06/07 12:12:59 lwall + * patch4: new copyright notice + * + * Revision 4.0 91/03/20 01:57:26 lwall + * 4.0 baseline. + * + */ + +#ifdef OS2 +#include "../patchlevel.h" +#endif +#include "util.h" +char *index(); + +char *filename; +char *myname; + +int checkers = 0; +STR *walk(); + +#ifdef OS2 +usage() +{ + printf("\nThis is the AWK to PERL translator, version 4.0, patchlevel %d\n", PATCHLEVEL); + printf("\nUsage: %s [-D<number>] [-F<char>] [-n<fieldlist>] [-<number>] filename\n", myname); + printf("\n -D<number> sets debugging flags." + "\n -F<character> the awk script to translate is always invoked with" + "\n this -F switch." + "\n -n<fieldlist> specifies the names of the input fields if input does" + "\n not have to be split into an array." + "\n -<number> causes a2p to assume that input will always have that" + "\n many fields.\n"); + exit(1); +} +#endif +main(argc,argv,env) +register int argc; +register char **argv; +register char **env; +{ + register STR *str; + register char *s; + int i; + STR *tmpstr; + + myname = argv[0]; + linestr = str_new(80); + str = str_new(0); /* first used for -I flags */ + for (argc--,argv++; argc; argc--,argv++) { + if (argv[0][0] != '-' || !argv[0][1]) + break; + reswitch: + switch (argv[0][1]) { +#ifdef DEBUGGING + case 'D': + debug = atoi(argv[0]+2); +#ifdef YYDEBUG + yydebug = (debug & 1); +#endif + break; +#endif + case '0': case '1': case '2': case '3': case '4': + case '5': case '6': case '7': case '8': case '9': + maxfld = atoi(argv[0]+1); + absmaxfld = TRUE; + break; + case 'F': + fswitch = argv[0][2]; + break; + case 'n': + namelist = savestr(argv[0]+2); + break; + case '-': + argc--,argv++; + goto switch_end; + case 0: + break; + default: + fatal("Unrecognized switch: %s\n",argv[0]); +#ifdef OS2 + usage(); +#endif + } + } + switch_end: + + /* open script */ + + if (argv[0] == Nullch) { +#ifdef OS2 + if ( isatty(fileno(stdin)) ) + usage(); +#endif + argv[0] = "-"; + } + filename = savestr(argv[0]); + + filename = savestr(argv[0]); + if (strEQ(filename,"-")) + argv[0] = ""; + if (!*argv[0]) + rsfp = stdin; + else + rsfp = fopen(argv[0],"r"); + if (rsfp == Nullfp) + fatal("Awk script \"%s\" doesn't seem to exist.\n",filename); + + /* init tokener */ + + bufptr = str_get(linestr); + symtab = hnew(); + curarghash = hnew(); + + /* now parse the report spec */ + + if (yyparse()) + fatal("Translation aborted due to syntax errors.\n"); + +#ifdef DEBUGGING + if (debug & 2) { + int type, len; + + for (i=1; i<mop;) { + type = ops[i].ival; + len = type >> 8; + type &= 255; + printf("%d\t%d\t%d\t%-10s",i++,type,len,opname[type]); + if (type == OSTRING) + printf("\t\"%s\"\n",ops[i].cval),i++; + else { + while (len--) { + printf("\t%d",ops[i].ival),i++; + } + putchar('\n'); + } + } + } + if (debug & 8) + dump(root); +#endif + + /* first pass to look for numeric variables */ + + prewalk(0,0,root,&i); + + /* second pass to produce new program */ + + tmpstr = walk(0,0,root,&i,P_MIN); + str = str_make("#!"); + str_cat(str, BIN); + str_cat(str, "/perl\neval \"exec "); + str_cat(str, BIN); + str_cat(str, "/perl -S $0 $*\"\n\ + if $running_under_some_shell;\n\ + # this emulates #! processing on NIH machines.\n\ + # (remove #! line above if indigestible)\n\n"); + str_cat(str, + "eval '$'.$1.'$2;' while $ARGV[0] =~ /^([A-Za-z_]+=)(.*)/ && shift;\n"); + str_cat(str, + " # process any FOO=bar switches\n\n"); + if (do_opens && opens) { + str_scat(str,opens); + str_free(opens); + str_cat(str,"\n"); + } + str_scat(str,tmpstr); + str_free(tmpstr); +#ifdef DEBUGGING + if (!(debug & 16)) +#endif + fixup(str); + putlines(str); + if (checkers) { + fprintf(stderr, + "Please check my work on the %d line%s I've marked with \"#???\".\n", + checkers, checkers == 1 ? "" : "s" ); + fprintf(stderr, + "The operation I've selected may be wrong for the operand types.\n"); + } + exit(0); +} + +#define RETURN(retval) return (bufptr = s,retval) +#define XTERM(retval) return (expectterm = TRUE,bufptr = s,retval) +#define XOP(retval) return (expectterm = FALSE,bufptr = s,retval) +#define ID(x) return (yylval=string(x,0),expectterm = FALSE,bufptr = s,idtype) + +int idtype; + +yylex() +{ + register char *s = bufptr; + register char *d; + register int tmp; + + retry: +#ifdef YYDEBUG + if (yydebug) + if (index(s,'\n')) + fprintf(stderr,"Tokener at %s",s); + else + fprintf(stderr,"Tokener at %s\n",s); +#endif + switch (*s) { + default: + fprintf(stderr, + "Unrecognized character %c in file %s line %d--ignoring.\n", + *s++,filename,line); + goto retry; + case '\\': + s++; + if (*s && *s != '\n') { + yyerror("Ignoring spurious backslash"); + goto retry; + } + /*FALLSTHROUGH*/ + case 0: + s = str_get(linestr); + *s = '\0'; + if (!rsfp) + RETURN(0); + line++; + if ((s = str_gets(linestr, rsfp)) == Nullch) { + if (rsfp != stdin) + fclose(rsfp); + rsfp = Nullfp; + s = str_get(linestr); + RETURN(0); + } + goto retry; + case ' ': case '\t': + s++; + goto retry; + case '\n': + *s = '\0'; + XTERM(NEWLINE); + case '#': + yylval = string(s,0); + *s = '\0'; + XTERM(COMMENT); + case ';': + tmp = *s++; + if (*s == '\n') { + s++; + XTERM(SEMINEW); + } + XTERM(tmp); + case '(': + tmp = *s++; + XTERM(tmp); + case '{': + case '[': + case ')': + case ']': + case '?': + case ':': + tmp = *s++; + XOP(tmp); + case 127: + s++; + XTERM('}'); + case '}': + for (d = s + 1; isspace(*d); d++) ; + if (!*d) + s = d - 1; + *s = 127; + XTERM(';'); + case ',': + tmp = *s++; + XTERM(tmp); + case '~': + s++; + yylval = string("~",1); + XTERM(MATCHOP); + case '+': + case '-': + if (s[1] == *s) { + s++; + if (*s++ == '+') + XTERM(INCR); + else + XTERM(DECR); + } + /* FALL THROUGH */ + case '*': + case '%': + case '^': + tmp = *s++; + if (*s == '=') { + if (tmp == '^') + yylval = string("**=",3); + else + yylval = string(s-1,2); + s++; + XTERM(ASGNOP); + } + XTERM(tmp); + case '&': + s++; + tmp = *s++; + if (tmp == '&') + XTERM(ANDAND); + s--; + XTERM('&'); + case '|': + s++; + tmp = *s++; + if (tmp == '|') + XTERM(OROR); + s--; + while (*s == ' ' || *s == '\t') + s++; + if (strnEQ(s,"getline",7)) + XTERM('p'); + else + XTERM('|'); + case '=': + s++; + tmp = *s++; + if (tmp == '=') { + yylval = string("==",2); + XTERM(RELOP); + } + s--; + yylval = string("=",1); + XTERM(ASGNOP); + case '!': + s++; + tmp = *s++; + if (tmp == '=') { + yylval = string("!=",2); + XTERM(RELOP); + } + if (tmp == '~') { + yylval = string("!~",2); + XTERM(MATCHOP); + } + s--; + XTERM(NOT); + case '<': + s++; + tmp = *s++; + if (tmp == '=') { + yylval = string("<=",2); + XTERM(RELOP); + } + s--; + XTERM('<'); + case '>': + s++; + tmp = *s++; + if (tmp == '>') { + yylval = string(">>",2); + XTERM(GRGR); + } + if (tmp == '=') { + yylval = string(">=",2); + XTERM(RELOP); + } + s--; + XTERM('>'); + +#define SNARFWORD \ + d = tokenbuf; \ + while (isalpha(*s) || isdigit(*s) || *s == '_') \ + *d++ = *s++; \ + *d = '\0'; \ + d = tokenbuf; \ + if (*s == '(') \ + idtype = USERFUN; \ + else \ + idtype = VAR; + + case '$': + s++; + if (*s == '0') { + s++; + do_chop = TRUE; + need_entire = TRUE; + idtype = VAR; + ID("0"); + } + do_split = TRUE; + if (isdigit(*s)) { + for (d = s; isdigit(*s); s++) ; + yylval = string(d,s-d); + tmp = atoi(d); + if (tmp > maxfld) + maxfld = tmp; + XOP(FIELD); + } + split_to_array = set_array_base = TRUE; + XOP(VFIELD); + + case '/': /* may either be division or pattern */ + if (expectterm) { + s = scanpat(s); + XTERM(REGEX); + } + tmp = *s++; + if (*s == '=') { + yylval = string("/=",2); + s++; + XTERM(ASGNOP); + } + XTERM(tmp); + + case '0': case '1': case '2': case '3': case '4': + case '5': case '6': case '7': case '8': case '9': case '.': + s = scannum(s); + XOP(NUMBER); + case '"': + s++; + s = cpy2(tokenbuf,s,s[-1]); + if (!*s) + fatal("String not terminated:\n%s",str_get(linestr)); + s++; + yylval = string(tokenbuf,0); + XOP(STRING); + + case 'a': case 'A': + SNARFWORD; + if (strEQ(d,"ARGC")) + set_array_base = TRUE; + if (strEQ(d,"ARGV")) { + yylval=numary(string("ARGV",0)); + XOP(VAR); + } + if (strEQ(d,"atan2")) { + yylval = OATAN2; + XTERM(FUNN); + } + ID(d); + case 'b': case 'B': + SNARFWORD; + if (strEQ(d,"break")) + XTERM(BREAK); + if (strEQ(d,"BEGIN")) + XTERM(BEGIN); + ID(d); + case 'c': case 'C': + SNARFWORD; + if (strEQ(d,"continue")) + XTERM(CONTINUE); + if (strEQ(d,"cos")) { + yylval = OCOS; + XTERM(FUN1); + } + if (strEQ(d,"close")) { + do_fancy_opens = 1; + yylval = OCLOSE; + XTERM(FUN1); + } + if (strEQ(d,"chdir")) + *d = toupper(*d); + else if (strEQ(d,"crypt")) + *d = toupper(*d); + else if (strEQ(d,"chop")) + *d = toupper(*d); + else if (strEQ(d,"chmod")) + *d = toupper(*d); + else if (strEQ(d,"chown")) + *d = toupper(*d); + ID(d); + case 'd': case 'D': + SNARFWORD; + if (strEQ(d,"do")) + XTERM(DO); + if (strEQ(d,"delete")) + XTERM(DELETE); + if (strEQ(d,"die")) + *d = toupper(*d); + ID(d); + case 'e': case 'E': + SNARFWORD; + if (strEQ(d,"END")) + XTERM(END); + if (strEQ(d,"else")) + XTERM(ELSE); + if (strEQ(d,"exit")) { + saw_line_op = TRUE; + XTERM(EXIT); + } + if (strEQ(d,"exp")) { + yylval = OEXP; + XTERM(FUN1); + } + if (strEQ(d,"elsif")) + *d = toupper(*d); + else if (strEQ(d,"eq")) + *d = toupper(*d); + else if (strEQ(d,"eval")) + *d = toupper(*d); + else if (strEQ(d,"eof")) + *d = toupper(*d); + else if (strEQ(d,"each")) + *d = toupper(*d); + else if (strEQ(d,"exec")) + *d = toupper(*d); + ID(d); + case 'f': case 'F': + SNARFWORD; + if (strEQ(d,"FS")) { + saw_FS++; + if (saw_FS == 1 && in_begin) { + for (d = s; *d && isspace(*d); d++) ; + if (*d == '=') { + for (d++; *d && isspace(*d); d++) ; + if (*d == '"' && d[2] == '"') + const_FS = d[1]; + } + } + ID(tokenbuf); + } + if (strEQ(d,"for")) + XTERM(FOR); + else if (strEQ(d,"function")) + XTERM(FUNCTION); + if (strEQ(d,"FILENAME")) + d = "ARGV"; + if (strEQ(d,"foreach")) + *d = toupper(*d); + else if (strEQ(d,"format")) + *d = toupper(*d); + else if (strEQ(d,"fork")) + *d = toupper(*d); + else if (strEQ(d,"fh")) + *d = toupper(*d); + ID(d); + case 'g': case 'G': + SNARFWORD; + if (strEQ(d,"getline")) + XTERM(GETLINE); + if (strEQ(d,"gsub")) + XTERM(GSUB); + if (strEQ(d,"ge")) + *d = toupper(*d); + else if (strEQ(d,"gt")) + *d = toupper(*d); + else if (strEQ(d,"goto")) + *d = toupper(*d); + else if (strEQ(d,"gmtime")) + *d = toupper(*d); + ID(d); + case 'h': case 'H': + SNARFWORD; + if (strEQ(d,"hex")) + *d = toupper(*d); + ID(d); + case 'i': case 'I': + SNARFWORD; + if (strEQ(d,"if")) + XTERM(IF); + if (strEQ(d,"in")) + XTERM(IN); + if (strEQ(d,"index")) { + set_array_base = TRUE; + XTERM(INDEX); + } + if (strEQ(d,"int")) { + yylval = OINT; + XTERM(FUN1); + } + ID(d); + case 'j': case 'J': + SNARFWORD; + if (strEQ(d,"join")) + *d = toupper(*d); + ID(d); + case 'k': case 'K': + SNARFWORD; + if (strEQ(d,"keys")) + *d = toupper(*d); + else if (strEQ(d,"kill")) + *d = toupper(*d); + ID(d); + case 'l': case 'L': + SNARFWORD; + if (strEQ(d,"length")) { + yylval = OLENGTH; + XTERM(FUN1); + } + if (strEQ(d,"log")) { + yylval = OLOG; + XTERM(FUN1); + } + if (strEQ(d,"last")) + *d = toupper(*d); + else if (strEQ(d,"local")) + *d = toupper(*d); + else if (strEQ(d,"lt")) + *d = toupper(*d); + else if (strEQ(d,"le")) + *d = toupper(*d); + else if (strEQ(d,"locatime")) + *d = toupper(*d); + else if (strEQ(d,"link")) + *d = toupper(*d); + ID(d); + case 'm': case 'M': + SNARFWORD; + if (strEQ(d,"match")) { + set_array_base = TRUE; + XTERM(MATCH); + } + if (strEQ(d,"m")) + *d = toupper(*d); + ID(d); + case 'n': case 'N': + SNARFWORD; + if (strEQ(d,"NF")) + do_chop = do_split = split_to_array = set_array_base = TRUE; + if (strEQ(d,"next")) { + saw_line_op = TRUE; + XTERM(NEXT); + } + if (strEQ(d,"ne")) + *d = toupper(*d); + ID(d); + case 'o': case 'O': + SNARFWORD; + if (strEQ(d,"ORS")) { + saw_ORS = TRUE; + d = "\\"; + } + if (strEQ(d,"OFS")) { + saw_OFS = TRUE; + d = ","; + } + if (strEQ(d,"OFMT")) { + d = "#"; + } + if (strEQ(d,"open")) + *d = toupper(*d); + else if (strEQ(d,"ord")) + *d = toupper(*d); + else if (strEQ(d,"oct")) + *d = toupper(*d); + ID(d); + case 'p': case 'P': + SNARFWORD; + if (strEQ(d,"print")) { + XTERM(PRINT); + } + if (strEQ(d,"printf")) { + XTERM(PRINTF); + } + if (strEQ(d,"push")) + *d = toupper(*d); + else if (strEQ(d,"pop")) + *d = toupper(*d); + ID(d); + case 'q': case 'Q': + SNARFWORD; + ID(d); + case 'r': case 'R': + SNARFWORD; + if (strEQ(d,"RS")) { + d = "/"; + saw_RS = TRUE; + } + if (strEQ(d,"rand")) { + yylval = ORAND; + XTERM(FUN1); + } + if (strEQ(d,"return")) + XTERM(RET); + if (strEQ(d,"reset")) + *d = toupper(*d); + else if (strEQ(d,"redo")) + *d = toupper(*d); + else if (strEQ(d,"rename")) + *d = toupper(*d); + ID(d); + case 's': case 'S': + SNARFWORD; + if (strEQ(d,"split")) { + set_array_base = TRUE; + XOP(SPLIT); + } + if (strEQ(d,"substr")) { + set_array_base = TRUE; + XTERM(SUBSTR); + } + if (strEQ(d,"sub")) + XTERM(SUB); + if (strEQ(d,"sprintf")) + XTERM(SPRINTF); + if (strEQ(d,"sqrt")) { + yylval = OSQRT; + XTERM(FUN1); + } + if (strEQ(d,"SUBSEP")) { + d = ";"; + } + if (strEQ(d,"sin")) { + yylval = OSIN; + XTERM(FUN1); + } + if (strEQ(d,"srand")) { + yylval = OSRAND; + XTERM(FUN1); + } + if (strEQ(d,"system")) { + yylval = OSYSTEM; + XTERM(FUN1); + } + if (strEQ(d,"s")) + *d = toupper(*d); + else if (strEQ(d,"shift")) + *d = toupper(*d); + else if (strEQ(d,"select")) + *d = toupper(*d); + else if (strEQ(d,"seek")) + *d = toupper(*d); + else if (strEQ(d,"stat")) + *d = toupper(*d); + else if (strEQ(d,"study")) + *d = toupper(*d); + else if (strEQ(d,"sleep")) + *d = toupper(*d); + else if (strEQ(d,"symlink")) + *d = toupper(*d); + else if (strEQ(d,"sort")) + *d = toupper(*d); + ID(d); + case 't': case 'T': + SNARFWORD; + if (strEQ(d,"tr")) + *d = toupper(*d); + else if (strEQ(d,"tell")) + *d = toupper(*d); + else if (strEQ(d,"time")) + *d = toupper(*d); + else if (strEQ(d,"times")) + *d = toupper(*d); + ID(d); + case 'u': case 'U': + SNARFWORD; + if (strEQ(d,"until")) + *d = toupper(*d); + else if (strEQ(d,"unless")) + *d = toupper(*d); + else if (strEQ(d,"umask")) + *d = toupper(*d); + else if (strEQ(d,"unshift")) + *d = toupper(*d); + else if (strEQ(d,"unlink")) + *d = toupper(*d); + else if (strEQ(d,"utime")) + *d = toupper(*d); + ID(d); + case 'v': case 'V': + SNARFWORD; + if (strEQ(d,"values")) + *d = toupper(*d); + ID(d); + case 'w': case 'W': + SNARFWORD; + if (strEQ(d,"while")) + XTERM(WHILE); + if (strEQ(d,"write")) + *d = toupper(*d); + else if (strEQ(d,"wait")) + *d = toupper(*d); + ID(d); + case 'x': case 'X': + SNARFWORD; + if (strEQ(d,"x")) + *d = toupper(*d); + ID(d); + case 'y': case 'Y': + SNARFWORD; + if (strEQ(d,"y")) + *d = toupper(*d); + ID(d); + case 'z': case 'Z': + SNARFWORD; + ID(d); + } +} + +char * +scanpat(s) +register char *s; +{ + register char *d; + + switch (*s++) { + case '/': + break; + default: + fatal("Search pattern not found:\n%s",str_get(linestr)); + } + + d = tokenbuf; + for (; *s; s++,d++) { + if (*s == '\\') { + if (s[1] == '/') + *d++ = *s++; + else if (s[1] == '\\') + *d++ = *s++; + else if (s[1] == '[') + *d++ = *s++; + } + else if (*s == '[') { + *d++ = *s++; + do { + if (*s == '\\' && s[1]) + *d++ = *s++; + if (*s == '/' || (*s == '-' && s[1] == ']')) + *d++ = '\\'; + *d++ = *s++; + } while (*s && *s != ']'); + } + else if (*s == '/') + break; + *d = *s; + } + *d = '\0'; + + if (!*s) + fatal("Search pattern not terminated:\n%s",str_get(linestr)); + s++; + yylval = string(tokenbuf,0); + return s; +} + +yyerror(s) +char *s; +{ + fprintf(stderr,"%s in file %s at line %d\n", + s,filename,line); +} + +char * +scannum(s) +register char *s; +{ + register char *d; + + switch (*s) { + case '1': case '2': case '3': case '4': case '5': + case '6': case '7': case '8': case '9': case '0' : case '.': + d = tokenbuf; + while (isdigit(*s)) { + *d++ = *s++; + } + if (*s == '.') { + if (isdigit(s[1])) { + *d++ = *s++; + while (isdigit(*s)) { + *d++ = *s++; + } + } + else + s++; + } + if (index("eE",*s) && index("+-0123456789",s[1])) { + *d++ = *s++; + if (*s == '+' || *s == '-') + *d++ = *s++; + while (isdigit(*s)) + *d++ = *s++; + } + *d = '\0'; + yylval = string(tokenbuf,0); + break; + } + return s; +} + +string(ptr,len) +char *ptr; +{ + int retval = mop; + + ops[mop++].ival = OSTRING + (1<<8); + if (!len) + len = strlen(ptr); + ops[mop].cval = safemalloc(len+1); + strncpy(ops[mop].cval,ptr,len); + ops[mop++].cval[len] = '\0'; + if (mop >= OPSMAX) + fatal("Recompile a2p with larger OPSMAX\n"); + return retval; +} + +oper0(type) +int type; +{ + int retval = mop; + + if (type > 255) + fatal("type > 255 (%d)\n",type); + ops[mop++].ival = type; + if (mop >= OPSMAX) + fatal("Recompile a2p with larger OPSMAX\n"); + return retval; +} + +oper1(type,arg1) +int type; +int arg1; +{ + int retval = mop; + + if (type > 255) + fatal("type > 255 (%d)\n",type); + ops[mop++].ival = type + (1<<8); + ops[mop++].ival = arg1; + if (mop >= OPSMAX) + fatal("Recompile a2p with larger OPSMAX\n"); + return retval; +} + +oper2(type,arg1,arg2) +int type; +int arg1; +int arg2; +{ + int retval = mop; + + if (type > 255) + fatal("type > 255 (%d)\n",type); + ops[mop++].ival = type + (2<<8); + ops[mop++].ival = arg1; + ops[mop++].ival = arg2; + if (mop >= OPSMAX) + fatal("Recompile a2p with larger OPSMAX\n"); + return retval; +} + +oper3(type,arg1,arg2,arg3) +int type; +int arg1; +int arg2; +int arg3; +{ + int retval = mop; + + if (type > 255) + fatal("type > 255 (%d)\n",type); + ops[mop++].ival = type + (3<<8); + ops[mop++].ival = arg1; + ops[mop++].ival = arg2; + ops[mop++].ival = arg3; + if (mop >= OPSMAX) + fatal("Recompile a2p with larger OPSMAX\n"); + return retval; +} + +oper4(type,arg1,arg2,arg3,arg4) +int type; +int arg1; +int arg2; +int arg3; +int arg4; +{ + int retval = mop; + + if (type > 255) + fatal("type > 255 (%d)\n",type); + ops[mop++].ival = type + (4<<8); + ops[mop++].ival = arg1; + ops[mop++].ival = arg2; + ops[mop++].ival = arg3; + ops[mop++].ival = arg4; + if (mop >= OPSMAX) + fatal("Recompile a2p with larger OPSMAX\n"); + return retval; +} + +oper5(type,arg1,arg2,arg3,arg4,arg5) +int type; +int arg1; +int arg2; +int arg3; +int arg4; +int arg5; +{ + int retval = mop; + + if (type > 255) + fatal("type > 255 (%d)\n",type); + ops[mop++].ival = type + (5<<8); + ops[mop++].ival = arg1; + ops[mop++].ival = arg2; + ops[mop++].ival = arg3; + ops[mop++].ival = arg4; + ops[mop++].ival = arg5; + if (mop >= OPSMAX) + fatal("Recompile a2p with larger OPSMAX\n"); + return retval; +} + +int depth = 0; + +dump(branch) +int branch; +{ + register int type; + register int len; + register int i; + + type = ops[branch].ival; + len = type >> 8; + type &= 255; + for (i=depth; i; i--) + printf(" "); + if (type == OSTRING) { + printf("%-5d\"%s\"\n",branch,ops[branch+1].cval); + } + else { + printf("(%-5d%s %d\n",branch,opname[type],len); + depth++; + for (i=1; i<=len; i++) + dump(ops[branch+i].ival); + depth--; + for (i=depth; i; i--) + printf(" "); + printf(")\n"); + } +} + +bl(arg,maybe) +int arg; +int maybe; +{ + if (!arg) + return 0; + else if ((ops[arg].ival & 255) != OBLOCK) + return oper2(OBLOCK,arg,maybe); + else if ((ops[arg].ival >> 8) < 2) + return oper2(OBLOCK,ops[arg+1].ival,maybe); + else + return arg; +} + +fixup(str) +STR *str; +{ + register char *s; + register char *t; + + for (s = str->str_ptr; *s; s++) { + if (*s == ';' && s[1] == ' ' && s[2] == '\n') { + strcpy(s+1,s+2); + s++; + } + else if (*s == '\n') { + for (t = s+1; isspace(*t & 127); t++) ; + t--; + while (isspace(*t & 127) && *t != '\n') t--; + if (*t == '\n' && t-s > 1) { + if (s[-1] == '{') + s--; + strcpy(s+1,t); + } + s++; + } + } +} + +putlines(str) +STR *str; +{ + register char *d, *s, *t, *e; + register int pos, newpos; + + d = tokenbuf; + pos = 0; + for (s = str->str_ptr; *s; s++) { + *d++ = *s; + pos++; + if (*s == '\n') { + *d = '\0'; + d = tokenbuf; + pos = 0; + putone(); + } + else if (*s == '\t') + pos += 7; + if (pos > 78) { /* split a long line? */ + *d-- = '\0'; + newpos = 0; + for (t = tokenbuf; isspace(*t & 127); t++) { + if (*t == '\t') + newpos += 8; + else + newpos += 1; + } + e = d; + while (d > tokenbuf && (*d != ' ' || d[-1] != ';')) + d--; + if (d < t+10) { + d = e; + while (d > tokenbuf && + (*d != ' ' || d[-1] != '|' || d[-2] != '|') ) + d--; + } + if (d < t+10) { + d = e; + while (d > tokenbuf && + (*d != ' ' || d[-1] != '&' || d[-2] != '&') ) + d--; + } + if (d < t+10) { + d = e; + while (d > tokenbuf && (*d != ' ' || d[-1] != ',')) + d--; + } + if (d < t+10) { + d = e; + while (d > tokenbuf && *d != ' ') + d--; + } + if (d > t+3) { + char save[2048]; + strcpy(save, d); + *d = '\n'; + d[1] = '\0'; + putone(); + putchar('\n'); + if (d[-1] != ';' && !(newpos % 4)) { + *t++ = ' '; + *t++ = ' '; + newpos += 2; + } + strcpy(t,save+1); + newpos += strlen(t); + d = t + strlen(t); + pos = newpos; + } + else + d = e + 1; + } + } +} + +putone() +{ + register char *t; + + for (t = tokenbuf; *t; t++) { + *t &= 127; + if (*t == 127) { + *t = ' '; + strcpy(t+strlen(t)-1, "\t#???\n"); + checkers++; + } + } + t = tokenbuf; + if (*t == '#') { + if (strnEQ(t,"#!/bin/awk",10) || strnEQ(t,"#! /bin/awk",11)) + return; + if (strnEQ(t,"#!/usr/bin/awk",14) || strnEQ(t,"#! /usr/bin/awk",15)) + return; + } + fputs(tokenbuf,stdout); +} + +numary(arg) +int arg; +{ + STR *key; + int dummy; + + key = walk(0,0,arg,&dummy,P_MIN); + str_cat(key,"[]"); + hstore(symtab,key->str_ptr,str_make("1")); + str_free(key); + set_array_base = TRUE; + return arg; +} + +rememberargs(arg) +int arg; +{ + int type; + STR *str; + + if (!arg) + return arg; + type = ops[arg].ival & 255; + if (type == OCOMMA) { + rememberargs(ops[arg+1].ival); + rememberargs(ops[arg+3].ival); + } + else if (type == OVAR) { + str = str_new(0); + hstore(curarghash,ops[ops[arg+1].ival+1].cval,str); + } + else + fatal("panic: unknown argument type %d, line %d\n",type,line); + return arg; +} + +aryrefarg(arg) +int arg; +{ + int type = ops[arg].ival & 255; + STR *str; + + if (type != OSTRING) + fatal("panic: aryrefarg %d, line %d\n",type,line); + str = hfetch(curarghash,ops[arg+1].cval); + if (str) + str_set(str,"*"); + return arg; +} + +fixfargs(name,arg,prevargs) +int name; +int arg; +int prevargs; +{ + int type; + STR *str; + int numargs; + + if (!arg) + return prevargs; + type = ops[arg].ival & 255; + if (type == OCOMMA) { + numargs = fixfargs(name,ops[arg+1].ival,prevargs); + numargs = fixfargs(name,ops[arg+3].ival,numargs); + } + else if (type == OVAR) { + str = hfetch(curarghash,ops[ops[arg+1].ival+1].cval); + if (strEQ(str_get(str),"*")) { + char tmpbuf[128]; + + str_set(str,""); /* in case another routine has this */ + ops[arg].ival &= ~255; + ops[arg].ival |= OSTAR; + sprintf(tmpbuf,"%s:%d",ops[name+1].cval,prevargs); + fprintf(stderr,"Adding %s\n",tmpbuf); + str = str_new(0); + str_set(str,"*"); + hstore(curarghash,tmpbuf,str); + } + numargs = prevargs + 1; + } + else + fatal("panic: unknown argument type %d, arg %d, line %d\n", + type,prevargs+1,line); + return numargs; +} + +fixrargs(name,arg,prevargs) +char *name; +int arg; +int prevargs; +{ + int type; + STR *str; + int numargs; + + if (!arg) + return prevargs; + type = ops[arg].ival & 255; + if (type == OCOMMA) { + numargs = fixrargs(name,ops[arg+1].ival,prevargs); + numargs = fixrargs(name,ops[arg+3].ival,numargs); + } + else { + char tmpbuf[128]; + + sprintf(tmpbuf,"%s:%d",name,prevargs); + str = hfetch(curarghash,tmpbuf); + if (str && strEQ(str->str_ptr,"*")) { + if (type == OVAR || type == OSTAR) { + ops[arg].ival &= ~255; + ops[arg].ival |= OSTAR; + } + else + fatal("Can't pass expression by reference as arg %d of %s\n", + prevargs+1, name); + } + numargs = prevargs + 1; + } + return numargs; +} + diff --git a/gnu/usr.bin/perl/x2p/find2perl b/gnu/usr.bin/perl/x2p/find2perl new file mode 100755 index 0000000..6d7f0ad --- /dev/null +++ b/gnu/usr.bin/perl/x2p/find2perl @@ -0,0 +1,568 @@ +#!/usr/gnu/bin/perl + +eval 'exec /usr/gnu/bin/perl -S $0 ${1+"$@"}' + if $running_under_some_shell; + +$bin = "/usr/gnu/bin"; + + +while ($ARGV[0] =~ /^[^-!(]/) { + push(@roots, shift); +} +@roots = ('.') unless @roots; +for (@roots) { $_ = "e($_); } +$roots = join(',', @roots); + +$indent = 1; + +while (@ARGV) { + $_ = shift; + s/^-// || /^[()!]/ || die "Unrecognized switch: $_\n"; + if ($_ eq '(') { + $out .= &tab . "(\n"; + $indent++; + next; + } + elsif ($_ eq ')') { + $indent--; + $out .= &tab . ")"; + } + elsif ($_ eq '!') { + $out .= &tab . "!"; + next; + } + elsif ($_ eq 'name') { + $out .= &tab; + $pat = &fileglob_to_re(shift); + $out .= '/' . $pat . "/"; + } + elsif ($_ eq 'perm') { + $onum = shift; + die "Malformed -perm argument: $onum\n" unless $onum =~ /^-?[0-7]+$/; + if ($onum =~ s/^-//) { + $onum = '0' . sprintf("%o", oct($onum) & 017777); # s/b 07777 ? + $out .= &tab . "((\$mode & $onum) == $onum)"; + } + else { + $onum = '0' . $onum unless $onum =~ /^0/; + $out .= &tab . "((\$mode & 0777) == $onum)"; + } + } + elsif ($_ eq 'type') { + ($filetest = shift) =~ tr/s/S/; + $out .= &tab . "-$filetest _"; + } + elsif ($_ eq 'print') { + $out .= &tab . 'print("$name\n")'; + } + elsif ($_ eq 'print0') { + $out .= &tab . 'print("$name\0")'; + } + elsif ($_ eq 'fstype') { + $out .= &tab; + $type = shift; + if ($type eq 'nfs') + { $out .= '$dev < 0'; } + else + { $out .= '$dev >= 0'; } + } + elsif ($_ eq 'user') { + $uname = shift; + $out .= &tab . "\$uid == \$uid{'$uname'}"; + $inituser++; + } + elsif ($_ eq 'group') { + $gname = shift; + $out .= &tab . "\$gid == \$gid{'$gname'}"; + $initgroup++; + } + elsif ($_ eq 'nouser') { + $out .= &tab . '!defined $uid{$uid}'; + $inituser++; + } + elsif ($_ eq 'nogroup') { + $out .= &tab . '!defined $gid{$gid}'; + $initgroup++; + } + elsif ($_ eq 'links') { + $out .= &tab . '$nlink ' . &n(shift); + } + elsif ($_ eq 'inum') { + $out .= &tab . '$ino ' . &n(shift); + } + elsif ($_ eq 'size') { + $out .= &tab . 'int((-s _ + 511) / 512) ' . &n(shift); + } + elsif ($_ eq 'atime') { + $out .= &tab . 'int(-A _) ' . &n(shift); + } + elsif ($_ eq 'mtime') { + $out .= &tab . 'int(-M _) ' . &n(shift); + } + elsif ($_ eq 'ctime') { + $out .= &tab . 'int(-C _) ' . &n(shift); + } + elsif ($_ eq 'exec') { + for (@cmd = (); @ARGV && $ARGV[0] ne ';'; push(@cmd,shift)) { } + shift; + $_ = "@cmd"; + if (m#^(/bin/)?rm -f {}$#) { + if (!@ARGV) { + $out .= &tab . 'unlink($_)'; + } + else { + $out .= &tab . '(unlink($_) || 1)'; + } + } + elsif (m#^(/bin/)?rm {}$#) { + $out .= &tab . '(unlink($_) || warn "$name: $!\n")'; + } + else { + for (@cmd) { s/'/\\'/g; } + $" = "','"; + $out .= &tab . "&exec(0, '@cmd')"; + $" = ' '; + $initexec++; + } + } + elsif ($_ eq 'ok') { + for (@cmd = (); @ARGV && $ARGV[0] ne ';'; push(@cmd,shift)) { } + shift; + for (@cmd) { s/'/\\'/g; } + $" = "','"; + $out .= &tab . "&exec(1, '@cmd')"; + $" = ' '; + $initexec++; + } + elsif ($_ eq 'prune') { + $out .= &tab . '($prune = 1)'; + } + elsif ($_ eq 'xdev') { + $out .= &tab . '(($prune |= ($dev != $topdev)),1)'; + } + elsif ($_ eq 'newer') { + $out .= &tab; + $file = shift; + $newername = 'AGE_OF' . $file; + $newername =~ s/[^\w]/_/g; + $newername = '$' . $newername; + $out .= "-M _ < $newername"; + $initnewer .= "$newername = -M " . "e($file) . ";\n"; + } + elsif ($_ eq 'eval') { + $prog = "e(shift); + $out .= &tab . "eval $prog"; + } + elsif ($_ eq 'depth') { + $depth++; + next; + } + elsif ($_ eq 'ls') { + $out .= &tab . "&ls"; + $initls++; + } + elsif ($_ eq 'tar') { + $out .= &tab; + die "-tar must have a filename argument\n" unless @ARGV; + $file = shift; + $fh = 'FH' . $file; + $fh =~ s/[^\w]/_/g; + $out .= "&tar($fh)"; + $file = '>' . $file; + $initfile .= "open($fh, " . "e($file) . + qq{) || die "Can't open $fh: \$!\\n";\n}; + $inittar++; + $flushall = "\n&tflushall;\n"; + } + elsif (/^n?cpio$/) { + $depth++; + $out .= &tab; + die "-$_ must have a filename argument\n" unless @ARGV; + $file = shift; + $fh = 'FH' . $file; + $fh =~ s/[^\w]/_/g; + $out .= "&cpio('" . substr($_,0,1) . "', $fh)"; + $file = '>' . $file; + $initfile .= "open($fh, " . "e($file) . + qq{) || die "Can't open $fh: \$!\\n";\n}; + $initcpio++; + $flushall = "\n&flushall;\n"; + } + else { + die "Unrecognized switch: -$_\n"; + } + if (@ARGV) { + if ($ARGV[0] eq '-o') { + { local($statdone) = 1; $out .= "\n" . &tab . "||\n"; } + $statdone = 0 if $indent == 1 && $delayedstat; + $saw_or++; + shift; + } + else { + $out .= " &&" unless $ARGV[0] eq ')'; + $out .= "\n"; + shift if $ARGV[0] eq '-a'; + } + } +} + +print <<"END"; +#!$bin/perl + +eval 'exec $bin/perl -S \$0 \${1+"\$@"}' + if \$running_under_some_shell; + +END + +if ($initls) { + print <<'END'; +@rwx = ('---','--x','-w-','-wx','r--','r-x','rw-','rwx'); +@moname = (Jan,Feb,Mar,Apr,May,Jun,Jul,Aug,Sep,Oct,Nov,Dec); + +END +} + +if ($inituser || $initls) { + print 'while (($name, $pw, $uid) = getpwent) {', "\n"; + print ' $uid{$name} = $uid{$uid} = $uid;', "\n" if $inituser; + print ' $user{$uid} = $name unless $user{$uid};', "\n" if $initls; + print "}\n\n"; +} + +if ($initgroup || $initls) { + print 'while (($name, $pw, $gid) = getgrent) {', "\n"; + print ' $gid{$name} = $gid{$gid} = $gid;', "\n" if $initgroup; + print ' $group{$gid} = $name unless $group{$gid};', "\n" if $initls; + print "}\n\n"; +} + +print $initnewer, "\n" if $initnewer; + +print $initfile, "\n" if $initfile; + +$find = $depth ? "finddepth" : "find"; +print <<"END"; +require "$find.pl"; + +# Traverse desired filesystems + +&$find($roots); +$flushall +exit; + +sub wanted { +$out; +} + +END + +if ($initexec) { + print <<'END'; +sub exec { + local($ok, @cmd) = @_; + foreach $word (@cmd) { + $word =~ s#{}#$name#g; + } + if ($ok) { + local($old) = select(STDOUT); + $| = 1; + print "@cmd"; + select($old); + return 0 unless <STDIN> =~ /^y/; + } + chdir $cwd; # sigh + system @cmd; + chdir $dir; + return !$?; +} + +END +} + +if ($initls) { + print <<'END'; +sub ls { + ($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$sizemm, + $atime,$mtime,$ctime,$blksize,$blocks) = lstat(_); + + $pname = $name; + + if (defined $blocks) { + $blocks = int(($blocks + 1) / 2); + } + else { + $blocks = int(($size + 1023) / 1024); + } + + if (-f _) { $perms = '-'; } + elsif (-d _) { $perms = 'd'; } + elsif (-c _) { $perms = 'c'; $sizemm = &sizemm; } + elsif (-b _) { $perms = 'b'; $sizemm = &sizemm; } + elsif (-p _) { $perms = 'p'; } + elsif (-S _) { $perms = 's'; } + else { $perms = 'l'; $pname .= ' -> ' . readlink($_); } + + $tmpmode = $mode; + $tmp = $rwx[$tmpmode & 7]; + $tmpmode >>= 3; + $tmp = $rwx[$tmpmode & 7] . $tmp; + $tmpmode >>= 3; + $tmp = $rwx[$tmpmode & 7] . $tmp; + substr($tmp,2,1) =~ tr/-x/Ss/ if -u _; + substr($tmp,5,1) =~ tr/-x/Ss/ if -g _; + substr($tmp,8,1) =~ tr/-x/Tt/ if -k _; + $perms .= $tmp; + + $user = $user{$uid} || $uid; + $group = $group{$gid} || $gid; + + ($sec,$min,$hour,$mday,$mon,$year) = localtime($mtime); + $moname = $moname[$mon]; + if (-M _ > 365.25 / 2) { + $timeyear = '19' . $year; + } + else { + $timeyear = sprintf("%02d:%02d", $hour, $min); + } + + printf "%5lu %4ld %-10s %2d %-8s %-8s %8s %s %2d %5s %s\n", + $ino, + $blocks, + $perms, + $nlink, + $user, + $group, + $sizemm, + $moname, + $mday, + $timeyear, + $pname; + 1; +} + +sub sizemm { + sprintf("%3d, %3d", ($rdev >> 8) & 255, $rdev & 255); +} + +END +} + +if ($initcpio) { +print <<'END'; +sub cpio { + local($nc,$fh) = @_; + local($text); + + if ($name eq 'TRAILER!!!') { + $text = ''; + $size = 0; + } + else { + ($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size, + $atime,$mtime,$ctime,$blksize,$blocks) = lstat(_); + if (-f _) { + open(IN, "./$_\0") || do { + warn "Couldn't open $name: $!\n"; + return; + }; + } + else { + $text = readlink($_); + $size = 0 unless defined $text; + } + } + + ($nm = $name) =~ s#^\./##; + $nc{$fh} = $nc; + if ($nc eq 'n') { + $cpout{$fh} .= + sprintf("%06o%06o%06o%06o%06o%06o%06o%06o%011lo%06o%011lo%s\0", + 070707, + $dev & 0777777, + $ino & 0777777, + $mode & 0777777, + $uid & 0777777, + $gid & 0777777, + $nlink & 0777777, + $rdev & 0177777, + $mtime, + length($nm)+1, + $size, + $nm); + } + else { + $cpout{$fh} .= "\0" if length($cpout{$fh}) & 1; + $cpout{$fh} .= pack("SSSSSSSSLSLa*", + 070707, $dev, $ino, $mode, $uid, $gid, $nlink, $rdev, $mtime, + length($nm)+1, $size, $nm . (length($nm) & 1 ? "\0" : "\0\0")); + } + if ($text ne '') { + $cpout{$fh} .= $text; + } + elsif ($size) { + &flush($fh) while ($l = length($cpout{$fh})) >= 5120; + while (sysread(IN, $cpout{$fh}, 5120 - $l, $l)) { + &flush($fh); + $l = length($cpout{$fh}); + } + } + close IN; +} + +sub flush { + local($fh) = @_; + + while (length($cpout{$fh}) >= 5120) { + syswrite($fh,$cpout{$fh},5120); + ++$blocks{$fh}; + substr($cpout{$fh}, 0, 5120) = ''; + } +} + +sub flushall { + $name = 'TRAILER!!!'; + foreach $fh (keys %cpout) { + &cpio($nc{$fh},$fh); + $cpout{$fh} .= "0" x (5120 - length($cpout{$fh})); + &flush($fh); + print $blocks{$fh} * 10, " blocks\n"; + } +} + +END +} + +if ($inittar) { +print <<'END'; +sub tar { + local($fh) = @_; + local($linkname,$header,$l,$slop); + local($linkflag) = "\0"; + + ($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size, + $atime,$mtime,$ctime,$blksize,$blocks) = lstat(_); + $nm = $name; + if ($nlink > 1) { + if ($linkname = $linkseen{$fh,$dev,$ino}) { + $linkflag = 1; + } + else { + $linkseen{$fh,$dev,$ino} = $nm; + } + } + if (-f _) { + open(IN, "./$_\0") || do { + warn "Couldn't open $name: $!\n"; + return; + }; + $size = 0 if $linkflag ne "\0"; + } + else { + $linkname = readlink($_); + $linkflag = 2 if defined $linkname; + $nm .= '/' if -d _; + $size = 0; + } + + $header = pack("a100a8a8a8a12a12a8a1a100", + $nm, + sprintf("%6o ", $mode & 0777), + sprintf("%6o ", $uid & 0777777), + sprintf("%6o ", $gid & 0777777), + sprintf("%11o ", $size), + sprintf("%11o ", $mtime), + " ", + $linkflag, + $linkname); + $l = length($header) % 512; + substr($header, 148, 6) = sprintf("%6o", unpack("%16C*", $header)); + substr($header, 154, 1) = "\0"; # blech + $tarout{$fh} .= $header; + $tarout{$fh} .= "\0" x (512 - $l) if $l; + if ($size) { + &tflush($fh) while ($l = length($tarout{$fh})) >= 10240; + while (sysread(IN, $tarout{$fh}, 10240 - $l, $l)) { + $slop = length($tarout{$fh}) % 512; + $tarout{$fh} .= "\0" x (512 - $slop) if $slop; + &tflush($fh); + $l = length($tarout{$fh}); + } + } + close IN; +} + +sub tflush { + local($fh) = @_; + + while (length($tarout{$fh}) >= 10240) { + syswrite($fh,$tarout{$fh},10240); + ++$blocks{$fh}; + substr($tarout{$fh}, 0, 10240) = ''; + } +} + +sub tflushall { + local($len); + + foreach $fh (keys %tarout) { + $len = 10240 - length($tarout{$fh}); + $len += 10240 if $len < 1024; + $tarout{$fh} .= "\0" x $len; + &tflush($fh); + } +} + +END +} + +exit; + +############################################################################ + +sub tab { + local($tabstring); + + $tabstring = "\t" x ($indent / 2) . ' ' x ($indent % 2 * 4); + if (!$statdone) { + if ($_ =~ /^(name|print|prune|exec|ok|\(|\))/) { + $delayedstat++; + } + else { + if ($saw_or) { + $tabstring .= <<'ENDOFSTAT' . $tabstring; +($nlink || (($dev,$ino,$mode,$nlink,$uid,$gid) = lstat($_))) && +ENDOFSTAT + } + else { + $tabstring .= <<'ENDOFSTAT' . $tabstring; +(($dev,$ino,$mode,$nlink,$uid,$gid) = lstat($_)) && +ENDOFSTAT + } + $statdone = 1; + } + } + $tabstring =~ s/^\s+/ / if $out =~ /!$/; + $tabstring; +} + +sub fileglob_to_re { + local($tmp) = @_; + + $tmp =~ s/([.^\$()])/\\$1/g; + $tmp =~ s/([?*])/.$1/g; + "^$tmp$"; +} + +sub n { + local($n) = @_; + + $n =~ s/^-/< / || $n =~ s/^\+/> / || $n =~ s/^/== /; + $n =~ s/ 0*(\d)/ $1/; + $n; +} + +sub quote { + local($string) = @_; + $string =~ s/'/\\'/; + "'$string'"; +} diff --git a/gnu/usr.bin/perl/x2p/h2ph b/gnu/usr.bin/perl/x2p/h2ph new file mode 100755 index 0000000..f093626 --- /dev/null +++ b/gnu/usr.bin/perl/x2p/h2ph @@ -0,0 +1,253 @@ +#!/usr/gnu/bin/perl +'di'; +'ig00'; + +$perlincl = '/usr/gnu/lib/perl'; + +chdir '/usr/include' || die "Can't cd /usr/include"; + +@isatype = split(' ',<<END); + char uchar u_char + short ushort u_short + int uint u_int + long ulong u_long + FILE +END + +@isatype{@isatype} = (1) x @isatype; + +@ARGV = ('-') unless @ARGV; + +foreach $file (@ARGV) { + if ($file eq '-') { + open(IN, "-"); + open(OUT, ">-"); + } + else { + ($outfile = $file) =~ s/\.h$/.ph/ || next; + print "$file -> $outfile\n"; + if ($file =~ m|^(.*)/|) { + $dir = $1; + if (!-d "$perlincl/$dir") { + mkdir("$perlincl/$dir",0777); + } + } + open(IN,"$file") || ((warn "Can't open $file: $!\n"),next); + open(OUT,">$perlincl/$outfile") || die "Can't create $outfile: $!\n"; + } + while (<IN>) { + chop; + while (/\\$/) { + chop; + $_ .= <IN>; + chop; + } + if (s:/\*:\200:g) { + s:\*/:\201:g; + s/\200[^\201]*\201//g; # delete single line comments + if (s/\200.*//) { # begin multi-line comment? + $_ .= '/*'; + $_ .= <IN>; + redo; + } + } + if (s/^#\s*//) { + if (s/^define\s+(\w+)//) { + $name = $1; + $new = ''; + s/\s+$//; + if (s/^\(([\w,\s]*)\)//) { + $args = $1; + if ($args ne '') { + foreach $arg (split(/,\s*/,$args)) { + $arg =~ s/^\s*([^\s].*[^\s])\s*$/$1/; + $curargs{$arg} = 1; + } + $args =~ s/\b(\w)/\$$1/g; + $args = "local($args) = \@_;\n$t "; + } + s/^\s+//; + do expr(); + $new =~ s/(["\\])/\\$1/g; + if ($t ne '') { + $new =~ s/(['\\])/\\$1/g; + print OUT $t, + "eval 'sub $name {\n$t ${args}eval \"$new\";\n$t}';\n"; + } + else { + print OUT "sub $name {\n ${args}eval \"$new\";\n}\n"; + } + %curargs = (); + } + else { + s/^\s+//; + do expr(); + $new = 1 if $new eq ''; + if ($t ne '') { + $new =~ s/(['\\])/\\$1/g; + print OUT $t,"eval 'sub $name {",$new,";}';\n"; + } + else { + print OUT $t,"sub $name {",$new,";}\n"; + } + } + } + elsif (/^include\s+<(.*)>/) { + ($incl = $1) =~ s/\.h$/.ph/; + print OUT $t,"require '$incl';\n"; + } + elsif (/^ifdef\s+(\w+)/) { + print OUT $t,"if (defined &$1) {\n"; + $tab += 4; + $t = "\t" x ($tab / 8) . ' ' x ($tab % 8); + } + elsif (/^ifndef\s+(\w+)/) { + print OUT $t,"if (!defined &$1) {\n"; + $tab += 4; + $t = "\t" x ($tab / 8) . ' ' x ($tab % 8); + } + elsif (s/^if\s+//) { + $new = ''; + do expr(); + print OUT $t,"if ($new) {\n"; + $tab += 4; + $t = "\t" x ($tab / 8) . ' ' x ($tab % 8); + } + elsif (s/^elif\s+//) { + $new = ''; + do expr(); + $tab -= 4; + $t = "\t" x ($tab / 8) . ' ' x ($tab % 8); + print OUT $t,"}\n${t}elsif ($new) {\n"; + $tab += 4; + $t = "\t" x ($tab / 8) . ' ' x ($tab % 8); + } + elsif (/^else/) { + $tab -= 4; + $t = "\t" x ($tab / 8) . ' ' x ($tab % 8); + print OUT $t,"}\n${t}else {\n"; + $tab += 4; + $t = "\t" x ($tab / 8) . ' ' x ($tab % 8); + } + elsif (/^endif/) { + $tab -= 4; + $t = "\t" x ($tab / 8) . ' ' x ($tab % 8); + print OUT $t,"}\n"; + } + } + } + print OUT "1;\n"; +} + +sub expr { + while ($_ ne '') { + s/^(\s+)// && do {$new .= ' '; next;}; + s/^(0x[0-9a-fA-F]+)// && do {$new .= $1; next;}; + s/^(\d+)// && do {$new .= $1; next;}; + s/^("(\\"|[^"])*")// && do {$new .= $1; next;}; + s/^'((\\"|[^"])*)'// && do { + if ($curargs{$1}) { + $new .= "ord('\$$1')"; + } + else { + $new .= "ord('$1')"; + } + next; + }; + s/^sizeof\s*\(([^)]+)\)/{$1}/ && do { + $new .= '$sizeof'; + next; + }; + s/^([_a-zA-Z]\w*)// && do { + $id = $1; + if ($id eq 'struct') { + s/^\s+(\w+)//; + $id .= ' ' . $1; + $isatype{$id} = 1; + } + elsif ($id eq 'unsigned') { + s/^\s+(\w+)//; + $id .= ' ' . $1; + $isatype{$id} = 1; + } + if ($curargs{$id}) { + $new .= '$' . $id; + } + elsif ($id eq 'defined') { + $new .= 'defined'; + } + elsif (/^\(/) { + s/^\((\w),/("$1",/ if $id =~ /^_IO[WR]*$/i; # cheat + $new .= " &$id"; + } + elsif ($isatype{$id}) { + if ($new =~ /{\s*$/) { + $new .= "'$id'"; + } + elsif ($new =~ /\(\s*$/ && /^[\s*]*\)/) { + $new =~ s/\(\s*$//; + s/^[\s*]*\)//; + } + else { + $new .= $id; + } + } + else { + $new .= ' &' . $id; + } + next; + }; + s/^(.)// && do {$new .= $1; next;}; + } +} +############################################################################## + + # These next few lines are legal in both Perl and nroff. + +.00; # finish .ig + +'di \" finish diversion--previous line must be blank +.nr nl 0-1 \" fake up transition to first page again +.nr % 0 \" start at page 1 +'; __END__ ############# From here on it's a standard manual page ############ +.TH H2PH 1 "August 8, 1990" +.AT 3 +.SH NAME +h2ph \- convert .h C header files to .ph Perl header files +.SH SYNOPSIS +.B h2ph [headerfiles] +.SH DESCRIPTION +.I h2ph +converts any C header files specified to the corresponding Perl header file +format. +It is most easily run while in /usr/include: +.nf + + cd /usr/include; h2ph * sys/* + +.fi +If run with no arguments, filters standard input to standard output. +.SH ENVIRONMENT +No environment variables are used. +.SH FILES +/usr/include/*.h +.br +/usr/include/sys/*.h +.br +etc. +.SH AUTHOR +Larry Wall +.SH "SEE ALSO" +perl(1) +.SH DIAGNOSTICS +The usual warnings if it can't read or write the files involved. +.SH BUGS +Doesn't construct the %sizeof array for you. +.PP +It doesn't handle all C constructs, but it does attempt to isolate +definitions inside evals so that you can get at the definitions +that it can translate. +.PP +It's only intended as a rough tool. +You may need to dicker with the files produced. +.ex diff --git a/gnu/usr.bin/perl/x2p/h2ph.1 b/gnu/usr.bin/perl/x2p/h2ph.1 new file mode 100755 index 0000000..f093626 --- /dev/null +++ b/gnu/usr.bin/perl/x2p/h2ph.1 @@ -0,0 +1,253 @@ +#!/usr/gnu/bin/perl +'di'; +'ig00'; + +$perlincl = '/usr/gnu/lib/perl'; + +chdir '/usr/include' || die "Can't cd /usr/include"; + +@isatype = split(' ',<<END); + char uchar u_char + short ushort u_short + int uint u_int + long ulong u_long + FILE +END + +@isatype{@isatype} = (1) x @isatype; + +@ARGV = ('-') unless @ARGV; + +foreach $file (@ARGV) { + if ($file eq '-') { + open(IN, "-"); + open(OUT, ">-"); + } + else { + ($outfile = $file) =~ s/\.h$/.ph/ || next; + print "$file -> $outfile\n"; + if ($file =~ m|^(.*)/|) { + $dir = $1; + if (!-d "$perlincl/$dir") { + mkdir("$perlincl/$dir",0777); + } + } + open(IN,"$file") || ((warn "Can't open $file: $!\n"),next); + open(OUT,">$perlincl/$outfile") || die "Can't create $outfile: $!\n"; + } + while (<IN>) { + chop; + while (/\\$/) { + chop; + $_ .= <IN>; + chop; + } + if (s:/\*:\200:g) { + s:\*/:\201:g; + s/\200[^\201]*\201//g; # delete single line comments + if (s/\200.*//) { # begin multi-line comment? + $_ .= '/*'; + $_ .= <IN>; + redo; + } + } + if (s/^#\s*//) { + if (s/^define\s+(\w+)//) { + $name = $1; + $new = ''; + s/\s+$//; + if (s/^\(([\w,\s]*)\)//) { + $args = $1; + if ($args ne '') { + foreach $arg (split(/,\s*/,$args)) { + $arg =~ s/^\s*([^\s].*[^\s])\s*$/$1/; + $curargs{$arg} = 1; + } + $args =~ s/\b(\w)/\$$1/g; + $args = "local($args) = \@_;\n$t "; + } + s/^\s+//; + do expr(); + $new =~ s/(["\\])/\\$1/g; + if ($t ne '') { + $new =~ s/(['\\])/\\$1/g; + print OUT $t, + "eval 'sub $name {\n$t ${args}eval \"$new\";\n$t}';\n"; + } + else { + print OUT "sub $name {\n ${args}eval \"$new\";\n}\n"; + } + %curargs = (); + } + else { + s/^\s+//; + do expr(); + $new = 1 if $new eq ''; + if ($t ne '') { + $new =~ s/(['\\])/\\$1/g; + print OUT $t,"eval 'sub $name {",$new,";}';\n"; + } + else { + print OUT $t,"sub $name {",$new,";}\n"; + } + } + } + elsif (/^include\s+<(.*)>/) { + ($incl = $1) =~ s/\.h$/.ph/; + print OUT $t,"require '$incl';\n"; + } + elsif (/^ifdef\s+(\w+)/) { + print OUT $t,"if (defined &$1) {\n"; + $tab += 4; + $t = "\t" x ($tab / 8) . ' ' x ($tab % 8); + } + elsif (/^ifndef\s+(\w+)/) { + print OUT $t,"if (!defined &$1) {\n"; + $tab += 4; + $t = "\t" x ($tab / 8) . ' ' x ($tab % 8); + } + elsif (s/^if\s+//) { + $new = ''; + do expr(); + print OUT $t,"if ($new) {\n"; + $tab += 4; + $t = "\t" x ($tab / 8) . ' ' x ($tab % 8); + } + elsif (s/^elif\s+//) { + $new = ''; + do expr(); + $tab -= 4; + $t = "\t" x ($tab / 8) . ' ' x ($tab % 8); + print OUT $t,"}\n${t}elsif ($new) {\n"; + $tab += 4; + $t = "\t" x ($tab / 8) . ' ' x ($tab % 8); + } + elsif (/^else/) { + $tab -= 4; + $t = "\t" x ($tab / 8) . ' ' x ($tab % 8); + print OUT $t,"}\n${t}else {\n"; + $tab += 4; + $t = "\t" x ($tab / 8) . ' ' x ($tab % 8); + } + elsif (/^endif/) { + $tab -= 4; + $t = "\t" x ($tab / 8) . ' ' x ($tab % 8); + print OUT $t,"}\n"; + } + } + } + print OUT "1;\n"; +} + +sub expr { + while ($_ ne '') { + s/^(\s+)// && do {$new .= ' '; next;}; + s/^(0x[0-9a-fA-F]+)// && do {$new .= $1; next;}; + s/^(\d+)// && do {$new .= $1; next;}; + s/^("(\\"|[^"])*")// && do {$new .= $1; next;}; + s/^'((\\"|[^"])*)'// && do { + if ($curargs{$1}) { + $new .= "ord('\$$1')"; + } + else { + $new .= "ord('$1')"; + } + next; + }; + s/^sizeof\s*\(([^)]+)\)/{$1}/ && do { + $new .= '$sizeof'; + next; + }; + s/^([_a-zA-Z]\w*)// && do { + $id = $1; + if ($id eq 'struct') { + s/^\s+(\w+)//; + $id .= ' ' . $1; + $isatype{$id} = 1; + } + elsif ($id eq 'unsigned') { + s/^\s+(\w+)//; + $id .= ' ' . $1; + $isatype{$id} = 1; + } + if ($curargs{$id}) { + $new .= '$' . $id; + } + elsif ($id eq 'defined') { + $new .= 'defined'; + } + elsif (/^\(/) { + s/^\((\w),/("$1",/ if $id =~ /^_IO[WR]*$/i; # cheat + $new .= " &$id"; + } + elsif ($isatype{$id}) { + if ($new =~ /{\s*$/) { + $new .= "'$id'"; + } + elsif ($new =~ /\(\s*$/ && /^[\s*]*\)/) { + $new =~ s/\(\s*$//; + s/^[\s*]*\)//; + } + else { + $new .= $id; + } + } + else { + $new .= ' &' . $id; + } + next; + }; + s/^(.)// && do {$new .= $1; next;}; + } +} +############################################################################## + + # These next few lines are legal in both Perl and nroff. + +.00; # finish .ig + +'di \" finish diversion--previous line must be blank +.nr nl 0-1 \" fake up transition to first page again +.nr % 0 \" start at page 1 +'; __END__ ############# From here on it's a standard manual page ############ +.TH H2PH 1 "August 8, 1990" +.AT 3 +.SH NAME +h2ph \- convert .h C header files to .ph Perl header files +.SH SYNOPSIS +.B h2ph [headerfiles] +.SH DESCRIPTION +.I h2ph +converts any C header files specified to the corresponding Perl header file +format. +It is most easily run while in /usr/include: +.nf + + cd /usr/include; h2ph * sys/* + +.fi +If run with no arguments, filters standard input to standard output. +.SH ENVIRONMENT +No environment variables are used. +.SH FILES +/usr/include/*.h +.br +/usr/include/sys/*.h +.br +etc. +.SH AUTHOR +Larry Wall +.SH "SEE ALSO" +perl(1) +.SH DIAGNOSTICS +The usual warnings if it can't read or write the files involved. +.SH BUGS +Doesn't construct the %sizeof array for you. +.PP +It doesn't handle all C constructs, but it does attempt to isolate +definitions inside evals so that you can get at the definitions +that it can translate. +.PP +It's only intended as a rough tool. +You may need to dicker with the files produced. +.ex diff --git a/gnu/usr.bin/perl/x2p/handy.h b/gnu/usr.bin/perl/x2p/handy.h new file mode 100644 index 0000000..85a777c --- /dev/null +++ b/gnu/usr.bin/perl/x2p/handy.h @@ -0,0 +1,46 @@ +/* $RCSfile: handy.h,v $$Revision: 1.1.1.1 $$Date: 1993/08/23 21:30:10 $ + * + * Copyright (c) 1991, 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: handy.h,v $ + * Revision 1.1.1.1 1993/08/23 21:30:10 nate + * PERL! + * + * Revision 4.0.1.2 91/06/07 12:15:43 lwall + * patch4: new copyright notice + * + * Revision 4.0.1.1 91/04/12 09:29:08 lwall + * patch1: random cleanup in cpp namespace + * + * Revision 4.0 91/03/20 01:57:45 lwall + * 4.0 baseline. + * + */ + +#define Null(type) ((type)0) +#define Nullch Null(char*) +#define Nullfp Null(FILE*) + +#define bool char +#ifdef TRUE +#undef TRUE +#endif +#ifdef FALSE +#undef FALSE +#endif +#define TRUE (1) +#define FALSE (0) + +#define Ctl(ch) (ch & 037) + +#define strNE(s1,s2) (strcmp(s1,s2)) +#define strEQ(s1,s2) (!strcmp(s1,s2)) +#define strLT(s1,s2) (strcmp(s1,s2) < 0) +#define strLE(s1,s2) (strcmp(s1,s2) <= 0) +#define strGT(s1,s2) (strcmp(s1,s2) > 0) +#define strGE(s1,s2) (strcmp(s1,s2) >= 0) +#define strnNE(s1,s2,l) (strncmp(s1,s2,l)) +#define strnEQ(s1,s2,l) (!strncmp(s1,s2,l)) diff --git a/gnu/usr.bin/perl/x2p/hash.c b/gnu/usr.bin/perl/x2p/hash.c new file mode 100644 index 0000000..d525882 --- /dev/null +++ b/gnu/usr.bin/perl/x2p/hash.c @@ -0,0 +1,250 @@ +/* $RCSfile: hash.c,v $$Revision: 1.1.1.1 $$Date: 1993/08/23 21:30:10 $ + * + * Copyright (c) 1991, 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: hash.c,v $ + * Revision 1.1.1.1 1993/08/23 21:30:10 nate + * PERL! + * + * Revision 4.0.1.1 91/06/07 12:15:55 lwall + * patch4: new copyright notice + * + * Revision 4.0 91/03/20 01:57:49 lwall + * 4.0 baseline. + * + */ + +#include <stdio.h> +#include "EXTERN.h" +#include "handy.h" +#include "util.h" +#include "a2p.h" + +STR * +hfetch(tb,key) +register HASH *tb; +char *key; +{ + register char *s; + register int i; + register int hash; + register HENT *entry; + + if (!tb) + return Nullstr; + for (s=key, i=0, hash = 0; + /* while */ *s; + s++, i++, hash *= 5) { + hash += *s * coeff[i]; + } + entry = tb->tbl_array[hash & tb->tbl_max]; + for (; entry; entry = entry->hent_next) { + if (entry->hent_hash != hash) /* strings can't be equal */ + continue; + if (strNE(entry->hent_key,key)) /* is this it? */ + continue; + return entry->hent_val; + } + return Nullstr; +} + +bool +hstore(tb,key,val) +register HASH *tb; +char *key; +STR *val; +{ + register char *s; + register int i; + register int hash; + register HENT *entry; + register HENT **oentry; + + if (!tb) + return FALSE; + for (s=key, i=0, hash = 0; + /* while */ *s; + s++, i++, hash *= 5) { + hash += *s * coeff[i]; + } + + oentry = &(tb->tbl_array[hash & tb->tbl_max]); + i = 1; + + for (entry = *oentry; entry; i=0, entry = entry->hent_next) { + if (entry->hent_hash != hash) /* strings can't be equal */ + continue; + if (strNE(entry->hent_key,key)) /* is this it? */ + continue; + /*NOSTRICT*/ + safefree((char*)entry->hent_val); + entry->hent_val = val; + return TRUE; + } + /*NOSTRICT*/ + entry = (HENT*) safemalloc(sizeof(HENT)); + + entry->hent_key = savestr(key); + entry->hent_val = val; + entry->hent_hash = hash; + entry->hent_next = *oentry; + *oentry = entry; + + if (i) { /* initial entry? */ + tb->tbl_fill++; + if ((tb->tbl_fill * 100 / (tb->tbl_max + 1)) > FILLPCT) + hsplit(tb); + } + + return FALSE; +} + +#ifdef NOTUSED +bool +hdelete(tb,key) +register HASH *tb; +char *key; +{ + register char *s; + register int i; + register int hash; + register HENT *entry; + register HENT **oentry; + + if (!tb) + return FALSE; + for (s=key, i=0, hash = 0; + /* while */ *s; + s++, i++, hash *= 5) { + hash += *s * coeff[i]; + } + + oentry = &(tb->tbl_array[hash & tb->tbl_max]); + entry = *oentry; + i = 1; + for (; entry; i=0, oentry = &entry->hent_next, entry = entry->hent_next) { + if (entry->hent_hash != hash) /* strings can't be equal */ + continue; + if (strNE(entry->hent_key,key)) /* is this it? */ + continue; + safefree((char*)entry->hent_val); + safefree(entry->hent_key); + *oentry = entry->hent_next; + safefree((char*)entry); + if (i) + tb->tbl_fill--; + return TRUE; + } + return FALSE; +} +#endif + +hsplit(tb) +HASH *tb; +{ + int oldsize = tb->tbl_max + 1; + register int newsize = oldsize * 2; + register int i; + register HENT **a; + register HENT **b; + register HENT *entry; + register HENT **oentry; + + a = (HENT**) saferealloc((char*)tb->tbl_array, newsize * sizeof(HENT*)); + bzero((char*)&a[oldsize], oldsize * sizeof(HENT*)); /* zero second half */ + tb->tbl_max = --newsize; + tb->tbl_array = a; + + for (i=0; i<oldsize; i++,a++) { + if (!*a) /* non-existent */ + continue; + b = a+oldsize; + for (oentry = a, entry = *a; entry; entry = *oentry) { + if ((entry->hent_hash & newsize) != i) { + *oentry = entry->hent_next; + entry->hent_next = *b; + if (!*b) + tb->tbl_fill++; + *b = entry; + continue; + } + else + oentry = &entry->hent_next; + } + if (!*a) /* everything moved */ + tb->tbl_fill--; + } +} + +HASH * +hnew() +{ + register HASH *tb = (HASH*)safemalloc(sizeof(HASH)); + + tb->tbl_array = (HENT**) safemalloc(8 * sizeof(HENT*)); + tb->tbl_fill = 0; + tb->tbl_max = 7; + hiterinit(tb); /* so each() will start off right */ + bzero((char*)tb->tbl_array, 8 * sizeof(HENT*)); + return tb; +} + +#ifdef NOTUSED +hshow(tb) +register HASH *tb; +{ + fprintf(stderr,"%5d %4d (%2d%%)\n", + tb->tbl_max+1, + tb->tbl_fill, + tb->tbl_fill * 100 / (tb->tbl_max+1)); +} +#endif + +hiterinit(tb) +register HASH *tb; +{ + tb->tbl_riter = -1; + tb->tbl_eiter = Null(HENT*); + return tb->tbl_fill; +} + +HENT * +hiternext(tb) +register HASH *tb; +{ + register HENT *entry; + + entry = tb->tbl_eiter; + do { + if (entry) + entry = entry->hent_next; + if (!entry) { + tb->tbl_riter++; + if (tb->tbl_riter > tb->tbl_max) { + tb->tbl_riter = -1; + break; + } + entry = tb->tbl_array[tb->tbl_riter]; + } + } while (!entry); + + tb->tbl_eiter = entry; + return entry; +} + +char * +hiterkey(entry) +register HENT *entry; +{ + return entry->hent_key; +} + +STR * +hiterval(entry) +register HENT *entry; +{ + return entry->hent_val; +} diff --git a/gnu/usr.bin/perl/x2p/hash.h b/gnu/usr.bin/perl/x2p/hash.h new file mode 100644 index 0000000..ae4ffaf --- /dev/null +++ b/gnu/usr.bin/perl/x2p/hash.h @@ -0,0 +1,60 @@ +/* $RCSfile: hash.h,v $$Revision: 1.1.1.1 $$Date: 1993/08/23 21:30:10 $ + * + * Copyright (c) 1991, 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: hash.h,v $ + * Revision 1.1.1.1 1993/08/23 21:30:10 nate + * PERL! + * + * Revision 4.0.1.1 91/06/07 12:16:04 lwall + * patch4: new copyright notice + * + * Revision 4.0 91/03/20 01:57:53 lwall + * 4.0 baseline. + * + */ + +#define FILLPCT 60 /* don't make greater than 99 */ + +#ifdef DOINIT +char coeff[] = { + 61,59,53,47,43,41,37,31,29,23,17,13,11,7,3,1, + 61,59,53,47,43,41,37,31,29,23,17,13,11,7,3,1, + 61,59,53,47,43,41,37,31,29,23,17,13,11,7,3,1, + 61,59,53,47,43,41,37,31,29,23,17,13,11,7,3,1, + 61,59,53,47,43,41,37,31,29,23,17,13,11,7,3,1, + 61,59,53,47,43,41,37,31,29,23,17,13,11,7,3,1, + 61,59,53,47,43,41,37,31,29,23,17,13,11,7,3,1, + 61,59,53,47,43,41,37,31,29,23,17,13,11,7,3,1}; +#else +extern char coeff[]; +#endif + +typedef struct hentry HENT; + +struct hentry { + HENT *hent_next; + char *hent_key; + STR *hent_val; + int hent_hash; +}; + +struct htbl { + HENT **tbl_array; + int tbl_max; + int tbl_fill; + int tbl_riter; /* current root of iterator */ + HENT *tbl_eiter; /* current entry of iterator */ +}; + +STR *hfetch(); +bool hstore(); +bool hdelete(); +HASH *hnew(); +int hiterinit(); +HENT *hiternext(); +char *hiterkey(); +STR *hiterval(); diff --git a/gnu/usr.bin/perl/x2p/malloc.c b/gnu/usr.bin/perl/x2p/malloc.c new file mode 100644 index 0000000..dd43390 --- /dev/null +++ b/gnu/usr.bin/perl/x2p/malloc.c @@ -0,0 +1,513 @@ +/* $RCSfile: malloc.c,v $$Revision: 1.2 $$Date: 1993/08/24 17:57:39 $ + * + * $Log: malloc.c,v $ + * Revision 1.2 1993/08/24 17:57:39 nate + * Fix for ALIGN macros in PERL that conflict with 4.4 macros + * + * Revision 1.1.1.1 1993/08/23 21:30:11 nate + * PERL! + * + * Revision 4.0.1.4 92/06/08 14:28:38 lwall + * patch20: removed implicit int declarations on functions + * patch20: hash tables now split only if the memory is available to do so + * patch20: realloc(0, size) now does malloc in case library routines call it + * + * Revision 4.0.1.3 91/11/05 17:57:40 lwall + * patch11: safe malloc code now integrated into Perl's malloc when possible + * + * Revision 4.0.1.2 91/06/07 11:20:45 lwall + * patch4: many, many itty-bitty portability fixes + * + * Revision 4.0.1.1 91/04/11 17:48:31 lwall + * patch1: Configure now figures out malloc ptr type + * + * Revision 4.0 91/03/20 01:28:52 lwall + * 4.0 baseline. + * + */ + +#ifndef lint +/*SUPPRESS 592*/ +static char sccsid[] = "@(#)malloc.c 4.3 (Berkeley) 9/16/83"; + +#ifdef DEBUGGING +#define RCHECK +#endif +/* + * malloc.c (Caltech) 2/21/82 + * Chris Kingsley, kingsley@cit-20. + * + * This is a very fast storage allocator. It allocates blocks of a small + * number of different sizes, and keeps free lists of each size. Blocks that + * don't exactly fit are passed up to the next larger size. In this + * implementation, the available sizes are 2^n-4 (or 2^n-12) bytes long. + * This is designed for use in a program that uses vast quantities of memory, + * but bombs when it runs out. + */ + +#include "EXTERN.h" +#include "../perl.h" + +static findbucket(), morecore(); + +/* I don't much care whether these are defined in sys/types.h--LAW */ + +#define u_char unsigned char +#define u_int unsigned int +#define u_short unsigned short + +/* + * The overhead on a block is at least 4 bytes. When free, this space + * contains a pointer to the next free block, and the bottom two bits must + * be zero. When in use, the first byte is set to MAGIC, and the second + * byte is the size index. The remaining bytes are for alignment. + * If range checking is enabled and the size of the block fits + * in two bytes, then the top two bytes hold the size of the requested block + * plus the range checking words, and the header word MINUS ONE. + */ +union overhead { + union overhead *ov_next; /* when free */ +#if ALIGN_BYTES > 4 + double strut; /* alignment problems */ +#endif + struct { + u_char ovu_magic; /* magic number */ + u_char ovu_index; /* bucket # */ +#ifdef RCHECK + u_short ovu_size; /* actual block size */ + u_int ovu_rmagic; /* range magic number */ +#endif + } ovu; +#define ov_magic ovu.ovu_magic +#define ov_index ovu.ovu_index +#define ov_size ovu.ovu_size +#define ov_rmagic ovu.ovu_rmagic +}; + +#define MAGIC 0xff /* magic # on accounting info */ +#define OLDMAGIC 0x7f /* same after a free() */ +#define RMAGIC 0x55555555 /* magic # on range info */ +#ifdef RCHECK +#define RSLOP sizeof (u_int) +#else +#define RSLOP 0 +#endif + +/* + * nextf[i] is the pointer to the next free block of size 2^(i+3). The + * smallest allocatable block is 8 bytes. The overhead information + * precedes the data area returned to the user. + */ +#define NBUCKETS 30 +static union overhead *nextf[NBUCKETS]; +extern char *sbrk(); + +#ifdef MSTATS +/* + * nmalloc[i] is the difference between the number of mallocs and frees + * for a given block size. + */ +static u_int nmalloc[NBUCKETS]; +#include <stdio.h> +#endif + +#ifdef debug +#define ASSERT(p) if (!(p)) botch("p"); else +static void +botch(s) + char *s; +{ + + printf("assertion botched: %s\n", s); + abort(); +} +#else +#define ASSERT(p) +#endif + +#ifdef safemalloc +static int an = 0; +#endif + +MALLOCPTRTYPE * +malloc(nbytes) + register MEM_SIZE nbytes; +{ + register union overhead *p; + register int bucket = 0; + register MEM_SIZE shiftr; + +#ifdef safemalloc +#ifdef DEBUGGING + MEM_SIZE size = nbytes; +#endif + +#ifdef MSDOS + if (nbytes > 0xffff) { + fprintf(stderr, "Allocation too large: %lx\n", (long)nbytes); + exit(1); + } +#endif /* MSDOS */ +#ifdef DEBUGGING + if ((long)nbytes < 0) + fatal("panic: malloc"); +#endif +#endif /* safemalloc */ + + /* + * Convert amount of memory requested into + * closest block size stored in hash buckets + * which satisfies request. Account for + * space used per block for accounting. + */ + nbytes += sizeof (union overhead) + RSLOP; + nbytes = (nbytes + 3) &~ 3; + shiftr = (nbytes - 1) >> 2; + /* apart from this loop, this is O(1) */ + while (shiftr >>= 1) + bucket++; + /* + * If nothing in hash bucket right now, + * request more memory from the system. + */ + if (nextf[bucket] == NULL) + morecore(bucket); + if ((p = (union overhead *)nextf[bucket]) == NULL) { +#ifdef safemalloc + if (!nomemok) { + fputs("Out of memory!\n", stderr); + exit(1); + } +#else + return (NULL); +#endif + } + +#ifdef safemalloc +#ifdef DEBUGGING +# if !(defined(I286) || defined(atarist)) + if (debug & 128) + fprintf(stderr,"0x%x: (%05d) malloc %ld bytes\n",p+1,an++,(long)size); +# else + if (debug & 128) + fprintf(stderr,"0x%lx: (%05d) malloc %ld bytes\n",p+1,an++,(long)size); +# endif +#endif +#endif /* safemalloc */ + + /* remove from linked list */ +#ifdef RCHECK + if (*((int*)p) & (sizeof(union overhead) - 1)) +#if !(defined(I286) || defined(atarist)) + fprintf(stderr,"Corrupt malloc ptr 0x%x at 0x%x\n",*((int*)p),p); +#else + fprintf(stderr,"Corrupt malloc ptr 0x%lx at 0x%lx\n",*((int*)p),p); +#endif +#endif + nextf[bucket] = p->ov_next; + p->ov_magic = MAGIC; + p->ov_index= bucket; +#ifdef MSTATS + nmalloc[bucket]++; +#endif +#ifdef RCHECK + /* + * Record allocated size of block and + * bound space with magic numbers. + */ + if (nbytes <= 0x10000) + p->ov_size = nbytes - 1; + p->ov_rmagic = RMAGIC; + *((u_int *)((caddr_t)p + nbytes - RSLOP)) = RMAGIC; +#endif + return ((MALLOCPTRTYPE *)(p + 1)); +} + +/* + * Allocate more memory to the indicated bucket. + */ +static +morecore(bucket) + register int bucket; +{ + register union overhead *op; + register int rnu; /* 2^rnu bytes will be requested */ + register int nblks; /* become nblks blocks of the desired size */ + register MEM_SIZE siz; + + if (nextf[bucket]) + return; + /* + * Insure memory is allocated + * on a page boundary. Should + * make getpageize call? + */ +#ifndef atarist /* on the atari we dont have to worry about this */ + op = (union overhead *)sbrk(0); +#ifndef I286 + if ((int)op & 0x3ff) + (void)sbrk(1024 - ((int)op & 0x3ff)); +#else + /* The sbrk(0) call on the I286 always returns the next segment */ +#endif +#endif /* atarist */ + +#if !(defined(I286) || defined(atarist)) + /* take 2k unless the block is bigger than that */ + rnu = (bucket <= 8) ? 11 : bucket + 3; +#else + /* take 16k unless the block is bigger than that + (80286s like large segments!), probably good on the atari too */ + rnu = (bucket <= 11) ? 14 : bucket + 3; +#endif + nblks = 1 << (rnu - (bucket + 3)); /* how many blocks to get */ + if (rnu < bucket) + rnu = bucket; + op = (union overhead *)sbrk(1L << rnu); + /* no more room! */ + if ((int)op == -1) + return; + /* + * Round up to minimum allocation size boundary + * and deduct from block count to reflect. + */ +#ifndef I286 + if ((int)op & 7) { + op = (union overhead *)(((MEM_SIZE)op + 8) &~ 7); + nblks--; + } +#else + /* Again, this should always be ok on an 80286 */ +#endif + /* + * Add new memory allocated to that on + * free list for this hash bucket. + */ + nextf[bucket] = op; + siz = 1 << (bucket + 3); + while (--nblks > 0) { + op->ov_next = (union overhead *)((caddr_t)op + siz); + op = (union overhead *)((caddr_t)op + siz); + } +} + +void +free(mp) + MALLOCPTRTYPE *mp; +{ + register MEM_SIZE size; + register union overhead *op; + char *cp = (char*)mp; + +#ifdef safemalloc +#ifdef DEBUGGING +# if !(defined(I286) || defined(atarist)) + if (debug & 128) + fprintf(stderr,"0x%x: (%05d) free\n",cp,an++); +# else + if (debug & 128) + fprintf(stderr,"0x%lx: (%05d) free\n",cp,an++); +# endif +#endif +#endif /* safemalloc */ + + if (cp == NULL) + return; + op = (union overhead *)((caddr_t)cp - sizeof (union overhead)); +#ifdef debug + ASSERT(op->ov_magic == MAGIC); /* make sure it was in use */ +#else + if (op->ov_magic != MAGIC) { + warn("%s free() ignored", + op->ov_magic == OLDMAGIC ? "Duplicate" : "Bad"); + return; /* sanity */ + } + op->ov_magic = OLDMAGIC; +#endif +#ifdef RCHECK + ASSERT(op->ov_rmagic == RMAGIC); + if (op->ov_index <= 13) + ASSERT(*(u_int *)((caddr_t)op + op->ov_size + 1 - RSLOP) == RMAGIC); +#endif + ASSERT(op->ov_index < NBUCKETS); + size = op->ov_index; + op->ov_next = nextf[size]; + nextf[size] = op; +#ifdef MSTATS + nmalloc[size]--; +#endif +} + +/* + * When a program attempts "storage compaction" as mentioned in the + * old malloc man page, it realloc's an already freed block. Usually + * this is the last block it freed; occasionally it might be farther + * back. We have to search all the free lists for the block in order + * to determine its bucket: 1st we make one pass thru the lists + * checking only the first block in each; if that fails we search + * ``reall_srchlen'' blocks in each list for a match (the variable + * is extern so the caller can modify it). If that fails we just copy + * however many bytes was given to realloc() and hope it's not huge. + */ +int reall_srchlen = 4; /* 4 should be plenty, -1 =>'s whole list */ + +MALLOCPTRTYPE * +realloc(mp, nbytes) + MALLOCPTRTYPE *mp; + MEM_SIZE nbytes; +{ + register MEM_SIZE onb; + union overhead *op; + char *res; + register int i; + int was_alloced = 0; + char *cp = (char*)mp; + +#ifdef safemalloc +#ifdef DEBUGGING + MEM_SIZE size = nbytes; +#endif + +#ifdef MSDOS + if (nbytes > 0xffff) { + fprintf(stderr, "Reallocation too large: %lx\n", size); + exit(1); + } +#endif /* MSDOS */ + if (!cp) + return malloc(nbytes); +#ifdef DEBUGGING + if ((long)nbytes < 0) + fatal("panic: realloc"); +#endif +#endif /* safemalloc */ + + op = (union overhead *)((caddr_t)cp - sizeof (union overhead)); + if (op->ov_magic == MAGIC) { + was_alloced++; + i = op->ov_index; + } else { + /* + * Already free, doing "compaction". + * + * Search for the old block of memory on the + * free list. First, check the most common + * case (last element free'd), then (this failing) + * the last ``reall_srchlen'' items free'd. + * If all lookups fail, then assume the size of + * the memory block being realloc'd is the + * smallest possible. + */ + if ((i = findbucket(op, 1)) < 0 && + (i = findbucket(op, reall_srchlen)) < 0) + i = 0; + } + onb = (1L << (i + 3)) - sizeof (*op) - RSLOP; + /* avoid the copy if same size block */ + if (was_alloced && + nbytes <= onb && nbytes > (onb >> 1) - sizeof(*op) - RSLOP) { +#ifdef RCHECK + /* + * Record new allocated size of block and + * bound space with magic numbers. + */ + if (op->ov_index <= 13) { + /* + * Convert amount of memory requested into + * closest block size stored in hash buckets + * which satisfies request. Account for + * space used per block for accounting. + */ + nbytes += sizeof (union overhead) + RSLOP; + nbytes = (nbytes + 3) &~ 3; + op->ov_size = nbytes - 1; + *((u_int *)((caddr_t)op + nbytes - RSLOP)) = RMAGIC; + } +#endif + res = cp; + } + else { + if ((res = (char*)malloc(nbytes)) == NULL) + return (NULL); + if (cp != res) /* common optimization */ + Copy(cp, res, (MEM_SIZE)(nbytes<onb?nbytes:onb), char); + if (was_alloced) + free(cp); + } + +#ifdef safemalloc +#ifdef DEBUGGING +# if !(defined(I286) || defined(atarist)) + if (debug & 128) { + fprintf(stderr,"0x%x: (%05d) rfree\n",res,an++); + fprintf(stderr,"0x%x: (%05d) realloc %ld bytes\n",res,an++,(long)size); + } +# else + if (debug & 128) { + fprintf(stderr,"0x%lx: (%05d) rfree\n",res,an++); + fprintf(stderr,"0x%lx: (%05d) realloc %ld bytes\n",res,an++,(long)size); + } +# endif +#endif +#endif /* safemalloc */ + return ((MALLOCPTRTYPE*)res); +} + +/* + * Search ``srchlen'' elements of each free list for a block whose + * header starts at ``freep''. If srchlen is -1 search the whole list. + * Return bucket number, or -1 if not found. + */ +static int +findbucket(freep, srchlen) + union overhead *freep; + int srchlen; +{ + register union overhead *p; + register int i, j; + + for (i = 0; i < NBUCKETS; i++) { + j = 0; + for (p = nextf[i]; p && j != srchlen; p = p->ov_next) { + if (p == freep) + return (i); + j++; + } + } + return (-1); +} + +#ifdef MSTATS +/* + * mstats - print out statistics about malloc + * + * Prints two lines of numbers, one showing the length of the free list + * for each size category, the second showing the number of mallocs - + * frees for each size category. + */ +void +mstats(s) + char *s; +{ + register int i, j; + register union overhead *p; + int totfree = 0, + totused = 0; + + fprintf(stderr, "Memory allocation statistics %s\nfree:\t", s); + for (i = 0; i < NBUCKETS; i++) { + for (j = 0, p = nextf[i]; p; p = p->ov_next, j++) + ; + fprintf(stderr, " %d", j); + totfree += j * (1 << (i + 3)); + } + fprintf(stderr, "\nused:\t"); + for (i = 0; i < NBUCKETS; i++) { + fprintf(stderr, " %d", nmalloc[i]); + totused += nmalloc[i] * (1 << (i + 3)); + } + fprintf(stderr, "\n\tTotal in use: %d, total free: %d\n", + totused, totfree); +} +#endif +#endif /* lint */ diff --git a/gnu/usr.bin/perl/x2p/s2p b/gnu/usr.bin/perl/x2p/s2p new file mode 100755 index 0000000..8a8a74c --- /dev/null +++ b/gnu/usr.bin/perl/x2p/s2p @@ -0,0 +1,766 @@ +#!/usr/gnu/bin/perl + +eval 'exec /usr/gnu/bin/perl -S $0 ${1+"$@"}' + if $running_under_some_shell; + +$bin = '/usr/gnu/bin'; + +# $RCSfile: s2p,v $$Revision: 1.2 $$Date: 1994/03/05 01:28:48 $ +# +# $Log: s2p,v $ +# Revision 1.2 1994/03/05 01:28:48 ache +# 1) Perl uses scrambler crypt() version from libc instead of proper one +# from -lcrypt (if exist) +# 2) We have now all sem/shm/msg stuff, add it to perl too +# +# Revision 1.1.1.1 1993/08/23 21:30:10 nate +# PERL! +# +# Revision 4.0.1.2 92/06/08 17:26:31 lwall +# patch20: s2p didn't output portable startup code +# patch20: added ... as variant on .. +# patch20: s2p didn't translate s/pat/\&/ or s/pat/\$/ or s/pat/\\1/ right +# +# Revision 4.0.1.1 91/06/07 12:19:18 lwall +# patch4: s2p now handles embedded newlines better and optimizes common idioms +# +# Revision 4.0 91/03/20 01:57:59 lwall +# 4.0 baseline. +# +# + +$indent = 4; +$shiftwidth = 4; +$l = '{'; $r = '}'; + +while ($ARGV[0] =~ /^-/) { + $_ = shift; + last if /^--/; + if (/^-D/) { + $debug++; + open(BODY,'>-'); + next; + } + if (/^-n/) { + $assumen++; + next; + } + if (/^-p/) { + $assumep++; + next; + } + die "I don't recognize this switch: $_\n"; +} + +unless ($debug) { + open(BODY,">/tmp/sperl$$") || + &Die("Can't open temp file: $!\n"); +} + +if (!$assumen && !$assumep) { + print BODY &q(<<'EOT'); +: while ($ARGV[0] =~ /^-/) { +: $_ = shift; +: last if /^--/; +: if (/^-n/) { +: $nflag++; +: next; +: } +: die "I don't recognize this switch: $_\\n"; +: } +: +EOT +} + +print BODY &q(<<'EOT'); +: #ifdef PRINTIT +: #ifdef ASSUMEP +: $printit++; +: #else +: $printit++ unless $nflag; +: #endif +: #endif +: <><> +: $\ = "\n"; # automatically add newline on print +: <><> +: #ifdef TOPLABEL +: LINE: +: while (chop($_ = <>)) { +: #else +: LINE: +: while (<>) { +: chop; +: #endif +EOT + +LINE: +while (<>) { + + # Wipe out surrounding whitespace. + + s/[ \t]*(.*)\n$/$1/; + + # Perhaps it's a label/comment. + + if (/^:/) { + s/^:[ \t]*//; + $label = &make_label($_); + if ($. == 1) { + $toplabel = $label; + if (/^(top|(re)?start|redo|begin(ning)|again|input)$/i) { + $_ = <>; + redo LINE; # Never referenced, so delete it if not a comment. + } + } + $_ = "$label:"; + if ($lastlinewaslabel++) { + $indent += 4; + print BODY &tab, ";\n"; + $indent -= 4; + } + if ($indent >= 2) { + $indent -= 2; + $indmod = 2; + } + next; + } else { + $lastlinewaslabel = ''; + } + + # Look for one or two address clauses + + $addr1 = ''; + $addr2 = ''; + if (s/^([0-9]+)//) { + $addr1 = "$1"; + $addr1 = "\$. == $addr1" unless /^,/; + } + elsif (s/^\$//) { + $addr1 = 'eof()'; + } + elsif (s|^/||) { + $addr1 = &fetchpat('/'); + } + if (s/^,//) { + if (s/^([0-9]+)//) { + $addr2 = "$1"; + } elsif (s/^\$//) { + $addr2 = "eof()"; + } elsif (s|^/||) { + $addr2 = &fetchpat('/'); + } else { + &Die("Invalid second address at line $.\n"); + } + if ($addr2 =~ /^\d+$/) { + $addr1 .= "..$addr2"; + } + else { + $addr1 .= "...$addr2"; + } + } + + # Now we check for metacommands {, }, and ! and worry + # about indentation. + + s/^[ \t]+//; + # a { to keep vi happy + if ($_ eq '}') { + $indent -= 4; + next; + } + if (s/^!//) { + $if = 'unless'; + $else = "$r else $l\n"; + } else { + $if = 'if'; + $else = ''; + } + if (s/^{//) { # a } to keep vi happy + $indmod = 4; + $redo = $_; + $_ = ''; + $rmaybe = ''; + } else { + $rmaybe = "\n$r"; + if ($addr2 || $addr1) { + $space = ' ' x $shiftwidth; + } else { + $space = ''; + } + $_ = &transmogrify(); + } + + # See if we can optimize to modifier form. + + if ($addr1) { + if ($_ !~ /[\n{}]/ && $rmaybe && !$change && + $_ !~ / if / && $_ !~ / unless /) { + s/;$/ $if $addr1;/; + $_ = substr($_,$shiftwidth,1000); + } else { + $_ = "$if ($addr1) $l\n$change$_$rmaybe"; + } + $change = ''; + next LINE; + } +} continue { + @lines = split(/\n/,$_); + for (@lines) { + unless (s/^ *<<--//) { + print BODY &tab; + } + print BODY $_, "\n"; + } + $indent += $indmod; + $indmod = 0; + if ($redo) { + $_ = $redo; + $redo = ''; + redo LINE; + } +} +if ($lastlinewaslabel++) { + $indent += 4; + print BODY &tab, ";\n"; + $indent -= 4; +} + +if ($appendseen || $tseen || !$assumen) { + $printit++ if $dseen || (!$assumen && !$assumep); + print BODY &q(<<'EOT'); +: #ifdef SAWNEXT +: } +: continue { +: #endif +: #ifdef PRINTIT +: #ifdef DSEEN +: #ifdef ASSUMEP +: print if $printit++; +: #else +: if ($printit) +: { print; } +: else +: { $printit++ unless $nflag; } +: #endif +: #else +: print if $printit; +: #endif +: #else +: print; +: #endif +: #ifdef TSEEN +: $tflag = 0; +: #endif +: #ifdef APPENDSEEN +: if ($atext) { chop $atext; print $atext; $atext = ''; } +: #endif +EOT + +print BODY &q(<<'EOT'); +: } +EOT +} + +close BODY; + +unless ($debug) { + open(HEAD,">/tmp/sperl2$$.c") + || &Die("Can't open temp file 2: $!\n"); + print HEAD "#define PRINTIT\n" if $printit; + print HEAD "#define APPENDSEEN\n" if $appendseen; + print HEAD "#define TSEEN\n" if $tseen; + print HEAD "#define DSEEN\n" if $dseen; + print HEAD "#define ASSUMEN\n" if $assumen; + print HEAD "#define ASSUMEP\n" if $assumep; + print HEAD "#define TOPLABEL\n" if $toplabel; + print HEAD "#define SAWNEXT\n" if $sawnext; + if ($opens) {print HEAD "$opens\n";} + open(BODY,"/tmp/sperl$$") + || &Die("Can't reopen temp file: $!\n"); + while (<BODY>) { + print HEAD $_; + } + close HEAD; + + print &q(<<"EOT"); +: #!$bin/perl +: eval 'exec $bin/perl -S \$0 \${1+"\$@"}' +: if \$running_under_some_shell; +: +EOT + open(BODY,"cc -E /tmp/sperl2$$.c |") || + &Die("Can't reopen temp file: $!\n"); + while (<BODY>) { + /^# [0-9]/ && next; + /^[ \t]*$/ && next; + s/^<><>//; + print; + } +} + +&Cleanup; +exit; + +sub Cleanup { + chdir "/tmp"; + unlink "sperl$$", "sperl2$$", "sperl2$$.c"; +} +sub Die { + &Cleanup; + die $_[0]; +} +sub tab { + "\t" x ($indent / 8) . ' ' x ($indent % 8); +} +sub make_filehandle { + local($_) = $_[0]; + local($fname) = $_; + if (!$seen{$fname}) { + $_ = "FH_" . $_ if /^\d/; + s/[^a-zA-Z0-9]/_/g; + s/^_*//; + $_ = "\U$_"; + if ($fhseen{$_}) { + for ($tmp = "a"; $fhseen{"$_$tmp"}; $a++) {} + $_ .= $tmp; + } + $fhseen{$_} = 1; + $opens .= &q(<<"EOT"); +: open($_, '>$fname') || die "Can't create $fname: \$!"; +EOT + $seen{$fname} = $_; + } + $seen{$fname}; +} + +sub make_label { + local($label) = @_; + $label =~ s/[^a-zA-Z0-9]/_/g; + if ($label =~ /^[0-9_]/) { $label = 'L' . $label; } + $label = substr($label,0,8); + + # Could be a reserved word, so capitalize it. + substr($label,0,1) =~ y/a-z/A-Z/ + if $label =~ /^[a-z]/; + + $label; +} + +sub transmogrify { + { # case + if (/^d/) { + $dseen++; + chop($_ = &q(<<'EOT')); +: <<--#ifdef PRINTIT +: $printit = 0; +: <<--#endif +: next LINE; +EOT + $sawnext++; + next; + } + + if (/^n/) { + chop($_ = &q(<<'EOT')); +: <<--#ifdef PRINTIT +: <<--#ifdef DSEEN +: <<--#ifdef ASSUMEP +: print if $printit++; +: <<--#else +: if ($printit) +: { print; } +: else +: { $printit++ unless $nflag; } +: <<--#endif +: <<--#else +: print if $printit; +: <<--#endif +: <<--#else +: print; +: <<--#endif +: <<--#ifdef APPENDSEEN +: if ($atext) {chop $atext; print $atext; $atext = '';} +: <<--#endif +: $_ = <>; +: chop; +: <<--#ifdef TSEEN +: $tflag = 0; +: <<--#endif +EOT + next; + } + + if (/^a/) { + $appendseen++; + $command = $space . "\$atext .= <<'End_Of_Text';\n<<--"; + $lastline = 0; + while (<>) { + s/^[ \t]*//; + s/^[\\]//; + unless (s|\\$||) { $lastline = 1;} + s/^([ \t]*\n)/<><>$1/; + $command .= $_; + $command .= '<<--'; + last if $lastline; + } + $_ = $command . "End_Of_Text"; + last; + } + + if (/^[ic]/) { + if (/^c/) { $change = 1; } + $addr1 = 1 if $addr1 eq ''; + $addr1 = '$iter = (' . $addr1 . ')'; + $command = $space . + " if (\$iter == 1) { print <<'End_Of_Text'; }\n<<--"; + $lastline = 0; + while (<>) { + s/^[ \t]*//; + s/^[\\]//; + unless (s/\\$//) { $lastline = 1;} + s/'/\\'/g; + s/^([ \t]*\n)/<><>$1/; + $command .= $_; + $command .= '<<--'; + last if $lastline; + } + $_ = $command . "End_Of_Text"; + if ($change) { + $dseen++; + $change = "$_\n"; + chop($_ = &q(<<"EOT")); +: <<--#ifdef PRINTIT +: $space\$printit = 0; +: <<--#endif +: ${space}next LINE; +EOT + $sawnext++; + } + last; + } + + if (/^s/) { + $delim = substr($_,1,1); + $len = length($_); + $repl = $end = 0; + $inbracket = 0; + for ($i = 2; $i < $len; $i++) { + $c = substr($_,$i,1); + if ($c eq $delim) { + if ($inbracket) { + substr($_, $i, 0) = '\\'; + $i++; + $len++; + } + else { + if ($repl) { + $end = $i; + last; + } else { + $repl = $i; + } + } + } + elsif ($c eq '\\') { + $i++; + if ($i >= $len) { + $_ .= 'n'; + $_ .= <>; + $len = length($_); + $_ = substr($_,0,--$len); + } + elsif (substr($_,$i,1) =~ /^[n]$/) { + ; + } + elsif (!$repl && + substr($_,$i,1) =~ /^[(){}\w]$/) { + $i--; + $len--; + substr($_, $i, 1) = ''; + } + elsif (!$repl && + substr($_,$i,1) =~ /^[<>]$/) { + substr($_,$i,1) = 'b'; + } + elsif ($repl && substr($_,$i,1) =~ /^\d$/) { + substr($_,$i-1,1) = '$'; + } + } + elsif ($c eq '&' && $repl) { + substr($_, $i, 0) = '$'; + $i++; + $len++; + } + elsif ($c eq '$' && $repl) { + substr($_, $i, 0) = '\\'; + $i++; + $len++; + } + elsif ($c eq '[' && !$repl) { + $i++ if substr($_,$i,1) eq '^'; + $i++ if substr($_,$i,1) eq ']'; + $inbracket = 1; + } + elsif ($c eq ']') { + $inbracket = 0; + } + elsif ($c eq "\t") { + substr($_, $i, 1) = '\\t'; + $i++; + $len++; + } + elsif (!$repl && index("()+",$c) >= 0) { + substr($_, $i, 0) = '\\'; + $i++; + $len++; + } + } + &Die("Malformed substitution at line $.\n") + unless $end; + $pat = substr($_, 0, $repl + 1); + $repl = substr($_, $repl+1, $end-$repl-1); + $end = substr($_, $end + 1, 1000); + &simplify($pat); + $dol = '$'; + $subst = "$pat$repl$delim"; + $cmd = ''; + while ($end) { + if ($end =~ s/^g//) { + $subst .= 'g'; + next; + } + if ($end =~ s/^p//) { + $cmd .= ' && (print)'; + next; + } + if ($end =~ s/^w[ \t]*//) { + $fh = &make_filehandle($end); + $cmd .= " && (print $fh \$_)"; + $end = ''; + next; + } + &Die("Unrecognized substitution command". + "($end) at line $.\n"); + } + chop ($_ = &q(<<"EOT")); +: <<--#ifdef TSEEN +: $subst && \$tflag++$cmd; +: <<--#else +: $subst$cmd; +: <<--#endif +EOT + next; + } + + if (/^p/) { + $_ = 'print;'; + next; + } + + if (/^w/) { + s/^w[ \t]*//; + $fh = &make_filehandle($_); + $_ = "print $fh \$_;"; + next; + } + + if (/^r/) { + $appendseen++; + s/^r[ \t]*//; + $file = $_; + $_ = "\$atext .= `cat $file 2>/dev/null`;"; + next; + } + + if (/^P/) { + $_ = 'print $1 if /^(.*)/;'; + next; + } + + if (/^D/) { + chop($_ = &q(<<'EOT')); +: s/^.*\n?//; +: redo LINE if $_; +: next LINE; +EOT + $sawnext++; + next; + } + + if (/^N/) { + chop($_ = &q(<<'EOT')); +: $_ .= "\n"; +: $len1 = length; +: $_ .= <>; +: chop if $len1 < length; +: <<--#ifdef TSEEN +: $tflag = 0; +: <<--#endif +EOT + next; + } + + if (/^h/) { + $_ = '$hold = $_;'; + next; + } + + if (/^H/) { + $_ = '$hold .= "\n"; $hold .= $_;'; + next; + } + + if (/^g/) { + $_ = '$_ = $hold;'; + next; + } + + if (/^G/) { + $_ = '$_ .= "\n"; $_ .= $hold;'; + next; + } + + if (/^x/) { + $_ = '($_, $hold) = ($hold, $_);'; + next; + } + + if (/^b$/) { + $_ = 'next LINE;'; + $sawnext++; + next; + } + + if (/^b/) { + s/^b[ \t]*//; + $lab = &make_label($_); + if ($lab eq $toplabel) { + $_ = 'redo LINE;'; + } else { + $_ = "goto $lab;"; + } + next; + } + + if (/^t$/) { + $_ = 'next LINE if $tflag;'; + $sawnext++; + $tseen++; + next; + } + + if (/^t/) { + s/^t[ \t]*//; + $lab = &make_label($_); + $_ = q/if ($tflag) {$tflag = 0; /; + if ($lab eq $toplabel) { + $_ .= 'redo LINE;}'; + } else { + $_ .= "goto $lab;}"; + } + $tseen++; + next; + } + + if (/^y/) { + s/abcdefghijklmnopqrstuvwxyz/a-z/g; + s/ABCDEFGHIJKLMNOPQRSTUVWXYZ/A-Z/g; + s/abcdef/a-f/g; + s/ABCDEF/A-F/g; + s/0123456789/0-9/g; + s/01234567/0-7/g; + $_ .= ';'; + } + + if (/^=/) { + $_ = 'print $.;'; + next; + } + + if (/^q/) { + chop($_ = &q(<<'EOT')); +: close(ARGV); +: @ARGV = (); +: next LINE; +EOT + $sawnext++; + next; + } + } continue { + if ($space) { + s/^/$space/; + s/(\n)(.)/$1$space$2/g; + } + last; + } + $_; +} + +sub fetchpat { + local($outer) = @_; + local($addr) = $outer; + local($inbracket); + local($prefix,$delim,$ch); + + # Process pattern one potential delimiter at a time. + + DELIM: while (s#^([^\]+(|)[\\/]*)([]+(|)[\\/])##) { + $prefix = $1; + $delim = $2; + if ($delim eq '\\') { + s/(.)//; + $ch = $1; + $delim = '' if $ch =~ /^[(){}A-Za-mo-z]$/; + $ch = 'b' if $ch =~ /^[<>]$/; + $delim .= $ch; + } + elsif ($delim eq '[') { + $inbracket = 1; + s/^\^// && ($delim .= '^'); + s/^]// && ($delim .= ']'); + } + elsif ($delim eq ']') { + $inbracket = 0; + } + elsif ($inbracket || $delim ne $outer) { + $delim = '\\' . $delim; + } + $addr .= $prefix; + $addr .= $delim; + if ($delim eq $outer && !$inbracket) { + last DELIM; + } + } + $addr =~ s/\t/\\t/g; + &simplify($addr); + $addr; +} + +sub q { + local($string) = @_; + local($*) = 1; + $string =~ s/^:\t?//g; + $string; +} + +sub simplify { + $_[0] =~ s/_a-za-z0-9/\\w/ig; + $_[0] =~ s/a-z_a-z0-9/\\w/ig; + $_[0] =~ s/a-za-z_0-9/\\w/ig; + $_[0] =~ s/a-za-z0-9_/\\w/ig; + $_[0] =~ s/_0-9a-za-z/\\w/ig; + $_[0] =~ s/0-9_a-za-z/\\w/ig; + $_[0] =~ s/0-9a-z_a-z/\\w/ig; + $_[0] =~ s/0-9a-za-z_/\\w/ig; + $_[0] =~ s/\[\\w\]/\\w/g; + $_[0] =~ s/\[^\\w\]/\\W/g; + $_[0] =~ s/\[0-9\]/\\d/g; + $_[0] =~ s/\[^0-9\]/\\D/g; + $_[0] =~ s/\\d\\d\*/\\d+/g; + $_[0] =~ s/\\D\\D\*/\\D+/g; + $_[0] =~ s/\\w\\w\*/\\w+/g; + $_[0] =~ s/\\t\\t\*/\\t+/g; + $_[0] =~ s/(\[.[^]]*\])\1\*/$1+/g; + $_[0] =~ s/([\w\s!@#%^&-=,:;'"])\1\*/$1+/g; +} + diff --git a/gnu/usr.bin/perl/x2p/s2p.1 b/gnu/usr.bin/perl/x2p/s2p.1 new file mode 100644 index 0000000..ab74717 --- /dev/null +++ b/gnu/usr.bin/perl/x2p/s2p.1 @@ -0,0 +1,108 @@ +.rn '' }` +''' $RCSfile: s2p.man,v $$Revision: 1.1.1.1 $$Date: 1993/08/23 21:30:10 $ +''' +''' $Log: s2p.man,v $ +.\" Revision 1.1.1.1 1993/08/23 21:30:10 nate +.\" PERL! +.\" +''' Revision 4.0.1.1 91/06/07 12:19:57 lwall +''' patch4: s2p now handles embedded newlines better and optimizes common idioms +''' +''' Revision 4.0 91/03/20 01:58:07 lwall +''' 4.0 baseline. +''' +''' Revision 3.0 89/10/18 15:35:09 lwall +''' 3.0 baseline +''' +''' Revision 2.0 88/06/05 00:15:59 root +''' Baseline version 2.0. +''' +''' +.de Sh +.br +.ne 5 +.PP +\fB\\$1\fR +.PP +.. +.de Sp +.if t .sp .5v +.if n .sp +.. +.de Ip +.br +.ie \\n.$>=3 .ne \\$3 +.el .ne 3 +.IP "\\$1" \\$2 +.. +''' +''' Set up \*(-- to give an unbreakable dash; +''' string Tr holds user defined translation string. +''' Bell System Logo is used as a dummy character. +''' +.tr \(*W-|\(bv\*(Tr +.ie n \{\ +.ds -- \(*W- +.if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch +.if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch +.ds L" "" +.ds R" "" +.ds L' ' +.ds R' ' +'br\} +.el\{\ +.ds -- \(em\| +.tr \*(Tr +.ds L" `` +.ds R" '' +.ds L' ` +.ds R' ' +'br\} +.TH S2P 1 NEW +.SH NAME +s2p - Sed to Perl translator +.SH SYNOPSIS +.B s2p [options] filename +.SH DESCRIPTION +.I S2p +takes a sed script specified on the command line (or from standard input) +and produces a comparable +.I perl +script on the standard output. +.Sh "Options" +Options include: +.TP 5 +.B \-D<number> +sets debugging flags. +.TP 5 +.B \-n +specifies that this sed script was always invoked with a sed -n. +Otherwise a switch parser is prepended to the front of the script. +.TP 5 +.B \-p +specifies that this sed script was never invoked with a sed -n. +Otherwise a switch parser is prepended to the front of the script. +.Sh "Considerations" +The perl script produced looks very sed-ish, and there may very well be +better ways to express what you want to do in perl. +For instance, s2p does not make any use of the split operator, but you might +want to. +.PP +The perl script you end up with may be either faster or slower than the original +sed script. +If you're only interested in speed you'll just have to try it both ways. +Of course, if you want to do something sed doesn't do, you have no choice. +It's often possible to speed up the perl script by various methods, such +as deleting all references to $\e and chop. +.SH ENVIRONMENT +S2p uses no environment variables. +.SH AUTHOR +Larry Wall <lwall@jpl-devvax.Jpl.Nasa.Gov> +.SH FILES +.SH SEE ALSO +perl The perl compiler/interpreter +.br +a2p awk to perl translator +.SH DIAGNOSTICS +.SH BUGS +.rn }` '' diff --git a/gnu/usr.bin/perl/x2p/str.c b/gnu/usr.bin/perl/x2p/str.c new file mode 100644 index 0000000..0461194 --- /dev/null +++ b/gnu/usr.bin/perl/x2p/str.c @@ -0,0 +1,467 @@ +/* $RCSfile: str.c,v $$Revision: 1.1.1.1 $$Date: 1993/08/23 21:30:09 $ + * + * Copyright (c) 1991, 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: str.c,v $ + * Revision 1.1.1.1 1993/08/23 21:30:09 nate + * PERL! + * + * Revision 4.0.1.1 91/06/07 12:20:08 lwall + * patch4: new copyright notice + * + * Revision 4.0 91/03/20 01:58:15 lwall + * 4.0 baseline. + * + */ + +#include "handy.h" +#include "EXTERN.h" +#include "util.h" +#include "a2p.h" + +str_numset(str,num) +register STR *str; +double num; +{ + str->str_nval = num; + str->str_pok = 0; /* invalidate pointer */ + str->str_nok = 1; /* validate number */ +} + +char * +str_2ptr(str) +register STR *str; +{ + register char *s; + + if (!str) + return ""; + GROWSTR(&(str->str_ptr), &(str->str_len), 24); + s = str->str_ptr; + if (str->str_nok) { + sprintf(s,"%.20g",str->str_nval); + while (*s) s++; + } + *s = '\0'; + str->str_cur = s - str->str_ptr; + str->str_pok = 1; +#ifdef DEBUGGING + if (debug & 32) + fprintf(stderr,"0x%lx ptr(%s)\n",str,str->str_ptr); +#endif + return str->str_ptr; +} + +double +str_2num(str) +register STR *str; +{ + if (!str) + return 0.0; + if (str->str_len && str->str_pok) + str->str_nval = atof(str->str_ptr); + else + str->str_nval = 0.0; + str->str_nok = 1; +#ifdef DEBUGGING + if (debug & 32) + fprintf(stderr,"0x%lx num(%g)\n",str,str->str_nval); +#endif + return str->str_nval; +} + +str_sset(dstr,sstr) +STR *dstr; +register STR *sstr; +{ + if (!sstr) + str_nset(dstr,No,0); + else if (sstr->str_nok) + str_numset(dstr,sstr->str_nval); + else if (sstr->str_pok) + str_nset(dstr,sstr->str_ptr,sstr->str_cur); + else + str_nset(dstr,"",0); +} + +str_nset(str,ptr,len) +register STR *str; +register char *ptr; +register int len; +{ + GROWSTR(&(str->str_ptr), &(str->str_len), len + 1); + bcopy(ptr,str->str_ptr,len); + str->str_cur = len; + *(str->str_ptr+str->str_cur) = '\0'; + str->str_nok = 0; /* invalidate number */ + str->str_pok = 1; /* validate pointer */ +} + +str_set(str,ptr) +register STR *str; +register char *ptr; +{ + register int len; + + if (!ptr) + ptr = ""; + len = strlen(ptr); + GROWSTR(&(str->str_ptr), &(str->str_len), len + 1); + bcopy(ptr,str->str_ptr,len+1); + str->str_cur = len; + str->str_nok = 0; /* invalidate number */ + str->str_pok = 1; /* validate pointer */ +} + +str_chop(str,ptr) /* like set but assuming ptr is in str */ +register STR *str; +register char *ptr; +{ + if (!(str->str_pok)) + str_2ptr(str); + str->str_cur -= (ptr - str->str_ptr); + bcopy(ptr,str->str_ptr, str->str_cur + 1); + str->str_nok = 0; /* invalidate number */ + str->str_pok = 1; /* validate pointer */ +} + +str_ncat(str,ptr,len) +register STR *str; +register char *ptr; +register int len; +{ + if (!(str->str_pok)) + str_2ptr(str); + GROWSTR(&(str->str_ptr), &(str->str_len), str->str_cur + len + 1); + bcopy(ptr,str->str_ptr+str->str_cur,len); + str->str_cur += len; + *(str->str_ptr+str->str_cur) = '\0'; + str->str_nok = 0; /* invalidate number */ + str->str_pok = 1; /* validate pointer */ +} + +str_scat(dstr,sstr) +STR *dstr; +register STR *sstr; +{ + if (!(sstr->str_pok)) + str_2ptr(sstr); + if (sstr) + str_ncat(dstr,sstr->str_ptr,sstr->str_cur); +} + +str_cat(str,ptr) +register STR *str; +register char *ptr; +{ + register int len; + + if (!ptr) + return; + if (!(str->str_pok)) + str_2ptr(str); + len = strlen(ptr); + GROWSTR(&(str->str_ptr), &(str->str_len), str->str_cur + len + 1); + bcopy(ptr,str->str_ptr+str->str_cur,len+1); + str->str_cur += len; + str->str_nok = 0; /* invalidate number */ + str->str_pok = 1; /* validate pointer */ +} + +char * +str_append_till(str,from,delim,keeplist) +register STR *str; +register char *from; +register int delim; +char *keeplist; +{ + register char *to; + register int len; + + if (!from) + return Nullch; + len = strlen(from); + GROWSTR(&(str->str_ptr), &(str->str_len), str->str_cur + len + 1); + str->str_nok = 0; /* invalidate number */ + str->str_pok = 1; /* validate pointer */ + to = str->str_ptr+str->str_cur; + for (; *from; from++,to++) { + if (*from == '\\' && from[1] && delim != '\\') { + if (!keeplist) { + if (from[1] == delim || from[1] == '\\') + from++; + else + *to++ = *from++; + } + else if (index(keeplist,from[1])) + *to++ = *from++; + else + from++; + } + else if (*from == delim) + break; + *to = *from; + } + *to = '\0'; + str->str_cur = to - str->str_ptr; + return from; +} + +STR * +str_new(len) +int len; +{ + register STR *str; + + if (freestrroot) { + str = freestrroot; + freestrroot = str->str_link.str_next; + } + else { + str = (STR *) safemalloc(sizeof(STR)); + bzero((char*)str,sizeof(STR)); + } + if (len) + GROWSTR(&(str->str_ptr), &(str->str_len), len + 1); + return str; +} + +void +str_grow(str,len) +register STR *str; +int len; +{ + if (len && str) + GROWSTR(&(str->str_ptr), &(str->str_len), len + 1); +} + +/* make str point to what nstr did */ + +void +str_replace(str,nstr) +register STR *str; +register STR *nstr; +{ + safefree(str->str_ptr); + str->str_ptr = nstr->str_ptr; + str->str_len = nstr->str_len; + str->str_cur = nstr->str_cur; + str->str_pok = nstr->str_pok; + if (str->str_nok = nstr->str_nok) + str->str_nval = nstr->str_nval; + safefree((char*)nstr); +} + +void +str_free(str) +register STR *str; +{ + if (!str) + return; + if (str->str_len) + str->str_ptr[0] = '\0'; + str->str_cur = 0; + str->str_nok = 0; + str->str_pok = 0; + str->str_link.str_next = freestrroot; + freestrroot = str; +} + +str_len(str) +register STR *str; +{ + if (!str) + return 0; + if (!(str->str_pok)) + str_2ptr(str); + if (str->str_len) + return str->str_cur; + else + return 0; +} + +char * +str_gets(str,fp) +register STR *str; +register FILE *fp; +{ +#ifdef STDSTDIO /* Here is some breathtakingly efficient cheating */ + + register char *bp; /* we're going to steal some values */ + register int cnt; /* from the stdio struct and put EVERYTHING */ + register STDCHAR *ptr; /* in the innermost loop into registers */ + register char newline = '\n'; /* (assuming at least 6 registers) */ + int i; + int bpx; + + cnt = fp->_cnt; /* get count into register */ + str->str_nok = 0; /* invalidate number */ + str->str_pok = 1; /* validate pointer */ + if (str->str_len <= cnt) /* make sure we have the room */ + GROWSTR(&(str->str_ptr), &(str->str_len), cnt+1); + bp = str->str_ptr; /* move these two too to registers */ + ptr = fp->_ptr; + for (;;) { + while (--cnt >= 0) { + if ((*bp++ = *ptr++) == newline) + if (bp <= str->str_ptr || bp[-2] != '\\') + goto thats_all_folks; + else { + line++; + bp -= 2; + } + } + + fp->_cnt = cnt; /* deregisterize cnt and ptr */ + fp->_ptr = ptr; + i = _filbuf(fp); /* get more characters */ + cnt = fp->_cnt; + ptr = fp->_ptr; /* reregisterize cnt and ptr */ + + bpx = bp - str->str_ptr; /* prepare for possible relocation */ + GROWSTR(&(str->str_ptr), &(str->str_len), str->str_cur + cnt + 1); + bp = str->str_ptr + bpx; /* reconstitute our pointer */ + + if (i == newline) { /* all done for now? */ + *bp++ = i; + goto thats_all_folks; + } + else if (i == EOF) /* all done for ever? */ + goto thats_all_folks; + *bp++ = i; /* now go back to screaming loop */ + } + +thats_all_folks: + fp->_cnt = cnt; /* put these back or we're in trouble */ + fp->_ptr = ptr; + *bp = '\0'; + str->str_cur = bp - str->str_ptr; /* set length */ + +#else /* !STDSTDIO */ /* The big, slow, and stupid way */ + + static char buf[4192]; + + if (fgets(buf, sizeof buf, fp) != Nullch) + str_set(str, buf); + else + str_set(str, No); + +#endif /* STDSTDIO */ + + return str->str_cur ? str->str_ptr : Nullch; +} + +void +str_inc(str) +register STR *str; +{ + register char *d; + + if (!str) + return; + if (str->str_nok) { + str->str_nval += 1.0; + str->str_pok = 0; + return; + } + if (!str->str_pok) { + str->str_nval = 1.0; + str->str_nok = 1; + return; + } + for (d = str->str_ptr; *d && *d != '.'; d++) ; + d--; + if (!isdigit(*str->str_ptr) || !isdigit(*d) ) { + str_numset(str,atof(str->str_ptr) + 1.0); /* punt */ + return; + } + while (d >= str->str_ptr) { + if (++*d <= '9') + return; + *(d--) = '0'; + } + /* oh,oh, the number grew */ + GROWSTR(&(str->str_ptr), &(str->str_len), str->str_cur + 2); + str->str_cur++; + for (d = str->str_ptr + str->str_cur; d > str->str_ptr; d--) + *d = d[-1]; + *d = '1'; +} + +void +str_dec(str) +register STR *str; +{ + register char *d; + + if (!str) + return; + if (str->str_nok) { + str->str_nval -= 1.0; + str->str_pok = 0; + return; + } + if (!str->str_pok) { + str->str_nval = -1.0; + str->str_nok = 1; + return; + } + for (d = str->str_ptr; *d && *d != '.'; d++) ; + d--; + if (!isdigit(*str->str_ptr) || !isdigit(*d) || (*d == '0' && d == str->str_ptr)) { + str_numset(str,atof(str->str_ptr) - 1.0); /* punt */ + return; + } + while (d >= str->str_ptr) { + if (--*d >= '0') + return; + *(d--) = '9'; + } +} + +/* make a string that will exist for the duration of the expression eval */ + +STR * +str_mortal(oldstr) +STR *oldstr; +{ + register STR *str = str_new(0); + static long tmps_size = -1; + + str_sset(str,oldstr); + if (++tmps_max > tmps_size) { + tmps_size = tmps_max; + if (!(tmps_size & 127)) { + if (tmps_size) + tmps_list = (STR**)saferealloc((char*)tmps_list, + (tmps_size + 128) * sizeof(STR*) ); + else + tmps_list = (STR**)safemalloc(128 * sizeof(char*)); + } + } + tmps_list[tmps_max] = str; + return str; +} + +STR * +str_make(s) +char *s; +{ + register STR *str = str_new(0); + + str_set(str,s); + return str; +} + +STR * +str_nmake(n) +double n; +{ + register STR *str = str_new(0); + + str_numset(str,n); + return str; +} diff --git a/gnu/usr.bin/perl/x2p/str.h b/gnu/usr.bin/perl/x2p/str.h new file mode 100644 index 0000000..765d9ea --- /dev/null +++ b/gnu/usr.bin/perl/x2p/str.h @@ -0,0 +1,46 @@ +/* $RCSfile: str.h,v $$Revision: 1.1.1.1 $$Date: 1993/08/23 21:30:10 $ + * + * Copyright (c) 1991, 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: str.h,v $ + * Revision 1.1.1.1 1993/08/23 21:30:10 nate + * PERL! + * + * Revision 4.0.1.1 91/06/07 12:20:22 lwall + * patch4: new copyright notice + * + * Revision 4.0 91/03/20 01:58:21 lwall + * 4.0 baseline. + * + */ + +struct string { + char * str_ptr; /* pointer to malloced string */ + double str_nval; /* numeric value, if any */ + int str_len; /* allocated size */ + int str_cur; /* length of str_ptr as a C string */ + union { + STR *str_next; /* while free, link to next free str */ + } str_link; + char str_pok; /* state of str_ptr */ + char str_nok; /* state of str_nval */ +}; + +#define Nullstr Null(STR*) + +/* the following macro updates any magic values this str is associated with */ + +#define STABSET(x) (x->str_link.str_magic && stabset(x->str_link.str_magic,x)) + +EXT STR **tmps_list; +EXT long tmps_max INIT(-1); + +char *str_2ptr(); +double str_2num(); +STR *str_mortal(); +STR *str_make(); +STR *str_nmake(); +char *str_gets(); diff --git a/gnu/usr.bin/perl/x2p/util.c b/gnu/usr.bin/perl/x2p/util.c new file mode 100644 index 0000000..4c5b078 --- /dev/null +++ b/gnu/usr.bin/perl/x2p/util.c @@ -0,0 +1,268 @@ +/* $RCSfile: util.c,v $$Revision: 1.1.1.1 $$Date: 1993/08/23 21:30:10 $ + * + * Copyright (c) 1991, 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: util.c,v $ + * Revision 1.1.1.1 1993/08/23 21:30:10 nate + * PERL! + * + * Revision 4.0.1.1 91/06/07 12:20:35 lwall + * patch4: new copyright notice + * + * Revision 4.0 91/03/20 01:58:25 lwall + * 4.0 baseline. + * + */ + +#include <stdio.h> + +#include "handy.h" +#include "EXTERN.h" +#include "a2p.h" +#include "INTERN.h" +#include "util.h" + +#define FLUSH +#define MEM_SIZE unsigned int + +static char nomem[] = "Out of memory!\n"; + +/* paranoid version of malloc */ + +static int an = 0; + +char * +safemalloc(size) +MEM_SIZE size; +{ + char *ptr; + char *malloc(); + + ptr = malloc(size?size:1); /* malloc(0) is NASTY on our system */ +#ifdef DEBUGGING + if (debug & 128) + fprintf(stderr,"0x%x: (%05d) malloc %d bytes\n",ptr,an++,size); +#endif + if (ptr != Nullch) + return ptr; + else { + fputs(nomem,stdout) FLUSH; + exit(1); + } + /*NOTREACHED*/ +} + +/* paranoid version of realloc */ + +char * +saferealloc(where,size) +char *where; +MEM_SIZE size; +{ + char *ptr; + char *realloc(); + + ptr = realloc(where,size?size:1); /* realloc(0) is NASTY on our system */ +#ifdef DEBUGGING + if (debug & 128) { + fprintf(stderr,"0x%x: (%05d) rfree\n",where,an++); + fprintf(stderr,"0x%x: (%05d) realloc %d bytes\n",ptr,an++,size); + } +#endif + if (ptr != Nullch) + return ptr; + else { + fputs(nomem,stdout) FLUSH; + exit(1); + } + /*NOTREACHED*/ +} + +/* safe version of free */ + +safefree(where) +char *where; +{ +#ifdef DEBUGGING + if (debug & 128) + fprintf(stderr,"0x%x: (%05d) free\n",where,an++); +#endif + free(where); +} + +/* safe version of string copy */ + +char * +safecpy(to,from,len) +char *to; +register char *from; +register int len; +{ + register char *dest = to; + + if (from != Nullch) + for (len--; len && (*dest++ = *from++); len--) ; + *dest = '\0'; + return to; +} + +/* copy a string up to some (non-backslashed) delimiter, if any */ + +char * +cpytill(to,from,delim) +register char *to, *from; +register int delim; +{ + for (; *from; from++,to++) { + if (*from == '\\') { + if (from[1] == delim) + from++; + else if (from[1] == '\\') + *to++ = *from++; + } + else if (*from == delim) + break; + *to = *from; + } + *to = '\0'; + return from; +} + + +char * +cpy2(to,from,delim) +register char *to, *from; +register int delim; +{ + for (; *from; from++,to++) { + if (*from == '\\') + *to++ = *from++; + else if (*from == '$') + *to++ = '\\'; + else if (*from == delim) + break; + *to = *from; + } + *to = '\0'; + return from; +} + +/* return ptr to little string in big string, NULL if not found */ + +char * +instr(big, little) +char *big, *little; + +{ + register char *t, *s, *x; + + for (t = big; *t; t++) { + for (x=t,s=little; *s; x++,s++) { + if (!*x) + return Nullch; + if (*s != *x) + break; + } + if (!*s) + return t; + } + return Nullch; +} + +/* copy a string to a safe spot */ + +char * +savestr(str) +char *str; +{ + register char *newaddr = safemalloc((MEM_SIZE)(strlen(str)+1)); + + (void)strcpy(newaddr,str); + return newaddr; +} + +/* grow a static string to at least a certain length */ + +void +growstr(strptr,curlen,newlen) +char **strptr; +int *curlen; +int newlen; +{ + if (newlen > *curlen) { /* need more room? */ + if (*curlen) + *strptr = saferealloc(*strptr,(MEM_SIZE)newlen); + else + *strptr = safemalloc((MEM_SIZE)newlen); + *curlen = newlen; + } +} + +/*VARARGS1*/ +fatal(pat,a1,a2,a3,a4) +char *pat; +{ + fprintf(stderr,pat,a1,a2,a3,a4); + exit(1); +} + +/*VARARGS1*/ +warn(pat,a1,a2,a3,a4) +char *pat; +{ + fprintf(stderr,pat,a1,a2,a3,a4); +} + +static bool firstsetenv = TRUE; +extern char **environ; + +void +setenv(nam,val) +char *nam, *val; +{ + register int i=envix(nam); /* where does it go? */ + + if (!environ[i]) { /* does not exist yet */ + if (firstsetenv) { /* need we copy environment? */ + int j; +#ifndef lint + char **tmpenv = (char**) /* point our wand at memory */ + safemalloc((i+2) * sizeof(char*)); +#else + char **tmpenv = Null(char **); +#endif /* lint */ + + firstsetenv = FALSE; + for (j=0; j<i; j++) /* copy environment */ + tmpenv[j] = environ[j]; + environ = tmpenv; /* tell exec where it is now */ + } +#ifndef lint + else + environ = (char**) saferealloc((char*) environ, + (i+2) * sizeof(char*)); + /* just expand it a bit */ +#endif /* lint */ + environ[i+1] = Nullch; /* make sure it's null terminated */ + } + environ[i] = safemalloc(strlen(nam) + strlen(val) + 2); + /* this may or may not be in */ + /* the old environ structure */ + sprintf(environ[i],"%s=%s",nam,val);/* all that work just for this */ +} + +int +envix(nam) +char *nam; +{ + register int i, len = strlen(nam); + + for (i = 0; environ[i]; i++) { + if (strnEQ(environ[i],nam,len) && environ[i][len] == '=') + break; /* strnEQ must come first to avoid */ + } /* potential SEGV's */ + return i; +} diff --git a/gnu/usr.bin/perl/x2p/util.h b/gnu/usr.bin/perl/x2p/util.h new file mode 100644 index 0000000..15bf78e5 --- /dev/null +++ b/gnu/usr.bin/perl/x2p/util.h @@ -0,0 +1,53 @@ +/* $RCSfile: util.h,v $$Revision: 1.1.1.1 $$Date: 1993/08/23 21:30:10 $ + * + * Copyright (c) 1991, 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: util.h,v $ + * Revision 1.1.1.1 1993/08/23 21:30:10 nate + * PERL! + * + * Revision 4.0.1.2 91/11/05 19:21:20 lwall + * patch11: various portability fixes + * + * Revision 4.0.1.1 91/06/07 12:20:43 lwall + * patch4: new copyright notice + * + * Revision 4.0 91/03/20 01:58:29 lwall + * 4.0 baseline. + * + */ + +/* is the string for makedir a directory name or a filename? */ + +#define fatal Myfatal + +#define MD_DIR 0 +#define MD_FILE 1 + +void util_init(); +int doshell(); +char *safemalloc(); +char *saferealloc(); +char *safecpy(); +char *safecat(); +char *cpytill(); +char *cpy2(); +char *instr(); +#ifdef SETUIDGID + int eaccess(); +#endif +char *getwd(); +void cat(); +void prexit(); +char *get_a_line(); +char *savestr(); +int makedir(); +void setenv(); +int envix(); +void notincl(); +char *getval(); +void growstr(); +void setdef(); diff --git a/gnu/usr.bin/perl/x2p/walk.c b/gnu/usr.bin/perl/x2p/walk.c new file mode 100644 index 0000000..4cc4a79 --- /dev/null +++ b/gnu/usr.bin/perl/x2p/walk.c @@ -0,0 +1,2086 @@ +/* $RCSfile: walk.c,v $$Revision: 1.1.1.1 $$Date: 1993/08/23 21:30:11 $ + * + * Copyright (c) 1991, 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: walk.c,v $ + * Revision 1.1.1.1 1993/08/23 21:30:11 nate + * PERL! + * + * Revision 4.0.1.3 92/06/08 17:33:46 lwall + * patch20: in a2p, simplified the filehandle model + * patch20: in a2p, made RS="" translate to $/ = "\n\n" + * patch20: in a2p, do {...} while ... was missing some reconstruction code + * patch20: in a2p, getline should allow variable to be array element + * + * Revision 4.0.1.2 91/11/05 19:25:09 lwall + * patch11: in a2p, split on whitespace produced extra null field + * + * Revision 4.0.1.1 91/06/07 12:22:04 lwall + * patch4: new copyright notice + * patch4: a2p didn't correctly implement -n switch + * + * Revision 4.0 91/03/20 01:58:36 lwall + * 4.0 baseline. + * + */ + +#include "handy.h" +#include "EXTERN.h" +#include "util.h" +#include "a2p.h" + +bool exitval = FALSE; +bool realexit = FALSE; +bool saw_getline = FALSE; +bool subretnum = FALSE; +bool saw_FNR = FALSE; +bool saw_argv0 = FALSE; +bool saw_fh = FALSE; +int maxtmp = 0; +char *lparen; +char *rparen; +char *limit; +STR *subs; +STR *curargs = Nullstr; + +STR * +walk(useval,level,node,numericptr,minprec) +int useval; +int level; +register int node; +int *numericptr; +int minprec; /* minimum precedence without parens */ +{ + register int len; + register STR *str; + register int type; + register int i; + register STR *tmpstr; + STR *tmp2str; + STR *tmp3str; + char *t; + char *d, *s; + int numarg; + int numeric = FALSE; + STR *fstr; + int prec = P_MAX; /* assume no parens needed */ + char *index(); + + if (!node) { + *numericptr = 0; + return str_make(""); + } + type = ops[node].ival; + len = type >> 8; + type &= 255; + switch (type) { + case OPROG: + arymax = 0; + if (namelist) { + while (isalpha(*namelist)) { + for (d = tokenbuf,s=namelist; + isalpha(*s) || isdigit(*s) || *s == '_'; + *d++ = *s++) ; + *d = '\0'; + while (*s && !isalpha(*s)) s++; + namelist = s; + nameary[++arymax] = savestr(tokenbuf); + } + } + if (maxfld < arymax) + maxfld = arymax; + opens = str_new(0); + subs = str_new(0); + str = walk(0,level,ops[node+1].ival,&numarg,P_MIN); + if (do_split && need_entire && !absmaxfld) + split_to_array = TRUE; + if (do_split && split_to_array) + set_array_base = TRUE; + if (set_array_base) { + str_cat(str,"$[ = 1;\t\t\t# set array base to 1\n"); + } + if (fswitch && !const_FS) + const_FS = fswitch; + if (saw_FS > 1 || saw_RS) + const_FS = 0; + if (saw_ORS && need_entire) + do_chop = TRUE; + if (fswitch) { + str_cat(str,"$FS = '"); + if (index("*+?.[]()|^$\\",fswitch)) + str_cat(str,"\\"); + sprintf(tokenbuf,"%c",fswitch); + str_cat(str,tokenbuf); + str_cat(str,"';\t\t# field separator from -F switch\n"); + } + else if (saw_FS && !const_FS) { + str_cat(str,"$FS = ' ';\t\t# set field separator\n"); + } + if (saw_OFS) { + str_cat(str,"$, = ' ';\t\t# set output field separator\n"); + } + if (saw_ORS) { + str_cat(str,"$\\ = \"\\n\";\t\t# set output record separator\n"); + } + if (saw_argv0) { + str_cat(str,"$ARGV0 = $0;\t\t# remember what we ran as\n"); + } + if (str->str_cur > 20) + str_cat(str,"\n"); + if (ops[node+2].ival) { + str_scat(str,fstr=walk(0,level,ops[node+2].ival,&numarg,P_MIN)); + str_free(fstr); + str_cat(str,"\n\n"); + } + fstr = walk(0,level+1,ops[node+3].ival,&numarg,P_MIN); + if (*fstr->str_ptr) { + if (saw_line_op) + str_cat(str,"line: "); + str_cat(str,"while (<>) {\n"); + tab(str,++level); + if (saw_FS && !const_FS) + do_chop = TRUE; + if (do_chop) { + str_cat(str,"chop;\t# strip record separator\n"); + tab(str,level); + } + if (do_split) + emit_split(str,level); + str_scat(str,fstr); + str_free(fstr); + fixtab(str,--level); + str_cat(str,"}\n"); + if (saw_FNR) + str_cat(str,"continue {\n $FNRbase = $. if eof;\n}\n"); + } + else + str_cat(str,"while (<>) { } # (no line actions)\n"); + if (ops[node+4].ival) { + realexit = TRUE; + str_cat(str,"\n"); + tab(str,level); + str_scat(str,fstr=walk(0,level,ops[node+4].ival,&numarg,P_MIN)); + str_free(fstr); + str_cat(str,"\n"); + } + if (exitval) + str_cat(str,"exit $ExitValue;\n"); + if (subs->str_ptr) { + str_cat(str,"\n"); + str_scat(str,subs); + } + if (saw_getline) { + for (len = 0; len < 4; len++) { + if (saw_getline & (1 << len)) { + sprintf(tokenbuf,"\nsub Getline%d {\n",len); + str_cat(str, tokenbuf); + if (len & 2) { + if (do_fancy_opens) + str_cat(str," &Pick('',@_);\n"); + else + str_cat(str," ($fh) = @_;\n"); + } + else { + if (saw_FNR) + str_cat(str," $FNRbase = $. if eof;\n"); + } + if (len & 1) + str_cat(str," local($_);\n"); + if (len & 2) + str_cat(str, + " if ($getline_ok = (($_ = <$fh>) ne ''))"); + else + str_cat(str, + " if ($getline_ok = (($_ = <>) ne ''))"); + str_cat(str, " {\n"); + level += 2; + tab(str,level); + i = 0; + if (do_chop) { + i++; + str_cat(str,"chop;\t# strip record separator\n"); + tab(str,level); + } + if (do_split && !(len & 1)) { + i++; + emit_split(str,level); + } + if (!i) + str_cat(str,";\n"); + fixtab(str,--level); + str_cat(str,"}\n $_;\n}\n"); + --level; + } + } + } + if (do_fancy_opens) { + str_cat(str,"\n\ +sub Pick {\n\ + local($mode,$name,$pipe) = @_;\n\ + $fh = $name;\n\ + open($name,$mode.$name.$pipe) unless $opened{$name}++;\n\ +}\n\ +"); + } + break; + case OHUNKS: + str = walk(0,level,ops[node+1].ival,&numarg,P_MIN); + str_scat(str,fstr=walk(0,level,ops[node+2].ival,&numarg,P_MIN)); + str_free(fstr); + if (len == 3) { + str_scat(str,fstr=walk(0,level,ops[node+3].ival,&numarg,P_MIN)); + str_free(fstr); + } + else { + } + break; + case ORANGE: + prec = P_DOTDOT; + str = walk(1,level,ops[node+1].ival,&numarg,prec+1); + str_cat(str," .. "); + str_scat(str,fstr=walk(1,level,ops[node+2].ival,&numarg,prec+1)); + str_free(fstr); + break; + case OPAT: + goto def; + case OREGEX: + str = str_new(0); + str_set(str,"/"); + tmpstr=walk(0,level,ops[node+1].ival,&numarg,P_MIN); + /* translate \nnn to [\nnn] */ + for (s = tmpstr->str_ptr, d = tokenbuf; *s; s++, d++) { + if (*s == '\\' && isdigit(s[1]) && isdigit(s[2]) && isdigit(s[3])){ + *d++ = '['; + *d++ = *s++; + *d++ = *s++; + *d++ = *s++; + *d++ = *s; + *d = ']'; + } + else + *d = *s; + } + *d = '\0'; + for (d=tokenbuf; *d; d++) + *d += 128; + str_cat(str,tokenbuf); + str_free(tmpstr); + str_cat(str,"/"); + break; + case OHUNK: + if (len == 1) { + str = str_new(0); + str = walk(0,level,oper1(OPRINT,0),&numarg,P_MIN); + str_cat(str," if "); + str_scat(str,fstr=walk(0,level,ops[node+1].ival,&numarg,P_MIN)); + str_free(fstr); + str_cat(str,";"); + } + else { + tmpstr = walk(0,level,ops[node+1].ival,&numarg,P_MIN); + if (*tmpstr->str_ptr) { + str = str_new(0); + str_set(str,"if ("); + str_scat(str,tmpstr); + str_cat(str,") {\n"); + tab(str,++level); + str_scat(str,fstr=walk(0,level,ops[node+2].ival,&numarg,P_MIN)); + str_free(fstr); + fixtab(str,--level); + str_cat(str,"}\n"); + tab(str,level); + } + else { + str = walk(0,level,ops[node+2].ival,&numarg,P_MIN); + } + } + break; + case OPPAREN: + str = str_new(0); + str_set(str,"("); + str_scat(str,fstr=walk(useval != 0,level,ops[node+1].ival,&numarg,P_MIN)); + str_free(fstr); + str_cat(str,")"); + break; + case OPANDAND: + prec = P_ANDAND; + str = walk(1,level,ops[node+1].ival,&numarg,prec); + str_cat(str," && "); + str_scat(str,fstr=walk(1,level,ops[node+2].ival,&numarg,prec+1)); + str_free(fstr); + str_scat(str,fstr=walk(1,level,ops[node+3].ival,&numarg,prec+1)); + str_free(fstr); + break; + case OPOROR: + prec = P_OROR; + str = walk(1,level,ops[node+1].ival,&numarg,prec); + str_cat(str," || "); + str_scat(str,fstr=walk(1,level,ops[node+2].ival,&numarg,prec+1)); + str_free(fstr); + str_scat(str,fstr=walk(1,level,ops[node+3].ival,&numarg,prec+1)); + str_free(fstr); + break; + case OPNOT: + prec = P_UNARY; + str = str_new(0); + str_set(str,"!"); + str_scat(str,fstr=walk(1,level,ops[node+1].ival,&numarg,prec)); + str_free(fstr); + break; + case OCOND: + prec = P_COND; + str = walk(1,level,ops[node+1].ival,&numarg,prec); + str_cat(str," ? "); + str_scat(str,fstr=walk(1,level,ops[node+2].ival,&numarg,prec+1)); + str_free(fstr); + str_cat(str," : "); + str_scat(str,fstr=walk(1,level,ops[node+3].ival,&numarg,prec+1)); + str_free(fstr); + break; + case OCPAREN: + str = str_new(0); + str_set(str,"("); + str_scat(str,fstr=walk(useval != 0,level,ops[node+1].ival,&numarg,P_MIN)); + str_free(fstr); + numeric |= numarg; + str_cat(str,")"); + break; + case OCANDAND: + prec = P_ANDAND; + str = walk(1,level,ops[node+1].ival,&numarg,prec); + numeric = 1; + str_cat(str," && "); + str_scat(str,fstr=walk(1,level,ops[node+2].ival,&numarg,prec+1)); + str_free(fstr); + str_scat(str,fstr=walk(1,level,ops[node+3].ival,&numarg,prec+1)); + str_free(fstr); + break; + case OCOROR: + prec = P_OROR; + str = walk(1,level,ops[node+1].ival,&numarg,prec); + numeric = 1; + str_cat(str," || "); + str_scat(str,fstr=walk(1,level,ops[node+2].ival,&numarg,prec+1)); + str_free(fstr); + str_scat(str,fstr=walk(1,level,ops[node+3].ival,&numarg,prec+1)); + str_free(fstr); + break; + case OCNOT: + prec = P_UNARY; + str = str_new(0); + str_set(str,"!"); + str_scat(str,fstr=walk(1,level,ops[node+1].ival,&numarg,prec)); + str_free(fstr); + numeric = 1; + break; + case ORELOP: + prec = P_REL; + str = walk(1,level,ops[node+2].ival,&numarg,prec+1); + numeric |= numarg; + tmpstr = walk(0,level,ops[node+1].ival,&numarg,P_MIN); + tmp2str = walk(1,level,ops[node+3].ival,&numarg,prec+1); + numeric |= numarg; + if (!numeric || + (!numarg && (*tmp2str->str_ptr == '"' || *tmp2str->str_ptr == '\''))) { + t = tmpstr->str_ptr; + if (strEQ(t,"==")) + str_set(tmpstr,"eq"); + else if (strEQ(t,"!=")) + str_set(tmpstr,"ne"); + else if (strEQ(t,"<")) + str_set(tmpstr,"lt"); + else if (strEQ(t,"<=")) + str_set(tmpstr,"le"); + else if (strEQ(t,">")) + str_set(tmpstr,"gt"); + else if (strEQ(t,">=")) + str_set(tmpstr,"ge"); + if (!index(tmpstr->str_ptr,'\'') && !index(tmpstr->str_ptr,'"') && + !index(tmp2str->str_ptr,'\'') && !index(tmp2str->str_ptr,'"') ) + numeric |= 2; + } + if (numeric & 2) { + if (numeric & 1) /* numeric is very good guess */ + str_cat(str," "); + else + str_cat(str,"\377"); + numeric = 1; + } + else + str_cat(str," "); + str_scat(str,tmpstr); + str_free(tmpstr); + str_cat(str," "); + str_scat(str,tmp2str); + str_free(tmp2str); + numeric = 1; + break; + case ORPAREN: + str = str_new(0); + str_set(str,"("); + str_scat(str,fstr=walk(useval != 0,level,ops[node+1].ival,&numarg,P_MIN)); + str_free(fstr); + numeric |= numarg; + str_cat(str,")"); + break; + case OMATCHOP: + prec = P_MATCH; + str = walk(1,level,ops[node+2].ival,&numarg,prec+1); + str_cat(str," "); + tmpstr = walk(0,level,ops[node+1].ival,&numarg,P_MIN); + if (strEQ(tmpstr->str_ptr,"~")) + str_cat(str,"=~"); + else { + str_scat(str,tmpstr); + str_free(tmpstr); + } + str_cat(str," "); + str_scat(str,fstr=walk(1,level,ops[node+3].ival,&numarg,prec+1)); + str_free(fstr); + numeric = 1; + break; + case OMPAREN: + str = str_new(0); + str_set(str,"("); + str_scat(str, + fstr=walk(useval != 0,level,ops[node+1].ival,&numarg,P_MIN)); + str_free(fstr); + numeric |= numarg; + str_cat(str,")"); + break; + case OCONCAT: + prec = P_ADD; + type = ops[ops[node+1].ival].ival & 255; + str = walk(1,level,ops[node+1].ival,&numarg,prec+(type != OCONCAT)); + str_cat(str," . "); + type = ops[ops[node+2].ival].ival & 255; + str_scat(str, + fstr=walk(1,level,ops[node+2].ival,&numarg,prec+(type != OCONCAT))); + str_free(fstr); + break; + case OASSIGN: + prec = P_ASSIGN; + str = walk(0,level,ops[node+2].ival,&numarg,prec+1); + str_cat(str," "); + tmpstr = walk(0,level,ops[node+1].ival,&numarg,P_MIN); + str_scat(str,tmpstr); + if (str_len(tmpstr) > 1) + numeric = 1; + str_free(tmpstr); + str_cat(str," "); + str_scat(str,fstr=walk(1,level,ops[node+3].ival,&numarg,prec)); + str_free(fstr); + numeric |= numarg; + if (strEQ(str->str_ptr,"$/ = ''")) + str_set(str, "$/ = \"\\n\\n\""); + break; + case OADD: + prec = P_ADD; + str = walk(1,level,ops[node+1].ival,&numarg,prec); + str_cat(str," + "); + str_scat(str,fstr=walk(1,level,ops[node+2].ival,&numarg,prec+1)); + str_free(fstr); + numeric = 1; + break; + case OSUBTRACT: + prec = P_ADD; + str = walk(1,level,ops[node+1].ival,&numarg,prec); + str_cat(str," - "); + str_scat(str,fstr=walk(1,level,ops[node+2].ival,&numarg,prec+1)); + str_free(fstr); + numeric = 1; + break; + case OMULT: + prec = P_MUL; + str = walk(1,level,ops[node+1].ival,&numarg,prec); + str_cat(str," * "); + str_scat(str,fstr=walk(1,level,ops[node+2].ival,&numarg,prec+1)); + str_free(fstr); + numeric = 1; + break; + case ODIV: + prec = P_MUL; + str = walk(1,level,ops[node+1].ival,&numarg,prec); + str_cat(str," / "); + str_scat(str,fstr=walk(1,level,ops[node+2].ival,&numarg,prec+1)); + str_free(fstr); + numeric = 1; + break; + case OPOW: + prec = P_POW; + str = walk(1,level,ops[node+1].ival,&numarg,prec+1); + str_cat(str," ** "); + str_scat(str,fstr=walk(1,level,ops[node+2].ival,&numarg,prec)); + str_free(fstr); + numeric = 1; + break; + case OMOD: + prec = P_MUL; + str = walk(1,level,ops[node+1].ival,&numarg,prec); + str_cat(str," % "); + str_scat(str,fstr=walk(1,level,ops[node+2].ival,&numarg,prec+1)); + str_free(fstr); + numeric = 1; + break; + case OPOSTINCR: + prec = P_AUTO; + str = walk(1,level,ops[node+1].ival,&numarg,prec+1); + str_cat(str,"++"); + numeric = 1; + break; + case OPOSTDECR: + prec = P_AUTO; + str = walk(1,level,ops[node+1].ival,&numarg,prec+1); + str_cat(str,"--"); + numeric = 1; + break; + case OPREINCR: + prec = P_AUTO; + str = str_new(0); + str_set(str,"++"); + str_scat(str,fstr=walk(1,level,ops[node+1].ival,&numarg,prec+1)); + str_free(fstr); + numeric = 1; + break; + case OPREDECR: + prec = P_AUTO; + str = str_new(0); + str_set(str,"--"); + str_scat(str,fstr=walk(1,level,ops[node+1].ival,&numarg,prec+1)); + str_free(fstr); + numeric = 1; + break; + case OUMINUS: + prec = P_UNARY; + str = str_new(0); + str_set(str,"-"); + str_scat(str,fstr=walk(1,level,ops[node+1].ival,&numarg,prec)); + str_free(fstr); + numeric = 1; + break; + case OUPLUS: + numeric = 1; + goto def; + case OPAREN: + str = str_new(0); + str_set(str,"("); + str_scat(str, + fstr=walk(useval != 0,level,ops[node+1].ival,&numarg,P_MIN)); + str_free(fstr); + str_cat(str,")"); + numeric |= numarg; + break; + case OGETLINE: + str = str_new(0); + if (useval) + str_cat(str,"("); + if (len > 0) { + str_scat(str,fstr=walk(1,level,ops[node+1].ival,&numarg,P_MIN)); + if (!*fstr->str_ptr) { + str_cat(str,"$_"); + len = 2; /* a legal fiction */ + } + str_free(fstr); + } + else + str_cat(str,"$_"); + if (len > 1) { + tmpstr=walk(1,level,ops[node+3].ival,&numarg,P_MIN); + fstr=walk(1,level,ops[node+2].ival,&numarg,P_MIN); + if (!do_fancy_opens) { + t = tmpstr->str_ptr; + if (*t == '"' || *t == '\'') + t = cpytill(tokenbuf,t+1,*t); + else + fatal("Internal error: OGETLINE %s", t); + d = savestr(t); + s = savestr(tokenbuf); + for (t = tokenbuf; *t; t++) { + *t &= 127; + if (islower(*t)) + *t = toupper(*t); + if (!isalpha(*t) && !isdigit(*t)) + *t = '_'; + } + if (!index(tokenbuf,'_')) + strcpy(t,"_FH"); + tmp3str = hfetch(symtab,tokenbuf); + if (!tmp3str) { + do_opens = TRUE; + str_cat(opens,"open("); + str_cat(opens,tokenbuf); + str_cat(opens,", "); + d[1] = '\0'; + str_cat(opens,d); + str_cat(opens,tmpstr->str_ptr+1); + opens->str_cur--; + if (*fstr->str_ptr == '|') + str_cat(opens,"|"); + str_cat(opens,d); + if (*fstr->str_ptr == '|') + str_cat(opens,") || die 'Cannot pipe from \""); + else + str_cat(opens,") || die 'Cannot open file \""); + if (*d == '"') + str_cat(opens,"'.\""); + str_cat(opens,s); + if (*d == '"') + str_cat(opens,"\".'"); + str_cat(opens,"\".';\n"); + hstore(symtab,tokenbuf,str_make("x")); + } + safefree(s); + safefree(d); + str_set(tmpstr,"'"); + str_cat(tmpstr,tokenbuf); + str_cat(tmpstr,"'"); + } + if (*fstr->str_ptr == '|') + str_cat(tmpstr,", '|'"); + str_free(fstr); + } + else + tmpstr = str_make(""); + sprintf(tokenbuf," = &Getline%d(%s)",len,tmpstr->str_ptr); + str_cat(str,tokenbuf); + str_free(tmpstr); + if (useval) + str_cat(str,",$getline_ok)"); + saw_getline |= 1 << len; + break; + case OSPRINTF: + str = str_new(0); + str_set(str,"sprintf("); + str_scat(str,fstr=walk(1,level,ops[node+1].ival,&numarg,P_MIN)); + str_free(fstr); + str_cat(str,")"); + break; + case OSUBSTR: + str = str_new(0); + str_set(str,"substr("); + str_scat(str,fstr=walk(1,level,ops[node+1].ival,&numarg,P_COMMA+1)); + str_free(fstr); + str_cat(str,", "); + str_scat(str,fstr=walk(1,level,ops[node+2].ival,&numarg,P_COMMA+1)); + str_free(fstr); + str_cat(str,", "); + if (len == 3) { + str_scat(str,fstr=walk(1,level,ops[node+3].ival,&numarg,P_COMMA+1)); + str_free(fstr); + } + else + str_cat(str,"999999"); + str_cat(str,")"); + break; + case OSTRING: + str = str_new(0); + str_set(str,ops[node+1].cval); + break; + case OSPLIT: + str = str_new(0); + limit = ", 9999)"; + numeric = 1; + tmpstr = walk(1,level,ops[node+2].ival,&numarg,P_MIN); + if (useval) + str_set(str,"(@"); + else + str_set(str,"@"); + str_scat(str,tmpstr); + str_cat(str," = split("); + if (len == 3) { + fstr = walk(1,level,ops[node+3].ival,&numarg,P_COMMA+1); + if (str_len(fstr) == 3 && *fstr->str_ptr == '\'') { + i = fstr->str_ptr[1] & 127; + if (index("*+?.[]()|^$\\",i)) + sprintf(tokenbuf,"/\\%c/",i); + else if (i == ' ') + sprintf(tokenbuf,"' '"); + else + sprintf(tokenbuf,"/%c/",i); + str_cat(str,tokenbuf); + } + else + str_scat(str,fstr); + str_free(fstr); + } + else if (const_FS) { + sprintf(tokenbuf,"/[%c\\n]/",const_FS); + str_cat(str,tokenbuf); + } + else if (saw_FS) + str_cat(str,"$FS"); + else { + str_cat(str,"' '"); + limit = ")"; + } + str_cat(str,", "); + str_scat(str,fstr=walk(1,level,ops[node+1].ival,&numarg,P_COMMA+1)); + str_free(fstr); + str_cat(str,limit); + if (useval) { + str_cat(str,")"); + } + str_free(tmpstr); + break; + case OINDEX: + str = str_new(0); + str_set(str,"index("); + str_scat(str,fstr=walk(1,level,ops[node+1].ival,&numarg,P_COMMA+1)); + str_free(fstr); + str_cat(str,", "); + str_scat(str,fstr=walk(1,level,ops[node+2].ival,&numarg,P_COMMA+1)); + str_free(fstr); + str_cat(str,")"); + numeric = 1; + break; + case OMATCH: + str = str_new(0); + prec = P_ANDAND; + str_scat(str,fstr=walk(1,level,ops[node+1].ival,&numarg,P_MATCH+1)); + str_free(fstr); + str_cat(str," =~ "); + str_scat(str,fstr=walk(1,level,ops[node+2].ival,&numarg,P_MATCH+1)); + str_free(fstr); + str_cat(str," && ($RLENGTH = length($&), $RSTART = length($`)+1)"); + numeric = 1; + break; + case OUSERDEF: + str = str_new(0); + subretnum = FALSE; + fstr=walk(1,level-1,ops[node+2].ival,&numarg,P_MIN); + curargs = str_new(0); + str_sset(curargs,fstr); + str_cat(curargs,","); + tmp2str=walk(1,level,ops[node+5].ival,&numarg,P_MIN); + str_free(curargs); + curargs = Nullstr; + level--; + subretnum |= numarg; + s = Nullch; + t = tmp2str->str_ptr; + while (t = instr(t,"return ")) + s = t++; + if (s) { + i = 0; + for (t = s+7; *t; t++) { + if (*t == ';' || *t == '}') + i++; + } + if (i == 1) { + strcpy(s,s+7); + tmp2str->str_cur -= 7; + } + } + str_set(str,"\n"); + tab(str,level); + str_cat(str,"sub "); + str_scat(str,tmpstr=walk(1,level,ops[node+1].ival,&numarg,P_MIN)); + str_cat(str," {\n"); + tab(str,++level); + if (fstr->str_cur) { + str_cat(str,"local("); + str_scat(str,fstr); + str_cat(str,") = @_;"); + } + str_free(fstr); + str_scat(str,fstr=walk(1,level,ops[node+3].ival,&numarg,P_MIN)); + str_free(fstr); + fixtab(str,level); + str_scat(str,fstr=walk(1,level,ops[node+4].ival,&numarg,P_MIN)); + str_free(fstr); + fixtab(str,level); + str_scat(str,tmp2str); + str_free(tmp2str); + fixtab(str,--level); + str_cat(str,"}\n"); + tab(str,level); + str_scat(subs,str); + str_set(str,""); + str_cat(tmpstr,"("); + tmp2str = str_new(0); + if (subretnum) + str_set(tmp2str,"1"); + hstore(symtab,tmpstr->str_ptr,tmp2str); + str_free(tmpstr); + level++; + break; + case ORETURN: + str = str_new(0); + if (len > 0) { + str_cat(str,"return "); + str_scat(str,fstr=walk(1,level,ops[node+1].ival,&numarg,P_UNI+1)); + str_free(fstr); + if (numarg) + subretnum = TRUE; + } + else + str_cat(str,"return"); + break; + case OUSERFUN: + str = str_new(0); + str_set(str,"&"); + str_scat(str,fstr=walk(1,level,ops[node+1].ival,&numarg,P_MIN)); + str_free(fstr); + str_cat(str,"("); + tmpstr = hfetch(symtab,str->str_ptr+3); + if (tmpstr && tmpstr->str_ptr) + numeric |= atoi(tmpstr->str_ptr); + str_scat(str,fstr=walk(1,level,ops[node+2].ival,&numarg,P_MIN)); + str_free(fstr); + str_cat(str,")"); + break; + case OGSUB: + case OSUB: + if (type == OGSUB) + s = "g"; + else + s = ""; + str = str_new(0); + tmpstr = str_new(0); + i = 0; + if (len == 3) { + tmpstr = walk(1,level,ops[node+3].ival,&numarg,P_MATCH+1); + if (strNE(tmpstr->str_ptr,"$_")) { + str_cat(tmpstr, " =~ s"); + i++; + } + else + str_set(tmpstr, "s"); + } + else + str_set(tmpstr, "s"); + type = ops[ops[node+2].ival].ival; + len = type >> 8; + type &= 255; + tmp3str = str_new(0); + if (type == OSTR) { + tmp2str=walk(1,level,ops[ops[node+2].ival+1].ival,&numarg,P_MIN); + for (t = tmp2str->str_ptr, d=tokenbuf; *t; d++,t++) { + if (*t == '&') + *d++ = '$' + 128; + else if (*t == '$') + *d++ = '\\' + 128; + *d = *t + 128; + } + *d = '\0'; + str_set(tmp2str,tokenbuf); + } + else { + tmp2str=walk(1,level,ops[node+2].ival,&numarg,P_MIN); + str_set(tmp3str,"($s_ = '\"'.("); + str_scat(tmp3str,tmp2str); + str_cat(tmp3str,").'\"') =~ s/&/\\$&/g, "); + str_set(tmp2str,"eval $s_"); + s = (*s == 'g' ? "ge" : "e"); + i++; + } + type = ops[ops[node+1].ival].ival; + len = type >> 8; + type &= 255; + fstr=walk(1,level,ops[node+1].ival,&numarg,P_MIN); + if (type == OREGEX) { + if (useval && i) + str_cat(str,"("); + str_scat(str,tmp3str); + str_scat(str,tmpstr); + str_scat(str,fstr); + str_scat(str,tmp2str); + str_cat(str,"/"); + str_cat(str,s); + } + else if ((type == OFLD && !split_to_array) || (type == OVAR && len == 1)) { + if (useval && i) + str_cat(str,"("); + str_scat(str,tmp3str); + str_scat(str,tmpstr); + str_cat(str,"/"); + str_scat(str,fstr); + str_cat(str,"/"); + str_scat(str,tmp2str); + str_cat(str,"/"); + str_cat(str,s); + } + else { + i++; + if (useval) + str_cat(str,"("); + str_cat(str,"$s = "); + str_scat(str,fstr); + str_cat(str,", "); + str_scat(str,tmp3str); + str_scat(str,tmpstr); + str_cat(str,"/$s/"); + str_scat(str,tmp2str); + str_cat(str,"/"); + str_cat(str,s); + } + if (useval && i) + str_cat(str,")"); + str_free(fstr); + str_free(tmpstr); + str_free(tmp2str); + str_free(tmp3str); + numeric = 1; + break; + case ONUM: + str = walk(1,level,ops[node+1].ival,&numarg,P_MIN); + numeric = 1; + break; + case OSTR: + tmpstr = walk(1,level,ops[node+1].ival,&numarg,P_MIN); + s = "'"; + for (t = tmpstr->str_ptr, d=tokenbuf; *t; d++,t++) { + if (*t == '\'') + s = "\""; + else if (*t == '\\') { + s = "\""; + *d++ = *t++ + 128; + switch (*t) { + case '\\': case '"': case 'n': case 't': case '$': + break; + default: /* hide this from perl */ + *d++ = '\\' + 128; + } + } + *d = *t + 128; + } + *d = '\0'; + str = str_new(0); + str_set(str,s); + str_cat(str,tokenbuf); + str_free(tmpstr); + str_cat(str,s); + break; + case ODEFINED: + prec = P_UNI; + str = str_new(0); + str_set(str,"defined $"); + goto addvar; + case ODELETE: + str = str_new(0); + str_set(str,"delete $"); + goto addvar; + case OSTAR: + str = str_new(0); + str_set(str,"*"); + goto addvar; + case OVAR: + str = str_new(0); + str_set(str,"$"); + addvar: + str_scat(str,tmpstr=walk(1,level,ops[node+1].ival,&numarg,P_MIN)); + if (len == 1) { + tmp2str = hfetch(symtab,tmpstr->str_ptr); + if (tmp2str && atoi(tmp2str->str_ptr)) + numeric = 2; + if (strEQ(str->str_ptr,"$FNR")) { + numeric = 1; + saw_FNR++; + str_set(str,"($.-$FNRbase)"); + } + else if (strEQ(str->str_ptr,"$NR")) { + numeric = 1; + str_set(str,"$."); + } + else if (strEQ(str->str_ptr,"$NF")) { + numeric = 1; + str_set(str,"$#Fld"); + } + else if (strEQ(str->str_ptr,"$0")) + str_set(str,"$_"); + else if (strEQ(str->str_ptr,"$ARGC")) + str_set(str,"($#ARGV+1)"); + } + else { +#ifdef NOTDEF + if (curargs) { + sprintf(tokenbuf,"$%s,",tmpstr->str_ptr); + ??? if (instr(curargs->str_ptr,tokenbuf)) + str_cat(str,"\377"); /* can't translate yet */ + } +#endif + str_cat(tmpstr,"[]"); + tmp2str = hfetch(symtab,tmpstr->str_ptr); + if (tmp2str && atoi(tmp2str->str_ptr)) + str_cat(str,"["); + else + str_cat(str,"{"); + str_scat(str,fstr=walk(1,level,ops[node+2].ival,&numarg,P_MIN)); + str_free(fstr); + if (strEQ(str->str_ptr,"$ARGV[0")) { + str_set(str,"$ARGV0"); + saw_argv0++; + } + else { + if (tmp2str && atoi(tmp2str->str_ptr)) + strcpy(tokenbuf,"]"); + else + strcpy(tokenbuf,"}"); + *tokenbuf += 128; + str_cat(str,tokenbuf); + } + } + str_free(tmpstr); + break; + case OFLD: + str = str_new(0); + if (split_to_array) { + str_set(str,"$Fld"); + str_cat(str,"["); + str_scat(str,fstr=walk(1,level,ops[node+1].ival,&numarg,P_MIN)); + str_free(fstr); + str_cat(str,"]"); + } + else { + i = atoi(walk(1,level,ops[node+1].ival,&numarg,P_MIN)->str_ptr); + if (i <= arymax) + sprintf(tokenbuf,"$%s",nameary[i]); + else + sprintf(tokenbuf,"$Fld%d",i); + str_set(str,tokenbuf); + } + break; + case OVFLD: + str = str_new(0); + str_set(str,"$Fld["); + i = ops[node+1].ival; + if ((ops[i].ival & 255) == OPAREN) + i = ops[i+1].ival; + tmpstr=walk(1,level,i,&numarg,P_MIN); + str_scat(str,tmpstr); + str_free(tmpstr); + str_cat(str,"]"); + break; + case OJUNK: + goto def; + case OSNEWLINE: + str = str_new(2); + str_set(str,";\n"); + tab(str,level); + break; + case ONEWLINE: + str = str_new(1); + str_set(str,"\n"); + tab(str,level); + break; + case OSCOMMENT: + str = str_new(0); + str_set(str,";"); + tmpstr = walk(0,level,ops[node+1].ival,&numarg,P_MIN); + for (s = tmpstr->str_ptr; *s && *s != '\n'; s++) + *s += 128; + str_scat(str,tmpstr); + str_free(tmpstr); + tab(str,level); + break; + case OCOMMENT: + str = str_new(0); + tmpstr = walk(0,level,ops[node+1].ival,&numarg,P_MIN); + for (s = tmpstr->str_ptr; *s && *s != '\n'; s++) + *s += 128; + str_scat(str,tmpstr); + str_free(tmpstr); + tab(str,level); + break; + case OCOMMA: + prec = P_COMMA; + str = walk(1,level,ops[node+1].ival,&numarg,prec); + str_cat(str,", "); + str_scat(str,fstr=walk(1,level,ops[node+2].ival,&numarg,P_MIN)); + str_free(fstr); + str_scat(str,fstr=walk(1,level,ops[node+3].ival,&numarg,prec+1)); + str_free(fstr); + break; + case OSEMICOLON: + str = str_new(1); + str_set(str,";\n"); + tab(str,level); + break; + case OSTATES: + str = walk(0,level,ops[node+1].ival,&numarg,P_MIN); + str_scat(str,fstr=walk(0,level,ops[node+2].ival,&numarg,P_MIN)); + str_free(fstr); + break; + case OSTATE: + str = str_new(0); + if (len >= 1) { + str_scat(str,fstr=walk(0,level,ops[node+1].ival,&numarg,P_MIN)); + str_free(fstr); + if (len >= 2) { + tmpstr = walk(0,level,ops[node+2].ival,&numarg,P_MIN); + if (*tmpstr->str_ptr == ';') { + addsemi(str); + str_cat(str,tmpstr->str_ptr+1); + } + str_free(tmpstr); + } + } + break; + case OCLOSE: + str = str_make("close("); + tmpstr = walk(1,level,ops[node+1].ival,&numarg,P_MIN); + if (!do_fancy_opens) { + t = tmpstr->str_ptr; + if (*t == '"' || *t == '\'') + t = cpytill(tokenbuf,t+1,*t); + else + fatal("Internal error: OCLOSE %s",t); + s = savestr(tokenbuf); + for (t = tokenbuf; *t; t++) { + *t &= 127; + if (islower(*t)) + *t = toupper(*t); + if (!isalpha(*t) && !isdigit(*t)) + *t = '_'; + } + if (!index(tokenbuf,'_')) + strcpy(t,"_FH"); + str_free(tmpstr); + safefree(s); + str_set(str,"close "); + str_cat(str,tokenbuf); + } + else { + sprintf(tokenbuf,"delete $opened{%s} && close(%s)", + tmpstr->str_ptr, tmpstr->str_ptr); + str_free(tmpstr); + str_set(str,tokenbuf); + } + break; + case OPRINTF: + case OPRINT: + lparen = ""; /* set to parens if necessary */ + rparen = ""; + str = str_new(0); + if (len == 3) { /* output redirection */ + tmpstr = walk(1,level,ops[node+3].ival,&numarg,P_MIN); + tmp2str = walk(1,level,ops[node+2].ival,&numarg,P_MIN); + if (!do_fancy_opens) { + t = tmpstr->str_ptr; + if (*t == '"' || *t == '\'') + t = cpytill(tokenbuf,t+1,*t); + else + fatal("Internal error: OPRINT"); + d = savestr(t); + s = savestr(tokenbuf); + for (t = tokenbuf; *t; t++) { + *t &= 127; + if (islower(*t)) + *t = toupper(*t); + if (!isalpha(*t) && !isdigit(*t)) + *t = '_'; + } + if (!index(tokenbuf,'_')) + strcpy(t,"_FH"); + tmp3str = hfetch(symtab,tokenbuf); + if (!tmp3str) { + str_cat(opens,"open("); + str_cat(opens,tokenbuf); + str_cat(opens,", "); + d[1] = '\0'; + str_cat(opens,d); + str_scat(opens,tmp2str); + str_cat(opens,tmpstr->str_ptr+1); + if (*tmp2str->str_ptr == '|') + str_cat(opens,") || die 'Cannot pipe to \""); + else + str_cat(opens,") || die 'Cannot create file \""); + if (*d == '"') + str_cat(opens,"'.\""); + str_cat(opens,s); + if (*d == '"') + str_cat(opens,"\".'"); + str_cat(opens,"\".';\n"); + hstore(symtab,tokenbuf,str_make("x")); + } + str_free(tmpstr); + str_free(tmp2str); + safefree(s); + safefree(d); + } + else { + sprintf(tokenbuf,"&Pick('%s', %s) &&\n", + tmp2str->str_ptr, tmpstr->str_ptr); + str_cat(str,tokenbuf); + tab(str,level+1); + strcpy(tokenbuf,"$fh"); + str_free(tmpstr); + str_free(tmp2str); + lparen = "("; + rparen = ")"; + } + } + else + strcpy(tokenbuf,""); + str_cat(str,lparen); /* may be null */ + if (type == OPRINTF) + str_cat(str,"printf"); + else + str_cat(str,"print"); + saw_fh = 0; + if (len == 3 || do_fancy_opens) { + if (*tokenbuf) { + str_cat(str," "); + saw_fh = 1; + } + str_cat(str,tokenbuf); + } + tmpstr = walk(1+(type==OPRINT),level,ops[node+1].ival,&numarg,P_MIN); + if (!*tmpstr->str_ptr && lval_field) { + t = saw_OFS ? "$," : "' '"; + if (split_to_array) { + sprintf(tokenbuf,"join(%s,@Fld)",t); + str_cat(tmpstr,tokenbuf); + } + else { + for (i = 1; i < maxfld; i++) { + if (i <= arymax) + sprintf(tokenbuf,"$%s, ",nameary[i]); + else + sprintf(tokenbuf,"$Fld%d, ",i); + str_cat(tmpstr,tokenbuf); + } + if (maxfld <= arymax) + sprintf(tokenbuf,"$%s",nameary[maxfld]); + else + sprintf(tokenbuf,"$Fld%d",maxfld); + str_cat(tmpstr,tokenbuf); + } + } + if (*tmpstr->str_ptr) { + str_cat(str," "); + if (!saw_fh && *tmpstr->str_ptr == '(') { + str_cat(str,"("); + str_scat(str,tmpstr); + str_cat(str,")"); + } + else + str_scat(str,tmpstr); + } + else { + str_cat(str," $_"); + } + str_cat(str,rparen); /* may be null */ + str_free(tmpstr); + break; + case ORAND: + str = str_make("rand(1)"); + break; + case OSRAND: + str = str_make("srand("); + goto maybe0; + case OATAN2: + str = str_make("atan2("); + goto maybe0; + case OSIN: + str = str_make("sin("); + goto maybe0; + case OCOS: + str = str_make("cos("); + goto maybe0; + case OSYSTEM: + str = str_make("system("); + goto maybe0; + case OLENGTH: + str = str_make("length("); + goto maybe0; + case OLOG: + str = str_make("log("); + goto maybe0; + case OEXP: + str = str_make("exp("); + goto maybe0; + case OSQRT: + str = str_make("sqrt("); + goto maybe0; + case OINT: + str = str_make("int("); + maybe0: + numeric = 1; + if (len > 0) + tmpstr = walk(1,level,ops[node+1].ival,&numarg,P_MIN); + else + tmpstr = str_new(0);; + if (!tmpstr->str_ptr || !*tmpstr->str_ptr) { + if (lval_field) { + t = saw_OFS ? "$," : "' '"; + if (split_to_array) { + sprintf(tokenbuf,"join(%s,@Fld)",t); + str_cat(tmpstr,tokenbuf); + } + else { + sprintf(tokenbuf,"join(%s, ",t); + str_cat(tmpstr,tokenbuf); + for (i = 1; i < maxfld; i++) { + if (i <= arymax) + sprintf(tokenbuf,"$%s,",nameary[i]); + else + sprintf(tokenbuf,"$Fld%d,",i); + str_cat(tmpstr,tokenbuf); + } + if (maxfld <= arymax) + sprintf(tokenbuf,"$%s)",nameary[maxfld]); + else + sprintf(tokenbuf,"$Fld%d)",maxfld); + str_cat(tmpstr,tokenbuf); + } + } + else + str_cat(tmpstr,"$_"); + } + if (strEQ(tmpstr->str_ptr,"$_")) { + if (type == OLENGTH && !do_chop) { + str = str_make("(length("); + str_cat(tmpstr,") - 1"); + } + } + str_scat(str,tmpstr); + str_free(tmpstr); + str_cat(str,")"); + break; + case OBREAK: + str = str_new(0); + str_set(str,"last"); + break; + case ONEXT: + str = str_new(0); + str_set(str,"next line"); + break; + case OEXIT: + str = str_new(0); + if (realexit) { + prec = P_UNI; + str_set(str,"exit"); + if (len == 1) { + str_cat(str," "); + exitval = TRUE; + str_scat(str, + fstr=walk(1,level,ops[node+1].ival,&numarg,prec+1)); + str_free(fstr); + } + } + else { + if (len == 1) { + str_set(str,"$ExitValue = "); + exitval = TRUE; + str_scat(str, + fstr=walk(1,level,ops[node+1].ival,&numarg,P_ASSIGN)); + str_free(fstr); + str_cat(str,"; "); + } + str_cat(str,"last line"); + } + break; + case OCONTINUE: + str = str_new(0); + str_set(str,"next"); + break; + case OREDIR: + goto def; + case OIF: + str = str_new(0); + str_set(str,"if ("); + str_scat(str,fstr=walk(1,level,ops[node+1].ival,&numarg,P_MIN)); + str_free(fstr); + str_cat(str,") "); + str_scat(str,fstr=walk(0,level,ops[node+2].ival,&numarg,P_MIN)); + str_free(fstr); + if (len == 3) { + i = ops[node+3].ival; + if (i) { + if ((ops[i].ival & 255) == OBLOCK) { + i = ops[i+1].ival; + if (i) { + if ((ops[i].ival & 255) != OIF) + i = 0; + } + } + else + i = 0; + } + if (i) { + str_cat(str,"els"); + str_scat(str,fstr=walk(0,level,i,&numarg,P_MIN)); + str_free(fstr); + } + else { + str_cat(str,"else "); + str_scat(str,fstr=walk(0,level,ops[node+3].ival,&numarg,P_MIN)); + str_free(fstr); + } + } + break; + case OWHILE: + str = str_new(0); + str_set(str,"while ("); + str_scat(str,fstr=walk(1,level,ops[node+1].ival,&numarg,P_MIN)); + str_free(fstr); + str_cat(str,") "); + str_scat(str,fstr=walk(0,level,ops[node+2].ival,&numarg,P_MIN)); + str_free(fstr); + break; + case ODO: + str = str_new(0); + str_set(str,"do "); + str_scat(str,fstr=walk(1,level,ops[node+1].ival,&numarg,P_MIN)); + str_free(fstr); + if (str->str_ptr[str->str_cur - 1] == '\n') + --str->str_cur;; + str_cat(str," while ("); + str_scat(str,fstr=walk(0,level,ops[node+2].ival,&numarg,P_MIN)); + str_free(fstr); + str_cat(str,");"); + break; + case OFOR: + str = str_new(0); + str_set(str,"for ("); + str_scat(str,tmpstr=walk(1,level,ops[node+1].ival,&numarg,P_MIN)); + i = numarg; + if (i) { + t = s = tmpstr->str_ptr; + while (isalpha(*t) || isdigit(*t) || *t == '$' || *t == '_') + t++; + i = t - s; + if (i < 2) + i = 0; + } + str_cat(str,"; "); + fstr=walk(1,level,ops[node+2].ival,&numarg,P_MIN); + if (i && (t = index(fstr->str_ptr,0377))) { + if (strnEQ(fstr->str_ptr,s,i)) + *t = ' '; + } + str_scat(str,fstr); + str_free(fstr); + str_free(tmpstr); + str_cat(str,"; "); + str_scat(str,fstr=walk(1,level,ops[node+3].ival,&numarg,P_MIN)); + str_free(fstr); + str_cat(str,") "); + str_scat(str,fstr=walk(0,level,ops[node+4].ival,&numarg,P_MIN)); + str_free(fstr); + break; + case OFORIN: + tmpstr = walk(0,level,ops[node+1].ival,&numarg,P_MIN); + d = index(tmpstr->str_ptr,'$'); + if (!d) + fatal("Illegal for loop: %s",tmpstr->str_ptr); + s = index(d,'{'); + if (!s) + s = index(d,'['); + if (!s) + fatal("Illegal for loop: %s",d); + *s++ = '\0'; + for (t = s; i = *t; t++) { + i &= 127; + if (i == '}' || i == ']') + break; + } + if (*t) + *t = '\0'; + str = str_new(0); + str_set(str,d+1); + str_cat(str,"[]"); + tmp2str = hfetch(symtab,str->str_ptr); + if (tmp2str && atoi(tmp2str->str_ptr)) { + sprintf(tokenbuf, + "foreach %s ($[ .. $#%s) ", + s, + d+1); + } + else { + sprintf(tokenbuf, + "foreach %s (keys %%%s) ", + s, + d+1); + } + str_set(str,tokenbuf); + str_scat(str,fstr=walk(0,level,ops[node+2].ival,&numarg,P_MIN)); + str_free(fstr); + str_free(tmpstr); + break; + case OBLOCK: + str = str_new(0); + str_set(str,"{"); + if (len >= 2 && ops[node+2].ival) { + str_scat(str,fstr=walk(0,level,ops[node+2].ival,&numarg,P_MIN)); + str_free(fstr); + } + fixtab(str,++level); + str_scat(str,fstr=walk(0,level,ops[node+1].ival,&numarg,P_MIN)); + str_free(fstr); + addsemi(str); + fixtab(str,--level); + str_cat(str,"}\n"); + tab(str,level); + if (len >= 3) { + str_scat(str,fstr=walk(0,level,ops[node+3].ival,&numarg,P_MIN)); + str_free(fstr); + } + break; + default: + def: + if (len) { + if (len > 5) + fatal("Garbage length in walk"); + str = walk(0,level,ops[node+1].ival,&numarg,P_MIN); + for (i = 2; i<= len; i++) { + str_scat(str,fstr=walk(0,level,ops[node+i].ival,&numarg,P_MIN)); + str_free(fstr); + } + } + else { + str = Nullstr; + } + break; + } + if (!str) + str = str_new(0); + + if (useval && prec < minprec) { /* need parens? */ + fstr = str_new(str->str_cur+2); + str_nset(fstr,"(",1); + str_scat(fstr,str); + str_ncat(fstr,")",1); + str_free(str); + str = fstr; + } + + *numericptr = numeric; +#ifdef DEBUGGING + if (debug & 4) { + printf("%3d %5d %15s %d %4d ",level,node,opname[type],len,str->str_cur); + for (t = str->str_ptr; *t && t - str->str_ptr < 40; t++) + if (*t == '\n') + printf("\\n"); + else if (*t == '\t') + printf("\\t"); + else + putchar(*t); + putchar('\n'); + } +#endif + return str; +} + +tab(str,lvl) +register STR *str; +register int lvl; +{ + while (lvl > 1) { + str_cat(str,"\t"); + lvl -= 2; + } + if (lvl) + str_cat(str," "); +} + +fixtab(str,lvl) +register STR *str; +register int lvl; +{ + register char *s; + + /* strip trailing white space */ + + s = str->str_ptr+str->str_cur - 1; + while (s >= str->str_ptr && (*s == ' ' || *s == '\t' || *s == '\n')) + s--; + s[1] = '\0'; + str->str_cur = s + 1 - str->str_ptr; + if (s >= str->str_ptr && *s != '\n') + str_cat(str,"\n"); + + tab(str,lvl); +} + +addsemi(str) +register STR *str; +{ + register char *s; + + s = str->str_ptr+str->str_cur - 1; + while (s >= str->str_ptr && (*s == ' ' || *s == '\t' || *s == '\n')) + s--; + if (s >= str->str_ptr && *s != ';' && *s != '}') + str_cat(str,";"); +} + +emit_split(str,level) +register STR *str; +int level; +{ + register int i; + + if (split_to_array) + str_cat(str,"@Fld"); + else { + str_cat(str,"("); + for (i = 1; i < maxfld; i++) { + if (i <= arymax) + sprintf(tokenbuf,"$%s,",nameary[i]); + else + sprintf(tokenbuf,"$Fld%d,",i); + str_cat(str,tokenbuf); + } + if (maxfld <= arymax) + sprintf(tokenbuf,"$%s)",nameary[maxfld]); + else + sprintf(tokenbuf,"$Fld%d)",maxfld); + str_cat(str,tokenbuf); + } + if (const_FS) { + sprintf(tokenbuf," = split(/[%c\\n]/, $_, 9999);\n",const_FS); + str_cat(str,tokenbuf); + } + else if (saw_FS) + str_cat(str," = split($FS, $_, 9999);\n"); + else + str_cat(str," = split(' ', $_, 9999);\n"); + tab(str,level); +} + +prewalk(numit,level,node,numericptr) +int numit; +int level; +register int node; +int *numericptr; +{ + register int len; + register int type; + register int i; + char *t; + char *d, *s; + int numarg; + int numeric = FALSE; + STR *tmpstr; + STR *tmp2str; + + if (!node) { + *numericptr = 0; + return 0; + } + type = ops[node].ival; + len = type >> 8; + type &= 255; + switch (type) { + case OPROG: + prewalk(0,level,ops[node+1].ival,&numarg); + if (ops[node+2].ival) { + prewalk(0,level,ops[node+2].ival,&numarg); + } + ++level; + prewalk(0,level,ops[node+3].ival,&numarg); + --level; + if (ops[node+3].ival) { + prewalk(0,level,ops[node+4].ival,&numarg); + } + break; + case OHUNKS: + prewalk(0,level,ops[node+1].ival,&numarg); + prewalk(0,level,ops[node+2].ival,&numarg); + if (len == 3) { + prewalk(0,level,ops[node+3].ival,&numarg); + } + break; + case ORANGE: + prewalk(1,level,ops[node+1].ival,&numarg); + prewalk(1,level,ops[node+2].ival,&numarg); + break; + case OPAT: + goto def; + case OREGEX: + prewalk(0,level,ops[node+1].ival,&numarg); + break; + case OHUNK: + if (len == 1) { + prewalk(0,level,ops[node+1].ival,&numarg); + } + else { + i = prewalk(0,level,ops[node+1].ival,&numarg); + if (i) { + ++level; + prewalk(0,level,ops[node+2].ival,&numarg); + --level; + } + else { + prewalk(0,level,ops[node+2].ival,&numarg); + } + } + break; + case OPPAREN: + prewalk(0,level,ops[node+1].ival,&numarg); + break; + case OPANDAND: + prewalk(0,level,ops[node+1].ival,&numarg); + prewalk(0,level,ops[node+2].ival,&numarg); + break; + case OPOROR: + prewalk(0,level,ops[node+1].ival,&numarg); + prewalk(0,level,ops[node+2].ival,&numarg); + break; + case OPNOT: + prewalk(0,level,ops[node+1].ival,&numarg); + break; + case OCPAREN: + prewalk(0,level,ops[node+1].ival,&numarg); + numeric |= numarg; + break; + case OCANDAND: + prewalk(0,level,ops[node+1].ival,&numarg); + numeric = 1; + prewalk(0,level,ops[node+2].ival,&numarg); + break; + case OCOROR: + prewalk(0,level,ops[node+1].ival,&numarg); + numeric = 1; + prewalk(0,level,ops[node+2].ival,&numarg); + break; + case OCNOT: + prewalk(0,level,ops[node+1].ival,&numarg); + numeric = 1; + break; + case ORELOP: + prewalk(0,level,ops[node+2].ival,&numarg); + numeric |= numarg; + prewalk(0,level,ops[node+1].ival,&numarg); + prewalk(0,level,ops[node+3].ival,&numarg); + numeric |= numarg; + numeric = 1; + break; + case ORPAREN: + prewalk(0,level,ops[node+1].ival,&numarg); + numeric |= numarg; + break; + case OMATCHOP: + prewalk(0,level,ops[node+2].ival,&numarg); + prewalk(0,level,ops[node+1].ival,&numarg); + prewalk(0,level,ops[node+3].ival,&numarg); + numeric = 1; + break; + case OMPAREN: + prewalk(0,level,ops[node+1].ival,&numarg); + numeric |= numarg; + break; + case OCONCAT: + prewalk(0,level,ops[node+1].ival,&numarg); + prewalk(0,level,ops[node+2].ival,&numarg); + break; + case OASSIGN: + prewalk(0,level,ops[node+2].ival,&numarg); + prewalk(0,level,ops[node+1].ival,&numarg); + prewalk(0,level,ops[node+3].ival,&numarg); + if (numarg || strlen(ops[ops[node+1].ival+1].cval) > 1) { + numericize(ops[node+2].ival); + if (!numarg) + numericize(ops[node+3].ival); + } + numeric |= numarg; + break; + case OADD: + prewalk(1,level,ops[node+1].ival,&numarg); + prewalk(1,level,ops[node+2].ival,&numarg); + numeric = 1; + break; + case OSUBTRACT: + prewalk(1,level,ops[node+1].ival,&numarg); + prewalk(1,level,ops[node+2].ival,&numarg); + numeric = 1; + break; + case OMULT: + prewalk(1,level,ops[node+1].ival,&numarg); + prewalk(1,level,ops[node+2].ival,&numarg); + numeric = 1; + break; + case ODIV: + prewalk(1,level,ops[node+1].ival,&numarg); + prewalk(1,level,ops[node+2].ival,&numarg); + numeric = 1; + break; + case OPOW: + prewalk(1,level,ops[node+1].ival,&numarg); + prewalk(1,level,ops[node+2].ival,&numarg); + numeric = 1; + break; + case OMOD: + prewalk(1,level,ops[node+1].ival,&numarg); + prewalk(1,level,ops[node+2].ival,&numarg); + numeric = 1; + break; + case OPOSTINCR: + prewalk(1,level,ops[node+1].ival,&numarg); + numeric = 1; + break; + case OPOSTDECR: + prewalk(1,level,ops[node+1].ival,&numarg); + numeric = 1; + break; + case OPREINCR: + prewalk(1,level,ops[node+1].ival,&numarg); + numeric = 1; + break; + case OPREDECR: + prewalk(1,level,ops[node+1].ival,&numarg); + numeric = 1; + break; + case OUMINUS: + prewalk(1,level,ops[node+1].ival,&numarg); + numeric = 1; + break; + case OUPLUS: + prewalk(1,level,ops[node+1].ival,&numarg); + numeric = 1; + break; + case OPAREN: + prewalk(0,level,ops[node+1].ival,&numarg); + numeric |= numarg; + break; + case OGETLINE: + break; + case OSPRINTF: + prewalk(0,level,ops[node+1].ival,&numarg); + break; + case OSUBSTR: + prewalk(0,level,ops[node+1].ival,&numarg); + prewalk(1,level,ops[node+2].ival,&numarg); + if (len == 3) { + prewalk(1,level,ops[node+3].ival,&numarg); + } + break; + case OSTRING: + break; + case OSPLIT: + numeric = 1; + prewalk(0,level,ops[node+2].ival,&numarg); + if (len == 3) + prewalk(0,level,ops[node+3].ival,&numarg); + prewalk(0,level,ops[node+1].ival,&numarg); + break; + case OINDEX: + prewalk(0,level,ops[node+1].ival,&numarg); + prewalk(0,level,ops[node+2].ival,&numarg); + numeric = 1; + break; + case OMATCH: + prewalk(0,level,ops[node+1].ival,&numarg); + prewalk(0,level,ops[node+2].ival,&numarg); + numeric = 1; + break; + case OUSERDEF: + subretnum = FALSE; + --level; + tmpstr = walk(0,level,ops[node+1].ival,&numarg,P_MIN); + ++level; + prewalk(0,level,ops[node+2].ival,&numarg); + prewalk(0,level,ops[node+4].ival,&numarg); + prewalk(0,level,ops[node+5].ival,&numarg); + --level; + str_cat(tmpstr,"("); + tmp2str = str_new(0); + if (subretnum || numarg) + str_set(tmp2str,"1"); + hstore(symtab,tmpstr->str_ptr,tmp2str); + str_free(tmpstr); + level++; + break; + case ORETURN: + if (len > 0) { + prewalk(0,level,ops[node+1].ival,&numarg); + if (numarg) + subretnum = TRUE; + } + break; + case OUSERFUN: + tmp2str = str_new(0); + str_scat(tmp2str,tmpstr=walk(1,level,ops[node+1].ival,&numarg,P_MIN)); + fixrargs(tmpstr->str_ptr,ops[node+2].ival,0); + str_free(tmpstr); + str_cat(tmp2str,"("); + tmpstr = hfetch(symtab,tmp2str->str_ptr); + if (tmpstr && tmpstr->str_ptr) + numeric |= atoi(tmpstr->str_ptr); + prewalk(0,level,ops[node+2].ival,&numarg); + str_free(tmp2str); + break; + case OGSUB: + case OSUB: + if (len >= 3) + prewalk(0,level,ops[node+3].ival,&numarg); + prewalk(0,level,ops[ops[node+2].ival+1].ival,&numarg); + prewalk(0,level,ops[node+1].ival,&numarg); + numeric = 1; + break; + case ONUM: + prewalk(0,level,ops[node+1].ival,&numarg); + numeric = 1; + break; + case OSTR: + prewalk(0,level,ops[node+1].ival,&numarg); + break; + case ODEFINED: + case ODELETE: + case OSTAR: + case OVAR: + prewalk(0,level,ops[node+1].ival,&numarg); + if (len == 1) { + if (numit) + numericize(node); + } + else { + prewalk(0,level,ops[node+2].ival,&numarg); + } + break; + case OFLD: + prewalk(0,level,ops[node+1].ival,&numarg); + break; + case OVFLD: + i = ops[node+1].ival; + prewalk(0,level,i,&numarg); + break; + case OJUNK: + goto def; + case OSNEWLINE: + break; + case ONEWLINE: + break; + case OSCOMMENT: + break; + case OCOMMENT: + break; + case OCOMMA: + prewalk(0,level,ops[node+1].ival,&numarg); + prewalk(0,level,ops[node+2].ival,&numarg); + prewalk(0,level,ops[node+3].ival,&numarg); + break; + case OSEMICOLON: + break; + case OSTATES: + prewalk(0,level,ops[node+1].ival,&numarg); + prewalk(0,level,ops[node+2].ival,&numarg); + break; + case OSTATE: + if (len >= 1) { + prewalk(0,level,ops[node+1].ival,&numarg); + if (len >= 2) { + prewalk(0,level,ops[node+2].ival,&numarg); + } + } + break; + case OCLOSE: + prewalk(0,level,ops[node+1].ival,&numarg); + break; + case OPRINTF: + case OPRINT: + if (len == 3) { /* output redirection */ + prewalk(0,level,ops[node+3].ival,&numarg); + prewalk(0,level,ops[node+2].ival,&numarg); + } + prewalk(0+(type==OPRINT),level,ops[node+1].ival,&numarg); + break; + case ORAND: + break; + case OSRAND: + goto maybe0; + case OATAN2: + goto maybe0; + case OSIN: + goto maybe0; + case OCOS: + goto maybe0; + case OSYSTEM: + goto maybe0; + case OLENGTH: + goto maybe0; + case OLOG: + goto maybe0; + case OEXP: + goto maybe0; + case OSQRT: + goto maybe0; + case OINT: + maybe0: + numeric = 1; + if (len > 0) + prewalk(type != OLENGTH && type != OSYSTEM, + level,ops[node+1].ival,&numarg); + break; + case OBREAK: + break; + case ONEXT: + break; + case OEXIT: + if (len == 1) { + prewalk(1,level,ops[node+1].ival,&numarg); + } + break; + case OCONTINUE: + break; + case OREDIR: + goto def; + case OIF: + prewalk(0,level,ops[node+1].ival,&numarg); + prewalk(0,level,ops[node+2].ival,&numarg); + if (len == 3) { + prewalk(0,level,ops[node+3].ival,&numarg); + } + break; + case OWHILE: + prewalk(0,level,ops[node+1].ival,&numarg); + prewalk(0,level,ops[node+2].ival,&numarg); + break; + case OFOR: + prewalk(0,level,ops[node+1].ival,&numarg); + prewalk(0,level,ops[node+2].ival,&numarg); + prewalk(0,level,ops[node+3].ival,&numarg); + prewalk(0,level,ops[node+4].ival,&numarg); + break; + case OFORIN: + prewalk(0,level,ops[node+2].ival,&numarg); + prewalk(0,level,ops[node+1].ival,&numarg); + break; + case OBLOCK: + if (len == 2) { + prewalk(0,level,ops[node+2].ival,&numarg); + } + ++level; + prewalk(0,level,ops[node+1].ival,&numarg); + --level; + break; + default: + def: + if (len) { + if (len > 5) + fatal("Garbage length in prewalk"); + prewalk(0,level,ops[node+1].ival,&numarg); + for (i = 2; i<= len; i++) { + prewalk(0,level,ops[node+i].ival,&numarg); + } + } + break; + } + *numericptr = numeric; + return 1; +} + +numericize(node) +register int node; +{ + register int len; + register int type; + register int i; + STR *tmpstr; + STR *tmp2str; + int numarg; + + type = ops[node].ival; + len = type >> 8; + type &= 255; + if (type == OVAR && len == 1) { + tmpstr=walk(0,0,ops[node+1].ival,&numarg,P_MIN); + tmp2str = str_make("1"); + hstore(symtab,tmpstr->str_ptr,tmp2str); + } +} |