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