comparison tests/agcl/parsifal/good/iaparams.c @ 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 /* immed.syn */
2 #include <stdio.h>
3
4 /*
5 * AnaGram, A System for Syntax Directed Programming
6 * File generated by: ...
7 *
8 * AnaGram Parsing Engine
9 * Copyright 1993-2002 Parsifal Software. All Rights Reserved.
10 *
11 * This software is provided 'as-is', without any express or implied
12 * warranty. In no event will the authors be held liable for any damages
13 * arising from the use of this software.
14 *
15 * Permission is granted to anyone to use this software for any purpose,
16 * including commercial applications, and to alter it and redistribute it
17 * freely, subject to the following restrictions:
18 *
19 * 1. The origin of this software must not be misrepresented; you must not
20 * claim that you wrote the original software. If you use this software
21 * in a product, an acknowledgment in the product documentation would be
22 * appreciated but is not required.
23 * 2. Altered source versions must be plainly marked as such, and must not be
24 * misrepresented as being the original software.
25 * 3. This notice may not be removed or altered from any source distribution.
26 */
27
28 #ifndef IAPARAMS_H
29 #include "iaparams.h"
30 #endif
31
32 #ifndef IAPARAMS_H
33 #error Mismatched header file
34 #endif
35
36 #include <ctype.h>
37 #include <stdio.h>
38
39 #define RULE_CONTEXT (&((PCB).cs[(PCB).ssx]))
40 #define ERROR_CONTEXT ((PCB).cs[(PCB).error_frame_ssx])
41 #define CONTEXT ((PCB).cs[(PCB).ssx])
42
43
44
45 iaparams_pcb_type iaparams_pcb;
46 #define PCB iaparams_pcb
47
48 /* Line -, iaparams.syn */
49 void main() { iaparams(); }
50 #ifndef CONVERT_CASE
51 #define CONVERT_CASE(c) (c)
52 #endif
53 #ifndef TAB_SPACING
54 #define TAB_SPACING 8
55 #endif
56
57 static int ag_rp_1(long n) {
58 /* Line -, iaparams.syn */
59 return n;
60 }
61
62 static long ag_rp_2(void) {
63 /* Line -, iaparams.syn */
64 return 0;
65 }
66
67 static void ag_rp_3(long n) {
68 /* Line -, iaparams.syn */
69 printf("(%ld)", n);
70 }
71
72 static void ag_rp_4(long n, int i) {
73 /* Line -, iaparams.syn */
74 printf("(%d)", i);
75 }
76
77 static long ag_rp_5(long n, int i) {
78 /* Line -, iaparams.syn */
79 return i + 10*n;
80 }
81
82 static int ag_rp_6(void) {
83 /* Line -, iaparams.syn */
84 return 0;
85 }
86
87 static int ag_rp_7(void) {
88 /* Line -, iaparams.syn */
89 return 1;
90 }
91
92 static int ag_rp_8(void) {
93 /* Line -, iaparams.syn */
94 return 2;
95 }
96
97 static int ag_rp_9(void) {
98 /* Line -, iaparams.syn */
99 return 3;
100 }
101
102 static int ag_rp_10(void) {
103 /* Line -, iaparams.syn */
104 return 4;
105 }
106
107 static int ag_rp_11(void) {
108 /* Line -, iaparams.syn */
109 return 5;
110 }
111
112 static int ag_rp_12(void) {
113 /* Line -, iaparams.syn */
114 return 6;
115 }
116
117 static int ag_rp_13(void) {
118 /* Line -, iaparams.syn */
119 return 7;
120 }
121
122 static int ag_rp_14(void) {
123 /* Line -, iaparams.syn */
124 return 8;
125 }
126
127 static int ag_rp_15(void) {
128 /* Line -, iaparams.syn */
129 return 9;
130 }
131
132
133 #define READ_COUNTS
134 #define WRITE_COUNTS
135 #undef V
136 #define V(i,t) (*t (&(PCB).vs[(PCB).ssx + i]))
137 #undef VS
138 #define VS(i) (PCB).vs[(PCB).ssx + i]
139
140 #ifndef GET_CONTEXT
141 #define GET_CONTEXT CONTEXT = (PCB).input_context
142 #endif
143
144 typedef enum {
145 ag_action_1,
146 ag_action_2,
147 ag_action_3,
148 ag_action_4,
149 ag_action_5,
150 ag_action_6,
151 ag_action_7,
152 ag_action_8,
153 ag_action_9,
154 ag_action_10,
155 ag_action_11,
156 ag_action_12
157 } ag_parser_action;
158
159
160 #ifndef NULL_VALUE_INITIALIZER
161 #define NULL_VALUE_INITIALIZER = { 0 }
162 #endif
163
164 static iaparams_vs_type const ag_null_value NULL_VALUE_INITIALIZER;
165
166 static const unsigned char ag_rpx[] = {
167 0, 0, 0, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
168 15
169 };
170 #define AG_TCV(x) (((int)(x) >= 0 && (int)(x) <= 255) ? ag_tcv[(x)] : 0)
171
172 static const unsigned char ag_tcv[] = {
173 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
174 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 6, 0, 0, 0,
175 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10, 11, 12, 13, 14, 15,
176 16, 17, 18, 19, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
177 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
178 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
179 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4, 0, 0, 0, 0, 0,
180 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
181 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
182 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
183 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
184 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
185 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
186 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
187 0, 0, 0, 0
188 };
189
190 #ifndef SYNTAX_ERROR
191 #define SYNTAX_ERROR fprintf(stderr,"%s, line %d, column %d\n", \
192 (PCB).error_message, (PCB).line, (PCB).column)
193 #endif
194
195 #ifndef FIRST_LINE
196 #define FIRST_LINE 1
197 #endif
198
199 #ifndef FIRST_COLUMN
200 #define FIRST_COLUMN 1
201 #endif
202
203 #ifndef PARSER_STACK_OVERFLOW
204 #define PARSER_STACK_OVERFLOW {fprintf(stderr, \
205 "\nParser stack overflow, line %d, column %d\n",\
206 (PCB).line, (PCB).column);}
207 #endif
208
209 #ifndef REDUCTION_TOKEN_ERROR
210 #define REDUCTION_TOKEN_ERROR {fprintf(stderr, \
211 "\nReduction token error, line %d, column %d\n", \
212 (PCB).line, (PCB).column);}
213 #endif
214
215
216 #ifndef GET_INPUT
217 #define GET_INPUT ((PCB).input_code = getchar())
218 #endif
219
220
221 #ifndef AG_NEWLINE
222 #define AG_NEWLINE 10
223 #endif
224
225 #ifndef AG_RETURN
226 #define AG_RETURN 13
227 #endif
228
229 #ifndef AG_FORMFEED
230 #define AG_FORMFEED 12
231 #endif
232
233 #ifndef AG_TABCHAR
234 #define AG_TABCHAR 9
235 #endif
236
237 static void ag_track(void) {
238 switch ((PCB).input_code) {
239 case AG_NEWLINE:
240 (PCB).column = 1, (PCB).line++;
241 case AG_RETURN:
242 case AG_FORMFEED:
243 break;
244 case AG_TABCHAR:
245 (PCB).column += (TAB_SPACING) - ((PCB).column - 1) % (TAB_SPACING);
246 break;
247 default:
248 (PCB).column++;
249 }
250 (PCB).read_flag = 1;
251 }
252
253
254 static void ag_prot(void) {
255 int ag_k;
256 ag_k = 128 - ++(PCB).btsx;
257 if (ag_k <= (PCB).ssx) {
258 (PCB).exit_flag = AG_STACK_ERROR_CODE;
259 PARSER_STACK_OVERFLOW;
260 return;
261 }
262 (PCB).bts[(PCB).btsx] = (PCB).sn;
263 (PCB).bts[ag_k] = (PCB).ssx;
264 (PCB).vs[ag_k] = (PCB).vs[(PCB).ssx];
265 (PCB).ss[ag_k] = (PCB).ss[(PCB).ssx];
266 }
267
268 static void ag_undo(void) {
269 if ((PCB).drt == -1) return;
270 while ((PCB).btsx) {
271 int ag_k = 128 - (PCB).btsx;
272 (PCB).sn = (PCB).bts[(PCB).btsx--];
273 (PCB).ssx = (PCB).bts[ag_k];
274 (PCB).vs[(PCB).ssx] = (PCB).vs[ag_k];
275 (PCB).ss[(PCB).ssx] = (PCB).ss[ag_k];
276 }
277 (PCB).token_number = (iaparams_token_type) (PCB).drt;
278 (PCB).ssx = (PCB).dssx;
279 (PCB).sn = (PCB).dsn;
280 (PCB).drt = -1;
281 }
282
283
284 static const unsigned char ag_tstt[] = {
285 19,18,17,16,15,14,13,12,11,10,6,0,1,2,3,5,
286 6,0,7,
287 19,18,17,16,15,14,13,12,11,10,6,4,0,2,5,
288 19,18,17,16,15,14,13,12,11,10,0,8,
289 19,18,17,16,15,14,13,12,11,10,6,0,9,
290
291 };
292
293
294 static unsigned const char ag_astt[59] = {
295 4,4,4,4,4,4,4,4,4,4,4,7,0,1,1,1,2,7,1,4,4,4,4,4,4,4,4,4,4,4,3,7,3,1,2,2,2,
296 2,2,2,2,2,2,2,7,1,4,4,4,4,4,4,4,4,4,4,4,7,2
297 };
298
299
300 static const unsigned char ag_pstt[] = {
301 5,5,5,5,5,5,5,5,5,5,5,0,0,2,2,1,
302 4,1,3,
303 5,5,5,5,5,5,5,5,5,5,5,3,2,2,1,
304 18,17,16,15,14,13,12,11,10,9,3,4,
305 7,7,7,7,7,7,7,7,7,7,7,4,8,
306
307 };
308
309
310 static const unsigned char ag_sbt[] = {
311 0, 16, 19, 34, 46, 59
312 };
313
314
315 static const unsigned char ag_sbe[] = {
316 11, 17, 31, 44, 57, 59
317 };
318
319
320 static const unsigned char ag_fl[] = {
321 1,1,2,2,2,0,0,0,4,1,1,1,1,1,1,1,1,1,1
322 };
323
324 static const unsigned char ag_ptt[] = {
325 0, 3, 3, 1, 2, 5, 7, 9, 5, 8, 8, 8, 8, 8, 8, 8, 8, 8,
326 8
327 };
328
329
330 static void ag_ra(void)
331 {
332 switch(ag_rpx[(PCB).ag_ap]) {
333 case 1: V(0,(int *)) = ag_rp_1(V(0,(long *))); break;
334 case 2: V(0,(long *)) = ag_rp_2(); break;
335 case 3: ag_rp_3(V(-1,(long *))); break;
336 case 4: ag_rp_4(V(-3,(long *)), V(-1,(int *))); break;
337 case 5: V(0,(long *)) = ag_rp_5(V(0,(long *)), V(2,(int *))); break;
338 case 6: V(0,(int *)) = ag_rp_6(); break;
339 case 7: V(0,(int *)) = ag_rp_7(); break;
340 case 8: V(0,(int *)) = ag_rp_8(); break;
341 case 9: V(0,(int *)) = ag_rp_9(); break;
342 case 10: V(0,(int *)) = ag_rp_10(); break;
343 case 11: V(0,(int *)) = ag_rp_11(); break;
344 case 12: V(0,(int *)) = ag_rp_12(); break;
345 case 13: V(0,(int *)) = ag_rp_13(); break;
346 case 14: V(0,(int *)) = ag_rp_14(); break;
347 case 15: V(0,(int *)) = ag_rp_15(); break;
348 }
349 }
350
351 #define TOKEN_NAMES iaparams_token_names
352 const char *const iaparams_token_names[20] = {
353 "grammar",
354 "grammar",
355 "whole number",
356 "",
357 "'x'",
358 "number",
359 "' '",
360 "",
361 "digit",
362 "",
363 "'0'",
364 "'1'",
365 "'2'",
366 "'3'",
367 "'4'",
368 "'5'",
369 "'6'",
370 "'7'",
371 "'8'",
372 "'9'",
373
374 };
375
376 #ifndef MISSING_FORMAT
377 #define MISSING_FORMAT "Missing %s"
378 #endif
379 #ifndef UNEXPECTED_FORMAT
380 #define UNEXPECTED_FORMAT "Unexpected %s"
381 #endif
382 #ifndef UNNAMED_TOKEN
383 #define UNNAMED_TOKEN "input"
384 #endif
385
386
387 static void ag_diagnose(void) {
388 int ag_snd = (PCB).sn;
389 int ag_k = ag_sbt[ag_snd];
390
391 if (*TOKEN_NAMES[ag_tstt[ag_k]] && ag_astt[ag_k + 1] == ag_action_8) {
392 sprintf((PCB).ag_msg, MISSING_FORMAT, TOKEN_NAMES[ag_tstt[ag_k]]);
393 }
394 else if (ag_astt[ag_sbe[(PCB).sn]] == ag_action_8
395 && (ag_k = (int) ag_sbe[(PCB).sn] + 1) == (int) ag_sbt[(PCB).sn+1] - 1
396 && *TOKEN_NAMES[ag_tstt[ag_k]]) {
397 sprintf((PCB).ag_msg, MISSING_FORMAT, TOKEN_NAMES[ag_tstt[ag_k]]);
398 }
399 else if ((PCB).token_number && *TOKEN_NAMES[(PCB).token_number]) {
400 sprintf((PCB).ag_msg, UNEXPECTED_FORMAT, TOKEN_NAMES[(PCB).token_number]);
401 }
402 else if (isprint(((PCB).input_code)) && ((PCB).input_code) != '\\') {
403 char buf[20];
404 sprintf(buf, "\'%c\'", (char) ((PCB).input_code));
405 sprintf((PCB).ag_msg, UNEXPECTED_FORMAT, buf);
406 }
407 else sprintf((PCB).ag_msg, UNEXPECTED_FORMAT, UNNAMED_TOKEN);
408 (PCB).error_message = (PCB).ag_msg;
409
410
411 }
412 static int ag_action_1_r_proc(void);
413 static int ag_action_2_r_proc(void);
414 static int ag_action_3_r_proc(void);
415 static int ag_action_4_r_proc(void);
416 static int ag_action_1_s_proc(void);
417 static int ag_action_3_s_proc(void);
418 static int ag_action_1_proc(void);
419 static int ag_action_2_proc(void);
420 static int ag_action_3_proc(void);
421 static int ag_action_4_proc(void);
422 static int ag_action_5_proc(void);
423 static int ag_action_6_proc(void);
424 static int ag_action_7_proc(void);
425 static int ag_action_8_proc(void);
426 static int ag_action_9_proc(void);
427 static int ag_action_10_proc(void);
428 static int ag_action_11_proc(void);
429 static int ag_action_8_proc(void);
430
431
432 static int (*const ag_r_procs_scan[])(void) = {
433 ag_action_1_r_proc,
434 ag_action_2_r_proc,
435 ag_action_3_r_proc,
436 ag_action_4_r_proc
437 };
438
439 static int (*const ag_s_procs_scan[])(void) = {
440 ag_action_1_s_proc,
441 ag_action_2_r_proc,
442 ag_action_3_s_proc,
443 ag_action_4_r_proc
444 };
445
446 static int (*const ag_gt_procs_scan[])(void) = {
447 ag_action_1_proc,
448 ag_action_2_proc,
449 ag_action_3_proc,
450 ag_action_4_proc,
451 ag_action_5_proc,
452 ag_action_6_proc,
453 ag_action_7_proc,
454 ag_action_8_proc,
455 ag_action_9_proc,
456 ag_action_10_proc,
457 ag_action_11_proc,
458 ag_action_8_proc
459 };
460
461
462 static int ag_action_10_proc(void) {
463 int ag_t = (PCB).token_number;
464 (PCB).btsx = 0, (PCB).drt = -1;
465 do {
466 ag_track();
467 if ((PCB).read_flag) {
468 (PCB).read_flag = 0;
469 GET_INPUT;
470 };
471 (PCB).token_number = (iaparams_token_type) AG_TCV((PCB).input_code);
472 } while ((PCB).token_number == (iaparams_token_type) ag_t);
473 return 1;
474 }
475
476 static int ag_action_11_proc(void) {
477 int ag_t = (PCB).token_number;
478
479 (PCB).btsx = 0, (PCB).drt = -1;
480 do {
481 (*(int *) &(PCB).vs[(PCB).ssx]) = (PCB).input_code;
482 (PCB).ssx--;
483 ag_track();
484 ag_ra();
485 if ((PCB).exit_flag != AG_RUNNING_CODE) return 0;
486 (PCB).ssx++;
487 if ((PCB).read_flag) {
488 (PCB).read_flag = 0;
489 GET_INPUT;
490 };
491 (PCB).token_number = (iaparams_token_type) AG_TCV((PCB).input_code);
492 }
493 while ((PCB).token_number == (iaparams_token_type) ag_t);
494 return 1;
495 }
496
497 static int ag_action_3_r_proc(void) {
498 int ag_sd = ag_fl[(PCB).ag_ap] - 1;
499 if (ag_sd) (PCB).sn = (PCB).ss[(PCB).ssx -= ag_sd];
500 (PCB).btsx = 0, (PCB).drt = -1;
501 (PCB).reduction_token = (iaparams_token_type) ag_ptt[(PCB).ag_ap];
502 ag_ra();
503 return (PCB).exit_flag == AG_RUNNING_CODE;
504 }
505
506 static int ag_action_3_s_proc(void) {
507 int ag_sd = ag_fl[(PCB).ag_ap] - 1;
508 if (ag_sd) (PCB).sn = (PCB).ss[(PCB).ssx -= ag_sd];
509 (PCB).btsx = 0, (PCB).drt = -1;
510 (PCB).reduction_token = (iaparams_token_type) ag_ptt[(PCB).ag_ap];
511 ag_ra();
512 return (PCB).exit_flag == AG_RUNNING_CODE;
513 }
514
515 static int ag_action_4_r_proc(void) {
516 int ag_sd = ag_fl[(PCB).ag_ap] - 1;
517 if (ag_sd) (PCB).sn = (PCB).ss[(PCB).ssx -= ag_sd];
518 (PCB).reduction_token = (iaparams_token_type) ag_ptt[(PCB).ag_ap];
519 return 1;
520 }
521
522 static int ag_action_2_proc(void) {
523 (PCB).btsx = 0, (PCB).drt = -1;
524 if ((PCB).ssx >= 128) {
525 (PCB).exit_flag = AG_STACK_ERROR_CODE;
526 PARSER_STACK_OVERFLOW;
527 }
528 (*(int *) &(PCB).vs[(PCB).ssx]) = (PCB).input_code;
529 (PCB).ss[(PCB).ssx] = (PCB).sn;
530 (PCB).ssx++;
531 (PCB).sn = (PCB).ag_ap;
532 ag_track();
533 return 0;
534 }
535
536 static int ag_action_9_proc(void) {
537 if ((PCB).drt == -1) {
538 (PCB).drt=(PCB).token_number;
539 (PCB).dssx=(PCB).ssx;
540 (PCB).dsn=(PCB).sn;
541 }
542 ag_prot();
543 (PCB).vs[(PCB).ssx] = ag_null_value;
544 (PCB).ss[(PCB).ssx] = (PCB).sn;
545 (PCB).ssx++;
546 (PCB).sn = (PCB).ag_ap;
547 return (PCB).exit_flag == AG_RUNNING_CODE;
548 }
549
550 static int ag_action_2_r_proc(void) {
551 (PCB).ssx++;
552 (PCB).sn = (PCB).ag_ap;
553 return 0;
554 }
555
556 static int ag_action_7_proc(void) {
557 --(PCB).ssx;
558 (PCB).exit_flag = AG_SUCCESS_CODE;
559 return 0;
560 }
561
562 static int ag_action_1_proc(void) {
563 ag_track();
564 (PCB).exit_flag = AG_SUCCESS_CODE;
565 return 0;
566 }
567
568 static int ag_action_1_r_proc(void) {
569 (PCB).exit_flag = AG_SUCCESS_CODE;
570 return 0;
571 }
572
573 static int ag_action_1_s_proc(void) {
574 (PCB).exit_flag = AG_SUCCESS_CODE;
575 return 0;
576 }
577
578 static int ag_action_4_proc(void) {
579 int ag_sd = ag_fl[(PCB).ag_ap] - 1;
580 (PCB).reduction_token = (iaparams_token_type) ag_ptt[(PCB).ag_ap];
581 (PCB).btsx = 0, (PCB).drt = -1;
582 (*(int *) &(PCB).vs[(PCB).ssx]) = (PCB).input_code;
583 if (ag_sd) (PCB).sn = (PCB).ss[(PCB).ssx -= ag_sd];
584 else (PCB).ss[(PCB).ssx] = (PCB).sn;
585 ag_track();
586 while ((PCB).exit_flag == AG_RUNNING_CODE) {
587 unsigned ag_t1 = ag_sbe[(PCB).sn] + 1;
588 unsigned ag_t2 = ag_sbt[(PCB).sn+1] - 1;
589 do {
590 unsigned ag_tx = (ag_t1 + ag_t2)/2;
591 if (ag_tstt[ag_tx] < (unsigned char)(PCB).reduction_token) ag_t1 = ag_tx + 1;
592 else ag_t2 = ag_tx;
593 } while (ag_t1 < ag_t2);
594 (PCB).ag_ap = ag_pstt[ag_t1];
595 if ((ag_s_procs_scan[ag_astt[ag_t1]])() == 0) break;
596 }
597 return 0;
598 }
599
600 static int ag_action_3_proc(void) {
601 int ag_sd = ag_fl[(PCB).ag_ap] - 1;
602 (PCB).btsx = 0, (PCB).drt = -1;
603 (*(int *) &(PCB).vs[(PCB).ssx]) = (PCB).input_code;
604 if (ag_sd) (PCB).sn = (PCB).ss[(PCB).ssx -= ag_sd];
605 else (PCB).ss[(PCB).ssx] = (PCB).sn;
606 ag_track();
607 (PCB).reduction_token = (iaparams_token_type) ag_ptt[(PCB).ag_ap];
608 ag_ra();
609 while ((PCB).exit_flag == AG_RUNNING_CODE) {
610 unsigned ag_t1 = ag_sbe[(PCB).sn] + 1;
611 unsigned ag_t2 = ag_sbt[(PCB).sn+1] - 1;
612 do {
613 unsigned ag_tx = (ag_t1 + ag_t2)/2;
614 if (ag_tstt[ag_tx] < (unsigned char)(PCB).reduction_token) ag_t1 = ag_tx + 1;
615 else ag_t2 = ag_tx;
616 } while (ag_t1 < ag_t2);
617 (PCB).ag_ap = ag_pstt[ag_t1];
618 if ((ag_s_procs_scan[ag_astt[ag_t1]])() == 0) break;
619 }
620 return 0;
621 }
622
623 static int ag_action_8_proc(void) {
624 ag_undo();
625 (PCB).exit_flag = AG_SYNTAX_ERROR_CODE;
626 ag_diagnose();
627 SYNTAX_ERROR;
628 ag_track();
629 return (PCB).exit_flag == AG_RUNNING_CODE;
630 }
631
632 static int ag_action_5_proc(void) {
633 int ag_sd = ag_fl[(PCB).ag_ap];
634 (PCB).btsx = 0, (PCB).drt = -1;
635 if (ag_sd) (PCB).sn = (PCB).ss[(PCB).ssx -= ag_sd];
636 else {
637 (PCB).ss[(PCB).ssx] = (PCB).sn;
638 }
639 (PCB).reduction_token = (iaparams_token_type) ag_ptt[(PCB).ag_ap];
640 ag_ra();
641 while ((PCB).exit_flag == AG_RUNNING_CODE) {
642 unsigned ag_t1 = ag_sbe[(PCB).sn] + 1;
643 unsigned ag_t2 = ag_sbt[(PCB).sn+1] - 1;
644 do {
645 unsigned ag_tx = (ag_t1 + ag_t2)/2;
646 if (ag_tstt[ag_tx] < (unsigned char)(PCB).reduction_token) ag_t1 = ag_tx + 1;
647 else ag_t2 = ag_tx;
648 } while (ag_t1 < ag_t2);
649 (PCB).ag_ap = ag_pstt[ag_t1];
650 if ((ag_r_procs_scan[ag_astt[ag_t1]])() == 0) break;
651 }
652 return (PCB).exit_flag == AG_RUNNING_CODE;
653 }
654
655 static int ag_action_6_proc(void) {
656 int ag_sd = ag_fl[(PCB).ag_ap];
657 (PCB).reduction_token = (iaparams_token_type) ag_ptt[(PCB).ag_ap];
658 if ((PCB).drt == -1) {
659 (PCB).drt=(PCB).token_number;
660 (PCB).dssx=(PCB).ssx;
661 (PCB).dsn=(PCB).sn;
662 }
663 if (ag_sd) {
664 (PCB).sn = (PCB).ss[(PCB).ssx -= ag_sd];
665 }
666 else {
667 ag_prot();
668 (PCB).vs[(PCB).ssx] = ag_null_value;
669 (PCB).ss[(PCB).ssx] = (PCB).sn;
670 }
671 while ((PCB).exit_flag == AG_RUNNING_CODE) {
672 unsigned ag_t1 = ag_sbe[(PCB).sn] + 1;
673 unsigned ag_t2 = ag_sbt[(PCB).sn+1] - 1;
674 do {
675 unsigned ag_tx = (ag_t1 + ag_t2)/2;
676 if (ag_tstt[ag_tx] < (unsigned char)(PCB).reduction_token) ag_t1 = ag_tx + 1;
677 else ag_t2 = ag_tx;
678 } while (ag_t1 < ag_t2);
679 (PCB).ag_ap = ag_pstt[ag_t1];
680 if ((ag_r_procs_scan[ag_astt[ag_t1]])() == 0) break;
681 }
682 return (PCB).exit_flag == AG_RUNNING_CODE;
683 }
684
685
686 void init_iaparams(void) {
687 (PCB).read_flag = 1;
688 (PCB).ss[0] = (PCB).sn = (PCB).ssx = 0;
689 (PCB).exit_flag = AG_RUNNING_CODE;
690 (PCB).line = FIRST_LINE;
691 (PCB).column = FIRST_COLUMN;
692 (PCB).btsx = 0, (PCB).drt = -1;
693 }
694
695 void iaparams(void) {
696 init_iaparams();
697 (PCB).exit_flag = AG_RUNNING_CODE;
698 while ((PCB).exit_flag == AG_RUNNING_CODE) {
699 unsigned ag_t1 = ag_sbt[(PCB).sn];
700 if (ag_tstt[ag_t1]) {
701 unsigned ag_t2 = ag_sbe[(PCB).sn] - 1;
702 if ((PCB).read_flag) {
703 (PCB).read_flag = 0;
704 GET_INPUT;
705 };
706 (PCB).token_number = (iaparams_token_type) AG_TCV((PCB).input_code);
707 do {
708 unsigned ag_tx = (ag_t1 + ag_t2)/2;
709 if (ag_tstt[ag_tx] > (unsigned char)(PCB).token_number)
710 ag_t1 = ag_tx + 1;
711 else ag_t2 = ag_tx;
712 } while (ag_t1 < ag_t2);
713 if (ag_tstt[ag_t1] != (unsigned char)(PCB).token_number)
714 ag_t1 = ag_sbe[(PCB).sn];
715 }
716 (PCB).ag_ap = ag_pstt[ag_t1];
717 (ag_gt_procs_scan[ag_astt[ag_t1]])();
718 }
719 }
720
721