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