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