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