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