perl 5.000d : [hint file updates]
[p5sagit/p5-mst-13.2.git] / x2p / a2p.h
CommitLineData
79072805 1/* $RCSfile: a2p.h,v $$Revision: 4.1 $$Date: 92/08/07 18:29:09 $
a687059c 2 *
2b317908 3 * Copyright (c) 1991, Larry Wall
a687059c 4 *
2b317908 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.
8d063cd8 7 *
8 * $Log: a2p.h,v $
8d063cd8 9 */
10
be04251a 11#define VOIDUSED 1
12#include "../config.h"
13
fe14fcc3 14#ifndef HAS_BCOPY
449aadca 15# define bcopy(s1,s2,l) memcpy(s2,s1,l)
16#endif
fe14fcc3 17#ifndef HAS_BZERO
449aadca 18# define bzero(s,l) memset(s,0,l)
be04251a 19#endif
20
8d063cd8 21#include "handy.h"
22#define Nullop 0
23
24#define OPROG 1
25#define OJUNK 2
26#define OHUNKS 3
27#define ORANGE 4
28#define OPAT 5
29#define OHUNK 6
30#define OPPAREN 7
31#define OPANDAND 8
32#define OPOROR 9
33#define OPNOT 10
34#define OCPAREN 11
35#define OCANDAND 12
36#define OCOROR 13
37#define OCNOT 14
38#define ORELOP 15
39#define ORPAREN 16
40#define OMATCHOP 17
41#define OMPAREN 18
42#define OCONCAT 19
43#define OASSIGN 20
44#define OADD 21
a687059c 45#define OSUBTRACT 22
8d063cd8 46#define OMULT 23
47#define ODIV 24
48#define OMOD 25
49#define OPOSTINCR 26
50#define OPOSTDECR 27
51#define OPREINCR 28
52#define OPREDECR 29
53#define OUMINUS 30
54#define OUPLUS 31
55#define OPAREN 32
56#define OGETLINE 33
57#define OSPRINTF 34
58#define OSUBSTR 35
59#define OSTRING 36
60#define OSPLIT 37
61#define OSNEWLINE 38
62#define OINDEX 39
63#define ONUM 40
64#define OSTR 41
65#define OVAR 42
66#define OFLD 43
67#define ONEWLINE 44
68#define OCOMMENT 45
69#define OCOMMA 46
70#define OSEMICOLON 47
71#define OSCOMMENT 48
72#define OSTATES 49
73#define OSTATE 50
74#define OPRINT 51
75#define OPRINTF 52
76#define OBREAK 53
77#define ONEXT 54
78#define OEXIT 55
79#define OCONTINUE 56
80#define OREDIR 57
81#define OIF 58
82#define OWHILE 59
83#define OFOR 60
84#define OFORIN 61
85#define OVFLD 62
86#define OBLOCK 63
87#define OREGEX 64
88#define OLENGTH 65
89#define OLOG 66
90#define OEXP 67
91#define OSQRT 68
92#define OINT 69
a687059c 93#define ODO 70
94#define OPOW 71
95#define OSUB 72
96#define OGSUB 73
97#define OMATCH 74
98#define OUSERFUN 75
99#define OUSERDEF 76
100#define OCLOSE 77
101#define OATAN2 78
102#define OSIN 79
103#define OCOS 80
104#define ORAND 81
105#define OSRAND 82
106#define ODELETE 83
107#define OSYSTEM 84
108#define OCOND 85
109#define ORETURN 86
110#define ODEFINED 87
111#define OSTAR 88
8d063cd8 112
113#ifdef DOINIT
114char *opname[] = {
115 "0",
116 "PROG",
117 "JUNK",
118 "HUNKS",
119 "RANGE",
120 "PAT",
121 "HUNK",
122 "PPAREN",
123 "PANDAND",
124 "POROR",
125 "PNOT",
126 "CPAREN",
127 "CANDAND",
128 "COROR",
129 "CNOT",
130 "RELOP",
131 "RPAREN",
132 "MATCHOP",
133 "MPAREN",
134 "CONCAT",
135 "ASSIGN",
136 "ADD",
a687059c 137 "SUBTRACT",
8d063cd8 138 "MULT",
139 "DIV",
140 "MOD",
141 "POSTINCR",
142 "POSTDECR",
143 "PREINCR",
144 "PREDECR",
145 "UMINUS",
146 "UPLUS",
147 "PAREN",
148 "GETLINE",
149 "SPRINTF",
150 "SUBSTR",
151 "STRING",
152 "SPLIT",
153 "SNEWLINE",
154 "INDEX",
155 "NUM",
156 "STR",
157 "VAR",
158 "FLD",
159 "NEWLINE",
160 "COMMENT",
161 "COMMA",
162 "SEMICOLON",
163 "SCOMMENT",
164 "STATES",
165 "STATE",
166 "PRINT",
167 "PRINTF",
168 "BREAK",
169 "NEXT",
170 "EXIT",
171 "CONTINUE",
172 "REDIR",
173 "IF",
174 "WHILE",
175 "FOR",
176 "FORIN",
177 "VFLD",
178 "BLOCK",
179 "REGEX",
180 "LENGTH",
181 "LOG",
182 "EXP",
183 "SQRT",
184 "INT",
a687059c 185 "DO",
186 "POW",
187 "SUB",
188 "GSUB",
189 "MATCH",
190 "USERFUN",
191 "USERDEF",
192 "CLOSE",
193 "ATAN2",
194 "SIN",
195 "COS",
196 "RAND",
197 "SRAND",
198 "DELETE",
199 "SYSTEM",
200 "COND",
201 "RETURN",
202 "DEFINED",
203 "STAR",
204 "89"
8d063cd8 205};
206#else
207extern char *opname[];
208#endif
209
a687059c 210EXT int mop INIT(1);
211
d8f2e4cc 212union u_ops {
8d063cd8 213 int ival;
214 char *cval;
d8f2e4cc 215};
216#if defined(iAPX286) || defined(M_I286) || defined(I80286) /* 80286 hack */
217#define OPSMAX (64000/sizeof(union u_ops)) /* approx. max segment size */
218#else
219#define OPSMAX 50000
220#endif /* 80286 hack */
a0d0e21e 221EXT union u_ops ops[OPSMAX];
8d063cd8 222
8d063cd8 223#include <stdio.h>
224#include <ctype.h>
8d063cd8 225
226typedef struct string STR;
227typedef struct htbl HASH;
228
229#include "str.h"
230#include "hash.h"
231
232/* A string is TRUE if not "" or "0". */
233#define True(val) (tmps = (val), (*tmps && !(*tmps == '0' && !tmps[1])))
234EXT char *Yes INIT("1");
235EXT char *No INIT("");
236
237#define str_true(str) (Str = (str), (Str->str_pok ? True(Str->str_ptr) : (Str->str_nok ? (Str->str_nval != 0.0) : 0 )))
238
239#define str_peek(str) (Str = (str), (Str->str_pok ? Str->str_ptr : (Str->str_nok ? (sprintf(buf,"num(%g)",Str->str_nval),buf) : "" )))
240#define str_get(str) (Str = (str), (Str->str_pok ? Str->str_ptr : str_2ptr(Str)))
241#define str_gnum(str) (Str = (str), (Str->str_nok ? Str->str_nval : str_2num(Str)))
242EXT STR *Str;
243
244#define GROWSTR(pp,lp,len) if (*(lp) < (len)) growstr(pp,lp,len)
245
246STR *str_new();
247
248char *scanpat();
249char *scannum();
250
251void str_free();
252
253EXT int line INIT(0);
254
255EXT FILE *rsfp;
fe14fcc3 256EXT char buf[2048];
8d063cd8 257EXT char *bufptr INIT(buf);
258
259EXT STR *linestr INIT(Nullstr);
260
fe14fcc3 261EXT char tokenbuf[2048];
8d063cd8 262EXT int expectterm INIT(TRUE);
263
264#ifdef DEBUGGING
265EXT int debug INIT(0);
266EXT int dlevel INIT(0);
9bb9d9f7 267#define YYDEBUG 1
8d063cd8 268extern int yydebug;
269#endif
270
271EXT STR *freestrroot INIT(Nullstr);
272
273EXT STR str_no;
274EXT STR str_yes;
275
276EXT bool do_split INIT(FALSE);
277EXT bool split_to_array INIT(FALSE);
278EXT bool set_array_base INIT(FALSE);
279EXT bool saw_RS INIT(FALSE);
280EXT bool saw_OFS INIT(FALSE);
281EXT bool saw_ORS INIT(FALSE);
282EXT bool saw_line_op INIT(FALSE);
283EXT bool in_begin INIT(TRUE);
284EXT bool do_opens INIT(FALSE);
285EXT bool do_fancy_opens INIT(FALSE);
286EXT bool lval_field INIT(FALSE);
287EXT bool do_chop INIT(FALSE);
288EXT bool need_entire INIT(FALSE);
289EXT bool absmaxfld INIT(FALSE);
a687059c 290EXT bool saw_altinput INIT(FALSE);
8d063cd8 291
bf10efe7 292EXT bool nomemok INIT(FALSE);
293
8d063cd8 294EXT char const_FS INIT(0);
295EXT char *namelist INIT(Nullch);
296EXT char fswitch INIT(0);
297
298EXT int saw_FS INIT(0);
299EXT int maxfld INIT(0);
300EXT int arymax INIT(0);
a0d0e21e 301EXT char *nameary[100];
8d063cd8 302
303EXT STR *opens;
304
305EXT HASH *symtab;
a687059c 306EXT HASH *curarghash;
307
308#define P_MIN 0
309#define P_LISTOP 5
310#define P_COMMA 10
311#define P_ASSIGN 15
312#define P_COND 20
313#define P_DOTDOT 25
314#define P_OROR 30
315#define P_ANDAND 35
316#define P_OR 40
317#define P_AND 45
318#define P_EQ 50
319#define P_REL 55
320#define P_UNI 60
321#define P_FILETEST 65
322#define P_SHIFT 70
323#define P_ADD 75
324#define P_MUL 80
325#define P_MATCH 85
326#define P_UNARY 90
327#define P_POW 95
328#define P_AUTO 100
329#define P_MAX 999
79072805 330
331EXT int an;