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