This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
applied installperl patch, corrected other little nits
[perl5.git] / x2p / a2p.h
CommitLineData
428aff04 1/* $RCSfile: a2p.h,v $$Revision: 4.1 $$Date: 92/08/07 18:29:09 $
a687059c 2 *
9607fc9c 3 * Copyright (c) 1991-1997, Larry Wall
a687059c 4 *
2b317908
LW
5 * You may distribute under the terms of either the GNU General Public
6 * License or the Artistic License, as specified in the README file.
8d063cd8
LW
7 *
8 * $Log: a2p.h,v $
8d063cd8
LW
9 */
10
be04251a 11#define VOIDUSED 1
d07c2202
GS
12
13#ifdef WIN32
14#define _INC_WIN32_PERL5 /* kludge around win32 stdio layer */
15#endif
16
774d564b 17#ifdef VMS
18# include "config.h"
19#else
20# include "../config.h"
21#endif
be04251a 22
3730b96e
GS
23#if defined(__STDC__) || defined(vax11c) || defined(_AIX) || defined(__stdc__) || defined(__cplusplus)
24# define STANDARD_C 1
25#endif
26
d07c2202
GS
27#ifdef WIN32
28#undef USE_STDIO_PTR /* XXX fast gets won't work, must investigate */
29# ifndef STANDARD_C
30# define STANDARD_C
31# endif
32# if defined(__BORLANDC__)
33# pragma warn -ccc
34# pragma warn -rch
35# pragma warn -sig
36# pragma warn -pia
37# pragma warn -par
38# pragma warn -aus
39# pragma warn -use
40# pragma warn -csu
41# pragma warn -pro
42# elif defined(_MSC_VER)
43# elif defined(__MINGW32__)
44# endif
45#endif
46
9c8d0b29
AD
47/* Use all the "standard" definitions? */
48#if defined(STANDARD_C) && defined(I_STDLIB)
49# include <stdlib.h>
50#endif /* STANDARD_C */
fed7345c 51
9c8d0b29
AD
52#include <stdio.h>
53
54#ifdef I_MATH
55#include <math.h>
56#endif
57
fed7345c
AD
58#ifdef I_SYS_TYPES
59# include <sys/types.h>
60#endif
61
dfe0b228 62#ifdef USE_NEXT_CTYPE
63
64#if NX_CURRENT_COMPILER_RELEASE >= 400
65#include <objc/NXCType.h>
66#else /* NX_CURRENT_COMPILER_RELEASE < 400 */
9c8d0b29 67#include <appkit/NXCType.h>
dfe0b228 68#endif /* NX_CURRENT_COMPILER_RELEASE >= 400 */
69
70#else /* !USE_NEXT_CTYPE */
9c8d0b29 71#include <ctype.h>
dfe0b228 72#endif /* USE_NEXT_CTYPE */
9c8d0b29
AD
73
74#define MEM_SIZE Size_t
75
55497cff 76#ifdef STANDARD_C
77# include <stdlib.h>
78#else
79 Malloc_t malloc _((MEM_SIZE nbytes));
80 Malloc_t calloc _((MEM_SIZE elements, MEM_SIZE size));
81 Malloc_t realloc _((Malloc_t where, MEM_SIZE nbytes));
82 Free_t free _((Malloc_t where));
83#endif
84
9c8d0b29
AD
85#if defined(I_STRING) || defined(__cplusplus)
86# include <string.h>
87#else
88# include <strings.h>
89#endif
90
f0f333f4 91#if !defined(HAS_BCOPY) || defined(__cplusplus)
75f92628
AD
92# define bcopy(s1,s2,l) memcpy(s2,s1,l)
93#endif
f0f333f4 94#if !defined(HAS_BZERO) || defined(__cplusplus)
75f92628
AD
95# define bzero(s,l) memset(s,0,l)
96#endif
97
9c8d0b29
AD
98#if !defined(HAS_STRCHR) && defined(HAS_INDEX) && !defined(strchr)
99#define strchr index
100#define strrchr rindex
101#endif
102
1aef975c
AD
103
104#ifdef I_TIME
105# include <time.h>
106#endif
107
108#ifdef I_SYS_TIME
109# ifdef I_SYS_TIME_KERNEL
110# define KERNEL
111# endif
112# include <sys/time.h>
113# ifdef I_SYS_TIME_KERNEL
114# undef KERNEL
115# endif
116#endif
117
118#ifndef MSDOS
119# if defined(HAS_TIMES) && defined(I_SYS_TIMES)
120# include <sys/times.h>
121# endif
122#endif
123
4633a7c4
LW
124#ifdef DOSISH
125# if defined(OS2)
126# include "../os2ish.h"
127# else
128# include "../dosish.h"
129# endif
130#else
131# if defined(VMS)
44a8e56a 132# define NO_PERL_TYPEDEFS
774d564b 133# include "vmsish.h"
4633a7c4
LW
134# endif
135#endif
136
1aef975c
AD
137#ifndef STANDARD_C
138/* All of these are in stdlib.h or time.h for ANSI C */
139Time_t time();
140struct tm *gmtime(), *localtime();
141char *strchr(), *strrchr();
142char *strcpy(), *strcat();
143#endif /* ! STANDARD_C */
144
774d564b 145#ifdef VMS
146# include "handy.h"
147#else
148# include "../handy.h"
149#endif
55497cff 150
151#undef Nullfp
152#define Nullfp Null(FILE*)
153
8d063cd8
LW
154#define Nullop 0
155
156#define OPROG 1
157#define OJUNK 2
158#define OHUNKS 3
159#define ORANGE 4
160#define OPAT 5
161#define OHUNK 6
162#define OPPAREN 7
163#define OPANDAND 8
164#define OPOROR 9
165#define OPNOT 10
166#define OCPAREN 11
167#define OCANDAND 12
168#define OCOROR 13
169#define OCNOT 14
170#define ORELOP 15
171#define ORPAREN 16
172#define OMATCHOP 17
173#define OMPAREN 18
174#define OCONCAT 19
175#define OASSIGN 20
176#define OADD 21
a687059c 177#define OSUBTRACT 22
8d063cd8
LW
178#define OMULT 23
179#define ODIV 24
180#define OMOD 25
181#define OPOSTINCR 26
182#define OPOSTDECR 27
183#define OPREINCR 28
184#define OPREDECR 29
185#define OUMINUS 30
186#define OUPLUS 31
187#define OPAREN 32
188#define OGETLINE 33
189#define OSPRINTF 34
190#define OSUBSTR 35
191#define OSTRING 36
192#define OSPLIT 37
193#define OSNEWLINE 38
194#define OINDEX 39
195#define ONUM 40
196#define OSTR 41
197#define OVAR 42
198#define OFLD 43
199#define ONEWLINE 44
200#define OCOMMENT 45
201#define OCOMMA 46
202#define OSEMICOLON 47
203#define OSCOMMENT 48
204#define OSTATES 49
205#define OSTATE 50
206#define OPRINT 51
207#define OPRINTF 52
208#define OBREAK 53
209#define ONEXT 54
210#define OEXIT 55
211#define OCONTINUE 56
212#define OREDIR 57
213#define OIF 58
214#define OWHILE 59
215#define OFOR 60
216#define OFORIN 61
217#define OVFLD 62
218#define OBLOCK 63
219#define OREGEX 64
220#define OLENGTH 65
221#define OLOG 66
222#define OEXP 67
223#define OSQRT 68
224#define OINT 69
a687059c
LW
225#define ODO 70
226#define OPOW 71
227#define OSUB 72
228#define OGSUB 73
229#define OMATCH 74
230#define OUSERFUN 75
231#define OUSERDEF 76
232#define OCLOSE 77
233#define OATAN2 78
234#define OSIN 79
235#define OCOS 80
236#define ORAND 81
237#define OSRAND 82
238#define ODELETE 83
239#define OSYSTEM 84
240#define OCOND 85
241#define ORETURN 86
242#define ODEFINED 87
243#define OSTAR 88
8d063cd8
LW
244
245#ifdef DOINIT
246char *opname[] = {
247 "0",
248 "PROG",
249 "JUNK",
250 "HUNKS",
251 "RANGE",
252 "PAT",
253 "HUNK",
254 "PPAREN",
255 "PANDAND",
256 "POROR",
257 "PNOT",
258 "CPAREN",
259 "CANDAND",
260 "COROR",
261 "CNOT",
262 "RELOP",
263 "RPAREN",
264 "MATCHOP",
265 "MPAREN",
266 "CONCAT",
267 "ASSIGN",
268 "ADD",
a687059c 269 "SUBTRACT",
8d063cd8
LW
270 "MULT",
271 "DIV",
272 "MOD",
273 "POSTINCR",
274 "POSTDECR",
275 "PREINCR",
276 "PREDECR",
277 "UMINUS",
278 "UPLUS",
279 "PAREN",
280 "GETLINE",
281 "SPRINTF",
282 "SUBSTR",
283 "STRING",
284 "SPLIT",
285 "SNEWLINE",
286 "INDEX",
287 "NUM",
288 "STR",
289 "VAR",
290 "FLD",
291 "NEWLINE",
292 "COMMENT",
293 "COMMA",
294 "SEMICOLON",
295 "SCOMMENT",
296 "STATES",
297 "STATE",
298 "PRINT",
299 "PRINTF",
300 "BREAK",
301 "NEXT",
302 "EXIT",
303 "CONTINUE",
304 "REDIR",
305 "IF",
306 "WHILE",
307 "FOR",
308 "FORIN",
309 "VFLD",
310 "BLOCK",
311 "REGEX",
312 "LENGTH",
313 "LOG",
314 "EXP",
315 "SQRT",
316 "INT",
a687059c
LW
317 "DO",
318 "POW",
319 "SUB",
320 "GSUB",
321 "MATCH",
322 "USERFUN",
323 "USERDEF",
324 "CLOSE",
325 "ATAN2",
326 "SIN",
327 "COS",
328 "RAND",
329 "SRAND",
330 "DELETE",
331 "SYSTEM",
332 "COND",
333 "RETURN",
334 "DEFINED",
335 "STAR",
336 "89"
8d063cd8
LW
337};
338#else
339extern char *opname[];
340#endif
341
a687059c
LW
342EXT int mop INIT(1);
343
d8f2e4cc 344union u_ops {
8d063cd8
LW
345 int ival;
346 char *cval;
d8f2e4cc
LW
347};
348#if defined(iAPX286) || defined(M_I286) || defined(I80286) /* 80286 hack */
349#define OPSMAX (64000/sizeof(union u_ops)) /* approx. max segment size */
350#else
351#define OPSMAX 50000
352#endif /* 80286 hack */
a0d0e21e 353EXT union u_ops ops[OPSMAX];
8d063cd8 354
8d063cd8
LW
355typedef struct string STR;
356typedef struct htbl HASH;
357
358#include "str.h"
359#include "hash.h"
360
9c8d0b29 361
8d063cd8
LW
362/* A string is TRUE if not "" or "0". */
363#define True(val) (tmps = (val), (*tmps && !(*tmps == '0' && !tmps[1])))
364EXT char *Yes INIT("1");
365EXT char *No INIT("");
366
367#define str_true(str) (Str = (str), (Str->str_pok ? True(Str->str_ptr) : (Str->str_nok ? (Str->str_nval != 0.0) : 0 )))
368
369#define str_peek(str) (Str = (str), (Str->str_pok ? Str->str_ptr : (Str->str_nok ? (sprintf(buf,"num(%g)",Str->str_nval),buf) : "" )))
370#define str_get(str) (Str = (str), (Str->str_pok ? Str->str_ptr : str_2ptr(Str)))
371#define str_gnum(str) (Str = (str), (Str->str_nok ? Str->str_nval : str_2num(Str)))
372EXT STR *Str;
373
374#define GROWSTR(pp,lp,len) if (*(lp) < (len)) growstr(pp,lp,len)
375
9c8d0b29
AD
376/* Prototypes for things in a2p.c */
377int aryrefarg _(( int arg ));
378int bl _(( int arg, int maybe ));
75f92628 379void dump _(( int branch ));
9c8d0b29
AD
380int fixfargs _(( int name, int arg, int prevargs ));
381int fixrargs _(( char *name, int arg, int prevargs ));
75f92628 382void fixup _(( STR *str ));
9c8d0b29
AD
383int numary _(( int arg ));
384int oper0 _(( int type ));
385int oper1 _(( int type, int arg1 ));
386int oper2 _(( int type, int arg1, int arg2 ));
387int oper3 _(( int type, int arg1, int arg2, int arg3 ));
388int oper4 _(( int type, int arg1, int arg2, int arg3, int arg4 ));
389int oper5 _(( int type, int arg1, int arg2, int arg3, int arg4, int arg5 ));
75f92628
AD
390void putlines _(( STR *str ));
391void putone _(( void ));
9c8d0b29
AD
392int rememberargs _(( int arg ));
393char * scannum _(( char *s ));
394char * scanpat _(( char *s ));
395int string _(( char *ptr, int len ));
75f92628 396void yyerror _(( char *s ));
9c8d0b29 397int yylex _(( void ));
8d063cd8
LW
398
399EXT int line INIT(0);
400
401EXT FILE *rsfp;
fe14fcc3 402EXT char buf[2048];
8d063cd8
LW
403EXT char *bufptr INIT(buf);
404
405EXT STR *linestr INIT(Nullstr);
406
fe14fcc3 407EXT char tokenbuf[2048];
8d063cd8
LW
408EXT int expectterm INIT(TRUE);
409
410#ifdef DEBUGGING
411EXT int debug INIT(0);
412EXT int dlevel INIT(0);
9bb9d9f7 413#define YYDEBUG 1
8d063cd8
LW
414extern int yydebug;
415#endif
416
417EXT STR *freestrroot INIT(Nullstr);
418
419EXT STR str_no;
420EXT STR str_yes;
421
422EXT bool do_split INIT(FALSE);
423EXT bool split_to_array INIT(FALSE);
424EXT bool set_array_base INIT(FALSE);
425EXT bool saw_RS INIT(FALSE);
426EXT bool saw_OFS INIT(FALSE);
427EXT bool saw_ORS INIT(FALSE);
428EXT bool saw_line_op INIT(FALSE);
429EXT bool in_begin INIT(TRUE);
430EXT bool do_opens INIT(FALSE);
431EXT bool do_fancy_opens INIT(FALSE);
432EXT bool lval_field INIT(FALSE);
433EXT bool do_chop INIT(FALSE);
434EXT bool need_entire INIT(FALSE);
435EXT bool absmaxfld INIT(FALSE);
a687059c 436EXT bool saw_altinput INIT(FALSE);
8d063cd8 437
bf10efe7
LW
438EXT bool nomemok INIT(FALSE);
439
8d063cd8
LW
440EXT char const_FS INIT(0);
441EXT char *namelist INIT(Nullch);
442EXT char fswitch INIT(0);
a5571d59 443EXT bool old_awk INIT(0);
8d063cd8
LW
444
445EXT int saw_FS INIT(0);
446EXT int maxfld INIT(0);
447EXT int arymax INIT(0);
a0d0e21e 448EXT char *nameary[100];
8d063cd8
LW
449
450EXT STR *opens;
451
452EXT HASH *symtab;
a687059c
LW
453EXT HASH *curarghash;
454
455#define P_MIN 0
456#define P_LISTOP 5
457#define P_COMMA 10
458#define P_ASSIGN 15
459#define P_COND 20
460#define P_DOTDOT 25
461#define P_OROR 30
462#define P_ANDAND 35
463#define P_OR 40
464#define P_AND 45
465#define P_EQ 50
466#define P_REL 55
467#define P_UNI 60
468#define P_FILETEST 65
469#define P_SHIFT 70
470#define P_ADD 75
471#define P_MUL 80
472#define P_MATCH 85
473#define P_UNARY 90
474#define P_POW 95
475#define P_AUTO 100
476#define P_MAX 999
79072805
LW
477
478EXT int an;