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>
37 #if NX_CURRENT_COMPILER_RELEASE >= 400
38 #include <objc/NXCType.h>
39 #else /* NX_CURRENT_COMPILER_RELEASE < 400 */
40 #include <appkit/NXCType.h>
41 #endif /* NX_CURRENT_COMPILER_RELEASE >= 400 */
43 #else /* !USE_NEXT_CTYPE */
45 #endif /* USE_NEXT_CTYPE */
47 #define MEM_SIZE Size_t
49 #if defined(I_STRING) || defined(__cplusplus)
56 # define bcopy(s1,s2,l) memcpy(s2,s1,l)
59 # define bzero(s,l) memset(s,0,l)
62 #if !defined(HAS_STRCHR) && defined(HAS_INDEX) && !defined(strchr)
64 #define strrchr rindex
73 # ifdef I_SYS_TIME_KERNEL
76 # include <sys/time.h>
77 # ifdef I_SYS_TIME_KERNEL
83 # if defined(HAS_TIMES) && defined(I_SYS_TIMES)
84 # include <sys/times.h>
90 # include "../os2ish.h"
92 # include "../dosish.h"
96 # include "../vmsish.h"
101 /* All of these are in stdlib.h or time.h for ANSI C */
103 struct tm *gmtime(), *localtime();
104 char *strchr(), *strrchr();
105 char *strcpy(), *strcat();
106 #endif /* ! STANDARD_C */
157 #define OSEMICOLON 47
294 extern char *opname[];
303 #if defined(iAPX286) || defined(M_I286) || defined(I80286) /* 80286 hack */
304 #define OPSMAX (64000/sizeof(union u_ops)) /* approx. max segment size */
307 #endif /* 80286 hack */
308 EXT union u_ops ops[OPSMAX];
310 typedef struct string STR;
311 typedef struct htbl HASH;
317 /* A string is TRUE if not "" or "0". */
318 #define True(val) (tmps = (val), (*tmps && !(*tmps == '0' && !tmps[1])))
319 EXT char *Yes INIT("1");
320 EXT char *No INIT("");
322 #define str_true(str) (Str = (str), (Str->str_pok ? True(Str->str_ptr) : (Str->str_nok ? (Str->str_nval != 0.0) : 0 )))
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)))
329 #define GROWSTR(pp,lp,len) if (*(lp) < (len)) growstr(pp,lp,len)
331 /* Prototypes for things in a2p.c */
332 int aryrefarg _(( int arg ));
333 int bl _(( int arg, int maybe ));
334 void dump _(( int branch ));
335 int fixfargs _(( int name, int arg, int prevargs ));
336 int fixrargs _(( char *name, int arg, int prevargs ));
337 void fixup _(( STR *str ));
338 int numary _(( int arg ));
339 int oper0 _(( int type ));
340 int oper1 _(( int type, int arg1 ));
341 int oper2 _(( int type, int arg1, int arg2 ));
342 int oper3 _(( int type, int arg1, int arg2, int arg3 ));
343 int oper4 _(( int type, int arg1, int arg2, int arg3, int arg4 ));
344 int oper5 _(( int type, int arg1, int arg2, int arg3, int arg4, int arg5 ));
345 void putlines _(( STR *str ));
346 void putone _(( void ));
347 int rememberargs _(( int arg ));
348 char * scannum _(( char *s ));
349 char * scanpat _(( char *s ));
350 int string _(( char *ptr, int len ));
351 void yyerror _(( char *s ));
352 int yylex _(( void ));
354 EXT int line INIT(0);
358 EXT char *bufptr INIT(buf);
360 EXT STR *linestr INIT(Nullstr);
362 EXT char tokenbuf[2048];
363 EXT int expectterm INIT(TRUE);
366 EXT int debug INIT(0);
367 EXT int dlevel INIT(0);
372 EXT STR *freestrroot INIT(Nullstr);
377 EXT bool do_split INIT(FALSE);
378 EXT bool split_to_array INIT(FALSE);
379 EXT bool set_array_base INIT(FALSE);
380 EXT bool saw_RS INIT(FALSE);
381 EXT bool saw_OFS INIT(FALSE);
382 EXT bool saw_ORS INIT(FALSE);
383 EXT bool saw_line_op INIT(FALSE);
384 EXT bool in_begin INIT(TRUE);
385 EXT bool do_opens INIT(FALSE);
386 EXT bool do_fancy_opens INIT(FALSE);
387 EXT bool lval_field INIT(FALSE);
388 EXT bool do_chop INIT(FALSE);
389 EXT bool need_entire INIT(FALSE);
390 EXT bool absmaxfld INIT(FALSE);
391 EXT bool saw_altinput INIT(FALSE);
393 EXT bool nomemok INIT(FALSE);
395 EXT char const_FS INIT(0);
396 EXT char *namelist INIT(Nullch);
397 EXT char fswitch INIT(0);
399 EXT int saw_FS INIT(0);
400 EXT int maxfld INIT(0);
401 EXT int arymax INIT(0);
402 EXT char *nameary[100];
407 EXT HASH *curarghash;
422 #define P_FILETEST 65