1 /* $RCSfile: a2p.h,v $$Revision: 4.1 $$Date: 92/08/07 18:29:09 $
3 * Copyright (c) 1991, Larry Wall
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.
13 #include "../config.h"
15 #if defined(__STDC__) || defined(vax11c) || defined(_AIX) || defined(__stdc__) || defined(__cplusplus)
19 /* Use all the "standard" definitions? */
20 #if defined(STANDARD_C) && defined(I_STDLIB)
22 #endif /* STANDARD_C */
31 # include <sys/types.h>
36 #include <appkit/NXCType.h>
41 #define MEM_SIZE Size_t
43 #if defined(I_STRING) || defined(__cplusplus)
50 # define bcopy(s1,s2,l) memcpy(s2,s1,l)
53 # define bzero(s,l) memset(s,0,l)
56 #if !defined(HAS_STRCHR) && defined(HAS_INDEX) && !defined(strchr)
58 #define strrchr rindex
67 # ifdef I_SYS_TIME_KERNEL
70 # include <sys/time.h>
71 # ifdef I_SYS_TIME_KERNEL
77 # if defined(HAS_TIMES) && defined(I_SYS_TIMES)
78 # include <sys/times.h>
84 # include "../os2ish.h"
86 # include "../dosish.h"
90 # include "../vmsish.h"
95 /* All of these are in stdlib.h or time.h for ANSI C */
97 struct tm *gmtime(), *localtime();
98 char *strchr(), *strrchr();
99 char *strcpy(), *strcat();
100 #endif /* ! STANDARD_C */
151 #define OSEMICOLON 47
288 extern char *opname[];
297 #if defined(iAPX286) || defined(M_I286) || defined(I80286) /* 80286 hack */
298 #define OPSMAX (64000/sizeof(union u_ops)) /* approx. max segment size */
301 #endif /* 80286 hack */
302 EXT union u_ops ops[OPSMAX];
304 typedef struct string STR;
305 typedef struct htbl HASH;
311 /* A string is TRUE if not "" or "0". */
312 #define True(val) (tmps = (val), (*tmps && !(*tmps == '0' && !tmps[1])))
313 EXT char *Yes INIT("1");
314 EXT char *No INIT("");
316 #define str_true(str) (Str = (str), (Str->str_pok ? True(Str->str_ptr) : (Str->str_nok ? (Str->str_nval != 0.0) : 0 )))
318 #define str_peek(str) (Str = (str), (Str->str_pok ? Str->str_ptr : (Str->str_nok ? (sprintf(buf,"num(%g)",Str->str_nval),buf) : "" )))
319 #define str_get(str) (Str = (str), (Str->str_pok ? Str->str_ptr : str_2ptr(Str)))
320 #define str_gnum(str) (Str = (str), (Str->str_nok ? Str->str_nval : str_2num(Str)))
323 #define GROWSTR(pp,lp,len) if (*(lp) < (len)) growstr(pp,lp,len)
325 /* Prototypes for things in a2p.c */
326 int aryrefarg _(( int arg ));
327 int bl _(( int arg, int maybe ));
328 void dump _(( int branch ));
329 int fixfargs _(( int name, int arg, int prevargs ));
330 int fixrargs _(( char *name, int arg, int prevargs ));
331 void fixup _(( STR *str ));
332 int numary _(( int arg ));
333 int oper0 _(( int type ));
334 int oper1 _(( int type, int arg1 ));
335 int oper2 _(( int type, int arg1, int arg2 ));
336 int oper3 _(( int type, int arg1, int arg2, int arg3 ));
337 int oper4 _(( int type, int arg1, int arg2, int arg3, int arg4 ));
338 int oper5 _(( int type, int arg1, int arg2, int arg3, int arg4, int arg5 ));
339 void putlines _(( STR *str ));
340 void putone _(( void ));
341 int rememberargs _(( int arg ));
342 char * scannum _(( char *s ));
343 char * scanpat _(( char *s ));
344 int string _(( char *ptr, int len ));
345 void yyerror _(( char *s ));
346 int yylex _(( void ));
348 EXT int line INIT(0);
352 EXT char *bufptr INIT(buf);
354 EXT STR *linestr INIT(Nullstr);
356 EXT char tokenbuf[2048];
357 EXT int expectterm INIT(TRUE);
360 EXT int debug INIT(0);
361 EXT int dlevel INIT(0);
366 EXT STR *freestrroot INIT(Nullstr);
371 EXT bool do_split INIT(FALSE);
372 EXT bool split_to_array INIT(FALSE);
373 EXT bool set_array_base INIT(FALSE);
374 EXT bool saw_RS INIT(FALSE);
375 EXT bool saw_OFS INIT(FALSE);
376 EXT bool saw_ORS INIT(FALSE);
377 EXT bool saw_line_op INIT(FALSE);
378 EXT bool in_begin INIT(TRUE);
379 EXT bool do_opens INIT(FALSE);
380 EXT bool do_fancy_opens INIT(FALSE);
381 EXT bool lval_field INIT(FALSE);
382 EXT bool do_chop INIT(FALSE);
383 EXT bool need_entire INIT(FALSE);
384 EXT bool absmaxfld INIT(FALSE);
385 EXT bool saw_altinput INIT(FALSE);
387 EXT bool nomemok INIT(FALSE);
389 EXT char const_FS INIT(0);
390 EXT char *namelist INIT(Nullch);
391 EXT char fswitch INIT(0);
393 EXT int saw_FS INIT(0);
394 EXT int maxfld INIT(0);
395 EXT int arymax INIT(0);
396 EXT char *nameary[100];
401 EXT HASH *curarghash;
416 #define P_FILETEST 65