comparison tests/agcl/ffcalc/good/ffc-w.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 FOUR FUNCTION CALCULATOR: FFCALC.SYN
3 */
4 #include "Number.h"
5
6 int Number::nCreated = 0;
7 char Number::buf[100];
8
9
10 /*
11 * AnaGram, A System for Syntax Directed Programming
12 * File generated by: ...
13 *
14 * AnaGram Parsing Engine
15 * Copyright 1993-2002 Parsifal Software. All Rights Reserved.
16 *
17 * This software is provided 'as-is', without any express or implied
18 * warranty. In no event will the authors be held liable for any damages
19 * arising from the use of this software.
20 *
21 * Permission is granted to anyone to use this software for any purpose,
22 * including commercial applications, and to alter it and redistribute it
23 * freely, subject to the following restrictions:
24 *
25 * 1. The origin of this software must not be misrepresented; you must not
26 * claim that you wrote the original software. If you use this software
27 * in a product, an acknowledgment in the product documentation would be
28 * appreciated but is not required.
29 * 2. Altered source versions must be plainly marked as such, and must not be
30 * misrepresented as being the original software.
31 * 3. This notice may not be removed or altered from any source distribution.
32 */
33
34 #ifndef FFC-W_H
35 #include "ffc-w.h"
36 #endif
37
38 #ifndef FFC-W_H
39 #error Mismatched header file
40 #endif
41
42 #include <ctype.h>
43 #include <stdio.h>
44
45 #define RULE_CONTEXT (&((PCB).cs[(PCB).ssx]))
46 #define ERROR_CONTEXT ((PCB).cs[(PCB).error_frame_ssx])
47 #define CONTEXT ((PCB).cs[(PCB).ssx])
48
49
50
51 ffc-w_pcb_type ffc-w_pcb;
52 #define PCB ffc-w_pcb
53 static void ag_delete_wrappers(void);
54 #ifndef DELETE_WRAPPERS
55 #define DELETE_WRAPPERS ag_delete_wrappers()
56 #endif
57 #define TOKEN_NAMES ffc-w_token_names
58 const char *const ffc-w_token_names[48] = {
59 "calculator",
60 "white space",
61 "real",
62 "calculator",
63 "calculation",
64 "",
65 "'\\n'",
66 "",
67 "",
68 "",
69 "eof",
70 "expression",
71 "name",
72 "'='",
73 "error",
74 "term",
75 "'+'",
76 "'-'",
77 "factor",
78 "'*'",
79 "'/'",
80 "'('",
81 "')'",
82 "",
83 "\"/*\"",
84 "",
85 "",
86 "",
87 "\"*/\"",
88 "",
89 "integer part",
90 "'.'",
91 "fraction part",
92 "",
93 "digit",
94 "",
95 "",
96 "",
97 "'\\n'",
98 "'='",
99 "'+'",
100 "'-'",
101 "'*'",
102 "'/'",
103 "real",
104 "')'",
105 "'('",
106 "",
107
108 };
109
110
111 #line - "ffc-w.syn"
112 /* -- EMBEDDED C ---------------------------------- */
113
114 #define SYNTAX_ERROR printf("%s, line %d, column %d\n", \
115 (PCB).error_message, (PCB).line, (PCB).column)
116
117 Number value[64]; /* registers */
118 int main(void) {
119 ffcalc();
120 return 0;
121 }
122 #line - "ffc-w.cpp"
123
124 #ifndef CONVERT_CASE
125 #define CONVERT_CASE(c) (c)
126 #endif
127 #ifndef TAB_SPACING
128 #define TAB_SPACING 8
129 #endif
130
131 static void ag_rp_1(Number &x) {
132 #line - "ffc-w.syn"
133 printf("%s\n", x.asString());
134 #line - "ffc-w.cpp"
135 }
136
137 static void ag_rp_2(int n, Number &x) {
138 #line - "ffc-w.syn"
139 printf("%c = %s\n",n+'A', (value[n]=x).asString());
140 #line - "ffc-w.cpp"
141 }
142
143 static Number ag_rp_3(Number &x, Number &t) {
144 #line - "ffc-w.syn"
145 printf("x = %s\n", x.asString());
146 printf("t = %s\n", t.asString());
147 x+=t;
148 printf("x = %s\n", x.asString());
149 return x;
150
151 #line - "ffc-w.cpp"
152 }
153
154 static Number ag_rp_4(Number &x, Number &t) {
155 #line - "ffc-w.syn"
156 return x-=t;
157 #line - "ffc-w.cpp"
158 }
159
160 static Number ag_rp_5(Number &t, Number &f) {
161 #line - "ffc-w.syn"
162 return t*=f;
163 #line - "ffc-w.cpp"
164 }
165
166 static Number ag_rp_6(Number &t, Number &f) {
167 #line - "ffc-w.syn"
168 return t/=f;
169 #line - "ffc-w.cpp"
170 }
171
172 static Number ag_rp_7(int n) {
173 #line - "ffc-w.syn"
174 return value[n];
175 #line - "ffc-w.cpp"
176 }
177
178 static Number ag_rp_8(double x) {
179 #line - "ffc-w.syn"
180 return Number(x);
181 #line - "ffc-w.cpp"
182 }
183
184 static Number ag_rp_9(Number &x) {
185 #line - "ffc-w.syn"
186 return x;
187 #line - "ffc-w.cpp"
188 }
189
190 static Number ag_rp_10(Number &f) {
191 #line - "ffc-w.syn"
192 return -f;
193 #line - "ffc-w.cpp"
194 }
195
196 static int ag_rp_11(int c) {
197 #line - "ffc-w.syn"
198 return c-'A';
199 #line - "ffc-w.cpp"
200 }
201
202 static double ag_rp_12(double i, double f) {
203 #line - "ffc-w.syn"
204 return i+f;
205 #line - "ffc-w.cpp"
206 }
207
208 static double ag_rp_13(double f) {
209 #line - "ffc-w.syn"
210 return f;
211 #line - "ffc-w.cpp"
212 }
213
214 static double ag_rp_14(int d) {
215 #line - "ffc-w.syn"
216 return d-'0';
217 #line - "ffc-w.cpp"
218 }
219
220 static double ag_rp_15(double x, int d) {
221 #line - "ffc-w.syn"
222 return 10*x + d-'0';
223 #line - "ffc-w.cpp"
224 }
225
226 static double ag_rp_16(int d) {
227 #line - "ffc-w.syn"
228 return (d-'0')/10.;
229 #line - "ffc-w.cpp"
230 }
231
232 static double ag_rp_17(int d, double f) {
233 #line - "ffc-w.syn"
234 return (d-'0' + f)/10.;
235 #line - "ffc-w.cpp"
236 }
237
238
239 #define READ_COUNTS
240 #define WRITE_COUNTS
241 #undef V
242 #define V(i,t) (*t (&(PCB).vs[(PCB).ssx + i]))
243 #undef VS
244 #define VS(i) (PCB).vs[(PCB).ssx + i]
245
246 #ifndef GET_CONTEXT
247 #define GET_CONTEXT CONTEXT = (PCB).input_context
248 #endif
249
250 typedef enum {
251 ag_action_1,
252 ag_action_2,
253 ag_action_3,
254 ag_action_4,
255 ag_action_5,
256 ag_action_6,
257 ag_action_7,
258 ag_action_8,
259 ag_action_9,
260 ag_action_10,
261 ag_action_11,
262 ag_action_12
263 } ag_parser_action;
264
265
266 #ifndef NULL_VALUE_INITIALIZER
267 #define NULL_VALUE_INITIALIZER = { 0 }
268 #endif
269
270
271 static const char ag_wdf[] = {
272 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4, 0, 4, 0, 0, 0, 0, 0, 4, 0, 0,
273 0, 0, 0, 0, 0, 0, 0, 0, 0, 4, 4, 4
274 };
275
276 #undef VW
277 #define VW(i,t) *(t) (&(PCB).vs[(PCB).ssx + (i)])
278 #undef VNO
279 #define VNO new(&(PCB).vs[(PCB).ssx])
280 #undef VRO
281 #define VRO(to,v) ag_replace_object((to) &(PCB).vs[(PCB).ssx], v)
282 #undef VWD
283 #define VWD(i,t) ag_delete_object((t) &(PCB).vs[(PCB).ssx + (i)]);
284 #undef VDO
285 #define VDO(to, v) ag_delete_object((to) &(PCB).vs[(PCB).ssx], v)
286
287 template <class NewObject, class OldObject>
288 static inline void ag_replace_object(AgObjectWrapper<OldObject> *p, const NewObject &o) {
289 delete p;
290 new(p) AgObjectWrapper<NewObject >(o);
291 }
292
293 template <class Object>
294 static inline void ag_delete_object(AgObjectWrapper<Object> *p) {
295 delete p;
296 }
297
298 template <class NewObject, class OldObject>
299 static inline const NewObject &ag_delete_object(AgObjectWrapper<OldObject> *p, const NewObject &o) {
300 delete p;
301 return o;
302 }
303
304
305 #undef AG_WRAP_4
306 #define AG_WRAP_4 AgObjectWrapper<Number >
307
308 static void ag_delete_wrappers(void) {
309 int sn = (PCB).sn;
310 int sx = (PCB).ssx;
311 while (sx--) {
312 switch (ag_wdf[sn]) {
313 case 4: ag_delete_object((AG_WRAP_4 *) &(PCB).vs[sx]); break;
314 default: break;
315 }
316 sn = (PCB).ss[sx];
317 }
318 }
319
320 void ag_delete_object(void) {
321 int sn = PCB.sn;
322 (PCB).sn = (PCB).ss[--(PCB).ssx];
323 switch (ag_wdf[sn]) {
324 case 4: {
325 AG_WRAP_4 *wrapper = (AG_WRAP_4 *) (&(PCB).vs[(PCB).ssx]);
326 delete wrapper;
327 break;
328 }
329 default: break;
330 }
331 }
332
333 static ffc-w_vs_type const ag_null_value NULL_VALUE_INITIALIZER;
334
335 static const unsigned char ag_rpx[] = {
336 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 0, 0, 3, 4, 0, 5, 6,
337 7, 8, 9, 10, 0, 0, 0, 0, 0, 0, 11, 12, 0, 0, 0, 13, 14, 15,
338 16, 17
339 };
340
341 static const unsigned char ag_key_itt[] = {
342 0
343 };
344
345 static const unsigned short ag_key_pt[] = {
346 0
347 };
348
349 static const unsigned char ag_key_ch[] = {
350 0, 47,255, 42,255
351 };
352
353 static const unsigned char ag_key_act[] = {
354 0,3,4,3,4
355 };
356
357 static const unsigned char ag_key_parm[] = {
358 0, 24, 0, 28, 0
359 };
360
361 static const unsigned char ag_key_jmp[] = {
362 0, 0, 0, 2, 0
363 };
364
365 static const unsigned char ag_key_index[] = {
366 1, 3, 1, 0, 3, 3, 0, 1, 1, 1, 1, 0, 0, 1, 0, 0, 0, 0,
367 0, 0, 1, 1, 0, 1, 0, 1, 0, 1, 0, 0, 1, 0, 1, 1, 0, 0,
368 0
369 };
370
371 static const unsigned char ag_key_ends[] = {
372 42,0, 47,0,
373 };
374 #define AG_TCV(x) (((int)(x) >= -1 && (int)(x) <= 255) ? ag_tcv[(x) + 1] : 0)
375
376 static const unsigned char ag_tcv[] = {
377 10, 35, 35, 35, 35, 35, 35, 35, 35, 35, 23, 38, 23, 23, 23, 35, 35, 35,
378 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 23, 35, 35,
379 35, 35, 35, 35, 35, 46, 45, 42, 40, 35, 41, 31, 43, 34, 34, 34, 34, 34,
380 34, 34, 34, 34, 34, 35, 35, 35, 39, 35, 35, 35, 47, 47, 47, 47, 47, 47,
381 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47,
382 47, 47, 35, 35, 35, 35, 35, 35, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47,
383 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 35, 35,
384 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35,
385 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35,
386 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35,
387 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35,
388 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35,
389 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35,
390 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35,
391 35, 35, 35, 35, 35
392 };
393
394 #ifndef SYNTAX_ERROR
395 #define SYNTAX_ERROR fprintf(stderr,"%s, line %d, column %d\n", \
396 (PCB).error_message, (PCB).line, (PCB).column)
397 #endif
398
399 #ifndef FIRST_LINE
400 #define FIRST_LINE 1
401 #endif
402
403 #ifndef FIRST_COLUMN
404 #define FIRST_COLUMN 1
405 #endif
406
407 #ifndef PARSER_STACK_OVERFLOW
408 #define PARSER_STACK_OVERFLOW {fprintf(stderr, \
409 "\nParser stack overflow, line %d, column %d\n",\
410 (PCB).line, (PCB).column);}
411 #endif
412
413 #ifndef REDUCTION_TOKEN_ERROR
414 #define REDUCTION_TOKEN_ERROR {fprintf(stderr, \
415 "\nReduction token error, line %d, column %d\n", \
416 (PCB).line, (PCB).column);}
417 #endif
418
419
420 typedef enum
421 {ag_accept_key, ag_set_key, ag_jmp_key, ag_end_key, ag_no_match_key,
422 ag_cf_accept_key, ag_cf_set_key, ag_cf_end_key} key_words;
423
424 #ifndef GET_INPUT
425 #define GET_INPUT ((PCB).input_code = getchar())
426 #endif
427
428
429 static int ag_look_ahead(void) {
430 if ((PCB).rx < (PCB).fx) {
431 return CONVERT_CASE((PCB).lab[(PCB).rx++]);
432 }
433 GET_INPUT;
434 (PCB).fx++;
435 return CONVERT_CASE((PCB).lab[(PCB).rx++] = (PCB).input_code);
436 }
437
438 static void ag_get_key_word(int ag_k) {
439 int save_index = (PCB).rx;
440 const unsigned char *sp;
441 int ag_ch;
442 while (1) {
443 switch (ag_key_act[ag_k]) {
444 case ag_cf_end_key:
445 sp = ag_key_ends + ag_key_jmp[ag_k];
446 do {
447 if ((ag_ch = *sp++) == 0) {
448 int ag_k1 = ag_key_parm[ag_k];
449 int ag_k2 = ag_key_pt[ag_k1];
450 if (ag_key_itt[ag_k2 + ag_look_ahead()]) goto ag_fail;
451 (PCB).rx--;
452 (PCB).token_number = (ffc-w_token_type) ag_key_pt[ag_k1 + 1];
453 return;
454 }
455 } while (ag_look_ahead() == ag_ch);
456 goto ag_fail;
457 case ag_end_key:
458 sp = ag_key_ends + ag_key_jmp[ag_k];
459 do {
460 if ((ag_ch = *sp++) == 0) {
461 (PCB).token_number = (ffc-w_token_type) ag_key_parm[ag_k];
462 return;
463 }
464 } while (ag_look_ahead() == ag_ch);
465 case ag_no_match_key:
466 ag_fail:
467 (PCB).rx = save_index;
468 return;
469 case ag_cf_set_key: {
470 int ag_k1 = ag_key_parm[ag_k];
471 int ag_k2 = ag_key_pt[ag_k1];
472 ag_k = ag_key_jmp[ag_k];
473 if (ag_key_itt[ag_k2 + (ag_ch = ag_look_ahead())]) break;
474 save_index = --(PCB).rx;
475 (PCB).token_number = (ffc-w_token_type) ag_key_pt[ag_k1+1];
476 break;
477 }
478 case ag_set_key:
479 save_index = (PCB).rx;
480 (PCB).token_number = (ffc-w_token_type) ag_key_parm[ag_k];
481 case ag_jmp_key:
482 ag_k = ag_key_jmp[ag_k];
483 ag_ch = ag_look_ahead();
484 break;
485 case ag_accept_key:
486 (PCB).token_number = (ffc-w_token_type) ag_key_parm[ag_k];
487 return;
488 case ag_cf_accept_key: {
489 int ag_k1 = ag_key_parm[ag_k];
490 int ag_k2 = ag_key_pt[ag_k1];
491 if (ag_key_itt[ag_k2 + ag_look_ahead()]) (PCB).rx = save_index;
492 else {
493 (PCB).rx--;
494 (PCB).token_number = (ffc-w_token_type) ag_key_pt[ag_k1+1];
495 }
496 return;
497 }
498 default:
499 /* not reachable; here to suppress compiler warnings */
500 goto ag_fail;
501 }
502 if (ag_ch <= 255) while (ag_key_ch[ag_k] < ag_ch) ag_k++;
503 if (ag_ch > 255 || ag_key_ch[ag_k] != ag_ch) {
504 (PCB).rx = save_index;
505 return;
506 }
507 }
508 }
509
510
511 #ifndef AG_NEWLINE
512 #define AG_NEWLINE 10
513 #endif
514
515 #ifndef AG_RETURN
516 #define AG_RETURN 13
517 #endif
518
519 #ifndef AG_FORMFEED
520 #define AG_FORMFEED 12
521 #endif
522
523 #ifndef AG_TABCHAR
524 #define AG_TABCHAR 9
525 #endif
526
527 static void ag_track(void) {
528 int ag_k = 0;
529 while (ag_k < (PCB).rx) {
530 int ag_ch = (PCB).lab[ag_k++];
531 switch (ag_ch) {
532 case AG_NEWLINE:
533 (PCB).column = 1, (PCB).line++;
534 case AG_RETURN:
535 case AG_FORMFEED:
536 break;
537 case AG_TABCHAR:
538 (PCB).column += (TAB_SPACING) - ((PCB).column - 1) % (TAB_SPACING);
539 break;
540 default:
541 (PCB).column++;
542 }
543 }
544 ag_k = 0;
545 while ((PCB).rx < (PCB).fx) (PCB).lab[ag_k++] = (PCB).lab[(PCB).rx++];
546 (PCB).fx = ag_k;
547 (PCB).rx = 0;
548 }
549
550
551 static void ag_prot(void) {
552 int ag_k;
553 ag_k = 128 - ++(PCB).btsx;
554 if (ag_k <= (PCB).ssx) {
555 (PCB).exit_flag = AG_STACK_ERROR_CODE;
556 PARSER_STACK_OVERFLOW;
557 return;
558 }
559 (PCB).bts[(PCB).btsx] = (PCB).sn;
560 (PCB).bts[ag_k] = (PCB).ssx;
561 (PCB).vs[ag_k] = (PCB).vs[(PCB).ssx];
562 (PCB).ss[ag_k] = (PCB).ss[(PCB).ssx];
563 }
564
565 static void ag_undo(void) {
566 if ((PCB).drt == -1) return;
567 while ((PCB).btsx) {
568 int ag_k = 128 - (PCB).btsx;
569 (PCB).sn = (PCB).bts[(PCB).btsx--];
570 (PCB).ssx = (PCB).bts[ag_k];
571 (PCB).vs[(PCB).ssx] = (PCB).vs[ag_k];
572 (PCB).ss[(PCB).ssx] = (PCB).ss[ag_k];
573 }
574 (PCB).token_number = (ffc-w_token_type) (PCB).drt;
575 (PCB).ssx = (PCB).dssx;
576 (PCB).sn = (PCB).dsn;
577 (PCB).drt = -1;
578 }
579
580
581 static const unsigned char ag_tstt[] = {
582 47,46,41,38,34,31,24,23,10,0,1,36,37,
583 47,46,45,43,42,41,40,39,38,35,34,31,28,23,0,26,27,
584 24,23,0,1,
585 47,46,41,38,34,31,14,10,0,2,3,4,5,7,8,9,11,12,15,17,18,21,29,30,44,
586 47,46,45,43,42,41,40,39,38,35,34,31,23,0,
587 28,0,
588 34,0,32,
589 45,43,42,41,40,38,34,31,24,23,0,33,
590 47,46,41,34,31,24,23,0,1,36,37,
591 47,46,41,34,31,24,23,0,1,36,37,
592 45,43,42,41,40,38,24,23,0,1,36,37,
593 47,46,41,34,31,0,2,12,17,18,21,29,30,44,
594 47,46,41,34,31,0,2,11,12,15,17,18,21,29,30,44,
595 45,43,42,41,40,39,38,24,23,0,1,36,37,
596 43,42,0,19,20,
597 43,42,41,40,39,38,0,13,
598 41,40,38,0,16,17,
599 38,0,6,
600 47,46,41,38,34,31,14,10,0,2,4,5,7,11,12,15,17,18,21,29,30,44,
601 10,0,
602 45,43,42,41,40,38,34,24,23,0,32,
603 34,0,32,
604 45,41,40,0,16,17,22,
605 47,46,41,34,31,24,23,0,1,36,37,
606 47,46,41,34,31,0,2,12,17,18,21,29,30,44,
607 47,46,41,34,31,24,23,0,1,36,37,
608 47,46,41,34,31,0,2,12,17,18,21,29,30,44,
609 47,46,41,34,31,24,23,0,1,36,37,
610 47,46,41,34,31,0,2,11,12,15,17,18,21,29,30,44,
611 47,46,41,34,31,0,2,12,15,17,18,21,29,30,44,
612 47,46,41,34,31,24,23,0,1,36,37,
613 47,46,41,34,31,0,2,12,15,17,18,21,29,30,44,
614 47,46,41,38,34,31,24,23,10,0,1,36,37,
615 45,43,42,41,40,38,24,23,0,1,36,37,
616 41,40,38,0,16,17,
617 45,43,42,41,40,38,0,19,20,
618 45,43,42,41,40,38,0,19,20,
619
620 };
621
622
623 static unsigned const char ag_astt[401] = {
624 8,8,8,8,8,8,1,1,8,7,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,8,1,7,1,1,1,9,5,3,1,1,1,
625 8,2,1,1,8,7,2,0,1,1,1,1,1,1,1,1,1,1,1,2,1,1,9,9,9,9,9,9,9,9,9,9,9,9,9,5,3,
626 7,1,7,2,5,5,5,5,5,5,10,1,5,5,7,3,5,5,5,5,5,1,1,7,1,1,3,5,5,5,5,5,1,1,7,1,1,
627 3,5,5,5,5,5,5,1,1,7,1,1,3,1,1,1,2,1,7,2,2,1,2,1,2,1,1,1,1,1,2,1,7,2,1,2,1,
628 1,1,1,2,1,1,5,5,5,5,5,5,5,1,1,7,1,1,3,1,1,5,1,1,4,4,4,4,1,4,7,1,1,1,4,7,1,
629 1,1,7,3,1,1,1,8,2,1,1,5,7,2,1,1,3,1,1,1,1,1,1,2,1,1,3,7,4,4,4,4,4,4,1,4,4,
630 7,2,1,5,2,1,1,1,7,1,1,2,5,5,5,5,5,1,1,7,1,1,3,1,1,1,2,1,7,2,2,1,2,1,2,1,1,
631 5,5,5,5,5,1,1,7,1,1,3,1,1,1,2,1,7,2,2,1,2,1,2,1,1,5,5,5,5,5,1,1,7,1,1,3,1,
632 1,1,2,1,7,2,1,2,1,1,1,1,2,1,1,1,1,1,2,1,7,2,2,1,1,1,1,2,1,1,5,5,5,5,5,1,1,
633 7,1,1,3,1,1,1,2,1,7,2,2,1,1,1,1,2,1,1,5,5,5,5,5,5,1,1,5,7,1,1,3,5,5,5,5,5,
634 5,1,1,7,1,1,3,1,1,4,7,1,1,4,1,1,4,4,4,7,1,1,4,1,1,4,4,4,7,1,1
635 };
636
637
638 static const unsigned char ag_pstt[] = {
639 3,3,3,3,3,3,1,2,3,0,2,2,3,
640 4,4,4,4,4,4,4,4,4,4,4,4,5,4,1,4,5,
641 1,52,54,52,
642 13,9,8,17,34,6,17,19,3,19,0,17,17,18,18,19,16,15,14,11,14,12,28,7,10,
643 24,24,24,24,24,24,24,24,24,24,24,24,24,26,
644 27,5,
645 20,6,33,
646 30,30,30,30,30,30,35,21,30,30,7,32,
647 53,53,53,53,53,1,2,8,2,2,58,
648 53,53,53,53,53,1,2,9,2,2,63,
649 53,53,53,53,53,53,1,2,10,2,2,61,
650 13,9,8,34,6,11,19,18,11,21,12,28,7,10,
651 13,9,8,34,6,12,19,22,18,14,11,14,12,28,7,10,
652 53,53,53,53,53,53,53,1,2,13,2,2,64,
653 23,25,12,26,24,
654 18,18,18,18,27,18,15,28,
655 8,30,9,16,31,29,
656 32,17,3,
657 13,9,8,17,34,6,17,7,18,19,17,17,5,16,15,14,11,14,12,28,7,10,
658 8,19,
659 36,36,36,36,36,36,20,36,36,20,37,
660 20,31,29,
661 33,8,30,22,31,29,20,
662 53,53,53,53,53,1,2,23,2,2,60,
663 13,9,8,34,6,24,19,18,11,17,12,28,7,10,
664 53,53,53,53,53,1,2,25,2,2,59,
665 13,9,8,34,6,26,19,18,11,16,12,28,7,10,
666 53,53,53,53,53,1,2,27,2,2,56,
667 13,9,8,34,6,28,19,34,18,14,11,14,12,28,7,10,
668 13,9,8,34,6,29,19,18,35,11,35,12,28,7,10,
669 53,53,53,53,53,1,2,30,2,2,57,
670 13,9,8,34,6,31,19,18,36,11,36,12,28,7,10,
671 53,53,53,53,53,53,1,2,53,32,2,2,55,
672 53,53,53,53,53,53,1,2,33,2,2,62,
673 8,30,10,34,31,29,
674 14,23,25,14,14,14,35,26,24,
675 13,23,25,13,13,13,36,26,24,
676
677 };
678
679
680 static const unsigned short ag_sbt[] = {
681 0, 13, 30, 34, 59, 73, 75, 78, 90, 101, 112, 124, 138, 154,
682 167, 172, 180, 186, 189, 211, 213, 224, 227, 234, 245, 259, 270, 284,
683 295, 311, 326, 337, 352, 365, 377, 383, 392, 401
684 };
685
686
687 static const unsigned short ag_sbe[] = {
688 9, 27, 32, 42, 72, 74, 76, 88, 97, 108, 120, 129, 143, 163,
689 169, 178, 183, 187, 197, 212, 222, 225, 230, 241, 250, 266, 275, 291,
690 300, 316, 333, 342, 361, 373, 380, 389, 398, 401
691 };
692
693
694 static const unsigned char ag_fl[] = {
695 2,0,1,2,1,2,0,1,2,1,3,1,1,3,3,1,3,3,1,1,3,2,1,1,2,0,1,3,1,3,0,1,2,2,1,
696 2,1,2,1,1,1,1,1,1,1,1,1,1,1,1,1,1,2,0,1,2,2,2,2,2,2,2,2,2,2
697 };
698
699 static const unsigned char ag_ptt[] = {
700 0, 5, 5, 7, 8, 8, 9, 9, 3, 4, 4, 4, 11, 11, 11, 15, 15, 15,
701 18, 18, 18, 18, 1, 26, 26, 27, 27, 1, 12, 44, 33, 33, 44, 44, 30, 30,
702 32, 32, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 36, 36, 37,
703 37, 6, 13, 16, 17, 19, 20, 2, 22, 21, 29
704 };
705
706
707 static void ag_ra(void)
708 {
709 switch(ag_rpx[(PCB).ag_ap]) {
710 case 1: ag_rp_1(VW(0, AG_WRAP_4 *));
711 VWD(0, AG_WRAP_4 *); break;
712 case 2: ag_rp_2(V(0,(int *)), VW(2, AG_WRAP_4 *));
713 VWD(2, AG_WRAP_4 *); break;
714 case 3: VRO(AG_WRAP_4 *, ag_rp_3(VW(0, AG_WRAP_4 *), VW(2, AG_WRAP_4 *)));
715 VWD(2, AG_WRAP_4 *); break;
716 case 4: VRO(AG_WRAP_4 *, ag_rp_4(VW(0, AG_WRAP_4 *), VW(2, AG_WRAP_4 *)));
717 VWD(2, AG_WRAP_4 *); break;
718 case 5: VRO(AG_WRAP_4 *, ag_rp_5(VW(0, AG_WRAP_4 *), VW(2, AG_WRAP_4 *)));
719 VWD(2, AG_WRAP_4 *); break;
720 case 6: VRO(AG_WRAP_4 *, ag_rp_6(VW(0, AG_WRAP_4 *), VW(2, AG_WRAP_4 *)));
721 VWD(2, AG_WRAP_4 *); break;
722 case 7: VNO AG_WRAP_4(ag_rp_7(V(0,(int *)))); break;
723 case 8: VNO AG_WRAP_4(ag_rp_8(V(0,(double *)))); break;
724 case 9: VNO AG_WRAP_4(ag_rp_9(VW(1, AG_WRAP_4 *)));
725 VWD(1, AG_WRAP_4 *); break;
726 case 10: VNO AG_WRAP_4(ag_rp_10(VW(1, AG_WRAP_4 *)));
727 VWD(1, AG_WRAP_4 *); break;
728 case 11: V(0,(int *)) = ag_rp_11(V(0,(int *))); break;
729 case 12: V(0,(double *)) = ag_rp_12(V(0,(double *)), V(2,(double *))); break;
730 case 13: V(0,(double *)) = ag_rp_13(V(1,(double *))); break;
731 case 14: V(0,(double *)) = ag_rp_14(V(0,(int *))); break;
732 case 15: V(0,(double *)) = ag_rp_15(V(0,(double *)), V(1,(int *))); break;
733 case 16: V(0,(double *)) = ag_rp_16(V(0,(int *))); break;
734 case 17: V(0,(double *)) = ag_rp_17(V(0,(int *)), V(1,(double *))); break;
735 }
736 }
737
738 #ifndef MISSING_FORMAT
739 #define MISSING_FORMAT "Missing %s"
740 #endif
741 #ifndef UNEXPECTED_FORMAT
742 #define UNEXPECTED_FORMAT "Unexpected %s"
743 #endif
744 #ifndef UNNAMED_TOKEN
745 #define UNNAMED_TOKEN "input"
746 #endif
747
748
749 static void ag_diagnose(void) {
750 int ag_snd = (PCB).sn;
751 int ag_k = ag_sbt[ag_snd];
752
753 if (*TOKEN_NAMES[ag_tstt[ag_k]] && ag_astt[ag_k + 1] == ag_action_8) {
754 sprintf((PCB).ag_msg, MISSING_FORMAT, TOKEN_NAMES[ag_tstt[ag_k]]);
755 }
756 else if (ag_astt[ag_sbe[(PCB).sn]] == ag_action_8
757 && (ag_k = (int) ag_sbe[(PCB).sn] + 1) == (int) ag_sbt[(PCB).sn+1] - 1
758 && *TOKEN_NAMES[ag_tstt[ag_k]]) {
759 sprintf((PCB).ag_msg, MISSING_FORMAT, TOKEN_NAMES[ag_tstt[ag_k]]);
760 }
761 else if ((PCB).token_number && *TOKEN_NAMES[(PCB).token_number]) {
762 sprintf((PCB).ag_msg, UNEXPECTED_FORMAT, TOKEN_NAMES[(PCB).token_number]);
763 }
764 else if (isprint((*(PCB).lab)) && (*(PCB).lab) != '\\') {
765 char buf[20];
766 sprintf(buf, "\'%c\'", (char) (*(PCB).lab));
767 sprintf((PCB).ag_msg, UNEXPECTED_FORMAT, buf);
768 }
769 else sprintf((PCB).ag_msg, UNEXPECTED_FORMAT, UNNAMED_TOKEN);
770 (PCB).error_message = (PCB).ag_msg;
771
772
773 }
774 static int ag_action_1_r_proc(void);
775 static int ag_action_2_r_proc(void);
776 static int ag_action_3_r_proc(void);
777 static int ag_action_4_r_proc(void);
778 static int ag_action_1_s_proc(void);
779 static int ag_action_3_s_proc(void);
780 static int ag_action_1_proc(void);
781 static int ag_action_2_proc(void);
782 static int ag_action_3_proc(void);
783 static int ag_action_4_proc(void);
784 static int ag_action_5_proc(void);
785 static int ag_action_6_proc(void);
786 static int ag_action_7_proc(void);
787 static int ag_action_8_proc(void);
788 static int ag_action_9_proc(void);
789 static int ag_action_10_proc(void);
790 static int ag_action_11_proc(void);
791 static int ag_action_8_proc(void);
792
793
794 static int (*const ag_r_procs_scan[])(void) = {
795 ag_action_1_r_proc,
796 ag_action_2_r_proc,
797 ag_action_3_r_proc,
798 ag_action_4_r_proc
799 };
800
801 static int (*const ag_s_procs_scan[])(void) = {
802 ag_action_1_s_proc,
803 ag_action_2_r_proc,
804 ag_action_3_s_proc,
805 ag_action_4_r_proc
806 };
807
808 static int (*const ag_gt_procs_scan[])(void) = {
809 ag_action_1_proc,
810 ag_action_2_proc,
811 ag_action_3_proc,
812 ag_action_4_proc,
813 ag_action_5_proc,
814 ag_action_6_proc,
815 ag_action_7_proc,
816 ag_action_8_proc,
817 ag_action_9_proc,
818 ag_action_10_proc,
819 ag_action_11_proc,
820 ag_action_8_proc
821 };
822
823
824 static int ag_action_1_er_proc(void);
825 static int ag_action_2_er_proc(void);
826 static int ag_action_3_er_proc(void);
827 static int ag_action_4_er_proc(void);
828
829 static int (*const ag_er_procs_scan[])(void) = {
830 ag_action_1_er_proc,
831 ag_action_2_er_proc,
832 ag_action_3_er_proc,
833 ag_action_4_er_proc
834 };
835
836
837 static void ag_error_resynch(void) {
838 int ag_k;
839 int ag_ssx = (PCB).ssx;
840
841 ag_diagnose();
842 SYNTAX_ERROR;
843 if ((PCB).exit_flag != AG_RUNNING_CODE) return;
844 while (1) {
845 ag_k = ag_sbt[(PCB).sn];
846 while (ag_tstt[ag_k] != 14 && ag_tstt[ag_k]) ag_k++;
847 if (ag_tstt[ag_k] || (PCB).ssx == 0) break;
848 ag_delete_object();
849 }
850 if (ag_tstt[ag_k] == 0) {
851 (PCB).sn = PCB.ss[(PCB).ssx = ag_ssx];
852 (PCB).exit_flag = AG_SYNTAX_ERROR_CODE;
853 return;
854 }
855 ag_k = ag_sbt[(PCB).sn];
856 while (ag_tstt[ag_k] != 14 && ag_tstt[ag_k]) ag_k++;
857 (PCB).ag_ap = ag_pstt[ag_k];
858 (ag_er_procs_scan[ag_astt[ag_k]])();
859 while (1) {
860 ag_k = ag_sbt[(PCB).sn];
861 while (ag_tstt[ag_k] != (unsigned char) (PCB).token_number && ag_tstt[ag_k])
862 ag_k++;
863 if (ag_tstt[ag_k] && ag_astt[ag_k] != ag_action_10) break;
864 if ((PCB).token_number == 10)
865 {(PCB).exit_flag = AG_SYNTAX_ERROR_CODE; return;}
866 {(PCB).rx = 1; ag_track();}
867 if ((PCB).rx < (PCB).fx) {
868 (PCB).input_code = (PCB).lab[(PCB).rx++];
869 (PCB).token_number = (ffc-w_token_type) AG_TCV((PCB).input_code);}
870 else {
871 GET_INPUT;
872 (PCB).lab[(PCB).fx++] = (PCB).input_code;
873 (PCB).token_number = (ffc-w_token_type) AG_TCV((PCB).input_code);
874 (PCB).rx++;
875 }
876 if (ag_key_index[(PCB).sn]) {
877 unsigned ag_k = ag_key_index[(PCB).sn];
878 int ag_ch = CONVERT_CASE((PCB).input_code);
879 if (ag_ch < 255) {
880 while (ag_key_ch[ag_k] < ag_ch) ag_k++;
881 if (ag_key_ch[ag_k] == ag_ch) ag_get_key_word(ag_k);
882 }
883 }
884 }
885 (PCB).rx = 0;
886 }
887
888
889 static int ag_action_10_proc(void) {
890 int ag_t = (PCB).token_number;
891 (PCB).btsx = 0, (PCB).drt = -1;
892 do {
893 ag_track();
894 if ((PCB).rx < (PCB).fx) {
895 (PCB).input_code = (PCB).lab[(PCB).rx++];
896 (PCB).token_number = (ffc-w_token_type) AG_TCV((PCB).input_code);}
897 else {
898 GET_INPUT;
899 (PCB).lab[(PCB).fx++] = (PCB).input_code;
900 (PCB).token_number = (ffc-w_token_type) AG_TCV((PCB).input_code);
901 (PCB).rx++;
902 }
903 if (ag_key_index[(PCB).sn]) {
904 unsigned ag_k = ag_key_index[(PCB).sn];
905 int ag_ch = CONVERT_CASE((PCB).input_code);
906 if (ag_ch < 255) {
907 while (ag_key_ch[ag_k] < ag_ch) ag_k++;
908 if (ag_key_ch[ag_k] == ag_ch) ag_get_key_word(ag_k);
909 }
910 }
911 } while ((PCB).token_number == (ffc-w_token_type) ag_t);
912 (PCB).rx = 0;
913 return 1;
914 }
915
916 static int ag_action_11_proc(void) {
917 int ag_t = (PCB).token_number;
918
919 (PCB).btsx = 0, (PCB).drt = -1;
920 do {
921 (*(int *) &(PCB).vs[(PCB).ssx]) = *(PCB).lab;
922 (PCB).ssx--;
923 ag_track();
924 ag_ra();
925 if ((PCB).exit_flag != AG_RUNNING_CODE) return 0;
926 (PCB).ssx++;
927 if ((PCB).rx < (PCB).fx) {
928 (PCB).input_code = (PCB).lab[(PCB).rx++];
929 (PCB).token_number = (ffc-w_token_type) AG_TCV((PCB).input_code);}
930 else {
931 GET_INPUT;
932 (PCB).lab[(PCB).fx++] = (PCB).input_code;
933 (PCB).token_number = (ffc-w_token_type) AG_TCV((PCB).input_code);
934 (PCB).rx++;
935 }
936 if (ag_key_index[(PCB).sn]) {
937 unsigned ag_k = ag_key_index[(PCB).sn];
938 int ag_ch = CONVERT_CASE((PCB).input_code);
939 if (ag_ch < 255) {
940 while (ag_key_ch[ag_k] < ag_ch) ag_k++;
941 if (ag_key_ch[ag_k] == ag_ch) ag_get_key_word(ag_k);
942 }
943 }
944 }
945 while ((PCB).token_number == (ffc-w_token_type) ag_t);
946 (PCB).rx = 0;
947 return 1;
948 }
949
950 static int ag_action_3_r_proc(void) {
951 int ag_sd = ag_fl[(PCB).ag_ap] - 1;
952 if (ag_sd) (PCB).sn = (PCB).ss[(PCB).ssx -= ag_sd];
953 (PCB).btsx = 0, (PCB).drt = -1;
954 (PCB).reduction_token = (ffc-w_token_type) ag_ptt[(PCB).ag_ap];
955 ag_ra();
956 return (PCB).exit_flag == AG_RUNNING_CODE;
957 }
958
959 static int ag_action_3_s_proc(void) {
960 int ag_sd = ag_fl[(PCB).ag_ap] - 1;
961 if (ag_sd) (PCB).sn = (PCB).ss[(PCB).ssx -= ag_sd];
962 (PCB).btsx = 0, (PCB).drt = -1;
963 (PCB).reduction_token = (ffc-w_token_type) ag_ptt[(PCB).ag_ap];
964 ag_ra();
965 return (PCB).exit_flag == AG_RUNNING_CODE;
966 }
967
968 static int ag_action_4_r_proc(void) {
969 int ag_sd = ag_fl[(PCB).ag_ap] - 1;
970 if (ag_sd) (PCB).sn = (PCB).ss[(PCB).ssx -= ag_sd];
971 (PCB).reduction_token = (ffc-w_token_type) ag_ptt[(PCB).ag_ap];
972 return 1;
973 }
974
975 static int ag_action_2_proc(void) {
976 (PCB).btsx = 0, (PCB).drt = -1;
977 if ((PCB).ssx >= 128) {
978 (PCB).exit_flag = AG_STACK_ERROR_CODE;
979 PARSER_STACK_OVERFLOW;
980 }
981 (*(int *) &(PCB).vs[(PCB).ssx]) = *(PCB).lab;
982 (PCB).ss[(PCB).ssx] = (PCB).sn;
983 (PCB).ssx++;
984 (PCB).sn = (PCB).ag_ap;
985 ag_track();
986 return 0;
987 }
988
989 static int ag_action_9_proc(void) {
990 if ((PCB).drt == -1) {
991 (PCB).drt=(PCB).token_number;
992 (PCB).dssx=(PCB).ssx;
993 (PCB).dsn=(PCB).sn;
994 }
995 ag_prot();
996 (PCB).vs[(PCB).ssx] = ag_null_value;
997 (PCB).ss[(PCB).ssx] = (PCB).sn;
998 (PCB).ssx++;
999 (PCB).sn = (PCB).ag_ap;
1000 (PCB).rx = 0;
1001 return (PCB).exit_flag == AG_RUNNING_CODE;
1002 }
1003
1004 static int ag_action_2_r_proc(void) {
1005 (PCB).ssx++;
1006 (PCB).sn = (PCB).ag_ap;
1007 return 0;
1008 }
1009
1010 static int ag_action_7_proc(void) {
1011 --(PCB).ssx;
1012 (PCB).rx = 0;
1013 (PCB).exit_flag = AG_SUCCESS_CODE;
1014 return 0;
1015 }
1016
1017 static int ag_action_1_proc(void) {
1018 ag_track();
1019 (PCB).exit_flag = AG_SUCCESS_CODE;
1020 return 0;
1021 }
1022
1023 static int ag_action_1_r_proc(void) {
1024 (PCB).exit_flag = AG_SUCCESS_CODE;
1025 return 0;
1026 }
1027
1028 static int ag_action_1_s_proc(void) {
1029 (PCB).exit_flag = AG_SUCCESS_CODE;
1030 return 0;
1031 }
1032
1033 static int ag_action_4_proc(void) {
1034 int ag_sd = ag_fl[(PCB).ag_ap] - 1;
1035 (PCB).reduction_token = (ffc-w_token_type) ag_ptt[(PCB).ag_ap];
1036 (PCB).btsx = 0, (PCB).drt = -1;
1037 (*(int *) &(PCB).vs[(PCB).ssx]) = *(PCB).lab;
1038 if (ag_sd) (PCB).sn = (PCB).ss[(PCB).ssx -= ag_sd];
1039 else (PCB).ss[(PCB).ssx] = (PCB).sn;
1040 ag_track();
1041 while ((PCB).exit_flag == AG_RUNNING_CODE) {
1042 unsigned ag_t1 = ag_sbe[(PCB).sn] + 1;
1043 unsigned ag_t2 = ag_sbt[(PCB).sn+1] - 1;
1044 do {
1045 unsigned ag_tx = (ag_t1 + ag_t2)/2;
1046 if (ag_tstt[ag_tx] < (unsigned char)(PCB).reduction_token) ag_t1 = ag_tx + 1;
1047 else ag_t2 = ag_tx;
1048 } while (ag_t1 < ag_t2);
1049 (PCB).ag_ap = ag_pstt[ag_t1];
1050 if ((ag_s_procs_scan[ag_astt[ag_t1]])() == 0) break;
1051 }
1052 return 0;
1053 }
1054
1055 static int ag_action_3_proc(void) {
1056 int ag_sd = ag_fl[(PCB).ag_ap] - 1;
1057 (PCB).btsx = 0, (PCB).drt = -1;
1058 (*(int *) &(PCB).vs[(PCB).ssx]) = *(PCB).lab;
1059 if (ag_sd) (PCB).sn = (PCB).ss[(PCB).ssx -= ag_sd];
1060 else (PCB).ss[(PCB).ssx] = (PCB).sn;
1061 ag_track();
1062 (PCB).reduction_token = (ffc-w_token_type) ag_ptt[(PCB).ag_ap];
1063 ag_ra();
1064 while ((PCB).exit_flag == AG_RUNNING_CODE) {
1065 unsigned ag_t1 = ag_sbe[(PCB).sn] + 1;
1066 unsigned ag_t2 = ag_sbt[(PCB).sn+1] - 1;
1067 do {
1068 unsigned ag_tx = (ag_t1 + ag_t2)/2;
1069 if (ag_tstt[ag_tx] < (unsigned char)(PCB).reduction_token) ag_t1 = ag_tx + 1;
1070 else ag_t2 = ag_tx;
1071 } while (ag_t1 < ag_t2);
1072 (PCB).ag_ap = ag_pstt[ag_t1];
1073 if ((ag_s_procs_scan[ag_astt[ag_t1]])() == 0) break;
1074 }
1075 return 0;
1076 }
1077
1078 static int ag_action_8_proc(void) {
1079 int ag_k = ag_sbt[(PCB).sn];
1080 while (ag_tstt[ag_k] != 14 && ag_tstt[ag_k]) ag_k++;
1081 if (ag_tstt[ag_k] == 0) ag_undo();
1082 (PCB).rx = 0;
1083 ag_error_resynch();
1084 return (PCB).exit_flag == AG_RUNNING_CODE;
1085 }
1086
1087 static int ag_action_5_proc(void) {
1088 int ag_sd = ag_fl[(PCB).ag_ap];
1089 (PCB).btsx = 0, (PCB).drt = -1;
1090 if (ag_sd) (PCB).sn = (PCB).ss[(PCB).ssx -= ag_sd];
1091 else {
1092 (PCB).ss[(PCB).ssx] = (PCB).sn;
1093 }
1094 (PCB).rx = 0;
1095 (PCB).reduction_token = (ffc-w_token_type) ag_ptt[(PCB).ag_ap];
1096 ag_ra();
1097 while ((PCB).exit_flag == AG_RUNNING_CODE) {
1098 unsigned ag_t1 = ag_sbe[(PCB).sn] + 1;
1099 unsigned ag_t2 = ag_sbt[(PCB).sn+1] - 1;
1100 do {
1101 unsigned ag_tx = (ag_t1 + ag_t2)/2;
1102 if (ag_tstt[ag_tx] < (unsigned char)(PCB).reduction_token) ag_t1 = ag_tx + 1;
1103 else ag_t2 = ag_tx;
1104 } while (ag_t1 < ag_t2);
1105 (PCB).ag_ap = ag_pstt[ag_t1];
1106 if ((ag_r_procs_scan[ag_astt[ag_t1]])() == 0) break;
1107 }
1108 return (PCB).exit_flag == AG_RUNNING_CODE;
1109 }
1110
1111 static int ag_action_6_proc(void) {
1112 int ag_sd = ag_fl[(PCB).ag_ap];
1113 (PCB).reduction_token = (ffc-w_token_type) ag_ptt[(PCB).ag_ap];
1114 if ((PCB).drt == -1) {
1115 (PCB).drt=(PCB).token_number;
1116 (PCB).dssx=(PCB).ssx;
1117 (PCB).dsn=(PCB).sn;
1118 }
1119 if (ag_sd) {
1120 (PCB).sn = (PCB).ss[(PCB).ssx -= ag_sd];
1121 }
1122 else {
1123 ag_prot();
1124 (PCB).vs[(PCB).ssx] = ag_null_value;
1125 (PCB).ss[(PCB).ssx] = (PCB).sn;
1126 }
1127 (PCB).rx = 0;
1128 while ((PCB).exit_flag == AG_RUNNING_CODE) {
1129 unsigned ag_t1 = ag_sbe[(PCB).sn] + 1;
1130 unsigned ag_t2 = ag_sbt[(PCB).sn+1] - 1;
1131 do {
1132 unsigned ag_tx = (ag_t1 + ag_t2)/2;
1133 if (ag_tstt[ag_tx] < (unsigned char)(PCB).reduction_token) ag_t1 = ag_tx + 1;
1134 else ag_t2 = ag_tx;
1135 } while (ag_t1 < ag_t2);
1136 (PCB).ag_ap = ag_pstt[ag_t1];
1137 if ((ag_r_procs_scan[ag_astt[ag_t1]])() == 0) break;
1138 }
1139 return (PCB).exit_flag == AG_RUNNING_CODE;
1140 }
1141
1142
1143 static int ag_action_2_er_proc(void) {
1144 (PCB).btsx = 0, (PCB).drt = -1;
1145 (*(int *) &(PCB).vs[(PCB).ssx]) = *(PCB).lab;
1146 (PCB).ssx++;
1147 (PCB).sn = (PCB).ag_ap;
1148 return 0;
1149 }
1150
1151 static int ag_action_1_er_proc(void) {
1152 (PCB).btsx = 0, (PCB).drt = -1;
1153 (PCB).exit_flag = AG_SUCCESS_CODE;
1154 return 0;
1155 }
1156
1157 static int ag_action_4_er_proc(void) {
1158 int ag_sd = ag_fl[(PCB).ag_ap] - 1;
1159 (PCB).btsx = 0, (PCB).drt = -1;
1160 (PCB).reduction_token = (ffc-w_token_type) ag_ptt[(PCB).ag_ap];
1161 if (ag_sd) (PCB).sn = (PCB).ss[(PCB).ssx -= ag_sd];
1162 else (PCB).ss[(PCB).ssx] = (PCB).sn;
1163 while ((PCB).exit_flag == AG_RUNNING_CODE) {
1164 unsigned ag_t1 = ag_sbe[(PCB).sn] + 1;
1165 unsigned ag_t2 = ag_sbt[(PCB).sn+1] - 1;
1166 do {
1167 unsigned ag_tx = (ag_t1 + ag_t2)/2;
1168 if (ag_tstt[ag_tx] < (unsigned char)(PCB).reduction_token) ag_t1 = ag_tx + 1;
1169 else ag_t2 = ag_tx;
1170 } while (ag_t1 < ag_t2);
1171 (PCB).ag_ap = ag_pstt[ag_t1];
1172 if ((ag_s_procs_scan[ag_astt[ag_t1]])() == 0) break;
1173 }
1174 return 0;
1175 }
1176
1177 static int ag_action_3_er_proc(void) {
1178 int ag_sd = ag_fl[(PCB).ag_ap] - 1;
1179 (PCB).btsx = 0, (PCB).drt = -1;
1180 if (ag_sd) (PCB).sn = (PCB).ss[(PCB).ssx -= ag_sd];
1181 else (PCB).ss[(PCB).ssx] = (PCB).sn;
1182 (PCB).reduction_token = (ffc-w_token_type) ag_ptt[(PCB).ag_ap];
1183 ag_ra();
1184 while ((PCB).exit_flag == AG_RUNNING_CODE) {
1185 unsigned ag_t1 = ag_sbe[(PCB).sn] + 1;
1186 unsigned ag_t2 = ag_sbt[(PCB).sn+1] - 1;
1187 do {
1188 unsigned ag_tx = (ag_t1 + ag_t2)/2;
1189 if (ag_tstt[ag_tx] < (unsigned char)(PCB).reduction_token) ag_t1 = ag_tx + 1;
1190 else ag_t2 = ag_tx;
1191 } while (ag_t1 < ag_t2);
1192 (PCB).ag_ap = ag_pstt[ag_t1];
1193 if ((ag_s_procs_scan[ag_astt[ag_t1]])() == 0) break;
1194 }
1195 return 0;
1196 }
1197
1198
1199 void init_ffc-w(void) {
1200 (PCB).rx = (PCB).fx = 0;
1201 (PCB).ss[0] = (PCB).sn = (PCB).ssx = 0;
1202 (PCB).exit_flag = AG_RUNNING_CODE;
1203 (PCB).line = FIRST_LINE;
1204 (PCB).column = FIRST_COLUMN;
1205 (PCB).btsx = 0, (PCB).drt = -1;
1206 }
1207
1208 void ffc-w(void) {
1209 init_ffc-w();
1210 (PCB).exit_flag = AG_RUNNING_CODE;
1211 while ((PCB).exit_flag == AG_RUNNING_CODE) {
1212 unsigned ag_t1 = ag_sbt[(PCB).sn];
1213 if (ag_tstt[ag_t1]) {
1214 unsigned ag_t2 = ag_sbe[(PCB).sn] - 1;
1215 if ((PCB).rx < (PCB).fx) {
1216 (PCB).input_code = (PCB).lab[(PCB).rx++];
1217 (PCB).token_number = (ffc-w_token_type) AG_TCV((PCB).input_code);}
1218 else {
1219 GET_INPUT;
1220 (PCB).lab[(PCB).fx++] = (PCB).input_code;
1221 (PCB).token_number = (ffc-w_token_type) AG_TCV((PCB).input_code);
1222 (PCB).rx++;
1223 }
1224 if (ag_key_index[(PCB).sn]) {
1225 unsigned ag_k = ag_key_index[(PCB).sn];
1226 int ag_ch = CONVERT_CASE((PCB).input_code);
1227 if (ag_ch < 255) {
1228 while (ag_key_ch[ag_k] < ag_ch) ag_k++;
1229 if (ag_key_ch[ag_k] == ag_ch) ag_get_key_word(ag_k);
1230 }
1231 }
1232 do {
1233 unsigned ag_tx = (ag_t1 + ag_t2)/2;
1234 if (ag_tstt[ag_tx] > (unsigned char)(PCB).token_number)
1235 ag_t1 = ag_tx + 1;
1236 else ag_t2 = ag_tx;
1237 } while (ag_t1 < ag_t2);
1238 if (ag_tstt[ag_t1] != (unsigned char)(PCB).token_number)
1239 ag_t1 = ag_sbe[(PCB).sn];
1240 }
1241 (PCB).ag_ap = ag_pstt[ag_t1];
1242 (ag_gt_procs_scan[ag_astt[ag_t1]])();
1243 }
1244 }
1245
1246