1 /* $RCSfile: a2p.h,v $$Revision: 4.1 $$Date: 92/08/07 18:29:09 $
3 * Copyright (c) 1991-1997, 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.
15 # include "../config.h"
18 #if defined(__STDC__) || defined(vax11c) || defined(_AIX) || defined(__stdc__) || defined(__cplusplus)
22 /* Use all the "standard" definitions? */
23 #if defined(STANDARD_C) && defined(I_STDLIB)
25 #endif /* STANDARD_C */
34 # include <sys/types.h>
39 #if NX_CURRENT_COMPILER_RELEASE >= 400
40 #include <objc/NXCType.h>
41 #else /* NX_CURRENT_COMPILER_RELEASE < 400 */
42 #include <appkit/NXCType.h>
43 #endif /* NX_CURRENT_COMPILER_RELEASE >= 400 */
45 #else /* !USE_NEXT_CTYPE */
47 #endif /* USE_NEXT_CTYPE */
49 #define MEM_SIZE Size_t
54 Malloc_t malloc _((MEM_SIZE nbytes));
55 Malloc_t calloc _((MEM_SIZE elements, MEM_SIZE size));
56 Malloc_t realloc _((Malloc_t where, MEM_SIZE nbytes));
57 Free_t free _((Malloc_t where));
60 #if defined(I_STRING) || defined(__cplusplus)
67 # define bcopy(s1,s2,l) memcpy(s2,s1,l)
70 # define bzero(s,l) memset(s,0,l)
73 #if !defined(HAS_STRCHR) && defined(HAS_INDEX) && !defined(strchr)
75 #define strrchr rindex
84 # ifdef I_SYS_TIME_KERNEL
87 # include <sys/time.h>
88 # ifdef I_SYS_TIME_KERNEL
94 # if defined(HAS_TIMES) && defined(I_SYS_TIMES)
95 # include <sys/times.h>
101 # include "../os2ish.h"
103 # include "../dosish.h"
107 # define NO_PERL_TYPEDEFS
113 /* All of these are in stdlib.h or time.h for ANSI C */
115 struct tm *gmtime(), *localtime();
116 char *strchr(), *strrchr();
117 char *strcpy(), *strcat();
118 #endif /* ! STANDARD_C */
123 # include "../handy.h"
127 #define Nullfp Null(FILE*)
177 #define OSEMICOLON 47
314 extern char *opname[];
323 #if defined(iAPX286) || defined(M_I286) || defined(I80286) /* 80286 hack */
324 #define OPSMAX (64000/sizeof(union u_ops)) /* approx. max segment size */
327 #endif /* 80286 hack */
328 EXT union u_ops ops[OPSMAX];
330 typedef struct string STR;
331 typedef struct htbl HASH;
337 /* A string is TRUE if not "" or "0". */
338 #define True(val) (tmps = (val), (*tmps && !(*tmps == '0' && !tmps[1])))
339 EXT char *Yes INIT("1");
340 EXT char *No INIT("");
342 #define str_true(str) (Str = (str), (Str->str_pok ? True(Str->str_ptr) : (Str->str_nok ? (Str->str_nval != 0.0) : 0 )))
344 #define str_peek(str) (Str = (str), (Str->str_pok ? Str->str_ptr : (Str->str_nok ? (sprintf(buf,"num(%g)",Str->str_nval),buf) : "" )))
345 #define str_get(str) (Str = (str), (Str->str_pok ? Str->str_ptr : str_2ptr(Str)))
346 #define str_gnum(str) (Str = (str), (Str->str_nok ? Str->str_nval : str_2num(Str)))
349 #define GROWSTR(pp,lp,len) if (*(lp) < (len)) growstr(pp,lp,len)
351 /* Prototypes for things in a2p.c */
352 int aryrefarg _(( int arg ));
353 int bl _(( int arg, int maybe ));
354 void dump _(( int branch ));
355 int fixfargs _(( int name, int arg, int prevargs ));
356 int fixrargs _(( char *name, int arg, int prevargs ));
357 void fixup _(( STR *str ));
358 int numary _(( int arg ));
359 int oper0 _(( int type ));
360 int oper1 _(( int type, int arg1 ));
361 int oper2 _(( int type, int arg1, int arg2 ));
362 int oper3 _(( int type, int arg1, int arg2, int arg3 ));
363 int oper4 _(( int type, int arg1, int arg2, int arg3, int arg4 ));
364 int oper5 _(( int type, int arg1, int arg2, int arg3, int arg4, int arg5 ));
365 void putlines _(( STR *str ));
366 void putone _(( void ));
367 int rememberargs _(( int arg ));
368 char * scannum _(( char *s ));
369 char * scanpat _(( char *s ));
370 int string _(( char *ptr, int len ));
371 void yyerror _(( char *s ));
372 int yylex _(( void ));
374 EXT int line INIT(0);
378 EXT char *bufptr INIT(buf);
380 EXT STR *linestr INIT(Nullstr);
382 EXT char tokenbuf[2048];
383 EXT int expectterm INIT(TRUE);
386 EXT int debug INIT(0);
387 EXT int dlevel INIT(0);
392 EXT STR *freestrroot INIT(Nullstr);
397 EXT bool do_split INIT(FALSE);
398 EXT bool split_to_array INIT(FALSE);
399 EXT bool set_array_base INIT(FALSE);
400 EXT bool saw_RS INIT(FALSE);
401 EXT bool saw_OFS INIT(FALSE);
402 EXT bool saw_ORS INIT(FALSE);
403 EXT bool saw_line_op INIT(FALSE);
404 EXT bool in_begin INIT(TRUE);
405 EXT bool do_opens INIT(FALSE);
406 EXT bool do_fancy_opens INIT(FALSE);
407 EXT bool lval_field INIT(FALSE);
408 EXT bool do_chop INIT(FALSE);
409 EXT bool need_entire INIT(FALSE);
410 EXT bool absmaxfld INIT(FALSE);
411 EXT bool saw_altinput INIT(FALSE);
413 EXT bool nomemok INIT(FALSE);
415 EXT char const_FS INIT(0);
416 EXT char *namelist INIT(Nullch);
417 EXT char fswitch INIT(0);
418 EXT bool old_awk INIT(0);
420 EXT int saw_FS INIT(0);
421 EXT int maxfld INIT(0);
422 EXT int arymax INIT(0);
423 EXT char *nameary[100];
428 EXT HASH *curarghash;
443 #define P_FILETEST 65