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 #include <appkit/NXCType.h>
40 #define MEM_SIZE Size_t
42 #if defined(I_STRING) || defined(__cplusplus)
49 # define bcopy(s1,s2,l) memcpy(s2,s1,l)
52 # define bzero(s,l) memset(s,0,l)
55 #if !defined(HAS_STRCHR) && defined(HAS_INDEX) && !defined(strchr)
57 #define strrchr rindex
66 # ifdef I_SYS_TIME_KERNEL
69 # include <sys/time.h>
70 # ifdef I_SYS_TIME_KERNEL
76 # if defined(HAS_TIMES) && defined(I_SYS_TIMES)
77 # include <sys/times.h>
82 /* All of these are in stdlib.h or time.h for ANSI C */
84 struct tm *gmtime(), *localtime();
85 char *strchr(), *strrchr();
86 char *strcpy(), *strcat();
87 #endif /* ! STANDARD_C */
138 #define OSEMICOLON 47
275 extern char *opname[];
284 #if defined(iAPX286) || defined(M_I286) || defined(I80286) /* 80286 hack */
285 #define OPSMAX (64000/sizeof(union u_ops)) /* approx. max segment size */
288 #endif /* 80286 hack */
289 EXT union u_ops ops[OPSMAX];
291 typedef struct string STR;
292 typedef struct htbl HASH;
298 /* A string is TRUE if not "" or "0". */
299 #define True(val) (tmps = (val), (*tmps && !(*tmps == '0' && !tmps[1])))
300 EXT char *Yes INIT("1");
301 EXT char *No INIT("");
303 #define str_true(str) (Str = (str), (Str->str_pok ? True(Str->str_ptr) : (Str->str_nok ? (Str->str_nval != 0.0) : 0 )))
305 #define str_peek(str) (Str = (str), (Str->str_pok ? Str->str_ptr : (Str->str_nok ? (sprintf(buf,"num(%g)",Str->str_nval),buf) : "" )))
306 #define str_get(str) (Str = (str), (Str->str_pok ? Str->str_ptr : str_2ptr(Str)))
307 #define str_gnum(str) (Str = (str), (Str->str_nok ? Str->str_nval : str_2num(Str)))
310 #define GROWSTR(pp,lp,len) if (*(lp) < (len)) growstr(pp,lp,len)
312 /* Prototypes for things in a2p.c */
313 int aryrefarg _(( int arg ));
314 int bl _(( int arg, int maybe ));
315 void dump _(( int branch ));
316 int fixfargs _(( int name, int arg, int prevargs ));
317 int fixrargs _(( char *name, int arg, int prevargs ));
318 void fixup _(( STR *str ));
319 int numary _(( int arg ));
320 int oper0 _(( int type ));
321 int oper1 _(( int type, int arg1 ));
322 int oper2 _(( int type, int arg1, int arg2 ));
323 int oper3 _(( int type, int arg1, int arg2, int arg3 ));
324 int oper4 _(( int type, int arg1, int arg2, int arg3, int arg4 ));
325 int oper5 _(( int type, int arg1, int arg2, int arg3, int arg4, int arg5 ));
326 void putlines _(( STR *str ));
327 void putone _(( void ));
328 int rememberargs _(( int arg ));
329 char * scannum _(( char *s ));
330 char * scanpat _(( char *s ));
331 int string _(( char *ptr, int len ));
332 void yyerror _(( char *s ));
333 int yylex _(( void ));
335 EXT int line INIT(0);
339 EXT char *bufptr INIT(buf);
341 EXT STR *linestr INIT(Nullstr);
343 EXT char tokenbuf[2048];
344 EXT int expectterm INIT(TRUE);
347 EXT int debug INIT(0);
348 EXT int dlevel INIT(0);
353 EXT STR *freestrroot INIT(Nullstr);
358 EXT bool do_split INIT(FALSE);
359 EXT bool split_to_array INIT(FALSE);
360 EXT bool set_array_base INIT(FALSE);
361 EXT bool saw_RS INIT(FALSE);
362 EXT bool saw_OFS INIT(FALSE);
363 EXT bool saw_ORS INIT(FALSE);
364 EXT bool saw_line_op INIT(FALSE);
365 EXT bool in_begin INIT(TRUE);
366 EXT bool do_opens INIT(FALSE);
367 EXT bool do_fancy_opens INIT(FALSE);
368 EXT bool lval_field INIT(FALSE);
369 EXT bool do_chop INIT(FALSE);
370 EXT bool need_entire INIT(FALSE);
371 EXT bool absmaxfld INIT(FALSE);
372 EXT bool saw_altinput INIT(FALSE);
374 EXT bool nomemok INIT(FALSE);
376 EXT char const_FS INIT(0);
377 EXT char *namelist INIT(Nullch);
378 EXT char fswitch INIT(0);
380 EXT int saw_FS INIT(0);
381 EXT int maxfld INIT(0);
382 EXT int arymax INIT(0);
383 EXT char *nameary[100];
388 EXT HASH *curarghash;
403 #define P_FILETEST 65