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