comparison tests/agcl/oldagsrc/good/y2ag.cpp @ 0:13d2b8934445

Import AnaGram (near-)release tree into Mercurial.
author David A. Holland
date Sat, 22 Dec 2007 17:52:45 -0500
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:13d2b8934445
1 /*
2
3 YACC to AnaGram converter.
4 Copyright (c) Jerome T. Holland, 1993
5 All Rights Reserved.
6
7 Converts YACC files to AnaGram, attempting to preserve comments.
8 Does not convert semantic actions.
9
10 */
11 /*
12 * AnaGram, A System for Syntax Directed Programming
13 * File generated by: ...
14 *
15 * AnaGram Parsing Engine
16 * Copyright 1993-2002 Parsifal Software. All Rights Reserved.
17 *
18 * This software is provided 'as-is', without any express or implied
19 * warranty. In no event will the authors be held liable for any damages
20 * arising from the use of this software.
21 *
22 * Permission is granted to anyone to use this software for any purpose,
23 * including commercial applications, and to alter it and redistribute it
24 * freely, subject to the following restrictions:
25 *
26 * 1. The origin of this software must not be misrepresented; you must not
27 * claim that you wrote the original software. If you use this software
28 * in a product, an acknowledgment in the product documentation would be
29 * appreciated but is not required.
30 * 2. Altered source versions must be plainly marked as such, and must not be
31 * misrepresented as being the original software.
32 * 3. This notice may not be removed or altered from any source distribution.
33 */
34
35 #ifndef Y2AG_H
36 #include "y2ag.h"
37 #endif
38
39 #ifndef Y2AG_H
40 #error Mismatched header file
41 #endif
42
43 #include <ctype.h>
44 #include <stdio.h>
45
46 #define RULE_CONTEXT (&((PCB).cs[(PCB).ssx]))
47 #define ERROR_CONTEXT ((PCB).cs[(PCB).error_frame_ssx])
48 #define CONTEXT ((PCB).cs[(PCB).ssx])
49
50
51
52 y2ag_pcb_type y2ag_pcb;
53 #define PCB y2ag_pcb
54
55 #line - "y2ag.syn"
56 #include <ctype.h>
57 #include <stdio.h>
58 #include "charsink.h"
59 #include "strdict.h"
60
61 string_accumulator c_code(64000);
62 string_accumulator comments(10000);
63 string_accumulator name(100);
64 string_accumulator white(100);
65 string_accumulator config(1000);
66 string_accumulator type_acc(100);
67 string_dictionary decl_dict(100);
68
69 char decl_name[100] = "";
70 int decl_table[100];
71
72 output_file out;
73
74 char *cs;
75
76 char *type_string = "int AG_RTV;\n";
77
78
79 int rvflag;
80
81 char *grammar_tag = " $";
82
83 void dump_comments(char *ps, char *cs) {
84 if (size(comments) == 0) return;
85 out << (char *) white << ps << (char *) comments << cs;
86 reset(comments);
87 }
88
89 void output_r(void) {
90 char *rs = "";
91 char *ts = "";
92 if (size(c_code) == 0) return;
93 out.printf(" ={%s%s%s}", ts,(char *) c_code,rs);
94 reset(c_code);
95 }
96
97 void output_il(void) {
98 char *rs = "";
99 char *ts = "";
100 if (size(c_code) == 0) return;
101 out.printf("%s!{\n%s%s%s}", cs, ts, (char *) c_code,rs);
102 reset(c_code);
103 cs = ",\n ";
104 }
105
106 void main(void) {
107 y2ag();
108 }
109
110 #line - "y2ag.cpp"
111
112 #ifndef CONVERT_CASE
113 #define CONVERT_CASE(c) (c)
114 #endif
115 #ifndef TAB_SPACING
116 #define TAB_SPACING 8
117 #endif
118
119 static void ag_rp_1(void) {
120 #line - "y2ag.syn"
121 if (size(config))
122 out << "\n[\n" << (char *) config << "]\n";
123 #line - "y2ag.cpp"
124 }
125
126 #define ag_rp_2() (comments << "*/")
127
128 #define ag_rp_3() (comments << "/*")
129
130 #define ag_rp_4(x) (comments << x)
131
132 #define ag_rp_5() (reset(white),out << '\n',dump_comments("", ""))
133
134 #define ag_rp_6() (reset(white), dump_comments("\t", ""))
135
136 #define ag_rp_7() (reset(white), dump_comments("", ""))
137
138 #define ag_rp_8() (out << '\n', dump_comments("", ""))
139
140 #define ag_rp_9() (dump_comments("\t", ""))
141
142 #define ag_rp_10(c) (reset(white), dump_comments("", ""))
143
144 #define ag_rp_11(c) (reset(white) << c,dump_comments("", ""))
145
146 #define ag_rp_12() (reset(white),dump_comments("", ""))
147
148 #define ag_rp_13(c) (dump_comments("\t", ""))
149
150 #define ag_rp_14(c) (white << c, dump_comments("", ""))
151
152 #define ag_rp_15(c) (reset(white),out << cs, cs = "", dump_comments("", ""))
153
154 #define ag_rp_16(c) (reset(white) << c,dump_comments("", ""))
155
156 #define ag_rp_17() (reset(white),dump_comments("", ""))
157
158 #define ag_rp_18(c) (out << cs, cs = "",dump_comments("", ""))
159
160 #define ag_rp_19(c) (white << c, dump_comments("", ""))
161
162 #define ag_rp_20() (dump_comments("\n","\n"))
163
164 static void ag_rp_21(void) {
165 #line - "y2ag.syn"
166 out.printf("[ grammar token = %s ]\n",(char *) name);
167 grammar_tag = "";
168
169 #line - "y2ag.cpp"
170 }
171
172 #define ag_rp_22() (out << '\n')
173
174 #define ag_rp_23() (config << "}\n")
175
176 #define ag_rp_24() (config << "}\n")
177
178 #define ag_rp_25() (config << "}\n")
179
180 #define ag_rp_26() (out << '\n')
181
182 #define ag_rp_27() (out << '\n')
183
184 #define ag_rp_28() (reset(name))
185
186 static void ag_rp_29(void) {
187 #line - "y2ag.syn"
188 int decl_ndx = decl_dict << decl_name;
189 int type_ndx = decl_dict << (char *) type_acc;
190 decl_table[decl_ndx] = type_ndx;
191 reset(type_acc);
192 reset(name);
193 *decl_name = 0;
194
195 #line - "y2ag.cpp"
196 }
197
198 #define ag_rp_30() (type_acc << (char *) decl_name, strcpy(decl_name, name), reset(name))
199
200 static void ag_rp_31(void) {
201 #line - "y2ag.syn"
202 if (*decl_name) type_acc << (char *) decl_name << ' ', *decl_name = 0;
203 #line - "y2ag.cpp"
204 }
205
206 #define ag_rp_32() (type_acc << (char *) decl_name << '*', *decl_name = 0)
207
208 #define ag_rp_33(n) (out.printf("/* expect %d unresolved conflicts */\n",n))
209
210 #define ag_rp_34() (config << " left {")
211
212 #define ag_rp_35() (config << " nonassoc {")
213
214 #define ag_rp_36() (config << " right {")
215
216 #define ag_rp_37() (out << '(' << decl_dict[decl_table[decl_dict[name]]] << ") ", reset(name))
217
218 #define ag_rp_38() (out << (char *) name, cs = ", ")
219
220 #define ag_rp_39() (out << cs << (char *) name)
221
222 #define ag_rp_40() (out << cs << (char *) name)
223
224 #define ag_rp_41(n) (out.printf(" = %d\n",n))
225
226 #define ag_rp_42() (config<< (char *) name, cs = ", ")
227
228 #define ag_rp_43() (config << cs << (char *) name)
229
230 #define ag_rp_44() (config << cs << (char *) name)
231
232 #define ag_rp_45(n) (config.printf("/* = %d*/",n))
233
234 #define ag_rp_46() (out << "\n{\n" << (char *) c_code << "\n}\n",reset(c_code))
235
236 #define ag_rp_47() (reset(c_code), rvflag = 0)
237
238 #define ag_rp_48(x) (c_code << x)
239
240 #define ag_rp_49() (c_code << '$')
241
242 #define ag_rp_50() (c_code << '}')
243
244 #define ag_rp_51() (c_code << '"')
245
246 #define ag_rp_52() (c_code << "*/")
247
248 #define ag_rp_53() (c_code << "/*")
249
250 #define ag_rp_54(x) (c_code << x)
251
252 #define ag_rp_55(d) (d - '0')
253
254 #define ag_rp_56(n, d) (10*n + d - '0')
255
256 #define ag_rp_57() (c_code << '{')
257
258 #define ag_rp_58(x) (c_code << '\'' << x << '\'')
259
260 #define ag_rp_59(x) (c_code << x)
261
262 #define ag_rp_60(x) (c_code << x)
263
264 #define ag_rp_61() (c_code << '"')
265
266 #define ag_rp_62(x) (c_code << x)
267
268 #define ag_rp_63(x) (c_code << '\\' << x)
269
270 #define ag_rp_64() (output_r())
271
272 static void ag_rp_65(void) {
273 #line - "y2ag.syn"
274 out << (char *) name << grammar_tag;
275 grammar_tag = "";
276 cs = "\n -> ";
277 dump_comments("\t","");
278
279 #line - "y2ag.cpp"
280 }
281
282 #define ag_rp_66() (output_r(), out << "\n -> ", cs = "")
283
284 #define ag_rp_67() (out << cs, cs = "")
285
286 static void ag_rp_68(void) {
287 #line - "y2ag.syn"
288 output_il();
289 out.printf("%s%s",cs,(char *) name); cs = ", ";
290
291 #line - "y2ag.cpp"
292 }
293
294 static void ag_rp_69(int x) {
295 #line - "y2ag.syn"
296 char *fmt = "%d";
297 if (isprint(x)) fmt ="'%c'";
298 reset(name).printf(fmt,x);
299 output_il();
300 out.printf("%s%s",cs,(char *) name); cs = ", ";
301
302 #line - "y2ag.cpp"
303 }
304
305 #define ag_rp_70() (out.printf(" /* %prec %s */",(char *) name))
306
307 #define ag_rp_71() (dump_comments("\t",""))
308
309 static void ag_rp_72(int x) {
310 #line - "y2ag.syn"
311 char *fmt = "%d";
312 if (isprint(x)) fmt ="'%c'";
313 reset(name).printf(fmt,x);
314
315 #line - "y2ag.cpp"
316 }
317
318 #define ag_rp_73(x) (x)
319
320 #define ag_rp_74(x) (x)
321
322 #define ag_rp_75() ('\n')
323
324 #define ag_rp_76() ('\r')
325
326 #define ag_rp_77() ('\b')
327
328 #define ag_rp_78() ('\b')
329
330 #define ag_rp_79() ('\v')
331
332 #define ag_rp_80(x) (x&037)
333
334 #define ag_rp_81(x) (x)
335
336 #define ag_rp_82(x) (reset(name) << x)
337
338 #define ag_rp_83(x) (name << x)
339
340 #define ag_rp_84() (name << ' ')
341
342 #define ag_rp_85(x) (x-'0')
343
344 #define ag_rp_86(v, x) (8*v + x-'0')
345
346 #define ag_rp_87() (out << "\n}\n")
347
348 #define ag_rp_88() (out << "\n{\n")
349
350 #define ag_rp_89(x) (out << x)
351
352
353 #define READ_COUNTS
354 #define WRITE_COUNTS
355 #undef V
356 #define V(i,t) (*t (&(PCB).vs[(PCB).ssx + i]))
357 #undef VS
358 #define VS(i) (PCB).vs[(PCB).ssx + i]
359
360 #ifndef GET_CONTEXT
361 #define GET_CONTEXT CONTEXT = (PCB).input_context
362 #endif
363
364 typedef enum {
365 ag_action_1,
366 ag_action_2,
367 ag_action_3,
368 ag_action_4,
369 ag_action_5,
370 ag_action_6,
371 ag_action_7,
372 ag_action_8,
373 ag_action_9,
374 ag_action_10,
375 ag_action_11,
376 ag_action_12
377 } ag_parser_action;
378
379
380 #ifndef NULL_VALUE_INITIALIZER
381 #define NULL_VALUE_INITIALIZER = 0
382 #endif
383
384 static int const ag_null_value NULL_VALUE_INITIALIZER;
385
386 static const unsigned char ag_rpx[] = {
387 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 2, 3, 4, 0, 0, 5, 6, 7,
388 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 0, 20, 21, 0, 0, 22,
389 0, 0, 23, 24, 25, 26, 27, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
390 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 28, 29, 30, 0, 0, 31, 32, 0,
391 0, 0, 33, 0, 0, 0, 0, 34, 0, 0, 0, 35, 0, 0, 36, 0, 0, 0,
392 0, 0, 0, 37, 0, 0, 0, 38, 39, 40, 41, 42, 43, 44, 45, 0, 46, 0,
393 0, 0, 47, 0, 48, 49, 0, 50, 0, 51, 52, 53, 54, 55, 56, 57, 0, 58,
394 0, 59, 60, 61, 0, 62, 63, 0, 0, 0, 0, 0, 0, 64, 65, 0, 0, 66,
395 0, 0, 0, 0, 67, 0, 0, 0, 68, 69, 0, 0, 70, 0, 0, 71, 0, 72,
396 73, 74, 0, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 0, 87, 88,
397 89
398 };
399
400 static const unsigned char ag_key_itt[] = {
401 0
402 };
403
404 static const unsigned short ag_key_pt[] = {
405 0
406 };
407
408 static const unsigned char ag_key_ch[] = {
409 0,101,111,121,255, 37, 48, 50, 60, 62, 98,101,108,110,114,115,116,117,
410 123,255, 37, 47,255, 42,255,101,111,121,255, 37, 48, 50, 60, 62, 98,101,
411 108,110,114,115,116,117,123,255, 37,255, 37,255, 47,255, 37, 47,255, 37,
412 123,255, 37, 47,255, 37,123,255, 37,255,101,111,121,255, 37, 48, 50, 60,
413 61, 62, 98,101,108,110,112,114,115,116,117,123,255, 37, 47,255, 61,112,
414 255, 37, 47,255, 37, 47,255, 61,112,255, 37,255
415 };
416
417 static const unsigned char ag_key_act[] = {
418 0,3,3,3,4,0,0,0,0,0,3,3,3,3,3,3,2,3,0,4,2,3,4,3,4,3,3,3,4,0,0,0,0,0,3,
419 3,3,3,3,3,2,3,0,4,2,4,3,4,3,4,3,3,4,0,0,4,2,3,4,0,0,4,2,4,3,3,3,4,0,0,
420 0,0,0,0,3,3,3,3,3,3,3,2,3,0,4,2,3,4,0,3,4,2,3,4,3,3,4,0,3,4,2,4
421 };
422
423 static const unsigned char ag_key_parm[] = {
424 0, 73, 72, 76, 0, 12, 74, 66, 61, 69, 65, 58, 60, 64, 68, 71, 0, 79,
425 83, 0, 0, 19, 0, 18, 0, 73, 72, 76, 0, 12, 74, 66, 61, 69, 65, 58,
426 60, 64, 68, 71, 0, 79, 83, 0, 0, 0, 12, 0, 19, 0, 85, 19, 0, 12,
427 83, 0, 0, 19, 0, 12, 83, 0, 0, 0, 73, 72, 76, 0, 12, 74, 66, 61,
428 126, 69, 65, 58, 60, 64,125, 68, 71, 0, 79, 83, 0, 0, 19, 0,126,125,
429 0, 0, 19, 0, 12, 19, 0,126,125, 0, 0, 0
430 };
431
432 static const unsigned char ag_key_jmp[] = {
433 0, 34, 37, 41, 0, 0, 0, 0, 0, 0, 0, 6, 12, 16, 24, 29, 1, 44,
434 0, 0, 5, 49, 0, 51, 0, 87, 90, 94, 0, 0, 0, 0, 0, 0, 53, 59,
435 65, 69, 77, 82, 25, 97, 0, 0, 29, 0,102, 0,104, 0,106,108, 0, 0,
436 0, 0, 53,110, 0, 0, 0, 0, 59, 0,150,153,157, 0, 0, 0, 0, 0,
437 0, 0,112,118,124,128,136,140,145, 64,160, 0, 0, 68,165, 0, 0,167,
438 0, 88,171, 0,173,175, 0, 0,177, 0, 97, 0
439 };
440
441 static const unsigned char ag_key_index[] = {
442 20, 23, 20, 20, 44, 44, 20, 20, 44, 46, 48, 48, 48, 48, 48, 48, 50, 48,
443 48, 20, 0, 0, 0, 0, 0, 0, 0, 56, 0, 48, 20, 50, 48, 0, 48, 0,
444 20, 20, 20, 0, 20, 48, 20, 0, 0, 20, 20, 62, 20, 23, 0, 0, 48, 20,
445 0, 20, 0, 85, 85, 44, 44, 44, 44, 44, 44, 48, 48, 48, 48, 48, 0, 48,
446 0, 0, 0, 0, 46, 0, 0, 0, 48, 48, 44, 48, 20, 85, 85, 48, 20, 48,
447 0, 48, 91, 94, 46, 46, 0, 0, 0,100, 0, 0, 0, 91, 91,100, 91, 91,
448 100, 91, 0, 0, 0, 48, 48, 91, 91, 91, 48, 48, 91, 48, 0, 48, 0, 48,
449 0, 0, 0, 48
450 };
451
452 static const unsigned char ag_key_ends[] = {
453 105,110,97,114,121,0, 120,112,101,99,116,0, 101,102,116,0,
454 111,110,97,115,115,111,99,0, 105,103,104,116,0, 116,97,114,116,0,
455 114,109,0, 107,101,110,0, 112,101,0, 110,105,111,110,0, 42,0,
456 47,0, 105,110,97,114,121,0, 120,112,101,99,116,0, 101,102,116,0,
457 111,110,97,115,115,111,99,0, 105,103,104,116,0, 116,97,114,116,0,
458 114,109,0, 107,101,110,0, 112,101,0, 110,105,111,110,0, 37,0,
459 42,0, 125,0, 42,0, 42,0, 105,110,97,114,121,0, 120,112,101,99,116,0,
460 101,102,116,0, 111,110,97,115,115,111,99,0, 114,101,99,0,
461 105,103,104,116,0, 116,97,114,116,0, 114,109,0, 107,101,110,0,
462 112,101,0, 110,105,111,110,0, 42,0, 114,101,99,0, 42,0, 37,0,
463 42,0, 114,101,99,0,
464 };
465 #define AG_TCV(x) (((int)(x) >= -1 && (int)(x) <= 255) ? ag_tcv[(x) + 1] : 0)
466
467 static const unsigned char ag_tcv[] = {
468 11, 11,143,143,143,143,143,143,143,143,140, 21, 21, 21,141,143,143,143,
469 143,143,143,143,143,143,143,143,143, 11,143,143,143,143,143,142,144, 97,
470 144, 91,144,144, 94,144,144, 55,144, 82,144,138,144,103,103,103,103,103,
471 103,103,103,145,145,113, 53, 77, 88, 78,144,144,146,146,146,146,146,146,
472 146,146,146,146,146,146,146,146,146,146,146,146,146,146,146,146,146,146,
473 146,146,144,101,144,144,146,144,146,131,146,146,146,133,146,146,146,146,
474 146,146,146,129,146,146,146,130,146,132,146,146,146,146,146,146, 41,116,
475 43,144,144,144,144,144,144,144,144,144,144,144,144,144,144,144,144,144,
476 144,144,144,144,144,144,144,144,144,144,144,144,144,144,144,144,144,144,
477 144,144,144,144,144,144,144,144,144,144,144,144,144,144,144,144,143,143,
478 143,143,143,143,143,143,143,143,143,143,143,143,143,143,143,143,143,143,
479 143,143,143,143,143,143,143,143,143,143,143,143,143,143,143,143,143,143,
480 143,143,143,143,143,143,143,143,143,143,143,143,143,143,143,143,143,143,
481 143,143,143,143,143,143,143,143,143,143,143,143,143,143,143,143,143,143,
482 143,143,143,143,143
483 };
484
485 #ifndef SYNTAX_ERROR
486 #define SYNTAX_ERROR fprintf(stderr,"%s, line %d, column %d\n", \
487 (PCB).error_message, (PCB).line, (PCB).column)
488 #endif
489
490 #ifndef FIRST_LINE
491 #define FIRST_LINE 1
492 #endif
493
494 #ifndef FIRST_COLUMN
495 #define FIRST_COLUMN 1
496 #endif
497
498 #ifndef PARSER_STACK_OVERFLOW
499 #define PARSER_STACK_OVERFLOW {fprintf(stderr, \
500 "\nParser stack overflow, line %d, column %d\n",\
501 (PCB).line, (PCB).column);}
502 #endif
503
504 #ifndef REDUCTION_TOKEN_ERROR
505 #define REDUCTION_TOKEN_ERROR {fprintf(stderr, \
506 "\nReduction token error, line %d, column %d\n", \
507 (PCB).line, (PCB).column);}
508 #endif
509
510
511 typedef enum
512 {ag_accept_key, ag_set_key, ag_jmp_key, ag_end_key, ag_no_match_key,
513 ag_cf_accept_key, ag_cf_set_key, ag_cf_end_key} key_words;
514
515 #ifndef GET_INPUT
516 #define GET_INPUT ((PCB).input_code = getchar())
517 #endif
518
519
520 static int ag_look_ahead(void) {
521 if ((PCB).rx < (PCB).fx) {
522 return CONVERT_CASE((PCB).lab[(PCB).rx++]);
523 }
524 GET_INPUT;
525 (PCB).fx++;
526 return CONVERT_CASE((PCB).lab[(PCB).rx++] = (PCB).input_code);
527 }
528
529 static void ag_get_key_word(int ag_k) {
530 int save_index = (PCB).rx;
531 const unsigned char *sp;
532 int ag_ch;
533 while (1) {
534 switch (ag_key_act[ag_k]) {
535 case ag_cf_end_key:
536 sp = ag_key_ends + ag_key_jmp[ag_k];
537 do {
538 if ((ag_ch = *sp++) == 0) {
539 int ag_k1 = ag_key_parm[ag_k];
540 int ag_k2 = ag_key_pt[ag_k1];
541 if (ag_key_itt[ag_k2 + ag_look_ahead()]) goto ag_fail;
542 (PCB).rx--;
543 (PCB).token_number = (y2ag_token_type) ag_key_pt[ag_k1 + 1];
544 return;
545 }
546 } while (ag_look_ahead() == ag_ch);
547 goto ag_fail;
548 case ag_end_key:
549 sp = ag_key_ends + ag_key_jmp[ag_k];
550 do {
551 if ((ag_ch = *sp++) == 0) {
552 (PCB).token_number = (y2ag_token_type) ag_key_parm[ag_k];
553 return;
554 }
555 } while (ag_look_ahead() == ag_ch);
556 case ag_no_match_key:
557 ag_fail:
558 (PCB).rx = save_index;
559 return;
560 case ag_cf_set_key: {
561 int ag_k1 = ag_key_parm[ag_k];
562 int ag_k2 = ag_key_pt[ag_k1];
563 ag_k = ag_key_jmp[ag_k];
564 if (ag_key_itt[ag_k2 + (ag_ch = ag_look_ahead())]) break;
565 save_index = --(PCB).rx;
566 (PCB).token_number = (y2ag_token_type) ag_key_pt[ag_k1+1];
567 break;
568 }
569 case ag_set_key:
570 save_index = (PCB).rx;
571 (PCB).token_number = (y2ag_token_type) ag_key_parm[ag_k];
572 case ag_jmp_key:
573 ag_k = ag_key_jmp[ag_k];
574 ag_ch = ag_look_ahead();
575 break;
576 case ag_accept_key:
577 (PCB).token_number = (y2ag_token_type) ag_key_parm[ag_k];
578 return;
579 case ag_cf_accept_key: {
580 int ag_k1 = ag_key_parm[ag_k];
581 int ag_k2 = ag_key_pt[ag_k1];
582 if (ag_key_itt[ag_k2 + ag_look_ahead()]) (PCB).rx = save_index;
583 else {
584 (PCB).rx--;
585 (PCB).token_number = (y2ag_token_type) ag_key_pt[ag_k1+1];
586 }
587 return;
588 }
589 default:
590 /* not reachable; here to suppress compiler warnings */
591 goto ag_fail;
592 }
593 if (ag_ch <= 255) while (ag_key_ch[ag_k] < ag_ch) ag_k++;
594 if (ag_ch > 255 || ag_key_ch[ag_k] != ag_ch) {
595 (PCB).rx = save_index;
596 return;
597 }
598 }
599 }
600
601
602 #ifndef AG_NEWLINE
603 #define AG_NEWLINE 10
604 #endif
605
606 #ifndef AG_RETURN
607 #define AG_RETURN 13
608 #endif
609
610 #ifndef AG_FORMFEED
611 #define AG_FORMFEED 12
612 #endif
613
614 #ifndef AG_TABCHAR
615 #define AG_TABCHAR 9
616 #endif
617
618 static void ag_track(void) {
619 int ag_k = 0;
620 while (ag_k < (PCB).rx) {
621 int ag_ch = (PCB).lab[ag_k++];
622 switch (ag_ch) {
623 case AG_NEWLINE:
624 (PCB).column = 1, (PCB).line++;
625 case AG_RETURN:
626 case AG_FORMFEED:
627 break;
628 case AG_TABCHAR:
629 (PCB).column += (TAB_SPACING) - ((PCB).column - 1) % (TAB_SPACING);
630 break;
631 default:
632 (PCB).column++;
633 }
634 }
635 ag_k = 0;
636 while ((PCB).rx < (PCB).fx) (PCB).lab[ag_k++] = (PCB).lab[(PCB).rx++];
637 (PCB).fx = ag_k;
638 (PCB).rx = 0;
639 }
640
641
642 static void ag_prot(void) {
643 int ag_k;
644 ag_k = 128 - ++(PCB).btsx;
645 if (ag_k <= (PCB).ssx) {
646 (PCB).exit_flag = AG_STACK_ERROR_CODE;
647 PARSER_STACK_OVERFLOW;
648 return;
649 }
650 (PCB).bts[(PCB).btsx] = (PCB).sn;
651 (PCB).bts[ag_k] = (PCB).ssx;
652 (PCB).vs[ag_k] = (PCB).vs[(PCB).ssx];
653 (PCB).ss[ag_k] = (PCB).ss[(PCB).ssx];
654 }
655
656 static void ag_undo(void) {
657 if ((PCB).drt == -1) return;
658 while ((PCB).btsx) {
659 int ag_k = 128 - (PCB).btsx;
660 (PCB).sn = (PCB).bts[(PCB).btsx--];
661 (PCB).ssx = (PCB).bts[ag_k];
662 (PCB).vs[(PCB).ssx] = (PCB).vs[ag_k];
663 (PCB).ss[(PCB).ssx] = (PCB).ss[ag_k];
664 }
665 (PCB).token_number = (y2ag_token_type) (PCB).drt;
666 (PCB).ssx = (PCB).dssx;
667 (PCB).sn = (PCB).dsn;
668 (PCB).drt = -1;
669 }
670
671
672 static const unsigned char ag_tstt[] = {
673 142,140,83,79,76,74,73,72,71,69,68,66,65,64,61,60,58,21,19,12,0,2,3,4,16,17,
674 146,145,144,143,142,141,140,138,133,132,131,130,129,116,113,103,101,97,94,
675 91,88,82,78,77,55,53,43,41,21,18,0,
676 146,145,142,140,138,133,132,131,130,129,103,97,94,83,82,79,78,77,76,74,73,
677 72,71,69,68,66,65,64,61,60,58,21,19,12,11,0,16,17,22,
678 146,145,142,140,138,133,132,131,130,129,103,97,94,83,82,79,78,77,76,74,73,
679 72,71,69,68,66,65,64,61,60,58,21,19,12,11,0,16,17,22,
680 142,140,21,0,
681 83,79,76,74,73,72,71,69,68,66,65,64,61,60,58,12,0,5,13,
682 146,145,142,140,138,133,132,131,130,129,103,97,94,83,82,79,78,77,76,74,73,
683 72,71,69,68,66,65,64,61,60,58,21,19,12,11,0,16,17,22,
684 146,145,142,140,138,133,132,131,130,129,103,97,94,83,82,79,78,77,76,74,73,
685 72,71,69,68,66,65,64,61,60,58,21,19,12,11,0,16,17,22,
686 83,79,76,74,73,72,71,69,68,66,65,64,61,60,58,0,7,26,27,29,31,33,36,37,38,40,
687 62,67,70,75,
688 12,0,6,
689 145,142,140,103,21,19,0,3,4,16,17,
690 142,141,140,21,19,0,14,16,17,54,
691 146,142,141,140,138,133,132,131,130,129,97,94,77,21,19,0,14,16,17,54,63,
692 146,142,141,140,138,133,132,131,130,129,97,94,77,21,19,0,14,16,17,54,63,
693 146,142,141,140,138,133,132,131,130,129,97,94,77,21,19,0,14,16,17,54,63,
694 146,142,141,140,138,133,132,131,130,129,97,94,77,21,19,0,14,16,17,54,63,
695 146,145,144,143,142,141,140,138,133,132,131,130,129,116,113,103,101,97,94,
696 91,88,85,82,78,77,55,53,41,21,19,0,84,
697 142,141,140,41,21,19,0,14,16,17,54,63,
698 146,142,141,140,138,133,132,131,130,129,97,94,21,19,0,14,16,17,54,63,
699 142,140,83,79,76,74,73,72,71,69,68,66,65,64,61,60,58,21,19,12,0,3,4,16,17,
700 77,0,39,
701 146,138,133,132,131,130,129,97,94,77,0,34,80,81,
702 146,138,133,132,131,130,129,97,94,77,0,34,80,81,
703 146,138,133,132,131,130,129,97,94,77,0,34,80,81,
704 146,138,133,132,131,130,129,97,94,77,0,32,80,81,
705 41,0,30,
706 146,138,133,132,131,130,129,97,94,0,1,28,122,
707 146,142,140,138,133,132,131,130,129,97,94,83,21,19,12,11,0,3,4,16,17,
708 145,103,0,59,
709 142,141,140,21,19,0,14,16,17,
710 142,141,140,21,19,0,14,16,17,
711 146,145,144,143,142,141,140,138,133,132,131,130,129,116,113,103,101,97,94,
712 91,88,85,82,78,77,55,53,41,21,19,0,89,92,96,98,
713 146,142,141,140,138,133,132,131,130,129,21,19,0,14,16,17,54,63,
714 146,138,133,132,131,130,129,97,94,77,0,32,80,81,
715 146,142,140,138,133,132,131,130,129,97,94,21,19,0,3,4,16,17,
716 146,138,133,132,131,130,129,97,94,0,1,28,122,
717 142,140,83,82,79,76,74,73,72,71,69,68,66,65,64,61,60,58,21,19,12,0,16,17,24,
718 35,
719 142,140,83,82,79,76,74,73,72,71,69,68,66,65,64,61,60,58,21,19,12,0,16,17,24,
720 35,
721 142,140,83,82,79,76,74,73,72,71,69,68,66,65,64,61,60,58,21,19,12,0,16,17,24,
722 35,
723 146,138,133,132,131,130,129,97,94,0,1,28,122,
724 142,140,83,82,79,76,74,73,72,71,69,68,66,65,64,61,60,58,21,19,12,0,3,4,16,
725 17,
726 146,142,141,140,138,133,132,131,130,129,55,53,21,19,0,1,14,16,17,42,44,45,
727 46,47,48,49,50,51,52,54,56,57,
728 142,140,83,79,76,74,73,72,71,69,68,66,65,64,61,60,58,21,19,12,0,3,4,16,17,
729 146,145,144,142,138,133,132,131,130,129,116,113,103,101,97,94,91,88,82,78,
730 77,55,53,43,41,0,128,
731 146,145,144,142,138,133,132,131,130,129,116,113,103,101,97,94,91,88,82,78,
732 77,55,53,43,41,0,128,
733 146,145,138,133,132,131,130,129,103,0,
734 142,140,83,79,76,74,73,72,71,69,68,66,65,64,61,60,58,21,19,12,0,3,4,16,17,
735 146,138,133,132,131,130,129,97,94,83,12,11,0,7,8,
736 145,103,0,
737 146,145,144,143,142,141,140,138,133,132,131,130,129,116,113,103,101,97,94,
738 91,88,82,78,77,55,53,43,41,21,18,0,
739 146,145,144,142,138,133,132,131,130,129,116,113,103,101,97,94,91,88,82,78,
740 77,55,53,43,41,0,104,
741 146,145,144,142,138,133,132,131,130,129,116,113,103,101,97,94,91,88,82,78,
742 77,55,53,43,41,0,95,
743 146,145,144,143,142,141,140,138,133,132,131,130,129,116,113,103,101,97,94,
744 91,88,82,78,77,55,53,43,41,21,19,0,93,
745 146,142,141,140,138,133,132,131,130,129,97,94,83,79,76,74,73,72,71,69,68,66,
746 65,64,61,60,58,21,19,12,11,0,14,16,17,54,63,
747 146,138,133,132,131,130,129,0,1,
748 142,140,83,82,79,76,74,73,72,71,69,68,66,65,64,61,60,58,21,19,12,0,3,4,16,
749 17,
750 146,138,133,132,131,130,129,97,94,0,1,28,122,
751 146,145,142,140,138,133,132,131,130,129,126,125,116,103,97,94,88,83,82,79,
752 76,74,73,72,71,69,68,66,65,64,61,60,58,53,41,21,19,12,0,16,17,22,
753 146,145,142,140,138,133,132,131,130,129,126,125,116,103,97,94,88,83,82,79,
754 76,74,73,72,71,69,68,66,65,64,61,60,58,53,41,21,19,12,0,16,17,22,
755 146,145,142,140,138,133,132,131,130,129,103,97,94,21,0,1,28,59,122,
756 82,0,
757 82,0,
758 82,0,
759 146,145,142,140,138,133,132,131,130,129,103,97,94,21,0,1,28,59,122,
760 82,0,
761 55,0,56,
762 142,141,140,21,19,0,14,16,17,
763 146,145,138,133,132,131,130,129,103,0,
764 146,142,141,140,138,133,132,131,130,129,55,21,19,0,1,14,16,17,44,45,46,54,
765 56,57,
766 146,142,141,140,138,133,132,131,130,129,53,21,19,0,1,14,16,17,44,45,47,54,
767 146,138,133,132,131,130,129,55,53,0,1,44,46,47,56,57,
768 142,141,140,55,53,21,19,0,14,16,17,45,46,47,54,56,57,
769 43,0,
770 146,145,144,142,138,133,132,131,130,129,116,113,103,101,97,94,91,88,82,78,
771 77,55,53,43,41,0,135,
772 97,0,
773 94,0,
774 146,138,133,132,131,130,129,97,94,12,11,0,1,9,28,107,108,109,110,111,122,
775 146,145,144,142,138,133,132,131,130,129,116,113,103,101,97,94,91,88,82,78,
776 77,55,53,43,41,0,
777 103,0,102,
778 94,0,
779 146,145,144,143,142,141,140,138,133,132,131,130,129,116,113,103,101,97,94,
780 91,88,82,78,77,55,53,43,41,21,19,0,89,92,96,98,
781 146,145,142,141,140,138,133,132,131,130,129,103,78,21,19,0,14,16,17,54,63,
782 82,0,
783 142,140,78,21,19,0,3,4,16,17,
784 145,103,0,
785 146,145,142,140,138,133,132,131,130,129,126,125,116,103,97,94,88,83,82,79,
786 76,74,73,72,71,69,68,66,65,64,61,60,58,53,41,21,19,12,0,16,17,22,
787 146,145,142,140,138,133,132,131,130,129,126,125,116,103,97,94,88,83,82,79,
788 76,74,73,72,71,69,68,66,65,64,61,60,58,53,41,21,19,12,0,16,17,22,
789 146,142,140,138,133,132,131,130,129,97,94,21,19,0,16,17,24,35,
790 145,103,0,
791 146,142,140,138,133,132,131,130,129,97,94,21,19,0,3,4,16,17,
792 103,0,
793 142,141,140,113,21,19,0,14,16,17,54,63,
794 146,142,140,138,133,132,131,130,129,126,125,116,97,94,88,53,41,21,19,0,16,
795 17,25,112,114,115,117,119,120,121,
796 146,142,140,138,133,132,131,130,129,97,94,21,19,12,11,0,3,4,16,17,
797 146,138,133,132,131,130,129,97,94,0,1,28,107,108,111,122,
798 12,11,0,6,10,
799 103,0,
800 78,0,
801 78,0,
802 142,140,21,0,
803 146,138,133,132,131,130,129,97,94,0,1,28,122,
804 146,138,133,132,131,130,129,97,94,0,1,28,122,
805 113,0,
806 146,142,140,138,133,132,131,130,129,126,125,116,97,94,88,53,41,21,19,0,16,
807 17,22,
808 146,142,140,138,133,132,131,130,129,126,125,116,97,94,88,53,41,21,19,0,16,
809 17,22,
810 142,140,21,0,
811 146,142,140,138,133,132,131,130,129,126,125,116,97,94,88,53,41,21,19,0,16,
812 17,24,35,
813 146,142,140,138,133,132,131,130,129,126,125,116,97,94,88,53,41,21,19,0,16,
814 17,24,35,
815 146,138,133,132,131,130,129,126,125,97,94,88,41,0,1,86,87,118,122,123,124,
816 127,
817 146,142,140,138,133,132,131,130,129,126,125,116,97,94,88,53,41,21,19,0,16,
818 17,25,114,117,119,120,121,
819 116,53,0,
820 146,145,144,143,142,141,140,138,133,132,131,130,129,116,113,103,101,97,94,
821 91,88,82,78,77,55,53,43,41,21,11,0,139,
822 11,0,
823 146,142,140,138,133,132,131,130,129,97,94,77,21,19,0,3,4,16,17,
824 146,142,140,138,133,132,131,130,129,97,94,21,19,0,3,4,16,17,
825 146,142,140,138,133,132,131,130,129,126,125,116,97,94,88,53,41,21,19,0,16,
826 17,22,
827 146,142,140,138,133,132,131,130,129,126,125,116,97,94,88,53,41,21,19,0,16,
828 17,22,
829 146,145,138,133,132,131,130,129,103,0,
830 146,145,144,143,142,141,140,138,133,132,131,130,129,116,113,103,101,97,94,
831 91,88,82,78,77,55,53,43,41,21,19,0,84,
832 142,141,140,41,21,19,0,14,16,17,54,63,
833 146,142,140,138,133,132,131,130,129,126,125,116,97,94,88,53,41,21,19,0,16,
834 17,24,35,
835 146,142,141,140,138,133,132,131,130,129,97,94,21,19,0,14,16,17,54,63,
836 146,138,133,132,131,130,129,97,94,0,1,28,122,
837 142,140,88,41,21,19,0,16,17,24,35,
838 146,145,144,143,142,141,140,138,133,132,131,130,129,116,113,103,101,97,94,
839 91,88,82,78,77,55,53,43,41,21,0,
840 146,145,144,143,142,141,140,138,133,132,131,130,129,116,113,103,101,97,94,
841 91,88,82,78,77,55,53,43,41,21,19,0,89,92,96,98,
842 41,0,87,
843 88,41,0,86,87,
844 142,140,116,88,53,41,21,0,
845 142,140,116,53,21,19,0,16,17,24,35,
846
847 };
848
849
850 static unsigned const char ag_astt[2277] = {
851 1,1,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,1,2,5,7,0,1,1,2,1,10,10,10,10,10,10,10,
852 10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,2,7,5,5,
853 5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,2,5,5,7,2,1,2,
854 5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,2,5,5,7,2,
855 1,2,1,1,1,5,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,5,7,1,1,5,5,5,5,5,5,5,5,5,5,5,5,
856 5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,2,5,5,7,2,1,2,5,5,5,5,5,5,5,5,5,5,
857 5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,2,5,5,7,2,1,2,1,1,1,1,1,1,1,1,
858 1,1,1,1,1,1,1,4,2,2,1,1,1,1,1,1,1,1,1,1,1,1,1,7,1,8,1,1,8,1,2,7,1,1,2,1,1,
859 1,1,1,2,7,1,1,1,1,5,1,1,1,5,5,5,5,5,5,5,5,5,1,2,7,1,1,1,1,2,5,1,1,1,5,5,5,
860 5,5,5,5,5,5,1,2,7,1,1,1,1,2,5,1,1,1,5,5,5,5,5,5,5,5,5,1,2,7,1,1,1,1,2,5,1,
861 1,1,5,5,5,5,5,5,5,5,5,1,2,7,1,1,1,1,3,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,
862 4,4,4,4,4,4,4,4,4,4,4,4,7,1,1,1,1,5,1,2,7,1,1,1,1,3,5,1,1,1,5,5,5,5,5,5,5,
863 5,1,2,7,1,1,1,1,3,1,1,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,1,2,5,7,1,2,2,1,1,7,1,
864 8,8,8,8,8,8,8,8,8,1,7,1,1,1,8,8,8,8,8,8,8,8,8,1,7,1,1,1,8,8,8,8,8,8,8,8,8,
865 1,7,1,1,1,8,8,8,8,8,8,8,8,8,1,7,1,1,1,1,7,1,2,2,2,2,2,2,2,1,1,7,1,1,2,5,1,
866 1,5,5,5,5,5,5,5,5,8,1,2,5,5,7,1,1,2,1,2,2,7,1,9,9,9,9,2,5,3,3,1,9,9,9,9,2,
867 5,3,3,1,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,1,2,2,1,2,2,2,2,2,1,2,2,7,3,3,
868 1,1,8,1,1,1,8,8,8,8,8,8,1,2,7,1,1,1,1,1,8,8,8,8,8,8,8,8,8,1,7,1,1,1,8,1,1,
869 8,8,8,8,8,8,8,8,1,2,7,1,1,2,1,2,2,2,2,2,2,2,1,1,7,1,2,2,1,1,5,8,5,5,5,5,5,
870 5,5,5,5,5,5,5,5,5,1,2,5,7,2,1,1,1,1,1,5,8,5,5,5,5,5,5,5,5,5,5,5,5,5,5,1,2,
871 5,7,2,1,1,1,1,1,5,8,5,5,5,5,5,5,5,5,5,5,5,5,5,5,1,2,5,7,2,1,1,1,2,2,2,2,2,
872 2,2,1,1,7,1,2,2,1,1,5,8,5,5,5,5,5,5,5,5,5,5,5,5,5,5,1,2,5,7,1,1,2,1,2,1,1,
873 1,2,2,2,2,2,2,2,2,1,2,7,1,1,1,1,1,1,1,1,1,1,1,1,1,2,1,1,1,1,1,5,5,5,5,5,5,
874 5,5,5,5,5,5,5,5,5,1,2,5,7,1,3,2,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
875 1,1,1,1,1,7,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,7,1,10,10,
876 10,10,10,10,10,10,10,5,1,1,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,1,2,5,7,1,2,2,1,8,
877 8,8,8,8,8,8,8,8,1,5,5,7,1,1,10,10,4,10,10,10,10,10,10,10,10,10,10,10,10,10,
878 10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,2,7,2,2,2,2,2,2,2,2,2,2,2,
879 2,2,1,2,2,2,2,2,2,2,2,2,2,2,7,3,2,2,2,2,2,2,2,2,2,2,2,2,2,1,2,2,2,2,2,2,2,
880 2,2,2,2,7,1,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,7,
881 1,5,1,1,1,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,1,2,5,5,7,1,1,1,1,
882 2,2,2,2,2,2,2,2,7,1,1,1,5,8,5,5,5,5,5,5,5,5,5,5,5,5,5,5,1,2,5,7,1,1,2,1,2,
883 2,2,2,2,2,2,1,1,7,1,1,2,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,
884 5,5,5,5,5,5,5,5,5,5,5,2,5,7,2,1,2,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,
885 5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,2,5,7,2,1,2,2,2,1,1,2,2,2,2,2,2,2,1,1,1,5,
886 1,2,1,2,1,4,1,4,1,4,2,2,1,1,2,2,2,2,2,2,2,1,1,1,5,1,2,1,2,1,4,2,5,3,9,9,9,
887 9,2,4,3,3,1,10,10,10,10,10,10,10,10,10,4,2,1,1,1,2,2,2,2,2,2,2,1,2,5,1,1,1,
888 1,3,3,3,1,1,1,2,1,1,1,2,2,2,2,2,2,2,1,2,5,1,1,1,1,3,3,3,1,2,2,2,2,2,2,2,2,
889 2,5,1,3,3,3,1,1,1,1,1,2,2,1,2,5,1,1,1,3,3,3,1,1,1,3,7,2,2,2,2,2,2,2,2,2,2,
890 2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,7,1,2,7,2,7,2,2,2,2,2,2,2,1,1,5,5,7,1,1,1,1,
891 1,1,1,1,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,7,2,7,1,3,7,2,
892 2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,1,2,2,2,2,2,2,2,2,1,2,2,7,3,3,1,1,10,10,
893 1,1,1,10,10,10,10,10,10,10,8,1,2,7,1,1,1,1,1,1,4,1,1,8,1,2,7,1,1,2,1,10,10,
894 4,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,
895 2,5,7,2,1,2,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,
896 5,5,5,5,5,2,5,7,2,1,2,8,1,1,8,8,8,8,8,8,8,8,1,2,7,2,1,1,1,10,10,4,8,1,1,8,
897 8,8,8,8,8,8,8,1,2,7,1,1,2,1,10,4,1,1,1,8,1,2,7,1,1,1,1,1,5,1,1,5,5,5,5,5,5,
898 5,5,5,5,5,5,5,5,1,2,7,2,1,1,1,1,1,1,2,1,1,5,1,1,5,5,5,5,5,5,5,5,1,2,5,5,7,
899 1,3,2,1,2,2,2,2,2,2,2,1,1,5,1,1,1,3,1,2,1,8,7,1,1,10,5,1,7,1,7,1,1,1,5,2,2,
900 2,2,2,2,2,1,1,7,1,2,2,2,2,2,2,2,2,2,1,1,7,1,2,2,2,7,5,5,5,5,5,5,5,5,5,5,5,
901 5,5,5,5,5,5,5,2,7,2,1,2,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,2,7,2,1,2,1,1,
902 1,5,5,1,1,5,5,5,5,5,5,5,5,5,5,5,5,5,5,1,2,7,2,1,1,3,5,1,1,5,5,5,5,5,5,5,5,
903 5,5,5,5,5,5,1,2,7,2,1,1,3,2,2,2,2,2,2,2,1,1,1,1,1,1,5,1,1,1,3,2,1,1,1,5,1,
904 1,5,5,5,5,5,5,5,5,5,5,5,5,5,5,1,2,7,2,1,1,3,1,2,1,1,2,2,7,4,4,4,4,4,4,4,4,
905 4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,7,1,3,7,5,1,1,5,5,5,5,5,5,5,5,
906 5,1,2,7,1,2,2,1,5,1,1,5,5,5,5,5,5,5,5,1,2,7,1,3,2,1,5,5,5,5,5,5,5,5,5,5,5,
907 5,5,5,5,5,5,5,2,7,2,1,2,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,2,7,2,1,2,10,
908 10,10,10,10,10,10,10,10,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,
909 4,4,4,4,4,4,7,1,1,1,1,8,1,2,7,1,1,1,1,1,5,1,1,5,5,5,5,5,5,5,5,5,5,5,5,5,5,
910 1,2,7,2,1,1,3,5,1,1,1,5,5,5,5,5,5,5,5,1,2,7,1,1,1,1,2,2,2,2,2,2,2,2,1,1,7,
911 1,2,2,1,1,8,8,1,2,7,2,1,1,1,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,
912 10,10,10,10,10,10,10,10,10,10,10,10,10,10,4,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,
913 2,2,2,1,2,2,2,2,2,2,2,3,1,2,2,7,3,3,1,1,1,7,3,1,1,7,1,1,1,1,5,5,5,5,1,7,1,
914 1,5,5,1,2,7,2,1,1,3
915 };
916
917
918 static const unsigned char ag_pstt[] = {
919 2,2,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,3,11,1,0,0,4,5,17,1,
920 12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,
921 12,12,12,12,10,1,
922 13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,
923 13,13,13,13,13,13,13,11,13,13,2,16,1,16,
924 13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,
925 13,13,13,13,13,13,13,11,13,13,3,15,1,15,
926 6,6,7,2,
927 8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,30,5,9,8,
928 13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,
929 13,13,13,13,13,13,13,11,13,13,6,19,1,19,
930 13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,
931 13,13,13,13,13,13,13,11,13,13,7,18,1,18,
932 16,17,11,15,15,15,18,13,13,12,12,12,14,14,10,7,31,31,26,25,24,23,22,21,20,
933 19,14,12,13,15,
934 27,9,27,
935 28,2,2,28,3,11,10,4,28,17,1,
936 29,29,29,29,11,11,29,29,1,29,
937 77,30,30,30,77,77,77,77,77,77,77,77,77,30,11,12,30,30,1,30,83,
938 77,30,30,30,77,77,77,77,77,77,77,77,77,30,11,13,30,30,1,30,86,
939 77,30,30,30,77,77,77,77,77,77,77,77,77,30,11,14,30,30,1,30,79,
940 77,30,30,30,77,77,77,77,77,77,77,77,77,30,11,15,30,30,1,30,91,
941 110,110,110,110,110,110,110,110,110,110,110,110,110,110,110,110,110,110,110,
942 110,110,110,110,110,110,110,110,110,110,110,16,31,
943 30,30,30,77,30,11,17,30,30,1,30,94,
944 77,30,30,30,77,77,77,77,77,77,77,77,30,11,18,30,30,1,30,87,
945 2,2,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,3,11,1,19,4,42,17,1,
946 32,20,33,
947 35,35,35,35,35,35,35,35,35,34,21,36,35,35,
948 35,35,35,35,35,35,35,35,35,34,22,37,35,35,
949 35,35,35,35,35,35,35,35,35,34,23,38,35,35,
950 39,39,39,39,39,39,39,39,39,34,24,40,39,39,
951 41,25,42,
952 172,172,172,172,172,172,172,43,44,26,45,46,161,
953 1,2,2,1,1,1,1,1,1,1,1,47,3,11,1,1,27,4,47,17,1,
954 121,121,28,48,
955 68,68,68,68,11,92,68,68,1,
956 68,68,68,68,11,78,68,68,1,
957 112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,129,51,
958 113,112,53,112,112,112,112,112,52,112,119,31,111,111,50,49,
959 54,30,30,30,54,54,54,54,54,54,30,11,32,30,30,1,30,54,
960 39,39,39,39,39,39,39,39,39,34,33,55,39,39,
961 56,2,2,56,56,56,56,56,56,56,56,3,11,34,4,56,17,1,
962 172,172,172,172,172,172,172,43,44,35,45,101,161,
963 57,57,36,60,36,36,36,36,36,36,36,36,36,36,36,36,36,36,58,11,36,36,22,1,59,
964 60,
965 57,57,36,61,36,36,36,36,36,36,36,36,36,36,36,36,36,36,58,11,36,37,22,1,59,
966 61,
967 57,57,36,62,36,36,36,36,36,36,36,36,36,36,36,36,36,36,58,11,36,38,22,1,59,
968 62,
969 172,172,172,172,172,172,172,43,44,39,45,97,161,
970 2,2,1,64,1,1,1,1,1,1,1,1,1,1,1,1,1,1,3,11,1,40,63,64,17,1,
971 172,66,66,66,172,172,172,172,172,172,70,65,66,11,41,67,66,66,1,72,71,70,69,
972 68,71,70,69,68,64,66,65,65,
973 2,2,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,3,11,1,42,4,33,17,1,
974 74,74,74,74,74,74,74,74,74,74,74,74,74,73,74,74,74,74,74,74,74,74,74,74,74,
975 43,74,
976 75,75,75,75,75,75,75,75,75,75,75,75,75,73,75,75,75,75,75,75,75,75,75,75,75,
977 44,75,
978 173,173,174,173,173,173,173,173,173,160,
979 2,2,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,3,11,1,46,4,32,17,1,
980 76,76,76,76,76,76,76,76,76,16,3,3,47,76,76,
981 122,122,74,
982 120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,120,
983 120,120,120,120,120,120,120,120,120,120,118,49,
984 131,131,131,131,131,131,131,131,131,131,131,131,131,77,117,131,131,131,131,
985 131,131,131,131,131,131,50,130,
986 125,125,125,125,125,125,125,125,125,125,125,125,125,78,125,125,125,125,125,
987 125,125,125,125,125,125,51,79,
988 123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,
989 123,123,123,123,123,123,123,123,123,123,123,52,80,
990 77,30,30,30,77,77,77,77,77,77,77,77,77,77,77,77,77,77,77,77,77,77,77,77,77,
991 77,77,30,11,77,77,53,30,30,1,30,106,
992 172,172,172,172,172,172,172,54,81,
993 2,2,1,82,1,1,1,1,1,1,1,1,1,1,1,1,1,1,3,11,1,55,63,82,17,1,
994 172,172,172,172,172,172,172,43,44,56,45,83,161,
995 13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,
996 13,13,13,13,13,13,13,13,13,13,13,11,13,57,21,1,21,
997 13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,
998 13,13,13,13,13,13,13,13,13,13,13,11,13,58,20,1,20,
999 172,121,85,85,172,172,172,172,172,172,121,43,44,86,37,45,102,84,161,
1000 87,40,
1001 87,39,
1002 87,38,
1003 172,121,6,6,172,172,172,172,172,172,121,43,44,7,2,45,98,88,161,
1004 89,35,
1005 70,73,72,
1006 68,68,68,68,11,69,68,68,1,
1007 173,173,174,173,173,173,173,173,173,66,
1008 172,66,66,66,172,172,172,172,172,172,70,66,11,63,67,66,66,1,47,51,55,66,65,
1009 65,
1010 172,66,66,66,172,172,172,172,172,172,65,66,11,62,67,66,66,1,46,50,58,66,
1011 172,172,172,172,172,172,172,70,65,61,67,45,53,57,65,65,
1012 66,66,66,70,65,66,11,60,66,66,1,48,52,56,66,65,65,
1013 43,72,
1014 170,170,170,170,170,169,168,167,166,165,170,170,175,170,170,170,170,170,170,
1015 170,170,170,170,170,170,73,90,
1016 163,74,
1017 162,75,
1018 172,172,172,172,172,172,172,43,44,136,136,76,45,95,91,93,94,94,95,92,161,
1019 132,132,132,132,132,132,132,132,132,132,132,132,132,132,132,132,132,132,132,
1020 132,132,132,132,132,132,77,
1021 127,78,96,
1022 116,79,
1023 112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,129,51,
1024 113,112,112,112,112,112,112,115,52,112,119,80,124,124,50,49,
1025 173,173,30,30,30,174,173,173,173,173,173,173,97,30,11,81,30,30,1,30,97,
1026 89,41,
1027 2,2,98,3,11,83,4,98,17,1,
1028 122,122,104,
1029 13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,
1030 13,13,13,13,13,13,13,13,13,13,13,11,13,85,24,1,24,
1031 13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,
1032 13,13,13,13,13,13,13,13,13,13,13,11,13,86,23,1,23,
1033 100,57,57,100,100,100,100,100,100,100,100,58,11,87,22,1,99,100,
1034 122,122,100,
1035 101,2,2,101,101,101,101,101,101,101,101,3,11,89,4,101,17,1,
1036 176,171,
1037 30,30,30,102,30,11,91,30,30,1,30,102,
1038 146,103,103,146,146,146,146,146,146,146,146,146,146,146,146,146,146,104,11,
1039 92,27,1,105,110,110,109,108,148,107,106,
1040 1,2,2,1,1,1,1,1,1,1,1,3,11,1,1,93,4,133,17,1,
1041 172,172,172,172,172,172,172,43,44,137,45,91,93,135,92,161,
1042 111,112,95,111,112,
1043 128,126,
1044 113,97,
1045 114,98,
1046 85,85,86,37,
1047 172,172,172,172,172,172,172,43,44,100,45,103,161,
1048 172,172,172,172,172,172,172,43,44,101,45,99,161,
1049 140,102,
1050 13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,11,103,26,1,26,
1051 13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,11,104,25,1,25,
1052 115,115,116,147,
1053 36,57,57,36,36,36,36,36,36,36,36,36,36,36,36,36,36,58,11,106,22,1,99,150,
1054 36,57,57,36,36,36,36,36,36,36,36,36,36,36,36,36,36,58,11,107,22,1,99,149,
1055 172,172,172,172,172,172,172,121,121,43,44,119,118,144,117,120,120,145,153,
1056 123,122,121,
1057 146,103,103,146,146,146,146,146,146,146,146,146,146,146,146,146,146,104,11,
1058 109,27,1,105,142,108,148,107,106,
1059 143,139,110,
1060 179,179,179,179,179,179,179,179,179,179,179,179,179,179,179,179,179,179,179,
1061 179,179,179,179,179,179,179,179,179,179,179,111,124,
1062 5,112,
1063 1,2,2,1,1,1,1,1,1,1,1,1,3,11,113,4,93,17,1,
1064 1,2,2,1,1,1,1,1,1,1,1,3,11,114,4,105,17,1,
1065 13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,11,115,29,1,29,
1066 13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,11,116,28,1,28,
1067 173,173,174,173,173,173,173,173,173,152,
1068 110,110,110,110,110,110,110,110,110,110,110,110,110,110,110,110,110,110,110,
1069 110,110,110,110,110,110,110,110,110,110,110,118,125,
1070 30,30,30,126,30,11,119,30,30,1,30,126,
1071 36,57,57,36,36,36,36,36,36,36,36,36,36,36,36,36,36,58,11,120,22,1,99,151,
1072 77,30,30,30,77,77,77,77,77,77,77,77,30,11,121,30,30,1,30,159,
1073 172,172,172,172,172,172,172,43,44,122,45,156,161,
1074 57,57,127,127,58,11,123,22,1,128,127,
1075 180,180,180,180,180,180,180,180,180,180,180,180,180,180,180,180,180,180,180,
1076 180,180,180,180,180,180,180,180,180,180,178,
1077 112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,112,129,51,
1078 113,112,112,112,112,112,112,109,52,112,119,125,111,111,50,49,
1079 118,126,108,
1080 119,118,127,129,129,
1081 85,85,154,37,154,37,86,128,
1082 57,57,36,36,58,11,129,22,1,99,155,
1083
1084 };
1085
1086
1087 static const unsigned short ag_sbt[] = {
1088 0, 26, 57, 96, 135, 139, 158, 197, 236, 266, 269, 280, 290, 311,
1089 332, 353, 374, 406, 418, 438, 463, 466, 480, 494, 508, 522, 525, 538,
1090 559, 563, 572, 581, 616, 634, 648, 666, 679, 705, 731, 757, 770, 796,
1091 828, 853, 880, 907, 917, 942, 957, 960, 991,1018,1045,1077,1114,1123,
1092 1149,1162,1204,1246,1265,1267,1269,1271,1290,1292,1295,1304,1314,1338,
1093 1360,1376,1393,1395,1422,1424,1426,1447,1473,1476,1478,1513,1534,1536,
1094 1546,1549,1591,1633,1651,1654,1672,1674,1686,1716,1736,1752,1757,1759,
1095 1761,1763,1767,1780,1793,1795,1818,1841,1845,1869,1893,1915,1943,1946,
1096 1978,1980,1999,2017,2040,2063,2073,2105,2117,2141,2161,2174,2185,2215,
1097 2250,2253,2258,2266,2277
1098 };
1099
1100
1101 static const unsigned short ag_sbe[] = {
1102 20, 56, 92, 131, 138, 155, 193, 232, 251, 267, 275, 285, 305, 326,
1103 347, 368, 404, 412, 432, 458, 464, 476, 490, 504, 518, 523, 534, 554,
1104 561, 568, 577, 611, 628, 644, 661, 675, 700, 726, 752, 766, 791, 810,
1105 848, 878, 905, 916, 937, 954, 959, 990,1016,1043,1075,1108,1121,1144,
1106 1158,1200,1242,1260,1266,1268,1270,1285,1291,1293,1300,1313,1327,1351,
1107 1369,1383,1394,1420,1423,1425,1437,1472,1474,1477,1508,1528,1535,1541,
1108 1548,1587,1629,1646,1653,1667,1673,1680,1705,1731,1745,1754,1758,1760,
1109 1762,1766,1776,1789,1794,1814,1837,1844,1864,1888,1906,1934,1945,1976,
1110 1979,1994,2012,2036,2059,2072,2103,2111,2136,2155,2170,2180,2214,2245,
1111 2251,2255,2265,2272,2277
1112 };
1113
1114
1115 static const unsigned char ag_fl[] = {
1116 1,0,1,0,1,8,1,1,1,1,2,1,2,0,1,2,2,1,3,3,2,2,1,3,3,2,2,1,3,3,0,2,3,3,1,
1117 3,0,1,3,3,3,4,2,3,1,2,2,2,2,1,2,2,2,2,1,2,2,2,2,1,1,1,1,1,1,1,1,1,2,1,
1118 1,1,2,1,3,1,1,0,1,2,1,1,1,2,1,1,2,2,1,1,1,2,2,6,2,0,1,2,3,5,3,2,3,5,3,
1119 6,4,1,3,3,0,2,1,1,1,3,3,2,2,1,2,1,2,0,2,1,2,1,2,1,2,1,2,2,1,2,0,1,1,3,
1120 3,1,2,2,1,2,0,1,1,2,2,3,2,2,2,4,2,1,1,2,1,1,3,3,1,2,2,2,2,2,2,2,1,2,2,
1121 1,2,0,2,0,2
1122 };
1123
1124 static const unsigned char ag_ptt[] = {
1125 0, 4, 4, 8, 8, 2, 6, 5, 14, 14, 16, 17, 17, 22, 22, 3, 3, 3,
1126 3, 3, 24, 24, 24, 24, 24, 25, 25, 25, 25, 25, 13, 13, 26, 26, 26, 26,
1127 35, 35, 26, 26, 26, 26, 26, 30, 48, 48, 48, 48, 49, 49, 49, 49, 50, 50,
1128 50, 50, 51, 51, 51, 51, 52, 52, 52, 52, 42, 47, 44, 54, 54, 45, 56, 57,
1129 57, 46, 40, 62, 62, 63, 63, 33, 67, 67, 67, 37, 70, 70, 36, 27, 75, 75,
1130 75, 31, 38, 39, 29, 81, 81, 32, 32, 32, 32, 34, 34, 34, 34, 80, 7, 86,
1131 86, 87, 84, 84, 89, 89, 89, 89, 89, 89, 92, 98, 98, 59, 59, 93, 93, 95,
1132 95,102,102, 96, 96,104,104,108,109,109,110,110, 9,107,111,112,112,115,
1133 114,114,119,119,117,117,117,117,120,121,118,118,123,127,127,124, 28, 28,
1134 122,122,128,128,128,128,128,128,128,128, 1, 1, 1,135,135, 10, 10,139,
1135 139
1136 };
1137
1138
1139 static void ag_ra(void)
1140 {
1141 switch(ag_rpx[(PCB).ag_ap]) {
1142 case 1: ag_rp_1(); break;
1143 case 2: ag_rp_2(); break;
1144 case 3: ag_rp_3(); break;
1145 case 4: ag_rp_4(VS(1)); break;
1146 case 5: ag_rp_5(); break;
1147 case 6: ag_rp_6(); break;
1148 case 7: ag_rp_7(); break;
1149 case 8: ag_rp_8(); break;
1150 case 9: ag_rp_9(); break;
1151 case 10: ag_rp_10(VS(0)); break;
1152 case 11: ag_rp_11(VS(0)); break;
1153 case 12: ag_rp_12(); break;
1154 case 13: ag_rp_13(VS(1)); break;
1155 case 14: ag_rp_14(VS(1)); break;
1156 case 15: ag_rp_15(VS(0)); break;
1157 case 16: ag_rp_16(VS(0)); break;
1158 case 17: ag_rp_17(); break;
1159 case 18: ag_rp_18(VS(1)); break;
1160 case 19: ag_rp_19(VS(1)); break;
1161 case 20: ag_rp_20(); break;
1162 case 21: ag_rp_21(); break;
1163 case 22: ag_rp_22(); break;
1164 case 23: ag_rp_23(); break;
1165 case 24: ag_rp_24(); break;
1166 case 25: ag_rp_25(); break;
1167 case 26: ag_rp_26(); break;
1168 case 27: ag_rp_27(); break;
1169 case 28: ag_rp_28(); break;
1170 case 29: ag_rp_29(); break;
1171 case 30: ag_rp_30(); break;
1172 case 31: ag_rp_31(); break;
1173 case 32: ag_rp_32(); break;
1174 case 33: ag_rp_33(VS(2)); break;
1175 case 34: ag_rp_34(); break;
1176 case 35: ag_rp_35(); break;
1177 case 36: ag_rp_36(); break;
1178 case 37: ag_rp_37(); break;
1179 case 38: ag_rp_38(); break;
1180 case 39: ag_rp_39(); break;
1181 case 40: ag_rp_40(); break;
1182 case 41: ag_rp_41(VS(2)); break;
1183 case 42: ag_rp_42(); break;
1184 case 43: ag_rp_43(); break;
1185 case 44: ag_rp_44(); break;
1186 case 45: ag_rp_45(VS(2)); break;
1187 case 46: ag_rp_46(); break;
1188 case 47: ag_rp_47(); break;
1189 case 48: ag_rp_48(VS(0)); break;
1190 case 49: ag_rp_49(); break;
1191 case 50: ag_rp_50(); break;
1192 case 51: ag_rp_51(); break;
1193 case 52: ag_rp_52(); break;
1194 case 53: ag_rp_53(); break;
1195 case 54: ag_rp_54(VS(1)); break;
1196 case 55: VS(0) = ag_rp_55(VS(0)); break;
1197 case 56: VS(0) = ag_rp_56(VS(0), VS(1)); break;
1198 case 57: ag_rp_57(); break;
1199 case 58: ag_rp_58(VS(0)); break;
1200 case 59: ag_rp_59(VS(0)); break;
1201 case 60: ag_rp_60(VS(1)); break;
1202 case 61: ag_rp_61(); break;
1203 case 62: ag_rp_62(VS(0)); break;
1204 case 63: ag_rp_63(VS(1)); break;
1205 case 64: ag_rp_64(); break;
1206 case 65: ag_rp_65(); break;
1207 case 66: ag_rp_66(); break;
1208 case 67: ag_rp_67(); break;
1209 case 68: ag_rp_68(); break;
1210 case 69: ag_rp_69(VS(1)); break;
1211 case 70: ag_rp_70(); break;
1212 case 71: ag_rp_71(); break;
1213 case 72: ag_rp_72(VS(0)); break;
1214 case 73: VS(0) = ag_rp_73(VS(1)); break;
1215 case 74: VS(0) = ag_rp_74(VS(1)); break;
1216 case 75: VS(0) = ag_rp_75(); break;
1217 case 76: VS(0) = ag_rp_76(); break;
1218 case 77: VS(0) = ag_rp_77(); break;
1219 case 78: VS(0) = ag_rp_78(); break;
1220 case 79: VS(0) = ag_rp_79(); break;
1221 case 80: VS(0) = ag_rp_80(VS(1)); break;
1222 case 81: VS(0) = ag_rp_81(VS(1)); break;
1223 case 82: ag_rp_82(VS(0)); break;
1224 case 83: ag_rp_83(VS(1)); break;
1225 case 84: ag_rp_84(); break;
1226 case 85: VS(0) = ag_rp_85(VS(0)); break;
1227 case 86: VS(0) = ag_rp_86(VS(0), VS(1)); break;
1228 case 87: ag_rp_87(); break;
1229 case 88: ag_rp_88(); break;
1230 case 89: ag_rp_89(VS(1)); break;
1231 }
1232 }
1233
1234 #define TOKEN_NAMES y2ag_token_names
1235 const char *const y2ag_token_names[147] = {
1236 "grammar",
1237 "name",
1238 "grammar",
1239 "elc",
1240 "",
1241 "definition block",
1242 "mark",
1243 "c code block",
1244 "",
1245 "rule section",
1246 "tail",
1247 "eof",
1248 "\"%%\"",
1249 "definitions",
1250 "white",
1251 "",
1252 "comment",
1253 "comment text",
1254 "\"*/\"",
1255 "\"/*\"",
1256 "anything",
1257 "",
1258 "",
1259 "",
1260 "blc",
1261 "clc",
1262 "definition",
1263 "start",
1264 "identifier",
1265 "union",
1266 "union text",
1267 "token",
1268 "print token list",
1269 "left",
1270 "print prec list",
1271 "",
1272 "right",
1273 "nonassoc",
1274 "type",
1275 "type name",
1276 "expect statement",
1277 "'{'",
1278 "decl",
1279 "'}'",
1280 "decl name",
1281 "decl white",
1282 "decl star",
1283 "decl term",
1284 "",
1285 "",
1286 "",
1287 "",
1288 "",
1289 "';'",
1290 "",
1291 "'*'",
1292 "",
1293 "",
1294 "\"%expect\"",
1295 "number",
1296 "\"%left\"",
1297 "\"%<\"",
1298 "",
1299 "",
1300 "\"%nonassoc\"",
1301 "\"%binary\"",
1302 "\"%2\"",
1303 "",
1304 "\"%right\"",
1305 "\"%>\"",
1306 "",
1307 "\"%start\"",
1308 "\"%token\"",
1309 "\"%term\"",
1310 "\"%0\"",
1311 "",
1312 "\"%type\"",
1313 "'<'",
1314 "'>'",
1315 "\"%union\"",
1316 "tag",
1317 "",
1318 "','",
1319 "\"%{\"",
1320 "c text",
1321 "\"%}\"",
1322 "action",
1323 "embedded c",
1324 "'='",
1325 "c char",
1326 "simple c char",
1327 "'$'",
1328 "c code comment",
1329 "nested c text",
1330 "'\\''",
1331 "c literal character",
1332 "literal string",
1333 "'\\\"'",
1334 "c code comment text",
1335 "digit",
1336 "",
1337 "'\\\\'",
1338 "octal digits",
1339 "",
1340 "string character",
1341 "",
1342 "",
1343 "production",
1344 "",
1345 "",
1346 "",
1347 "production head",
1348 "complete rules",
1349 "':'",
1350 "complete rule",
1351 "rule set continuation",
1352 "'|'",
1353 "rule",
1354 "explicit precedence",
1355 "",
1356 "rule name continuation",
1357 "rule literal continuation",
1358 "literal",
1359 "explicit precedence head",
1360 "prec",
1361 "\"%prec\"",
1362 "\"%=\"",
1363 "",
1364 "literal character",
1365 "'n'",
1366 "'r'",
1367 "'b'",
1368 "'t'",
1369 "'f'",
1370 "",
1371 "octal number",
1372 "",
1373 "",
1374 "dot",
1375 "tail code",
1376 "",
1377 "",
1378 "",
1379 "",
1380 "",
1381 "",
1382 "",
1383
1384 };
1385
1386 #ifndef MISSING_FORMAT
1387 #define MISSING_FORMAT "Missing %s"
1388 #endif
1389 #ifndef UNEXPECTED_FORMAT
1390 #define UNEXPECTED_FORMAT "Unexpected %s"
1391 #endif
1392 #ifndef UNNAMED_TOKEN
1393 #define UNNAMED_TOKEN "input"
1394 #endif
1395
1396
1397 static void ag_diagnose(void) {
1398 int ag_snd = (PCB).sn;
1399 int ag_k = ag_sbt[ag_snd];
1400
1401 if (*TOKEN_NAMES[ag_tstt[ag_k]] && ag_astt[ag_k + 1] == ag_action_8) {
1402 sprintf((PCB).ag_msg, MISSING_FORMAT, TOKEN_NAMES[ag_tstt[ag_k]]);
1403 }
1404 else if (ag_astt[ag_sbe[(PCB).sn]] == ag_action_8
1405 && (ag_k = (int) ag_sbe[(PCB).sn] + 1) == (int) ag_sbt[(PCB).sn+1] - 1
1406 && *TOKEN_NAMES[ag_tstt[ag_k]]) {
1407 sprintf((PCB).ag_msg, MISSING_FORMAT, TOKEN_NAMES[ag_tstt[ag_k]]);
1408 }
1409 else if ((PCB).token_number && *TOKEN_NAMES[(PCB).token_number]) {
1410 sprintf((PCB).ag_msg, UNEXPECTED_FORMAT, TOKEN_NAMES[(PCB).token_number]);
1411 }
1412 else if (isprint((*(PCB).lab)) && (*(PCB).lab) != '\\') {
1413 char buf[20];
1414 sprintf(buf, "\'%c\'", (char) (*(PCB).lab));
1415 sprintf((PCB).ag_msg, UNEXPECTED_FORMAT, buf);
1416 }
1417 else sprintf((PCB).ag_msg, UNEXPECTED_FORMAT, UNNAMED_TOKEN);
1418 (PCB).error_message = (PCB).ag_msg;
1419
1420
1421 }
1422 static int ag_action_1_r_proc(void);
1423 static int ag_action_2_r_proc(void);
1424 static int ag_action_3_r_proc(void);
1425 static int ag_action_4_r_proc(void);
1426 static int ag_action_1_s_proc(void);
1427 static int ag_action_3_s_proc(void);
1428 static int ag_action_1_proc(void);
1429 static int ag_action_2_proc(void);
1430 static int ag_action_3_proc(void);
1431 static int ag_action_4_proc(void);
1432 static int ag_action_5_proc(void);
1433 static int ag_action_6_proc(void);
1434 static int ag_action_7_proc(void);
1435 static int ag_action_8_proc(void);
1436 static int ag_action_9_proc(void);
1437 static int ag_action_10_proc(void);
1438 static int ag_action_11_proc(void);
1439 static int ag_action_8_proc(void);
1440
1441
1442 static int (*const ag_r_procs_scan[])(void) = {
1443 ag_action_1_r_proc,
1444 ag_action_2_r_proc,
1445 ag_action_3_r_proc,
1446 ag_action_4_r_proc
1447 };
1448
1449 static int (*const ag_s_procs_scan[])(void) = {
1450 ag_action_1_s_proc,
1451 ag_action_2_r_proc,
1452 ag_action_3_s_proc,
1453 ag_action_4_r_proc
1454 };
1455
1456 static int (*const ag_gt_procs_scan[])(void) = {
1457 ag_action_1_proc,
1458 ag_action_2_proc,
1459 ag_action_3_proc,
1460 ag_action_4_proc,
1461 ag_action_5_proc,
1462 ag_action_6_proc,
1463 ag_action_7_proc,
1464 ag_action_8_proc,
1465 ag_action_9_proc,
1466 ag_action_10_proc,
1467 ag_action_11_proc,
1468 ag_action_8_proc
1469 };
1470
1471
1472 static int ag_action_10_proc(void) {
1473 int ag_t = (PCB).token_number;
1474 (PCB).btsx = 0, (PCB).drt = -1;
1475 do {
1476 ag_track();
1477 if ((PCB).rx < (PCB).fx) {
1478 (PCB).input_code = (PCB).lab[(PCB).rx++];
1479 (PCB).token_number = (y2ag_token_type) AG_TCV((PCB).input_code);}
1480 else {
1481 GET_INPUT;
1482 (PCB).lab[(PCB).fx++] = (PCB).input_code;
1483 (PCB).token_number = (y2ag_token_type) AG_TCV((PCB).input_code);
1484 (PCB).rx++;
1485 }
1486 if (ag_key_index[(PCB).sn]) {
1487 unsigned ag_k = ag_key_index[(PCB).sn];
1488 int ag_ch = CONVERT_CASE((PCB).input_code);
1489 if (ag_ch < 255) {
1490 while (ag_key_ch[ag_k] < ag_ch) ag_k++;
1491 if (ag_key_ch[ag_k] == ag_ch) ag_get_key_word(ag_k);
1492 }
1493 }
1494 } while ((PCB).token_number == (y2ag_token_type) ag_t);
1495 (PCB).rx = 0;
1496 return 1;
1497 }
1498
1499 static int ag_action_11_proc(void) {
1500 int ag_t = (PCB).token_number;
1501
1502 (PCB).btsx = 0, (PCB).drt = -1;
1503 do {
1504 (PCB).vs[(PCB).ssx] = *(PCB).lab;
1505 (PCB).ssx--;
1506 ag_track();
1507 ag_ra();
1508 if ((PCB).exit_flag != AG_RUNNING_CODE) return 0;
1509 (PCB).ssx++;
1510 if ((PCB).rx < (PCB).fx) {
1511 (PCB).input_code = (PCB).lab[(PCB).rx++];
1512 (PCB).token_number = (y2ag_token_type) AG_TCV((PCB).input_code);}
1513 else {
1514 GET_INPUT;
1515 (PCB).lab[(PCB).fx++] = (PCB).input_code;
1516 (PCB).token_number = (y2ag_token_type) AG_TCV((PCB).input_code);
1517 (PCB).rx++;
1518 }
1519 if (ag_key_index[(PCB).sn]) {
1520 unsigned ag_k = ag_key_index[(PCB).sn];
1521 int ag_ch = CONVERT_CASE((PCB).input_code);
1522 if (ag_ch < 255) {
1523 while (ag_key_ch[ag_k] < ag_ch) ag_k++;
1524 if (ag_key_ch[ag_k] == ag_ch) ag_get_key_word(ag_k);
1525 }
1526 }
1527 }
1528 while ((PCB).token_number == (y2ag_token_type) ag_t);
1529 (PCB).rx = 0;
1530 return 1;
1531 }
1532
1533 static int ag_action_3_r_proc(void) {
1534 int ag_sd = ag_fl[(PCB).ag_ap] - 1;
1535 if (ag_sd) (PCB).sn = (PCB).ss[(PCB).ssx -= ag_sd];
1536 (PCB).btsx = 0, (PCB).drt = -1;
1537 (PCB).reduction_token = (y2ag_token_type) ag_ptt[(PCB).ag_ap];
1538 ag_ra();
1539 return (PCB).exit_flag == AG_RUNNING_CODE;
1540 }
1541
1542 static int ag_action_3_s_proc(void) {
1543 int ag_sd = ag_fl[(PCB).ag_ap] - 1;
1544 if (ag_sd) (PCB).sn = (PCB).ss[(PCB).ssx -= ag_sd];
1545 (PCB).btsx = 0, (PCB).drt = -1;
1546 (PCB).reduction_token = (y2ag_token_type) ag_ptt[(PCB).ag_ap];
1547 ag_ra();
1548 return (PCB).exit_flag == AG_RUNNING_CODE;
1549 }
1550
1551 static int ag_action_4_r_proc(void) {
1552 int ag_sd = ag_fl[(PCB).ag_ap] - 1;
1553 if (ag_sd) (PCB).sn = (PCB).ss[(PCB).ssx -= ag_sd];
1554 (PCB).reduction_token = (y2ag_token_type) ag_ptt[(PCB).ag_ap];
1555 return 1;
1556 }
1557
1558 static int ag_action_2_proc(void) {
1559 (PCB).btsx = 0, (PCB).drt = -1;
1560 if ((PCB).ssx >= 128) {
1561 (PCB).exit_flag = AG_STACK_ERROR_CODE;
1562 PARSER_STACK_OVERFLOW;
1563 }
1564 (PCB).vs[(PCB).ssx] = *(PCB).lab;
1565 (PCB).ss[(PCB).ssx] = (PCB).sn;
1566 (PCB).ssx++;
1567 (PCB).sn = (PCB).ag_ap;
1568 ag_track();
1569 return 0;
1570 }
1571
1572 static int ag_action_9_proc(void) {
1573 if ((PCB).drt == -1) {
1574 (PCB).drt=(PCB).token_number;
1575 (PCB).dssx=(PCB).ssx;
1576 (PCB).dsn=(PCB).sn;
1577 }
1578 ag_prot();
1579 (PCB).vs[(PCB).ssx] = ag_null_value;
1580 (PCB).ss[(PCB).ssx] = (PCB).sn;
1581 (PCB).ssx++;
1582 (PCB).sn = (PCB).ag_ap;
1583 (PCB).rx = 0;
1584 return (PCB).exit_flag == AG_RUNNING_CODE;
1585 }
1586
1587 static int ag_action_2_r_proc(void) {
1588 (PCB).ssx++;
1589 (PCB).sn = (PCB).ag_ap;
1590 return 0;
1591 }
1592
1593 static int ag_action_7_proc(void) {
1594 --(PCB).ssx;
1595 (PCB).rx = 0;
1596 (PCB).exit_flag = AG_SUCCESS_CODE;
1597 return 0;
1598 }
1599
1600 static int ag_action_1_proc(void) {
1601 ag_track();
1602 (PCB).exit_flag = AG_SUCCESS_CODE;
1603 return 0;
1604 }
1605
1606 static int ag_action_1_r_proc(void) {
1607 (PCB).exit_flag = AG_SUCCESS_CODE;
1608 return 0;
1609 }
1610
1611 static int ag_action_1_s_proc(void) {
1612 (PCB).exit_flag = AG_SUCCESS_CODE;
1613 return 0;
1614 }
1615
1616 static int ag_action_4_proc(void) {
1617 int ag_sd = ag_fl[(PCB).ag_ap] - 1;
1618 (PCB).reduction_token = (y2ag_token_type) ag_ptt[(PCB).ag_ap];
1619 (PCB).btsx = 0, (PCB).drt = -1;
1620 (PCB).vs[(PCB).ssx] = *(PCB).lab;
1621 if (ag_sd) (PCB).sn = (PCB).ss[(PCB).ssx -= ag_sd];
1622 else (PCB).ss[(PCB).ssx] = (PCB).sn;
1623 ag_track();
1624 while ((PCB).exit_flag == AG_RUNNING_CODE) {
1625 unsigned ag_t1 = ag_sbe[(PCB).sn] + 1;
1626 unsigned ag_t2 = ag_sbt[(PCB).sn+1] - 1;
1627 do {
1628 unsigned ag_tx = (ag_t1 + ag_t2)/2;
1629 if (ag_tstt[ag_tx] < (unsigned char)(PCB).reduction_token) ag_t1 = ag_tx + 1;
1630 else ag_t2 = ag_tx;
1631 } while (ag_t1 < ag_t2);
1632 (PCB).ag_ap = ag_pstt[ag_t1];
1633 if ((ag_s_procs_scan[ag_astt[ag_t1]])() == 0) break;
1634 }
1635 return 0;
1636 }
1637
1638 static int ag_action_3_proc(void) {
1639 int ag_sd = ag_fl[(PCB).ag_ap] - 1;
1640 (PCB).btsx = 0, (PCB).drt = -1;
1641 (PCB).vs[(PCB).ssx] = *(PCB).lab;
1642 if (ag_sd) (PCB).sn = (PCB).ss[(PCB).ssx -= ag_sd];
1643 else (PCB).ss[(PCB).ssx] = (PCB).sn;
1644 ag_track();
1645 (PCB).reduction_token = (y2ag_token_type) ag_ptt[(PCB).ag_ap];
1646 ag_ra();
1647 while ((PCB).exit_flag == AG_RUNNING_CODE) {
1648 unsigned ag_t1 = ag_sbe[(PCB).sn] + 1;
1649 unsigned ag_t2 = ag_sbt[(PCB).sn+1] - 1;
1650 do {
1651 unsigned ag_tx = (ag_t1 + ag_t2)/2;
1652 if (ag_tstt[ag_tx] < (unsigned char)(PCB).reduction_token) ag_t1 = ag_tx + 1;
1653 else ag_t2 = ag_tx;
1654 } while (ag_t1 < ag_t2);
1655 (PCB).ag_ap = ag_pstt[ag_t1];
1656 if ((ag_s_procs_scan[ag_astt[ag_t1]])() == 0) break;
1657 }
1658 return 0;
1659 }
1660
1661 static int ag_action_8_proc(void) {
1662 ag_undo();
1663 (PCB).rx = 0;
1664 (PCB).exit_flag = AG_SYNTAX_ERROR_CODE;
1665 ag_diagnose();
1666 SYNTAX_ERROR;
1667 {(PCB).rx = 1; ag_track();}
1668 return (PCB).exit_flag == AG_RUNNING_CODE;
1669 }
1670
1671 static int ag_action_5_proc(void) {
1672 int ag_sd = ag_fl[(PCB).ag_ap];
1673 (PCB).btsx = 0, (PCB).drt = -1;
1674 if (ag_sd) (PCB).sn = (PCB).ss[(PCB).ssx -= ag_sd];
1675 else {
1676 (PCB).ss[(PCB).ssx] = (PCB).sn;
1677 }
1678 (PCB).rx = 0;
1679 (PCB).reduction_token = (y2ag_token_type) ag_ptt[(PCB).ag_ap];
1680 ag_ra();
1681 while ((PCB).exit_flag == AG_RUNNING_CODE) {
1682 unsigned ag_t1 = ag_sbe[(PCB).sn] + 1;
1683 unsigned ag_t2 = ag_sbt[(PCB).sn+1] - 1;
1684 do {
1685 unsigned ag_tx = (ag_t1 + ag_t2)/2;
1686 if (ag_tstt[ag_tx] < (unsigned char)(PCB).reduction_token) ag_t1 = ag_tx + 1;
1687 else ag_t2 = ag_tx;
1688 } while (ag_t1 < ag_t2);
1689 (PCB).ag_ap = ag_pstt[ag_t1];
1690 if ((ag_r_procs_scan[ag_astt[ag_t1]])() == 0) break;
1691 }
1692 return (PCB).exit_flag == AG_RUNNING_CODE;
1693 }
1694
1695 static int ag_action_6_proc(void) {
1696 int ag_sd = ag_fl[(PCB).ag_ap];
1697 (PCB).reduction_token = (y2ag_token_type) ag_ptt[(PCB).ag_ap];
1698 if ((PCB).drt == -1) {
1699 (PCB).drt=(PCB).token_number;
1700 (PCB).dssx=(PCB).ssx;
1701 (PCB).dsn=(PCB).sn;
1702 }
1703 if (ag_sd) {
1704 (PCB).sn = (PCB).ss[(PCB).ssx -= ag_sd];
1705 }
1706 else {
1707 ag_prot();
1708 (PCB).vs[(PCB).ssx] = ag_null_value;
1709 (PCB).ss[(PCB).ssx] = (PCB).sn;
1710 }
1711 (PCB).rx = 0;
1712 while ((PCB).exit_flag == AG_RUNNING_CODE) {
1713 unsigned ag_t1 = ag_sbe[(PCB).sn] + 1;
1714 unsigned ag_t2 = ag_sbt[(PCB).sn+1] - 1;
1715 do {
1716 unsigned ag_tx = (ag_t1 + ag_t2)/2;
1717 if (ag_tstt[ag_tx] < (unsigned char)(PCB).reduction_token) ag_t1 = ag_tx + 1;
1718 else ag_t2 = ag_tx;
1719 } while (ag_t1 < ag_t2);
1720 (PCB).ag_ap = ag_pstt[ag_t1];
1721 if ((ag_r_procs_scan[ag_astt[ag_t1]])() == 0) break;
1722 }
1723 return (PCB).exit_flag == AG_RUNNING_CODE;
1724 }
1725
1726
1727 void init_y2ag(void) {
1728 (PCB).rx = (PCB).fx = 0;
1729 (PCB).ss[0] = (PCB).sn = (PCB).ssx = 0;
1730 (PCB).exit_flag = AG_RUNNING_CODE;
1731 (PCB).line = FIRST_LINE;
1732 (PCB).column = FIRST_COLUMN;
1733 (PCB).btsx = 0, (PCB).drt = -1;
1734 }
1735
1736 void y2ag(void) {
1737 init_y2ag();
1738 (PCB).exit_flag = AG_RUNNING_CODE;
1739 while ((PCB).exit_flag == AG_RUNNING_CODE) {
1740 unsigned ag_t1 = ag_sbt[(PCB).sn];
1741 if (ag_tstt[ag_t1]) {
1742 unsigned ag_t2 = ag_sbe[(PCB).sn] - 1;
1743 if ((PCB).rx < (PCB).fx) {
1744 (PCB).input_code = (PCB).lab[(PCB).rx++];
1745 (PCB).token_number = (y2ag_token_type) AG_TCV((PCB).input_code);}
1746 else {
1747 GET_INPUT;
1748 (PCB).lab[(PCB).fx++] = (PCB).input_code;
1749 (PCB).token_number = (y2ag_token_type) AG_TCV((PCB).input_code);
1750 (PCB).rx++;
1751 }
1752 if (ag_key_index[(PCB).sn]) {
1753 unsigned ag_k = ag_key_index[(PCB).sn];
1754 int ag_ch = CONVERT_CASE((PCB).input_code);
1755 if (ag_ch < 255) {
1756 while (ag_key_ch[ag_k] < ag_ch) ag_k++;
1757 if (ag_key_ch[ag_k] == ag_ch) ag_get_key_word(ag_k);
1758 }
1759 }
1760 do {
1761 unsigned ag_tx = (ag_t1 + ag_t2)/2;
1762 if (ag_tstt[ag_tx] > (unsigned char)(PCB).token_number)
1763 ag_t1 = ag_tx + 1;
1764 else ag_t2 = ag_tx;
1765 } while (ag_t1 < ag_t2);
1766 if (ag_tstt[ag_t1] != (unsigned char)(PCB).token_number)
1767 ag_t1 = ag_sbe[(PCB).sn];
1768 }
1769 (PCB).ag_ap = ag_pstt[ag_t1];
1770 (ag_gt_procs_scan[ag_astt[ag_t1]])();
1771 }
1772 }
1773
1774