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