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