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