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