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.
12 #include "../config.h"
14 #if defined(__STDC__) || defined(vax11c) || defined(_AIX) || defined(__stdc__) || defined(__cplusplus)
18 /* Use all the "standard" definitions? */
19 #if defined(STANDARD_C) && defined(I_STDLIB)
21 #endif /* STANDARD_C */
30 # include <sys/types.h>
35 #if NX_CURRENT_COMPILER_RELEASE >= 400
36 #include <objc/NXCType.h>
37 #else /* NX_CURRENT_COMPILER_RELEASE < 400 */
38 #include <appkit/NXCType.h>
39 #endif /* NX_CURRENT_COMPILER_RELEASE >= 400 */
41 #else /* !USE_NEXT_CTYPE */
43 #endif /* USE_NEXT_CTYPE */
45 #define MEM_SIZE Size_t
50 Malloc_t malloc _((MEM_SIZE nbytes));
51 Malloc_t calloc _((MEM_SIZE elements, MEM_SIZE size));
52 Malloc_t realloc _((Malloc_t where, MEM_SIZE nbytes));
53 Free_t free _((Malloc_t where));
56 #if defined(I_STRING) || defined(__cplusplus)
63 # define bcopy(s1,s2,l) memcpy(s2,s1,l)
66 # define bzero(s,l) memset(s,0,l)
69 #if !defined(HAS_STRCHR) && defined(HAS_INDEX) && !defined(strchr)
71 #define strrchr rindex
80 # ifdef I_SYS_TIME_KERNEL
83 # include <sys/time.h>
84 # ifdef I_SYS_TIME_KERNEL
90 # if defined(HAS_TIMES) && defined(I_SYS_TIMES)
91 # include <sys/times.h>
97 # include "../os2ish.h"
99 # include "../dosish.h"
103 # include "../vmsish.h"
108 /* All of these are in stdlib.h or time.h for ANSI C */
110 struct tm *gmtime(), *localtime();
111 char *strchr(), *strrchr();
112 char *strcpy(), *strcat();
113 #endif /* ! STANDARD_C */
115 #include "../handy.h"
118 #define Nullfp Null(FILE*)
168 #define OSEMICOLON 47
305 extern char *opname[];
314 #if defined(iAPX286) || defined(M_I286) || defined(I80286) /* 80286 hack */
315 #define OPSMAX (64000/sizeof(union u_ops)) /* approx. max segment size */
318 #endif /* 80286 hack */
319 EXT union u_ops ops[OPSMAX];
321 typedef struct string STR;
322 typedef struct htbl HASH;
328 /* A string is TRUE if not "" or "0". */
329 #define True(val) (tmps = (val), (*tmps && !(*tmps == '0' && !tmps[1])))
330 EXT char *Yes INIT("1");
331 EXT char *No INIT("");
333 #define str_true(str) (Str = (str), (Str->str_pok ? True(Str->str_ptr) : (Str->str_nok ? (Str->str_nval != 0.0) : 0 )))
335 #define str_peek(str) (Str = (str), (Str->str_pok ? Str->str_ptr : (Str->str_nok ? (sprintf(buf,"num(%g)",Str->str_nval),buf) : "" )))
336 #define str_get(str) (Str = (str), (Str->str_pok ? Str->str_ptr : str_2ptr(Str)))
337 #define str_gnum(str) (Str = (str), (Str->str_nok ? Str->str_nval : str_2num(Str)))
340 #define GROWSTR(pp,lp,len) if (*(lp) < (len)) growstr(pp,lp,len)
342 /* Prototypes for things in a2p.c */
343 int aryrefarg _(( int arg ));
344 int bl _(( int arg, int maybe ));
345 void dump _(( int branch ));
346 int fixfargs _(( int name, int arg, int prevargs ));
347 int fixrargs _(( char *name, int arg, int prevargs ));
348 void fixup _(( STR *str ));
349 int numary _(( int arg ));
350 int oper0 _(( int type ));
351 int oper1 _(( int type, int arg1 ));
352 int oper2 _(( int type, int arg1, int arg2 ));
353 int oper3 _(( int type, int arg1, int arg2, int arg3 ));
354 int oper4 _(( int type, int arg1, int arg2, int arg3, int arg4 ));
355 int oper5 _(( int type, int arg1, int arg2, int arg3, int arg4, int arg5 ));
356 void putlines _(( STR *str ));
357 void putone _(( void ));
358 int rememberargs _(( int arg ));
359 char * scannum _(( char *s ));
360 char * scanpat _(( char *s ));
361 int string _(( char *ptr, int len ));
362 void yyerror _(( char *s ));
363 int yylex _(( void ));
365 EXT int line INIT(0);
369 EXT char *bufptr INIT(buf);
371 EXT STR *linestr INIT(Nullstr);
373 EXT char tokenbuf[2048];
374 EXT int expectterm INIT(TRUE);
377 EXT int debug INIT(0);
378 EXT int dlevel INIT(0);
383 EXT STR *freestrroot INIT(Nullstr);
388 EXT bool do_split INIT(FALSE);
389 EXT bool split_to_array INIT(FALSE);
390 EXT bool set_array_base INIT(FALSE);
391 EXT bool saw_RS INIT(FALSE);
392 EXT bool saw_OFS INIT(FALSE);
393 EXT bool saw_ORS INIT(FALSE);
394 EXT bool saw_line_op INIT(FALSE);
395 EXT bool in_begin INIT(TRUE);
396 EXT bool do_opens INIT(FALSE);
397 EXT bool do_fancy_opens INIT(FALSE);
398 EXT bool lval_field INIT(FALSE);
399 EXT bool do_chop INIT(FALSE);
400 EXT bool need_entire INIT(FALSE);
401 EXT bool absmaxfld INIT(FALSE);
402 EXT bool saw_altinput INIT(FALSE);
404 EXT bool nomemok INIT(FALSE);
406 EXT char const_FS INIT(0);
407 EXT char *namelist INIT(Nullch);
408 EXT char fswitch INIT(0);
410 EXT int saw_FS INIT(0);
411 EXT int maxfld INIT(0);
412 EXT int arymax INIT(0);
413 EXT char *nameary[100];
418 EXT HASH *curarghash;
433 #define P_FILETEST 65