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 */
29 #include <appkit/NXCType.h>
34 #define MEM_SIZE Size_t
36 #if defined(I_STRING) || defined(__cplusplus)
43 # define bcopy(s1,s2,l) memcpy(s2,s1,l)
46 # define bzero(s,l) memset(s,0,l)
49 #if !defined(HAS_STRCHR) && defined(HAS_INDEX) && !defined(strchr)
51 #define strrchr rindex
60 # ifdef I_SYS_TIME_KERNEL
63 # include <sys/time.h>
64 # ifdef I_SYS_TIME_KERNEL
70 # if defined(HAS_TIMES) && defined(I_SYS_TIMES)
71 # include <sys/times.h>
76 /* All of these are in stdlib.h or time.h for ANSI C */
78 struct tm *gmtime(), *localtime();
79 char *strchr(), *strrchr();
80 char *strcpy(), *strcat();
81 #endif /* ! STANDARD_C */
132 #define OSEMICOLON 47
269 extern char *opname[];
278 #if defined(iAPX286) || defined(M_I286) || defined(I80286) /* 80286 hack */
279 #define OPSMAX (64000/sizeof(union u_ops)) /* approx. max segment size */
282 #endif /* 80286 hack */
283 EXT union u_ops ops[OPSMAX];
285 typedef struct string STR;
286 typedef struct htbl HASH;
292 /* A string is TRUE if not "" or "0". */
293 #define True(val) (tmps = (val), (*tmps && !(*tmps == '0' && !tmps[1])))
294 EXT char *Yes INIT("1");
295 EXT char *No INIT("");
297 #define str_true(str) (Str = (str), (Str->str_pok ? True(Str->str_ptr) : (Str->str_nok ? (Str->str_nval != 0.0) : 0 )))
299 #define str_peek(str) (Str = (str), (Str->str_pok ? Str->str_ptr : (Str->str_nok ? (sprintf(buf,"num(%g)",Str->str_nval),buf) : "" )))
300 #define str_get(str) (Str = (str), (Str->str_pok ? Str->str_ptr : str_2ptr(Str)))
301 #define str_gnum(str) (Str = (str), (Str->str_nok ? Str->str_nval : str_2num(Str)))
304 #define GROWSTR(pp,lp,len) if (*(lp) < (len)) growstr(pp,lp,len)
306 /* Prototypes for things in a2p.c */
307 int aryrefarg _(( int arg ));
308 int bl _(( int arg, int maybe ));
309 void dump _(( int branch ));
310 int fixfargs _(( int name, int arg, int prevargs ));
311 int fixrargs _(( char *name, int arg, int prevargs ));
312 void fixup _(( STR *str ));
313 int numary _(( int arg ));
314 int oper0 _(( int type ));
315 int oper1 _(( int type, int arg1 ));
316 int oper2 _(( int type, int arg1, int arg2 ));
317 int oper3 _(( int type, int arg1, int arg2, int arg3 ));
318 int oper4 _(( int type, int arg1, int arg2, int arg3, int arg4 ));
319 int oper5 _(( int type, int arg1, int arg2, int arg3, int arg4, int arg5 ));
320 void putlines _(( STR *str ));
321 void putone _(( void ));
322 int rememberargs _(( int arg ));
323 char * scannum _(( char *s ));
324 char * scanpat _(( char *s ));
325 int string _(( char *ptr, int len ));
326 void yyerror _(( char *s ));
327 int yylex _(( void ));
329 EXT int line INIT(0);
333 EXT char *bufptr INIT(buf);
335 EXT STR *linestr INIT(Nullstr);
337 EXT char tokenbuf[2048];
338 EXT int expectterm INIT(TRUE);
341 EXT int debug INIT(0);
342 EXT int dlevel INIT(0);
347 EXT STR *freestrroot INIT(Nullstr);
352 EXT bool do_split INIT(FALSE);
353 EXT bool split_to_array INIT(FALSE);
354 EXT bool set_array_base INIT(FALSE);
355 EXT bool saw_RS INIT(FALSE);
356 EXT bool saw_OFS INIT(FALSE);
357 EXT bool saw_ORS INIT(FALSE);
358 EXT bool saw_line_op INIT(FALSE);
359 EXT bool in_begin INIT(TRUE);
360 EXT bool do_opens INIT(FALSE);
361 EXT bool do_fancy_opens INIT(FALSE);
362 EXT bool lval_field INIT(FALSE);
363 EXT bool do_chop INIT(FALSE);
364 EXT bool need_entire INIT(FALSE);
365 EXT bool absmaxfld INIT(FALSE);
366 EXT bool saw_altinput INIT(FALSE);
368 EXT bool nomemok INIT(FALSE);
370 EXT char const_FS INIT(0);
371 EXT char *namelist INIT(Nullch);
372 EXT char fswitch INIT(0);
374 EXT int saw_FS INIT(0);
375 EXT int maxfld INIT(0);
376 EXT int arymax INIT(0);
377 EXT char *nameary[100];
382 EXT HASH *curarghash;
397 #define P_FILETEST 65