perl 2.0 (no announcement message available)
[p5sagit/p5-mst-13.2.git] / x2p / a2p.h
1 /* $Header: a2p.h,v 2.0 88/06/05 00:15:33 root Exp $
2  *
3  * $Log:        a2p.h,v $
4  * Revision 2.0  88/06/05  00:15:33  root
5  * Baseline version 2.0.
6  * 
7  */
8
9 #define VOIDUSED 1
10 #include "../config.h"
11
12 #ifndef BCOPY
13 #   define bcopy(s1,s2,l) memcpy(s2,s1,l);
14 #   define bzero(s,l) memset(s,0,l);
15 #endif
16
17 #include "handy.h"
18 #define Nullop 0
19
20 #define OPROG           1
21 #define OJUNK           2
22 #define OHUNKS          3
23 #define ORANGE          4
24 #define OPAT            5
25 #define OHUNK           6
26 #define OPPAREN         7
27 #define OPANDAND        8
28 #define OPOROR          9
29 #define OPNOT           10
30 #define OCPAREN         11
31 #define OCANDAND        12
32 #define OCOROR          13
33 #define OCNOT           14
34 #define ORELOP          15
35 #define ORPAREN         16
36 #define OMATCHOP        17
37 #define OMPAREN         18
38 #define OCONCAT         19
39 #define OASSIGN         20
40 #define OADD            21
41 #define OSUB            22
42 #define OMULT           23
43 #define ODIV            24
44 #define OMOD            25
45 #define OPOSTINCR       26
46 #define OPOSTDECR       27
47 #define OPREINCR        28
48 #define OPREDECR        29
49 #define OUMINUS         30
50 #define OUPLUS          31
51 #define OPAREN          32
52 #define OGETLINE        33
53 #define OSPRINTF        34
54 #define OSUBSTR         35
55 #define OSTRING         36
56 #define OSPLIT          37
57 #define OSNEWLINE       38
58 #define OINDEX          39
59 #define ONUM            40
60 #define OSTR            41
61 #define OVAR            42
62 #define OFLD            43
63 #define ONEWLINE        44
64 #define OCOMMENT        45
65 #define OCOMMA          46
66 #define OSEMICOLON      47
67 #define OSCOMMENT       48
68 #define OSTATES         49
69 #define OSTATE          50
70 #define OPRINT          51
71 #define OPRINTF         52
72 #define OBREAK          53
73 #define ONEXT           54
74 #define OEXIT           55
75 #define OCONTINUE       56
76 #define OREDIR          57
77 #define OIF             58
78 #define OWHILE          59
79 #define OFOR            60
80 #define OFORIN          61
81 #define OVFLD           62
82 #define OBLOCK          63
83 #define OREGEX          64
84 #define OLENGTH         65
85 #define OLOG            66
86 #define OEXP            67
87 #define OSQRT           68
88 #define OINT            69
89
90 #ifdef DOINIT
91 char *opname[] = {
92     "0",
93     "PROG",
94     "JUNK",
95     "HUNKS",
96     "RANGE",
97     "PAT",
98     "HUNK",
99     "PPAREN",
100     "PANDAND",
101     "POROR",
102     "PNOT",
103     "CPAREN",
104     "CANDAND",
105     "COROR",
106     "CNOT",
107     "RELOP",
108     "RPAREN",
109     "MATCHOP",
110     "MPAREN",
111     "CONCAT",
112     "ASSIGN",
113     "ADD",
114     "SUB",
115     "MULT",
116     "DIV",
117     "MOD",
118     "POSTINCR",
119     "POSTDECR",
120     "PREINCR",
121     "PREDECR",
122     "UMINUS",
123     "UPLUS",
124     "PAREN",
125     "GETLINE",
126     "SPRINTF",
127     "SUBSTR",
128     "STRING",
129     "SPLIT",
130     "SNEWLINE",
131     "INDEX",
132     "NUM",
133     "STR",
134     "VAR",
135     "FLD",
136     "NEWLINE",
137     "COMMENT",
138     "COMMA",
139     "SEMICOLON",
140     "SCOMMENT",
141     "STATES",
142     "STATE",
143     "PRINT",
144     "PRINTF",
145     "BREAK",
146     "NEXT",
147     "EXIT",
148     "CONTINUE",
149     "REDIR",
150     "IF",
151     "WHILE",
152     "FOR",
153     "FORIN",
154     "VFLD",
155     "BLOCK",
156     "REGEX",
157     "LENGTH",
158     "LOG",
159     "EXP",
160     "SQRT",
161     "INT",
162     "70"
163 };
164 #else
165 extern char *opname[];
166 #endif
167
168 union {
169     int ival;
170     char *cval;
171 } ops[50000];           /* hope they have 200k to spare */
172
173 EXT int mop INIT(1);
174
175 #define DEBUGGING
176
177 #include <stdio.h>
178 #include <ctype.h>
179
180 typedef struct string STR;
181 typedef struct htbl HASH;
182
183 #include "str.h"
184 #include "hash.h"
185
186 /* A string is TRUE if not "" or "0". */
187 #define True(val) (tmps = (val), (*tmps && !(*tmps == '0' && !tmps[1])))
188 EXT char *Yes INIT("1");
189 EXT char *No INIT("");
190
191 #define str_true(str) (Str = (str), (Str->str_pok ? True(Str->str_ptr) : (Str->str_nok ? (Str->str_nval != 0.0) : 0 )))
192
193 #define str_peek(str) (Str = (str), (Str->str_pok ? Str->str_ptr : (Str->str_nok ? (sprintf(buf,"num(%g)",Str->str_nval),buf) : "" )))
194 #define str_get(str) (Str = (str), (Str->str_pok ? Str->str_ptr : str_2ptr(Str)))
195 #define str_gnum(str) (Str = (str), (Str->str_nok ? Str->str_nval : str_2num(Str)))
196 EXT STR *Str;
197
198 #define GROWSTR(pp,lp,len) if (*(lp) < (len)) growstr(pp,lp,len)
199
200 STR *str_new();
201
202 char *scanpat();
203 char *scannum();
204
205 void str_free();
206
207 EXT int line INIT(0);
208
209 EXT FILE *rsfp;
210 EXT char buf[1024];
211 EXT char *bufptr INIT(buf);
212
213 EXT STR *linestr INIT(Nullstr);
214
215 EXT char tokenbuf[256];
216 EXT int expectterm INIT(TRUE);
217
218 #ifdef DEBUGGING
219 EXT int debug INIT(0);
220 EXT int dlevel INIT(0);
221 #define YYDEBUG 1
222 extern int yydebug;
223 #endif
224
225 EXT STR *freestrroot INIT(Nullstr);
226
227 EXT STR str_no;
228 EXT STR str_yes;
229
230 EXT bool do_split INIT(FALSE);
231 EXT bool split_to_array INIT(FALSE);
232 EXT bool set_array_base INIT(FALSE);
233 EXT bool saw_RS INIT(FALSE);
234 EXT bool saw_OFS INIT(FALSE);
235 EXT bool saw_ORS INIT(FALSE);
236 EXT bool saw_line_op INIT(FALSE);
237 EXT bool in_begin INIT(TRUE);
238 EXT bool do_opens INIT(FALSE);
239 EXT bool do_fancy_opens INIT(FALSE);
240 EXT bool lval_field INIT(FALSE);
241 EXT bool do_chop INIT(FALSE);
242 EXT bool need_entire INIT(FALSE);
243 EXT bool absmaxfld INIT(FALSE);
244
245 EXT char const_FS INIT(0);
246 EXT char *namelist INIT(Nullch);
247 EXT char fswitch INIT(0);
248
249 EXT int saw_FS INIT(0);
250 EXT int maxfld INIT(0);
251 EXT int arymax INIT(0);
252 char *nameary[100];
253
254 EXT STR *opens;
255
256 EXT HASH *symtab;