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