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 # define NO_PERL_TYPEDEFS
104 # include "[-]vmsish.h"
109 /* All of these are in stdlib.h or time.h for ANSI C */
111 struct tm *gmtime(), *localtime();
112 char *strchr(), *strrchr();
113 char *strcpy(), *strcat();
114 #endif /* ! STANDARD_C */
116 #include "../handy.h"
119 #define Nullfp Null(FILE*)
169 #define OSEMICOLON 47
306 extern char *opname[];
315 #if defined(iAPX286) || defined(M_I286) || defined(I80286) /* 80286 hack */
316 #define OPSMAX (64000/sizeof(union u_ops)) /* approx. max segment size */
319 #endif /* 80286 hack */
320 EXT union u_ops ops[OPSMAX];
322 typedef struct string STR;
323 typedef struct htbl HASH;
329 /* A string is TRUE if not "" or "0". */
330 #define True(val) (tmps = (val), (*tmps && !(*tmps == '0' && !tmps[1])))
331 EXT char *Yes INIT("1");
332 EXT char *No INIT("");
334 #define str_true(str) (Str = (str), (Str->str_pok ? True(Str->str_ptr) : (Str->str_nok ? (Str->str_nval != 0.0) : 0 )))
336 #define str_peek(str) (Str = (str), (Str->str_pok ? Str->str_ptr : (Str->str_nok ? (sprintf(buf,"num(%g)",Str->str_nval),buf) : "" )))
337 #define str_get(str) (Str = (str), (Str->str_pok ? Str->str_ptr : str_2ptr(Str)))
338 #define str_gnum(str) (Str = (str), (Str->str_nok ? Str->str_nval : str_2num(Str)))
341 #define GROWSTR(pp,lp,len) if (*(lp) < (len)) growstr(pp,lp,len)
343 /* Prototypes for things in a2p.c */
344 int aryrefarg _(( int arg ));
345 int bl _(( int arg, int maybe ));
346 void dump _(( int branch ));
347 int fixfargs _(( int name, int arg, int prevargs ));
348 int fixrargs _(( char *name, int arg, int prevargs ));
349 void fixup _(( STR *str ));
350 int numary _(( int arg ));
351 int oper0 _(( int type ));
352 int oper1 _(( int type, int arg1 ));
353 int oper2 _(( int type, int arg1, int arg2 ));
354 int oper3 _(( int type, int arg1, int arg2, int arg3 ));
355 int oper4 _(( int type, int arg1, int arg2, int arg3, int arg4 ));
356 int oper5 _(( int type, int arg1, int arg2, int arg3, int arg4, int arg5 ));
357 void putlines _(( STR *str ));
358 void putone _(( void ));
359 int rememberargs _(( int arg ));
360 char * scannum _(( char *s ));
361 char * scanpat _(( char *s ));
362 int string _(( char *ptr, int len ));
363 void yyerror _(( char *s ));
364 int yylex _(( void ));
366 EXT int line INIT(0);
370 EXT char *bufptr INIT(buf);
372 EXT STR *linestr INIT(Nullstr);
374 EXT char tokenbuf[2048];
375 EXT int expectterm INIT(TRUE);
378 EXT int debug INIT(0);
379 EXT int dlevel INIT(0);
384 EXT STR *freestrroot INIT(Nullstr);
389 EXT bool do_split INIT(FALSE);
390 EXT bool split_to_array INIT(FALSE);
391 EXT bool set_array_base INIT(FALSE);
392 EXT bool saw_RS INIT(FALSE);
393 EXT bool saw_OFS INIT(FALSE);
394 EXT bool saw_ORS INIT(FALSE);
395 EXT bool saw_line_op INIT(FALSE);
396 EXT bool in_begin INIT(TRUE);
397 EXT bool do_opens INIT(FALSE);
398 EXT bool do_fancy_opens INIT(FALSE);
399 EXT bool lval_field INIT(FALSE);
400 EXT bool do_chop INIT(FALSE);
401 EXT bool need_entire INIT(FALSE);
402 EXT bool absmaxfld INIT(FALSE);
403 EXT bool saw_altinput INIT(FALSE);
405 EXT bool nomemok INIT(FALSE);
407 EXT char const_FS INIT(0);
408 EXT char *namelist INIT(Nullch);
409 EXT char fswitch INIT(0);
411 EXT int saw_FS INIT(0);
412 EXT int maxfld INIT(0);
413 EXT int arymax INIT(0);
414 EXT char *nameary[100];
419 EXT HASH *curarghash;
434 #define P_FILETEST 65