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 /* Use all the "standard" definitions? */
15 #if defined(STANDARD_C) && defined(I_STDLIB)
17 #endif /* STANDARD_C */
25 #include <appkit/NXCType.h>
30 #define MEM_SIZE Size_t
32 #if defined(I_STRING) || defined(__cplusplus)
39 # define bcopy(s1,s2,l) memcpy(s2,s1,l)
42 # define bzero(s,l) memset(s,0,l)
45 #if !defined(HAS_STRCHR) && defined(HAS_INDEX) && !defined(strchr)
47 #define strrchr rindex
236 extern char *opname[];
245 #if defined(iAPX286) || defined(M_I286) || defined(I80286) /* 80286 hack */
246 #define OPSMAX (64000/sizeof(union u_ops)) /* approx. max segment size */
249 #endif /* 80286 hack */
250 EXT union u_ops ops[OPSMAX];
252 typedef struct string STR;
253 typedef struct htbl HASH;
259 /* A string is TRUE if not "" or "0". */
260 #define True(val) (tmps = (val), (*tmps && !(*tmps == '0' && !tmps[1])))
261 EXT char *Yes INIT("1");
262 EXT char *No INIT("");
264 #define str_true(str) (Str = (str), (Str->str_pok ? True(Str->str_ptr) : (Str->str_nok ? (Str->str_nval != 0.0) : 0 )))
266 #define str_peek(str) (Str = (str), (Str->str_pok ? Str->str_ptr : (Str->str_nok ? (sprintf(buf,"num(%g)",Str->str_nval),buf) : "" )))
267 #define str_get(str) (Str = (str), (Str->str_pok ? Str->str_ptr : str_2ptr(Str)))
268 #define str_gnum(str) (Str = (str), (Str->str_nok ? Str->str_nval : str_2num(Str)))
271 #define GROWSTR(pp,lp,len) if (*(lp) < (len)) growstr(pp,lp,len)
273 /* Prototypes for things in a2p.c */
274 int aryrefarg _(( int arg ));
275 int bl _(( int arg, int maybe ));
276 void dump _(( int branch ));
277 int fixfargs _(( int name, int arg, int prevargs ));
278 int fixrargs _(( char *name, int arg, int prevargs ));
279 void fixup _(( STR *str ));
280 int numary _(( int arg ));
281 int oper0 _(( int type ));
282 int oper1 _(( int type, int arg1 ));
283 int oper2 _(( int type, int arg1, int arg2 ));
284 int oper3 _(( int type, int arg1, int arg2, int arg3 ));
285 int oper4 _(( int type, int arg1, int arg2, int arg3, int arg4 ));
286 int oper5 _(( int type, int arg1, int arg2, int arg3, int arg4, int arg5 ));
287 void putlines _(( STR *str ));
288 void putone _(( void ));
289 int rememberargs _(( int arg ));
290 char * scannum _(( char *s ));
291 char * scanpat _(( char *s ));
292 int string _(( char *ptr, int len ));
293 void yyerror _(( char *s ));
294 int yylex _(( void ));
296 EXT int line INIT(0);
300 EXT char *bufptr INIT(buf);
302 EXT STR *linestr INIT(Nullstr);
304 EXT char tokenbuf[2048];
305 EXT int expectterm INIT(TRUE);
308 EXT int debug INIT(0);
309 EXT int dlevel INIT(0);
314 EXT STR *freestrroot INIT(Nullstr);
319 EXT bool do_split INIT(FALSE);
320 EXT bool split_to_array INIT(FALSE);
321 EXT bool set_array_base INIT(FALSE);
322 EXT bool saw_RS INIT(FALSE);
323 EXT bool saw_OFS INIT(FALSE);
324 EXT bool saw_ORS INIT(FALSE);
325 EXT bool saw_line_op INIT(FALSE);
326 EXT bool in_begin INIT(TRUE);
327 EXT bool do_opens INIT(FALSE);
328 EXT bool do_fancy_opens INIT(FALSE);
329 EXT bool lval_field INIT(FALSE);
330 EXT bool do_chop INIT(FALSE);
331 EXT bool need_entire INIT(FALSE);
332 EXT bool absmaxfld INIT(FALSE);
333 EXT bool saw_altinput INIT(FALSE);
335 EXT bool nomemok INIT(FALSE);
337 EXT char const_FS INIT(0);
338 EXT char *namelist INIT(Nullch);
339 EXT char fswitch INIT(0);
341 EXT int saw_FS INIT(0);
342 EXT int maxfld INIT(0);
343 EXT int arymax INIT(0);
344 EXT char *nameary[100];
349 EXT HASH *curarghash;
364 #define P_FILETEST 65