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