3 yyrcsid
[] = "$FreeBSD: src/usr.bin/yacc/skeleton.c,v 1.28 2000/01/17 02:04:06 bde Exp $";
11 #define yyclearin (yychar=(YYEMPTY))
12 #define yyerrok (yyerrflag=0)
13 #define YYRECOVERING() (yyerrflag!=0)
14 static int yygrowstack();
18 #include "../config.h"
25 #include "interpret.h"
31 #include <X11/Intrinsic.h>
34 #include "../util/VMSparam.h"
37 #include <sys/param.h>
45 /* Macros to add error processing to AddOp and AddSym calls */
46 #define ADD_OP(op) if (!AddOp(op, &ErrMsg)) return 1
47 #define ADD_SYM(sym) if (!AddSym(sym, &ErrMsg)) return 1
48 #define ADD_IMMED(val) if (!AddImmediate(val, &ErrMsg)) return 1
49 #define ADD_BR_OFF(to) if (!AddBranchOffset(to, &ErrMsg)) return 1
50 #define SET_BR_OFF(from, to) ((from)->value) = ((Inst *)(to)) - ((Inst *)(from))
52 /* Max. length for a string constant (... there shouldn't be a maximum) */
53 #define MAX_STRING_CONST_LEN 5000
55 static const char CVSID
[] = "$Id: parse_noyacc.c,v 1.10 2007/01/12 16:19:35 tringali Exp $";
56 static int yyerror(char *s
);
57 static int yylex(void);
59 static int follow(char expect
, int yes
, int no
);
60 static int follow2(char expect1
, int yes1
, char expect2
, int yes2
, int no
);
61 static int follow_non_whitespace(char expect
, int yes
, int no
);
62 static Symbol
*matchesActionRoutine(char **inPtr
);
66 extern Inst
*LoopStack
[]; /* addresses of break, cont stmts */
67 extern Inst
**LoopStackPtr
; /* to fill at the end of a loop */
81 #define ARG_LOOKUP 261
89 #define IF_NO_ELSE 269
107 #define UNARY_MINUS 287
112 const short yylhs
[] = { -1,
113 0, 0, 0, 0, 13, 13, 13, 12, 12, 14,
114 14, 14, 14, 14, 16, 14, 14, 14, 14, 14,
115 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
116 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
117 15, 15, 15, 15, 15, 15, 10, 3, 3, 3,
118 1, 1, 1, 17, 17, 19, 19, 18, 18, 9,
119 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,
120 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,
121 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,
122 20, 20, 5, 4, 6, 2, 2, 7, 8, 11,
125 const short yylen
[] = { 2,
126 2, 5, 4, 1, 5, 4, 1, 1, 2, 3,
127 6, 9, 6, 10, 0, 9, 3, 3, 4, 3,
128 3, 3, 3, 3, 3, 3, 3, 3, 5, 6,
129 6, 6, 6, 6, 6, 6, 6, 5, 5, 5,
130 5, 4, 2, 2, 2, 2, 1, 0, 1, 3,
131 0, 1, 3, 1, 2, 1, 4, 1, 4, 1,
132 1, 1, 1, 4, 3, 4, 3, 1, 4, 3,
133 3, 3, 3, 3, 3, 2, 3, 3, 3, 3,
134 3, 3, 3, 3, 3, 3, 2, 2, 2, 2,
135 2, 3, 1, 1, 1, 0, 1, 1, 1, 0,
138 const short yydefred
[] = { 0,
139 4, 0, 0, 0, 0, 0, 93, 94, 0, 0,
140 0, 0, 0, 100, 101, 0, 0, 0, 0, 8,
141 0, 0, 0, 44, 46, 0, 58, 0, 0, 100,
142 100, 61, 62, 0, 0, 0, 0, 0, 0, 0,
143 100, 0, 0, 0, 0, 0, 0, 0, 0, 0,
144 0, 0, 0, 0, 0, 0, 0, 9, 100, 0,
145 0, 0, 0, 0, 0, 0, 0, 0, 89, 91,
146 0, 0, 0, 0, 88, 90, 0, 0, 100, 0,
147 99, 98, 0, 0, 0, 0, 0, 0, 0, 0,
148 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
149 0, 0, 3, 0, 0, 0, 49, 0, 0, 0,
150 0, 0, 0, 0, 0, 0, 0, 42, 0, 0,
151 100, 0, 67, 0, 65, 0, 0, 0, 0, 0,
152 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
153 0, 0, 0, 0, 0, 0, 2, 0, 0, 0,
154 100, 0, 0, 0, 0, 64, 66, 69, 0, 0,
155 0, 0, 0, 50, 0, 0, 0, 0, 0, 0,
156 0, 0, 0, 38, 39, 100, 0, 7, 15, 0,
157 13, 0, 0, 0, 0, 0, 0, 0, 0, 0,
158 95, 100, 100, 0, 100, 0, 0, 0, 100, 0,
159 100, 12, 16, 0, 0, 14,
161 const short yydgoto
[] = { 2,
162 62, 65, 106, 16, 17, 192, 99, 100, 161, 18,
163 3, 19, 177, 178, 21, 193, 63, 28, 22, 43,
165 const short yysindex
[] = { -242,
166 0, 0, 221, 6, -243, -15, 0, 0, 32, 42,
167 603, -209, -204, 0, 0, 54, 58, 768, 1179, 0,
168 77, 22, 843, 0, 0, 843, 0, 38, 843, 0,
169 0, 0, 0, 8, 44, 843, 843, -150, -142, 843,
170 0, 747, 1368, 0, 46, 0, 49, 369, 101, 843,
171 843, 843, 843, 843, 843, 843, 843, 0, 0, 843,
172 843, -26, 843, 843, 82, 1368, 121, 121, 0, 0,
173 843, 975, -87, -87, 0, 0, 837, 121, 0, 1368,
174 0, 0, 843, 843, 843, 843, 843, 843, 843, 843,
175 843, 843, 843, 843, 843, 843, 843, 843, 843, 843,
176 843, 843, 0, 328, -31, -27, 0, 104, 843, 843,
177 843, 843, 843, 843, 843, 121, -22, 0, 843, -21,
178 0, -17, 0, -35, 0, 121, 65, 163, -9, -9,
179 -9, -9, -9, -9, -9, 2, 2, -87, -87, -87,
180 -87, -7, 23, 1250, 39, 40, 0, 843, 843, 504,
181 0, 624, 843, 0, 292, 0, 0, 0, 0, 0,
182 110, 1368, 94, 0, 292, 843, 843, 843, 843, 843,
183 843, 843, 843, 0, 0, 0, -110, 0, 0, 504,
184 0, 843, 843, 843, 843, 843, 843, 843, 843, 665,
185 0, 0, 0, 55, 0, 464, 292, 292, 0, 121,
186 0, 0, 0, 292, 121, 0,
188 const short yyrindex
[] = { 700,
189 0, 0, 0, -91, 0, 0, 0, 0, 0, 0,
190 0, 0, 0, 0, 0, 0, 0, 0, 155, 0,
191 0, 0, 0, 0, 0, 56, 0, 0, 116, 0,
192 0, 0, 0, 383, 128, 0, 0, 0, 0, 0,
193 0, 0, 179, 10, 0, 108, 0, 0, -18, 116,
194 0, 0, 0, 0, 0, 0, 0, 0, 0, 51,
195 47, 0, -1, 51, 0, -28, 1, 11, 0, 0,
196 56, 0, 419, 455, 0, 0, 0, 21, 0, 431,
197 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
198 0, 0, 0, 0, 0, 0, 0, 51, 0, 0,
199 51, 51, 0, 0, -91, 0, 0, 0, 75, 80,
200 117, 481, 503, 568, 611, 53, 0, 0, 0, 0,
201 0, 0, 0, 0, 0, 63, 1342, 1337, 899, 934,
202 969, 1197, 1232, 1267, 1302, 827, 863, 491, 527, 563,
203 791, 0, 1377, 877, 0, 0, 0, 0, 127, 0,
204 0, 69, 18, 118, 0, 0, 0, 0, 391, 539,
205 0, 122, 0, 0, 0, 0, 0, 0, 0, 0,
206 0, 0, 0, 0, 0, 0, 115, 0, 0, 81,
207 0, 613, 755, 815, 875, 932, 936, 940, 942, 0,
208 0, 0, 0, 0, 0, 0, 0, 0, 0, 73,
211 const short yygindex
[] = { 0,
212 444, -45, -16, 0, 0, 0, 0, 0, 0, 0,
213 1272, -42, 37, 26, -30, 0, 24, 0, 129, 1632,
215 #define YYTABLESIZE 1821
216 const short yytable
[] = { 56,
217 17, 96, 84, 98, 108, 104, 94, 92, 26, 93,
218 18, 95, 97, 1, 118, 27, 150, 119, 107, 43,
219 20, 119, 119, 156, 29, 48, 119, 96, 20, 23,
220 97, 149, 94, 92, 42, 93, 119, 95, 96, 52,
221 48, 30, 52, 94, 58, 26, 61, 71, 95, 44,
222 43, 31, 10, 43, 46, 98, 21, 157, 53, 96,
223 84, 53, 19, 77, 94, 92, 23, 93, 43, 95,
224 152, 154, 6, 20, 109, 110, 111, 112, 113, 114,
225 115, 98, 119, 119, 22, 158, 59, 21, 83, 23,
226 21, 52, 98, 49, 51, 199, 51, 50, 150, 51,
227 56, 96, 84, 163, 5, 21, 94, 92, 75, 93,
228 53, 95, 60, 98, 11, 22, 76, 45, 22, 164,
229 23, 48, 121, 23, 48, 17, 24, 29, 64, 58,
230 15, 159, 160, 22, 72, 18, 101, 68, 23, 102,
231 45, 47, 153, 51, 151, 20, 83, 196, 45, 107,
232 179, 45, 180, 191, 1, 98, 96, 24, 29, 57,
233 24, 29, 60, 194, 68, 68, 45, 68, 68, 68,
234 68, 68, 68, 0, 68, 24, 29, 10, 47, 47,
235 47, 47, 47, 47, 47, 96, 68, 19, 54, 182,
236 183, 184, 185, 186, 187, 188, 189, 6, 56, 96,
237 0, 181, 0, 97, 94, 92, 0, 93, 59, 95,
238 0, 0, 0, 0, 0, 20, 0, 0, 54, 54,
239 68, 58, 54, 0, 0, 0, 0, 0, 0, 5,
240 15, 0, 0, 202, 203, 0, 0, 54, 0, 11,
241 206, 0, 81, 82, 85, 86, 87, 88, 89, 90,
242 91, 68, 0, 98, 148, 97, 0, 24, 25, 17,
243 17, 0, 17, 17, 17, 17, 17, 17, 17, 18,
244 18, 54, 18, 18, 18, 18, 18, 18, 18, 20,
245 20, 97, 20, 20, 20, 20, 20, 20, 20, 17,
246 17, 0, 97, 0, 24, 25, 69, 70, 0, 18,
247 18, 15, 85, 86, 87, 88, 89, 90, 91, 20,
248 20, 10, 10, 97, 10, 10, 10, 10, 10, 10,
249 10, 19, 19, 0, 19, 19, 19, 19, 19, 19,
250 19, 6, 6, 0, 6, 6, 6, 6, 6, 6,
251 6, 10, 10, 14, 85, 86, 87, 88, 89, 90,
252 91, 19, 19, 0, 0, 97, 0, 0, 0, 105,
253 5, 6, 6, 5, 5, 0, 5, 5, 5, 5,
254 5, 5, 5, 11, 11, 0, 11, 11, 15, 11,
255 11, 11, 11, 0, 68, 68, 68, 0, 68, 12,
256 13, 0, 63, 5, 5, 0, 0, 0, 0, 0,
257 40, 0, 0, 11, 11, 68, 68, 68, 68, 68,
258 68, 68, 68, 68, 176, 68, 68, 68, 68, 63,
259 63, 0, 0, 63, 63, 63, 63, 63, 76, 63,
260 0, 40, 0, 0, 40, 54, 54, 54, 0, 54,
261 55, 63, 85, 86, 87, 88, 89, 90, 91, 40,
262 0, 0, 147, 97, 0, 76, 76, 0, 76, 76,
263 76, 76, 76, 76, 87, 76, 54, 54, 54, 0,
264 55, 55, 0, 63, 55, 63, 0, 76, 0, 4,
265 5, 57, 6, 7, 0, 8, 9, 10, 11, 55,
266 25, 87, 87, 103, 87, 87, 87, 87, 87, 87,
267 72, 87, 0, 117, 0, 0, 63, 120, 0, 12,
268 13, 76, 26, 87, 122, 0, 0, 0, 0, 0,
269 0, 25, 0, 55, 25, 0, 0, 72, 72, 0,
270 72, 72, 72, 72, 72, 72, 73, 72, 0, 25,
271 0, 142, 76, 26, 145, 146, 26, 87, 41, 72,
272 4, 5, 0, 6, 7, 0, 8, 9, 10, 11,
273 0, 26, 0, 73, 73, 0, 73, 73, 73, 73,
274 73, 73, 74, 73, 0, 0, 0, 27, 87, 41,
275 12, 13, 41, 72, 0, 73, 4, 5, 201, 6,
276 7, 0, 8, 9, 10, 11, 0, 41, 0, 74,
277 74, 0, 74, 74, 74, 74, 74, 74, 27, 74,
278 0, 27, 41, 0, 72, 0, 12, 13, 0, 73,
279 28, 74, 30, 0, 0, 0, 27, 4, 5, 57,
280 6, 7, 0, 8, 9, 10, 11, 0, 0, 63,
281 63, 63, 40, 63, 0, 0, 0, 36, 0, 0,
282 73, 28, 0, 30, 28, 74, 30, 12, 13, 0,
283 63, 63, 63, 63, 63, 63, 63, 63, 63, 28,
284 63, 30, 0, 63, 15, 76, 76, 76, 0, 76,
285 0, 0, 0, 0, 166, 0, 74, 55, 55, 55,
286 0, 55, 0, 0, 0, 0, 76, 76, 76, 76,
287 76, 76, 76, 76, 76, 0, 76, 76, 76, 100,
288 0, 87, 87, 87, 0, 87, 0, 0, 55, 55,
289 55, 0, 4, 5, 0, 6, 7, 0, 8, 9,
290 10, 11, 87, 87, 87, 87, 87, 87, 87, 87,
291 87, 0, 87, 87, 87, 0, 0, 72, 72, 72,
292 0, 72, 12, 13, 0, 0, 79, 0, 0, 0,
293 0, 0, 4, 5, 31, 0, 0, 0, 72, 72,
294 72, 72, 72, 72, 72, 72, 72, 0, 72, 72,
295 72, 0, 0, 73, 73, 73, 40, 73, 0, 195,
296 0, 36, 12, 13, 0, 31, 0, 0, 31, 0,
297 75, 0, 0, 0, 73, 73, 73, 73, 73, 73,
298 73, 73, 73, 31, 73, 73, 73, 0, 0, 74,
299 74, 74, 100, 74, 32, 0, 0, 75, 75, 0,
300 75, 75, 75, 75, 75, 75, 70, 75, 0, 0,
301 74, 74, 74, 74, 74, 74, 74, 74, 74, 75,
302 74, 74, 74, 0, 0, 32, 0, 0, 32, 32,
303 33, 34, 0, 35, 70, 0, 70, 70, 0, 70,
304 70, 70, 71, 32, 0, 0, 40, 125, 0, 0,
305 0, 36, 40, 75, 33, 70, 86, 36, 0, 0,
306 37, 38, 39, 167, 168, 169, 170, 171, 172, 173,
307 71, 0, 71, 71, 0, 71, 71, 71, 77, 0,
308 0, 0, 174, 175, 75, 33, 86, 86, 33, 70,
309 86, 71, 0, 4, 5, 0, 6, 7, 0, 8,
310 9, 10, 11, 33, 0, 86, 77, 0, 77, 77,
311 0, 34, 77, 78, 0, 35, 0, 0, 0, 36,
312 70, 37, 0, 12, 13, 71, 0, 77, 100, 100,
313 0, 100, 100, 0, 100, 100, 100, 100, 0, 86,
314 0, 78, 34, 78, 78, 34, 35, 78, 79, 35,
315 36, 0, 37, 36, 0, 37, 71, 0, 100, 100,
316 34, 77, 78, 0, 35, 0, 0, 0, 36, 0,
317 37, 0, 0, 32, 33, 34, 79, 35, 79, 79,
318 0, 0, 79, 0, 40, 0, 0, 0, 0, 36,
319 0, 0, 77, 0, 0, 0, 78, 79, 0, 0,
320 0, 0, 0, 0, 37, 38, 39, 51, 52, 53,
321 54, 55, 56, 57, 0, 0, 0, 75, 75, 75,
322 0, 75, 0, 0, 0, 0, 0, 78, 0, 0,
323 0, 79, 0, 0, 0, 0, 0, 123, 75, 75,
324 75, 75, 75, 75, 75, 75, 75, 0, 75, 75,
325 75, 0, 0, 70, 70, 70, 0, 70, 0, 0,
326 0, 0, 79, 32, 33, 34, 0, 35, 0, 32,
327 33, 34, 0, 35, 70, 70, 70, 70, 70, 70,
328 70, 70, 70, 0, 70, 70, 70, 0, 0, 71,
329 71, 71, 0, 71, 37, 38, 39, 0, 0, 0,
330 37, 38, 39, 86, 86, 86, 0, 86, 0, 0,
331 71, 71, 71, 71, 71, 71, 71, 71, 71, 0,
332 71, 71, 71, 0, 86, 77, 77, 77, 0, 77,
333 0, 0, 0, 0, 86, 86, 86, 0, 0, 0,
334 0, 0, 0, 0, 0, 0, 77, 77, 77, 77,
335 77, 77, 77, 77, 77, 0, 77, 77, 77, 0,
336 78, 78, 78, 0, 78, 0, 0, 0, 0, 0,
337 0, 0, 0, 0, 0, 0, 80, 0, 0, 0,
338 0, 78, 78, 78, 78, 78, 78, 78, 78, 78,
339 0, 78, 78, 78, 0, 79, 79, 79, 0, 79,
340 0, 32, 33, 34, 80, 35, 80, 80, 0, 0,
341 80, 81, 0, 0, 0, 0, 79, 79, 79, 79,
342 79, 79, 79, 79, 79, 80, 79, 79, 79, 0,
343 0, 0, 37, 38, 39, 0, 0, 0, 0, 81,
344 0, 81, 81, 0, 0, 81, 82, 0, 0, 0,
345 0, 0, 0, 0, 0, 48, 96, 84, 0, 80,
346 81, 94, 92, 0, 93, 0, 95, 0, 0, 0,
347 0, 67, 68, 0, 82, 0, 82, 82, 0, 0,
348 82, 92, 78, 0, 0, 0, 0, 0, 0, 0,
349 80, 0, 0, 0, 81, 82, 0, 0, 0, 0,
350 116, 0, 0, 0, 0, 0, 0, 0, 0, 92,
351 98, 92, 92, 0, 0, 92, 83, 0, 0, 0,
352 126, 84, 0, 0, 0, 81, 0, 0, 0, 82,
353 92, 0, 0, 0, 0, 0, 0, 0, 0, 0,
354 0, 0, 0, 83, 83, 0, 83, 83, 0, 0,
355 83, 84, 84, 0, 0, 84, 85, 0, 0, 0,
356 82, 0, 155, 0, 92, 83, 0, 0, 0, 0,
357 84, 0, 0, 0, 96, 84, 0, 0, 0, 94,
358 92, 0, 93, 0, 95, 0, 85, 85, 0, 0,
359 85, 0, 165, 0, 0, 92, 0, 0, 0, 83,
360 0, 0, 0, 0, 84, 85, 0, 4, 5, 0,
361 6, 7, 0, 8, 9, 10, 11, 190, 0, 0,
362 0, 0, 0, 80, 80, 80, 0, 80, 98, 0,
363 83, 0, 0, 197, 198, 84, 200, 12, 13, 85,
364 204, 0, 205, 0, 80, 80, 80, 80, 80, 80,
365 80, 80, 80, 0, 80, 80, 80, 0, 81, 81,
366 81, 83, 81, 0, 0, 0, 0, 0, 0, 0,
367 0, 0, 0, 0, 0, 0, 0, 0, 0, 81,
368 81, 81, 81, 81, 81, 81, 81, 81, 0, 81,
369 81, 81, 0, 82, 82, 82, 0, 82, 82, 85,
370 86, 87, 88, 89, 90, 91, 0, 0, 0, 0,
371 97, 0, 0, 0, 82, 82, 82, 82, 82, 82,
372 82, 82, 82, 0, 82, 82, 82, 0, 92, 92,
373 92, 0, 92, 0, 0, 0, 0, 0, 0, 0,
374 0, 0, 0, 0, 0, 0, 0, 0, 0, 92,
375 92, 92, 92, 92, 92, 92, 92, 92, 0, 92,
376 92, 92, 0, 83, 83, 83, 0, 83, 84, 84,
377 84, 0, 84, 0, 0, 0, 0, 0, 0, 0,
378 0, 0, 0, 0, 83, 83, 0, 0, 0, 84,
379 84, 0, 0, 0, 83, 83, 83, 0, 0, 84,
380 84, 84, 0, 85, 85, 85, 0, 85, 0, 0,
381 0, 0, 0, 0, 0, 81, 82, 85, 86, 87,
382 88, 89, 90, 91, 85, 85, 0, 0, 97, 0,
383 66, 0, 0, 0, 85, 85, 85, 73, 74, 0,
384 0, 0, 0, 80, 0, 0, 0, 0, 0, 0,
385 0, 66, 0, 0, 0, 0, 0, 0, 0, 0,
386 0, 0, 80, 0, 80, 0, 0, 0, 0, 0,
387 0, 0, 0, 124, 0, 0, 0, 0, 80, 0,
388 0, 0, 0, 0, 127, 128, 129, 130, 131, 132,
389 133, 134, 135, 136, 137, 138, 139, 140, 141, 0,
390 143, 144, 0, 0, 0, 0, 0, 0, 0, 0,
391 80, 80, 80, 80, 80, 80, 80, 0, 0, 0,
392 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
393 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
394 0, 0, 0, 0, 0, 0, 0, 0, 0, 162,
395 66, 0, 0, 0, 80, 0, 0, 0, 0, 0,
396 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
397 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
398 0, 0, 0, 80, 80, 80, 80, 80, 80, 80,
401 const short yycheck
[] = { 91,
402 0, 37, 38, 91, 50, 48, 42, 43, 40, 45,
403 0, 47, 41, 256, 41, 259, 44, 44, 49, 10,
404 0, 44, 44, 41, 40, 44, 44, 37, 3, 61,
405 59, 59, 42, 43, 11, 45, 44, 47, 37, 41,
406 59, 10, 44, 42, 19, 40, 23, 40, 47, 259,
407 41, 10, 0, 44, 259, 91, 10, 93, 41, 37,
408 38, 44, 0, 40, 42, 43, 61, 45, 59, 47,
409 93, 93, 0, 48, 51, 52, 53, 54, 55, 56,
410 57, 91, 44, 44, 10, 93, 10, 41, 124, 10,
411 44, 93, 91, 40, 44, 41, 41, 40, 44, 44,
412 91, 37, 38, 149, 0, 59, 42, 43, 259, 45,
413 93, 47, 91, 91, 0, 41, 259, 10, 44, 150,
414 41, 41, 41, 44, 44, 125, 10, 10, 91, 104,
415 10, 93, 93, 59, 91, 125, 91, 10, 59, 91,
416 12, 13, 119, 93, 41, 125, 124, 190, 41, 180,
417 41, 44, 59, 264, 0, 91, 41, 41, 41, 91,
418 44, 44, 41, 180, 37, 38, 59, 40, 41, 42,
419 43, 44, 45, -1, 47, 59, 59, 125, 270, 271,
420 272, 273, 274, 275, 276, 59, 59, 125, 10, 166,
421 167, 168, 169, 170, 171, 172, 173, 125, 91, 37,
422 -1, 165, -1, 291, 42, 43, -1, 45, 91, 47,
423 -1, -1, -1, -1, -1, 190, -1, -1, 40, 41,
424 93, 196, 44, -1, -1, -1, -1, -1, -1, 125,
425 10, -1, -1, 197, 198, -1, -1, 59, -1, 125,
426 204, -1, 278, 279, 280, 281, 282, 283, 284, 285,
427 286, 124, -1, 91, 286, 291, -1, 289, 290, 259,
428 260, -1, 262, 263, 264, 265, 266, 267, 268, 259,
429 260, 93, 262, 263, 264, 265, 266, 267, 268, 259,
430 260, 291, 262, 263, 264, 265, 266, 267, 268, 289,
431 290, -1, 291, -1, 289, 290, 289, 290, -1, 289,
432 290, 10, 280, 281, 282, 283, 284, 285, 286, 289,
433 290, 259, 260, 291, 262, 263, 264, 265, 266, 267,
434 268, 259, 260, -1, 262, 263, 264, 265, 266, 267,
435 268, 259, 260, -1, 262, 263, 264, 265, 266, 267,
436 268, 289, 290, 123, 280, 281, 282, 283, 284, 285,
437 286, 289, 290, -1, -1, 291, -1, -1, -1, 259,
438 260, 289, 290, 259, 260, -1, 262, 263, 264, 265,
439 266, 267, 268, 259, 260, -1, 262, 263, 10, 265,
440 266, 267, 268, -1, 257, 258, 259, -1, 261, 289,
441 290, -1, 10, 289, 290, -1, -1, -1, -1, -1,
442 10, -1, -1, 289, 290, 278, 279, 280, 281, 282,
443 283, 284, 285, 286, 123, 288, 289, 290, 291, 37,
444 38, -1, -1, 41, 42, 43, 44, 45, 10, 47,
445 -1, 41, -1, -1, 44, 257, 258, 259, -1, 261,
446 10, 59, 280, 281, 282, 283, 284, 285, 286, 59,
447 -1, -1, 125, 291, -1, 37, 38, -1, 40, 41,
448 42, 43, 44, 45, 10, 47, 288, 289, 290, -1,
449 40, 41, -1, 91, 44, 93, -1, 59, -1, 259,
450 260, 91, 262, 263, -1, 265, 266, 267, 268, 59,
451 10, 37, 38, 125, 40, 41, 42, 43, 44, 45,
452 10, 47, -1, 60, -1, -1, 124, 64, -1, 289,
453 290, 93, 10, 59, 71, -1, -1, -1, -1, -1,
454 -1, 41, -1, 93, 44, -1, -1, 37, 38, -1,
455 40, 41, 42, 43, 44, 45, 10, 47, -1, 59,
456 -1, 98, 124, 41, 101, 102, 44, 93, 10, 59,
457 259, 260, -1, 262, 263, -1, 265, 266, 267, 268,
458 -1, 59, -1, 37, 38, -1, 40, 41, 42, 43,
459 44, 45, 10, 47, -1, -1, -1, 10, 124, 41,
460 289, 290, 44, 93, -1, 59, 259, 260, 125, 262,
461 263, -1, 265, 266, 267, 268, -1, 59, -1, 37,
462 38, -1, 40, 41, 42, 43, 44, 45, 41, 47,
463 -1, 44, 10, -1, 124, -1, 289, 290, -1, 93,
464 10, 59, 10, -1, -1, -1, 59, 259, 260, 91,
465 262, 263, -1, 265, 266, 267, 268, -1, -1, 257,
466 258, 259, 40, 261, -1, -1, -1, 45, -1, -1,
467 124, 41, -1, 41, 44, 93, 44, 289, 290, -1,
468 278, 279, 280, 281, 282, 283, 284, 285, 286, 59,
469 288, 59, -1, 291, 10, 257, 258, 259, -1, 261,
470 -1, -1, -1, -1, 61, -1, 124, 257, 258, 259,
471 -1, 261, -1, -1, -1, -1, 278, 279, 280, 281,
472 282, 283, 284, 285, 286, -1, 288, 289, 290, 10,
473 -1, 257, 258, 259, -1, 261, -1, -1, 288, 289,
474 290, -1, 259, 260, -1, 262, 263, -1, 265, 266,
475 267, 268, 278, 279, 280, 281, 282, 283, 284, 285,
476 286, -1, 288, 289, 290, -1, -1, 257, 258, 259,
477 -1, 261, 289, 290, -1, -1, 10, -1, -1, -1,
478 -1, -1, 259, 260, 10, -1, -1, -1, 278, 279,
479 280, 281, 282, 283, 284, 285, 286, -1, 288, 289,
480 290, -1, -1, 257, 258, 259, 40, 261, -1, 125,
481 -1, 45, 289, 290, -1, 41, -1, -1, 44, -1,
482 10, -1, -1, -1, 278, 279, 280, 281, 282, 283,
483 284, 285, 286, 59, 288, 289, 290, -1, -1, 257,
484 258, 259, 123, 261, 10, -1, -1, 37, 38, -1,
485 40, 41, 42, 43, 44, 45, 10, 47, -1, -1,
486 278, 279, 280, 281, 282, 283, 284, 285, 286, 59,
487 288, 289, 290, -1, -1, 41, -1, -1, 44, 257,
488 258, 259, -1, 261, 38, -1, 40, 41, -1, 43,
489 44, 45, 10, 59, -1, -1, 40, 41, -1, -1,
490 -1, 45, 40, 93, 10, 59, 10, 45, -1, -1,
491 288, 289, 290, 270, 271, 272, 273, 274, 275, 276,
492 38, -1, 40, 41, -1, 43, 44, 45, 10, -1,
493 -1, -1, 289, 290, 124, 41, 40, 41, 44, 93,
494 44, 59, -1, 259, 260, -1, 262, 263, -1, 265,
495 266, 267, 268, 59, -1, 59, 38, -1, 40, 41,
496 -1, 10, 44, 10, -1, 10, -1, -1, -1, 10,
497 124, 10, -1, 289, 290, 93, -1, 59, 259, 260,
498 -1, 262, 263, -1, 265, 266, 267, 268, -1, 93,
499 -1, 38, 41, 40, 41, 44, 41, 44, 10, 44,
500 41, -1, 41, 44, -1, 44, 124, -1, 289, 290,
501 59, 93, 59, -1, 59, -1, -1, -1, 59, -1,
502 59, -1, -1, 257, 258, 259, 38, 261, 40, 41,
503 -1, -1, 44, -1, 40, -1, -1, -1, -1, 45,
504 -1, -1, 124, -1, -1, -1, 93, 59, -1, -1,
505 -1, -1, -1, -1, 288, 289, 290, 270, 271, 272,
506 273, 274, 275, 276, -1, -1, -1, 257, 258, 259,
507 -1, 261, -1, -1, -1, -1, -1, 124, -1, -1,
508 -1, 93, -1, -1, -1, -1, -1, 93, 278, 279,
509 280, 281, 282, 283, 284, 285, 286, -1, 288, 289,
510 290, -1, -1, 257, 258, 259, -1, 261, -1, -1,
511 -1, -1, 124, 257, 258, 259, -1, 261, -1, 257,
512 258, 259, -1, 261, 278, 279, 280, 281, 282, 283,
513 284, 285, 286, -1, 288, 289, 290, -1, -1, 257,
514 258, 259, -1, 261, 288, 289, 290, -1, -1, -1,
515 288, 289, 290, 257, 258, 259, -1, 261, -1, -1,
516 278, 279, 280, 281, 282, 283, 284, 285, 286, -1,
517 288, 289, 290, -1, 278, 257, 258, 259, -1, 261,
518 -1, -1, -1, -1, 288, 289, 290, -1, -1, -1,
519 -1, -1, -1, -1, -1, -1, 278, 279, 280, 281,
520 282, 283, 284, 285, 286, -1, 288, 289, 290, -1,
521 257, 258, 259, -1, 261, -1, -1, -1, -1, -1,
522 -1, -1, -1, -1, -1, -1, 10, -1, -1, -1,
523 -1, 278, 279, 280, 281, 282, 283, 284, 285, 286,
524 -1, 288, 289, 290, -1, 257, 258, 259, -1, 261,
525 -1, 257, 258, 259, 38, 261, 40, 41, -1, -1,
526 44, 10, -1, -1, -1, -1, 278, 279, 280, 281,
527 282, 283, 284, 285, 286, 59, 288, 289, 290, -1,
528 -1, -1, 288, 289, 290, -1, -1, -1, -1, 38,
529 -1, 40, 41, -1, -1, 44, 10, -1, -1, -1,
530 -1, -1, -1, -1, -1, 14, 37, 38, -1, 93,
531 59, 42, 43, -1, 45, -1, 47, -1, -1, -1,
532 -1, 30, 31, -1, 38, -1, 40, 41, -1, -1,
533 44, 10, 41, -1, -1, -1, -1, -1, -1, -1,
534 124, -1, -1, -1, 93, 59, -1, -1, -1, -1,
535 59, -1, -1, -1, -1, -1, -1, -1, -1, 38,
536 91, 40, 41, -1, -1, 44, 10, -1, -1, -1,
537 79, 10, -1, -1, -1, 124, -1, -1, -1, 93,
538 59, -1, -1, -1, -1, -1, -1, -1, -1, -1,
539 -1, -1, -1, 124, 38, -1, 40, 41, -1, -1,
540 44, 40, 41, -1, -1, 44, 10, -1, -1, -1,
541 124, -1, 121, -1, 93, 59, -1, -1, -1, -1,
542 59, -1, -1, -1, 37, 38, -1, -1, -1, 42,
543 43, -1, 45, -1, 47, -1, 40, 41, -1, -1,
544 44, -1, 151, -1, -1, 124, -1, -1, -1, 93,
545 -1, -1, -1, -1, 93, 59, -1, 259, 260, -1,
546 262, 263, -1, 265, 266, 267, 268, 176, -1, -1,
547 -1, -1, -1, 257, 258, 259, -1, 261, 91, -1,
548 124, -1, -1, 192, 193, 124, 195, 289, 290, 93,
549 199, -1, 201, -1, 278, 279, 280, 281, 282, 283,
550 284, 285, 286, -1, 288, 289, 290, -1, 257, 258,
551 259, 124, 261, -1, -1, -1, -1, -1, -1, -1,
552 -1, -1, -1, -1, -1, -1, -1, -1, -1, 278,
553 279, 280, 281, 282, 283, 284, 285, 286, -1, 288,
554 289, 290, -1, 257, 258, 259, -1, 261, 279, 280,
555 281, 282, 283, 284, 285, 286, -1, -1, -1, -1,
556 291, -1, -1, -1, 278, 279, 280, 281, 282, 283,
557 284, 285, 286, -1, 288, 289, 290, -1, 257, 258,
558 259, -1, 261, -1, -1, -1, -1, -1, -1, -1,
559 -1, -1, -1, -1, -1, -1, -1, -1, -1, 278,
560 279, 280, 281, 282, 283, 284, 285, 286, -1, 288,
561 289, 290, -1, 257, 258, 259, -1, 261, 257, 258,
562 259, -1, 261, -1, -1, -1, -1, -1, -1, -1,
563 -1, -1, -1, -1, 278, 279, -1, -1, -1, 278,
564 279, -1, -1, -1, 288, 289, 290, -1, -1, 288,
565 289, 290, -1, 257, 258, 259, -1, 261, -1, -1,
566 -1, -1, -1, -1, -1, 278, 279, 280, 281, 282,
567 283, 284, 285, 286, 278, 279, -1, -1, 291, -1,
568 29, -1, -1, -1, 288, 289, 290, 36, 37, -1,
569 -1, -1, -1, 42, -1, -1, -1, -1, -1, -1,
570 -1, 50, -1, -1, -1, -1, -1, -1, -1, -1,
571 -1, -1, 61, -1, 63, -1, -1, -1, -1, -1,
572 -1, -1, -1, 72, -1, -1, -1, -1, 77, -1,
573 -1, -1, -1, -1, 83, 84, 85, 86, 87, 88,
574 89, 90, 91, 92, 93, 94, 95, 96, 97, -1,
575 99, 100, -1, -1, -1, -1, -1, -1, -1, -1,
576 109, 110, 111, 112, 113, 114, 115, -1, -1, -1,
577 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
578 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
579 -1, -1, -1, -1, -1, -1, -1, -1, -1, 148,
580 149, -1, -1, -1, 153, -1, -1, -1, -1, -1,
581 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
582 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
583 -1, -1, -1, 182, 183, 184, 185, 186, 187, 188,
590 #define YYMAXTOKEN 291
592 const char * const yyname
[] = {
593 "end-of-file",0,0,0,0,0,0,0,0,0,"'\\n'",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
594 0,0,0,0,0,0,"'%'","'&'",0,"'('","')'","'*'","'+'","','","'-'",0,"'/'",0,0,0,0,0,
595 0,0,0,0,0,0,"';'",0,"'='",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
596 0,0,"'['",0,"']'",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
597 "'{'","'|'","'}'",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
598 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
599 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
600 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,"NUMBER","STRING","SYMBOL","DELETE",
601 "ARG_LOOKUP","IF","WHILE","ELSE","FOR","BREAK","CONTINUE","RETURN","IF_NO_ELSE",
602 "ADDEQ","SUBEQ","MULEQ","DIVEQ","MODEQ","ANDEQ","OREQ","CONCAT","OR","AND","GT",
603 "GE","LT","LE","EQ","NE","IN","UNARY_MINUS","NOT","INCR","DECR","POW",
605 const char * const yyrule
[] = {
607 "program : blank stmts",
608 "program : blank '{' blank stmts '}'",
609 "program : blank '{' blank '}'",
611 "block : '{' blank stmts '}' blank",
612 "block : '{' blank '}' blank",
615 "stmts : stmts stmt",
616 "stmt : simpstmt '\\n' blank",
617 "stmt : IF '(' cond ')' blank block",
618 "stmt : IF '(' cond ')' blank block else blank block",
619 "stmt : while '(' cond ')' blank block",
620 "stmt : for '(' comastmts ';' cond ';' comastmts ')' blank block",
622 "stmt : for '(' SYMBOL IN arrayexpr ')' $$1 blank block",
623 "stmt : BREAK '\\n' blank",
624 "stmt : CONTINUE '\\n' blank",
625 "stmt : RETURN expr '\\n' blank",
626 "stmt : RETURN '\\n' blank",
627 "simpstmt : SYMBOL '=' expr",
628 "simpstmt : evalsym ADDEQ expr",
629 "simpstmt : evalsym SUBEQ expr",
630 "simpstmt : evalsym MULEQ expr",
631 "simpstmt : evalsym DIVEQ expr",
632 "simpstmt : evalsym MODEQ expr",
633 "simpstmt : evalsym ANDEQ expr",
634 "simpstmt : evalsym OREQ expr",
635 "simpstmt : DELETE arraylv '[' arglist ']'",
636 "simpstmt : initarraylv '[' arglist ']' '=' expr",
637 "simpstmt : initarraylv '[' arglist ']' ADDEQ expr",
638 "simpstmt : initarraylv '[' arglist ']' SUBEQ expr",
639 "simpstmt : initarraylv '[' arglist ']' MULEQ expr",
640 "simpstmt : initarraylv '[' arglist ']' DIVEQ expr",
641 "simpstmt : initarraylv '[' arglist ']' MODEQ expr",
642 "simpstmt : initarraylv '[' arglist ']' ANDEQ expr",
643 "simpstmt : initarraylv '[' arglist ']' OREQ expr",
644 "simpstmt : initarraylv '[' arglist ']' INCR",
645 "simpstmt : initarraylv '[' arglist ']' DECR",
646 "simpstmt : INCR initarraylv '[' arglist ']'",
647 "simpstmt : DECR initarraylv '[' arglist ']'",
648 "simpstmt : SYMBOL '(' arglist ')'",
649 "simpstmt : INCR SYMBOL",
650 "simpstmt : SYMBOL INCR",
651 "simpstmt : DECR SYMBOL",
652 "simpstmt : SYMBOL DECR",
655 "comastmts : simpstmt",
656 "comastmts : comastmts ',' simpstmt",
659 "arglist : arglist ',' expr",
661 "expr : expr numexpr",
662 "initarraylv : SYMBOL",
663 "initarraylv : initarraylv '[' arglist ']'",
665 "arraylv : arraylv '[' arglist ']'",
666 "arrayexpr : numexpr",
670 "numexpr : SYMBOL '(' arglist ')'",
671 "numexpr : '(' expr ')'",
672 "numexpr : ARG_LOOKUP '[' numexpr ']'",
673 "numexpr : ARG_LOOKUP '[' ']'",
674 "numexpr : ARG_LOOKUP",
675 "numexpr : numexpr '[' arglist ']'",
676 "numexpr : numexpr '+' numexpr",
677 "numexpr : numexpr '-' numexpr",
678 "numexpr : numexpr '*' numexpr",
679 "numexpr : numexpr '/' numexpr",
680 "numexpr : numexpr '%' numexpr",
681 "numexpr : numexpr POW numexpr",
682 "numexpr : '-' numexpr",
683 "numexpr : numexpr GT numexpr",
684 "numexpr : numexpr GE numexpr",
685 "numexpr : numexpr LT numexpr",
686 "numexpr : numexpr LE numexpr",
687 "numexpr : numexpr EQ numexpr",
688 "numexpr : numexpr NE numexpr",
689 "numexpr : numexpr '&' numexpr",
690 "numexpr : numexpr '|' numexpr",
691 "numexpr : numexpr and numexpr",
692 "numexpr : numexpr or numexpr",
693 "numexpr : NOT numexpr",
694 "numexpr : INCR SYMBOL",
695 "numexpr : SYMBOL INCR",
696 "numexpr : DECR SYMBOL",
697 "numexpr : SYMBOL DECR",
698 "numexpr : numexpr IN numexpr",
707 "blank : blank '\\n'",
715 #define YYMAXDEPTH YYSTACKSIZE
718 #define YYSTACKSIZE YYMAXDEPTH
720 #define YYSTACKSIZE 10000
721 #define YYMAXDEPTH 10000
724 #define YYINITSTACKSIZE 200
738 /* User Subroutines Section */
742 ** Parse a null terminated string and create a program from it (this is the
743 ** parser entry point). The program created by this routine can be
744 ** executed using ExecuteProgram. Returns program on success, or NULL
745 ** on failure. If the command failed, the error message is returned
746 ** as a pointer to a static string in msg, and the length of the string up
747 ** to where parsing failed in stoppedAt.
749 Program
*ParseMacro(char *expr
, char **msg
, char **stoppedAt
)
753 BeginCreatingProgram();
755 /* call yyparse to parse the string and check for success. If the parse
756 failed, return the error message and string index (the grammar aborts
757 parsing at the first error) */
762 FreeProgram(FinishCreatingProgram());
766 /* get the newly created program */
767 prog
= FinishCreatingProgram();
769 /* parse succeeded */
776 static int yylex(void)
780 static DataValue value
= {NO_TAG
, {0}};
781 static char escape
[] = "\\\"ntbrfave";
782 #ifdef EBCDIC_CHARSET
783 static char replace
[] = "\\\"\n\t\b\r\f\a\v\x27"; /* EBCDIC escape */
785 static char replace
[] = "\\\"\n\t\b\r\f\a\v\x1B"; /* ASCII escape */
788 /* skip whitespace, backslash-newline combinations, and comments, which are
789 all considered whitespace */
791 if (*InPtr
== '\\' && *(InPtr
+ 1) == '\n')
793 else if (*InPtr
== ' ' || *InPtr
== '\t')
795 else if (*InPtr
== '#')
796 while (*InPtr
!= '\n' && *InPtr
!= '\0') {
797 /* Comments stop at escaped newlines */
798 if (*InPtr
== '\\' && *(InPtr
+ 1) == '\n') {
808 /* return end of input at the end of the string */
809 if (*InPtr
== '\0') {
813 /* process number tokens */
814 if (isdigit((unsigned char)*InPtr
)) { /* number */
816 sscanf(InPtr
, "%d%n", &value
.val
.n
, &len
);
817 sprintf(name
, "const %d", value
.val
.n
);
820 if ((yylval
.sym
=LookupSymbol(name
)) == NULL
)
821 yylval
.sym
= InstallSymbol(name
, CONST_SYM
, value
);
825 /* process symbol tokens. "define" is a special case not handled
826 by this parser, considered end of input. Another special case
827 is action routine names which are allowed to contain '-' despite
828 the ambiguity, handled in matchesActionRoutine. */
829 if (isalpha((unsigned char)*InPtr
) || *InPtr
== '$') {
830 if ((s
=matchesActionRoutine(&InPtr
)) == NULL
) {
831 char symName
[MAX_SYM_LEN
+1], *p
= symName
;
833 while (isalnum((unsigned char)*InPtr
) || *InPtr
=='_') {
834 if (p
>= symName
+ MAX_SYM_LEN
)
840 if (!strcmp(symName
, "while")) return WHILE
;
841 if (!strcmp(symName
, "if")) return IF
;
842 if (!strcmp(symName
, "else")) return ELSE
;
843 if (!strcmp(symName
, "for")) return FOR
;
844 if (!strcmp(symName
, "break")) return BREAK
;
845 if (!strcmp(symName
, "continue")) return CONTINUE
;
846 if (!strcmp(symName
, "return")) return RETURN
;
847 if (!strcmp(symName
, "in")) return IN
;
848 if (!strcmp(symName
, "$args")) return ARG_LOOKUP
;
849 if (!strcmp(symName
, "delete") && follow_non_whitespace('(', SYMBOL
, DELETE
) == DELETE
) return DELETE
;
850 if (!strcmp(symName
, "define")) {
854 if ((s
=LookupSymbol(symName
)) == NULL
) {
855 s
= InstallSymbol(symName
, symName
[0]=='$' ?
856 (((symName
[1] > '0' && symName
[1] <= '9') && symName
[2] == 0) ?
857 ARG_SYM
: GLOBAL_SYM
) : LOCAL_SYM
, value
);
858 s
->value
.tag
= NO_TAG
;
865 /* Process quoted strings with embedded escape sequences:
866 For backslashes we recognise hexadecimal values with initial 'x' such
867 as "\x1B"; octal value (upto 3 oct digits with a possible leading zero)
868 such as "\33", "\033" or "\0033", and the C escapes: \", \', \n, \t, \b,
869 \r, \f, \a, \v, and the added \e for the escape character, as for REs.
870 Disallow hex/octal zero values (NUL): instead ignore the introductory
871 backslash, eg "\x0xyz" becomes "x0xyz" and "\0000hello" becomes
874 if (*InPtr
== '\"') {
875 char string
[MAX_STRING_CONST_LEN
], *p
= string
;
878 while (*InPtr
!= '\0' && *InPtr
!= '\"' && *InPtr
!= '\n') {
879 if (p
>= string
+ MAX_STRING_CONST_LEN
) {
883 if (*InPtr
== '\\') {
886 if (*InPtr
== '\n') {
891 /* a hex introducer */
893 const char *hexDigits
= "0123456789abcdef";
896 if (*InPtr
== '\0' ||
897 (hexD
= strchr(hexDigits
, tolower(*InPtr
))) == NULL
) {
901 hexValue
= hexD
- hexDigits
;
903 /* now do we have another digit? only accept one more */
904 if (*InPtr
!= '\0' &&
905 (hexD
= strchr(hexDigits
,tolower(*InPtr
))) != NULL
){
906 hexValue
= hexD
- hexDigits
+ (hexValue
<< 4);
910 *p
++ = (char)hexValue
;
913 InPtr
= backslash
+ 1; /* just skip the backslash */
918 /* the RE documentation requires \0 as the octal introducer;
919 here you can start with any octal digit, but you are only
920 allowed up to three (or four if the first is '0'). */
921 if ('0' <= *InPtr
&& *InPtr
<= '7') {
923 InPtr
++; /* octal introducer: don't count this digit */
925 if ('0' <= *InPtr
&& *InPtr
<= '7') {
926 /* treat as octal - first digit */
927 char octD
= *InPtr
++;
928 int octValue
= octD
- '0';
929 if ('0' <= *InPtr
&& *InPtr
<= '7') {
932 octValue
= (octValue
<< 3) + octD
- '0';
933 /* now do we have another digit? can we add it?
934 if value is going to be too big for char (greater
935 than 0377), stop converting now before adding the
937 if ('0' <= *InPtr
&& *InPtr
<= '7' &&
939 /* third digit is acceptable */
941 octValue
= (octValue
<< 3) + octD
- '0';
945 *p
++ = (char)octValue
;
948 InPtr
= backslash
+ 1; /* just skip the backslash */
951 else { /* \0 followed by non-digits: go back to 0 */
952 InPtr
= backslash
+ 1; /* just skip the backslash */
956 for (i
=0; escape
[i
]!='\0'; i
++) {
957 if (escape
[i
] == *InPtr
) {
963 /* if we get here, we didn't recognise the character after
964 the backslash: just copy it next time round the loop */
972 yylval
.sym
= InstallStringConstSymbol(string
);
976 /* process remaining two character tokens or return single char as token */
978 case '>': return follow('=', GE
, GT
);
979 case '<': return follow('=', LE
, LT
);
980 case '=': return follow('=', EQ
, '=');
981 case '!': return follow('=', NE
, NOT
);
982 case '+': return follow2('+', INCR
, '=', ADDEQ
, '+');
983 case '-': return follow2('-', DECR
, '=', SUBEQ
, '-');
984 case '|': return follow2('|', OR
, '=', OREQ
, '|');
985 case '&': return follow2('&', AND
, '=', ANDEQ
, '&');
986 case '*': return follow2('*', POW
, '=', MULEQ
, '*');
987 case '/': return follow('=', DIVEQ
, '/');
988 case '%': return follow('=', MODEQ
, '%');
989 case '^': return POW
;
990 default: return *(InPtr
-1);
995 ** look ahead for >=, etc.
997 static int follow(char expect
, int yes
, int no
)
999 if (*InPtr
++ == expect
)
1004 static int follow2(char expect1
, int yes1
, char expect2
, int yes2
, int no
)
1006 char next
= *InPtr
++;
1007 if (next
== expect1
)
1009 if (next
== expect2
)
1015 static int follow_non_whitespace(char expect
, int yes
, int no
)
1017 char *localInPtr
= InPtr
;
1020 if (*localInPtr
== ' ' || *localInPtr
== '\t') {
1023 else if (*localInPtr
== '\\' && *(localInPtr
+ 1) == '\n') {
1026 else if (*localInPtr
== expect
) {
1036 ** Look (way) ahead for hyphenated routine names which begin at inPtr. A
1037 ** hyphenated name is allowed if it is pre-defined in the global symbol
1038 ** table. If a matching name exists, returns the symbol, and update "inPtr".
1040 ** I know this is horrible language design, but existing nedit action routine
1041 ** names contain hyphens. Handling them here in the lexical analysis process
1042 ** is much easier than trying to deal with it in the parser itself. (sorry)
1044 static Symbol
*matchesActionRoutine(char **inPtr
)
1047 int hasDash
= False
;
1048 char symbolName
[MAX_SYM_LEN
+1];
1051 symPtr
= symbolName
;
1052 for (c
= *inPtr
; isalnum((unsigned char)*c
) || *c
=='_' ||
1053 ( *c
=='-' && isalnum((unsigned char)(*(c
+1)))); c
++) {
1061 s
= LookupSymbol(symbolName
);
1068 ** Called by yacc to report errors (just stores for returning when
1069 ** parsing is aborted. The error token action is to immediate abort
1070 ** parsing, so this message is immediately reported to the caller
1073 static int yyerror(char *s
)
1078 #line 1079 "y.tab.c"
1079 /* allocate initial stack or double stack size, up to YYMAXDEPTH */
1080 static int yygrowstack()
1086 if ((newsize
= yystacksize
) == 0)
1087 newsize
= YYINITSTACKSIZE
;
1088 else if (newsize
>= YYMAXDEPTH
)
1090 else if ((newsize
*= 2) > YYMAXDEPTH
)
1091 newsize
= YYMAXDEPTH
;
1093 newss
= yyss
? (short *)realloc(yyss
, newsize
* sizeof *newss
) :
1094 (short *)malloc(newsize
* sizeof *newss
);
1099 newvs
= yyvs
? (YYSTYPE
*)realloc(yyvs
, newsize
* sizeof *newvs
) :
1100 (YYSTYPE
*)malloc(newsize
* sizeof *newvs
);
1105 yystacksize
= newsize
;
1106 yysslim
= yyss
+ newsize
- 1;
1110 #define YYABORT goto yyabort
1111 #define YYREJECT goto yyabort
1112 #define YYACCEPT goto yyaccept
1113 #define YYERROR goto yyerrlab
1115 #ifndef YYPARSE_PARAM
1116 #if defined(__cplusplus) || __STDC__
1117 #define YYPARSE_PARAM_ARG void
1118 #define YYPARSE_PARAM_DECL
1119 #else /* ! ANSI-C/C++ */
1120 #define YYPARSE_PARAM_ARG
1121 #define YYPARSE_PARAM_DECL
1122 #endif /* ANSI-C/C++ */
1123 #else /* YYPARSE_PARAM */
1124 #ifndef YYPARSE_PARAM_TYPE
1125 #define YYPARSE_PARAM_TYPE void *
1127 #if defined(__cplusplus) || __STDC__
1128 #define YYPARSE_PARAM_ARG YYPARSE_PARAM_TYPE YYPARSE_PARAM
1129 #define YYPARSE_PARAM_DECL
1130 #else /* ! ANSI-C/C++ */
1131 #define YYPARSE_PARAM_ARG YYPARSE_PARAM
1132 #define YYPARSE_PARAM_DECL YYPARSE_PARAM_TYPE YYPARSE_PARAM;
1133 #endif /* ANSI-C/C++ */
1134 #endif /* ! YYPARSE_PARAM */
1137 yyparse (YYPARSE_PARAM_ARG
)
1140 register int yym
, yyn
, yystate
;
1142 register const char *yys
;
1144 if ((yys
= getenv("YYDEBUG")))
1147 if (yyn
>= '0' && yyn
<= '9')
1148 yydebug
= yyn
- '0';
1156 if (yyss
== NULL
&& yygrowstack()) goto yyoverflow
;
1159 *yyssp
= yystate
= 0;
1162 if ((yyn
= yydefred
[yystate
])) goto yyreduce
;
1165 if ((yychar
= yylex()) < 0) yychar
= 0;
1170 if (yychar
<= YYMAXTOKEN
) yys
= yyname
[yychar
];
1171 if (!yys
) yys
= "illegal-symbol";
1172 printf("%sdebug: state %d, reading %d (%s)\n",
1173 YYPREFIX
, yystate
, yychar
, yys
);
1177 if ((yyn
= yysindex
[yystate
]) && (yyn
+= yychar
) >= 0 &&
1178 yyn
<= YYTABLESIZE
&& yycheck
[yyn
] == yychar
)
1182 printf("%sdebug: state %d, shifting to state %d\n",
1183 YYPREFIX
, yystate
, yytable
[yyn
]);
1185 if (yyssp
>= yysslim
&& yygrowstack())
1189 *++yyssp
= yystate
= yytable
[yyn
];
1192 if (yyerrflag
> 0) --yyerrflag
;
1195 if ((yyn
= yyrindex
[yystate
]) && (yyn
+= yychar
) >= 0 &&
1196 yyn
<= YYTABLESIZE
&& yycheck
[yyn
] == yychar
)
1201 if (yyerrflag
) goto yyinrecovery
;
1202 #if defined(lint) || defined(__GNUC__)
1206 yyerror("syntax error");
1207 #if defined(lint) || defined(__GNUC__)
1218 if ((yyn
= yysindex
[*yyssp
]) && (yyn
+= YYERRCODE
) >= 0 &&
1219 yyn
<= YYTABLESIZE
&& yycheck
[yyn
] == YYERRCODE
)
1223 printf("%sdebug: state %d, error recovery shifting\
1224 to state %d\n", YYPREFIX
, *yyssp
, yytable
[yyn
]);
1226 if (yyssp
>= yysslim
&& yygrowstack())
1230 *++yyssp
= yystate
= yytable
[yyn
];
1238 printf("%sdebug: error recovery discarding state %d\n",
1241 if (yyssp
<= yyss
) goto yyabort
;
1249 if (yychar
== 0) goto yyabort
;
1254 if (yychar
<= YYMAXTOKEN
) yys
= yyname
[yychar
];
1255 if (!yys
) yys
= "illegal-symbol";
1256 printf("%sdebug: state %d, error recovery discards token %d (%s)\n",
1257 YYPREFIX
, yystate
, yychar
, yys
);
1266 printf("%sdebug: state %d, reducing by rule %d (%s)\n",
1267 YYPREFIX
, yystate
, yyn
, yyrule
[yyn
]);
1270 yyval
= yyvsp
[1-yym
];
1276 ADD_OP(OP_RETURN_NO_VAL
); return 0;
1282 ADD_OP(OP_RETURN_NO_VAL
); return 0;
1288 ADD_OP(OP_RETURN_NO_VAL
); return 0;
1300 SET_BR_OFF(yyvsp
[-3].inst
, GetPC());
1306 SET_BR_OFF(yyvsp
[-6].inst
, (yyvsp
[-2].inst
+1)); SET_BR_OFF(yyvsp
[-2].inst
, GetPC());
1312 ADD_OP(OP_BRANCH
); ADD_BR_OFF(yyvsp
[-5].inst
);
1313 SET_BR_OFF(yyvsp
[-3].inst
, GetPC()); FillLoopAddrs(GetPC(), yyvsp
[-5].inst
);
1319 FillLoopAddrs(GetPC()+2+(yyvsp
[-3].inst
-(yyvsp
[-5].inst
+1)), GetPC());
1320 SwapCode(yyvsp
[-5].inst
+1, yyvsp
[-3].inst
, GetPC());
1321 ADD_OP(OP_BRANCH
); ADD_BR_OFF(yyvsp
[-7].inst
); SET_BR_OFF(yyvsp
[-5].inst
, GetPC());
1327 Symbol
*iterSym
= InstallIteratorSymbol();
1328 ADD_OP(OP_BEGIN_ARRAY_ITER
); ADD_SYM(iterSym
);
1329 ADD_OP(OP_ARRAY_ITER
); ADD_SYM(yyvsp
[-3].sym
); ADD_SYM(iterSym
); ADD_BR_OFF(0);
1335 ADD_OP(OP_BRANCH
); ADD_BR_OFF(yyvsp
[-4].inst
+2);
1336 SET_BR_OFF(yyvsp
[-4].inst
+5, GetPC());
1337 FillLoopAddrs(GetPC(), yyvsp
[-4].inst
+2);
1343 ADD_OP(OP_BRANCH
); ADD_BR_OFF(0);
1344 if (AddBreakAddr(GetPC()-1)) {
1345 yyerror("break outside loop"); YYERROR
;
1352 ADD_OP(OP_BRANCH
); ADD_BR_OFF(0);
1353 if (AddContinueAddr(GetPC()-1)) {
1354 yyerror("continue outside loop"); YYERROR
;
1367 ADD_OP(OP_RETURN_NO_VAL
);
1373 ADD_OP(OP_ASSIGN
); ADD_SYM(yyvsp
[-2].sym
);
1379 ADD_OP(OP_ADD
); ADD_OP(OP_ASSIGN
); ADD_SYM(yyvsp
[-2].sym
);
1385 ADD_OP(OP_SUB
); ADD_OP(OP_ASSIGN
); ADD_SYM(yyvsp
[-2].sym
);
1391 ADD_OP(OP_MUL
); ADD_OP(OP_ASSIGN
); ADD_SYM(yyvsp
[-2].sym
);
1397 ADD_OP(OP_DIV
); ADD_OP(OP_ASSIGN
); ADD_SYM(yyvsp
[-2].sym
);
1403 ADD_OP(OP_MOD
); ADD_OP(OP_ASSIGN
); ADD_SYM(yyvsp
[-2].sym
);
1409 ADD_OP(OP_BIT_AND
); ADD_OP(OP_ASSIGN
); ADD_SYM(yyvsp
[-2].sym
);
1415 ADD_OP(OP_BIT_OR
); ADD_OP(OP_ASSIGN
); ADD_SYM(yyvsp
[-2].sym
);
1421 ADD_OP(OP_ARRAY_DELETE
); ADD_IMMED(yyvsp
[-1].nArgs
);
1427 ADD_OP(OP_ARRAY_ASSIGN
); ADD_IMMED(yyvsp
[-3].nArgs
);
1433 ADD_OP(OP_ARRAY_REF_ASSIGN_SETUP
); ADD_IMMED(1); ADD_IMMED(yyvsp
[-3].nArgs
);
1435 ADD_OP(OP_ARRAY_ASSIGN
); ADD_IMMED(yyvsp
[-3].nArgs
);
1441 ADD_OP(OP_ARRAY_REF_ASSIGN_SETUP
); ADD_IMMED(1); ADD_IMMED(yyvsp
[-3].nArgs
);
1443 ADD_OP(OP_ARRAY_ASSIGN
); ADD_IMMED(yyvsp
[-3].nArgs
);
1449 ADD_OP(OP_ARRAY_REF_ASSIGN_SETUP
); ADD_IMMED(1); ADD_IMMED(yyvsp
[-3].nArgs
);
1451 ADD_OP(OP_ARRAY_ASSIGN
); ADD_IMMED(yyvsp
[-3].nArgs
);
1457 ADD_OP(OP_ARRAY_REF_ASSIGN_SETUP
); ADD_IMMED(1); ADD_IMMED(yyvsp
[-3].nArgs
);
1459 ADD_OP(OP_ARRAY_ASSIGN
); ADD_IMMED(yyvsp
[-3].nArgs
);
1465 ADD_OP(OP_ARRAY_REF_ASSIGN_SETUP
); ADD_IMMED(1); ADD_IMMED(yyvsp
[-3].nArgs
);
1467 ADD_OP(OP_ARRAY_ASSIGN
); ADD_IMMED(yyvsp
[-3].nArgs
);
1473 ADD_OP(OP_ARRAY_REF_ASSIGN_SETUP
); ADD_IMMED(1); ADD_IMMED(yyvsp
[-3].nArgs
);
1475 ADD_OP(OP_ARRAY_ASSIGN
); ADD_IMMED(yyvsp
[-3].nArgs
);
1481 ADD_OP(OP_ARRAY_REF_ASSIGN_SETUP
); ADD_IMMED(1); ADD_IMMED(yyvsp
[-3].nArgs
);
1483 ADD_OP(OP_ARRAY_ASSIGN
); ADD_IMMED(yyvsp
[-3].nArgs
);
1489 ADD_OP(OP_ARRAY_REF_ASSIGN_SETUP
); ADD_IMMED(0); ADD_IMMED(yyvsp
[-2].nArgs
);
1491 ADD_OP(OP_ARRAY_ASSIGN
); ADD_IMMED(yyvsp
[-2].nArgs
);
1497 ADD_OP(OP_ARRAY_REF_ASSIGN_SETUP
); ADD_IMMED(0); ADD_IMMED(yyvsp
[-2].nArgs
);
1499 ADD_OP(OP_ARRAY_ASSIGN
); ADD_IMMED(yyvsp
[-2].nArgs
);
1505 ADD_OP(OP_ARRAY_REF_ASSIGN_SETUP
); ADD_IMMED(0); ADD_IMMED(yyvsp
[-1].nArgs
);
1507 ADD_OP(OP_ARRAY_ASSIGN
); ADD_IMMED(yyvsp
[-1].nArgs
);
1513 ADD_OP(OP_ARRAY_REF_ASSIGN_SETUP
); ADD_IMMED(0); ADD_IMMED(yyvsp
[-1].nArgs
);
1515 ADD_OP(OP_ARRAY_ASSIGN
); ADD_IMMED(yyvsp
[-1].nArgs
);
1521 ADD_OP(OP_SUBR_CALL
);
1522 ADD_SYM(PromoteToGlobal(yyvsp
[-3].sym
)); ADD_IMMED(yyvsp
[-1].nArgs
);
1528 ADD_OP(OP_PUSH_SYM
); ADD_SYM(yyvsp
[0].sym
); ADD_OP(OP_INCR
);
1529 ADD_OP(OP_ASSIGN
); ADD_SYM(yyvsp
[0].sym
);
1535 ADD_OP(OP_PUSH_SYM
); ADD_SYM(yyvsp
[-1].sym
); ADD_OP(OP_INCR
);
1536 ADD_OP(OP_ASSIGN
); ADD_SYM(yyvsp
[-1].sym
);
1542 ADD_OP(OP_PUSH_SYM
); ADD_SYM(yyvsp
[0].sym
); ADD_OP(OP_DECR
);
1543 ADD_OP(OP_ASSIGN
); ADD_SYM(yyvsp
[0].sym
);
1549 ADD_OP(OP_PUSH_SYM
); ADD_SYM(yyvsp
[-1].sym
); ADD_OP(OP_DECR
);
1550 ADD_OP(OP_ASSIGN
); ADD_SYM(yyvsp
[-1].sym
);
1556 yyval
.sym
= yyvsp
[0].sym
; ADD_OP(OP_PUSH_SYM
); ADD_SYM(yyvsp
[0].sym
);
1562 yyval
.inst
= GetPC();
1568 yyval
.inst
= GetPC();
1574 yyval
.inst
= GetPC();
1592 yyval
.nArgs
= yyvsp
[-2].nArgs
+ 1;
1604 ADD_OP(OP_PUSH_ARRAY_SYM
); ADD_SYM(yyvsp
[0].sym
); ADD_IMMED(1);
1610 ADD_OP(OP_ARRAY_REF
); ADD_IMMED(yyvsp
[-1].nArgs
);
1616 ADD_OP(OP_PUSH_ARRAY_SYM
); ADD_SYM(yyvsp
[0].sym
); ADD_IMMED(0);
1622 ADD_OP(OP_ARRAY_REF
); ADD_IMMED(yyvsp
[-1].nArgs
);
1628 yyval
.inst
= GetPC();
1634 ADD_OP(OP_PUSH_SYM
); ADD_SYM(yyvsp
[0].sym
);
1640 ADD_OP(OP_PUSH_SYM
); ADD_SYM(yyvsp
[0].sym
);
1646 ADD_OP(OP_PUSH_SYM
); ADD_SYM(yyvsp
[0].sym
);
1652 ADD_OP(OP_SUBR_CALL
);
1653 ADD_SYM(PromoteToGlobal(yyvsp
[-3].sym
)); ADD_IMMED(yyvsp
[-1].nArgs
);
1654 ADD_OP(OP_FETCH_RET_VAL
);
1660 ADD_OP(OP_PUSH_ARG
);
1666 ADD_OP(OP_PUSH_ARG_COUNT
);
1672 ADD_OP(OP_PUSH_ARG_ARRAY
);
1678 ADD_OP(OP_ARRAY_REF
); ADD_IMMED(yyvsp
[-1].nArgs
);
1774 ADD_OP(OP_AND
); SET_BR_OFF(yyvsp
[-1].inst
, GetPC());
1780 ADD_OP(OP_OR
); SET_BR_OFF(yyvsp
[-1].inst
, GetPC());
1792 ADD_OP(OP_PUSH_SYM
); ADD_SYM(yyvsp
[0].sym
); ADD_OP(OP_INCR
);
1793 ADD_OP(OP_DUP
); ADD_OP(OP_ASSIGN
); ADD_SYM(yyvsp
[0].sym
);
1799 ADD_OP(OP_PUSH_SYM
); ADD_SYM(yyvsp
[-1].sym
); ADD_OP(OP_DUP
);
1800 ADD_OP(OP_INCR
); ADD_OP(OP_ASSIGN
); ADD_SYM(yyvsp
[-1].sym
);
1806 ADD_OP(OP_PUSH_SYM
); ADD_SYM(yyvsp
[0].sym
); ADD_OP(OP_DECR
);
1807 ADD_OP(OP_DUP
); ADD_OP(OP_ASSIGN
); ADD_SYM(yyvsp
[0].sym
);
1813 ADD_OP(OP_PUSH_SYM
); ADD_SYM(yyvsp
[-1].sym
); ADD_OP(OP_DUP
);
1814 ADD_OP(OP_DECR
); ADD_OP(OP_ASSIGN
); ADD_SYM(yyvsp
[-1].sym
);
1820 ADD_OP(OP_IN_ARRAY
);
1826 yyval
.inst
= GetPC(); StartLoopAddrList();
1832 StartLoopAddrList(); yyval
.inst
= GetPC();
1838 ADD_OP(OP_BRANCH
); yyval
.inst
= GetPC(); ADD_BR_OFF(0);
1844 ADD_OP(OP_BRANCH_NEVER
); yyval
.inst
= GetPC(); ADD_BR_OFF(0);
1850 ADD_OP(OP_BRANCH_FALSE
); yyval
.inst
= GetPC(); ADD_BR_OFF(0);
1856 ADD_OP(OP_DUP
); ADD_OP(OP_BRANCH_FALSE
); yyval
.inst
= GetPC();
1863 ADD_OP(OP_DUP
); ADD_OP(OP_BRANCH_TRUE
); yyval
.inst
= GetPC();
1867 #line 1868 "y.tab.c"
1873 if (yystate
== 0 && yym
== 0)
1877 printf("%sdebug: after reduction, shifting from state 0 to\
1878 state %d\n", YYPREFIX
, YYFINAL
);
1885 if ((yychar
= yylex()) < 0) yychar
= 0;
1890 if (yychar
<= YYMAXTOKEN
) yys
= yyname
[yychar
];
1891 if (!yys
) yys
= "illegal-symbol";
1892 printf("%sdebug: state %d, reading %d (%s)\n",
1893 YYPREFIX
, YYFINAL
, yychar
, yys
);
1897 if (yychar
== 0) goto yyaccept
;
1900 if ((yyn
= yygindex
[yym
]) && (yyn
+= yystate
) >= 0 &&
1901 yyn
<= YYTABLESIZE
&& yycheck
[yyn
] == yystate
)
1902 yystate
= yytable
[yyn
];
1904 yystate
= yydgoto
[yym
];
1907 printf("%sdebug: after reduction, shifting from state %d \
1908 to state %d\n", YYPREFIX
, *yyssp
, yystate
);
1910 if (yyssp
>= yysslim
&& yygrowstack())
1918 yyerror("yacc stack overflow");