Mercurial > ~dholland > hg > ag > index.cgi
comparison tests/agcl/parsifal/good/eval-e.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 /* | |
2 EVALKERN.SYN | |
3 | |
4 evaluateExpression: A Simple Expression Evaluator | |
5 Copyright (c) 1996 Parsifal Software, All Rights Reserved. | |
6 See the file COPYING for license and usage terms. | |
7 | |
8 EVALKERN.SYN is the kernel of the example, consisting | |
9 of the expression parser itself. Support functions are | |
10 defined in EVALWRAP.C. A test program is defined in | |
11 EVALDEMO.C. Global declarations are contained in | |
12 EVALDEFS.H. | |
13 | |
14 The parse function defined in EVALKERN.SYN is called | |
15 evalKernel. All communication with evalKernel is via | |
16 the parser control block. The wrapper function, | |
17 evaluateExpression, defined in EVALWRAP.C, provides | |
18 a more convenient interface for the function. | |
19 | |
20 The expression syntax is borrowed from C but with the | |
21 addition of the FORTRAN exponentiation operator (**). | |
22 | |
23 The cast, increment, and decrement operators are not | |
24 implemented, nor are operations that are defined only | |
25 for integers: | |
26 Bitwise logical operators: &, |, ^, ~, &=, |=, ^= | |
27 Remainder operators: %, %= | |
28 Shift operators: <<, >>, >>=, <<= | |
29 | |
30 The supported operations are: | |
31 Assignment operators: =, +=, -=, *=, /= | |
32 Conditional expressions: ? : | |
33 Logical operators: !, &&, || | |
34 Comparison operators: ==, !=, <, <=, >, >= | |
35 Binary arithmetic operators: +, -, *, / | |
36 Exponentiation: ** | |
37 Unary arithmetic operators: +, - | |
38 Parentheses | |
39 Function calls | |
40 | |
41 All arithmetic is double precision floating point. | |
42 | |
43 Input strings may contain any number of expressions, separated by | |
44 commas or semicolons. White space may be used freely, including | |
45 both C and C++ style comments. | |
46 | |
47 eval makes the following external calls: | |
48 void pushChar(int character); | |
49 Push the specified character onto a character stack. | |
50 | |
51 double *locateVariable(int nameLength); | |
52 Pop the last nameLength characters from the character stack | |
53 and, treating them as the name of a variable, return a pointer | |
54 to the location where the value of the variable is stored. | |
55 | |
56 void pushArg(double value); | |
57 Push the specified value onto an argument stack. | |
58 | |
59 double callFunction(nameLength, int argCount); | |
60 Pop the last nameLength characters from the character stack | |
61 and, treating them as the name of a function, identify the | |
62 function and invoke it with argCount arguments popped from | |
63 the argument stack. | |
64 | |
65 double checkZero(double value); | |
66 Verify that value is not zero. | |
67 | |
68 Overrides for macros defined by AnaGram, such as SYNTAX_ERROR | |
69 should are included in EVALDEFS.H | |
70 | |
71 EVALKERN.SYN is compiled with the AnaGram parser generator | |
72 yielding EVALKERN.H and EVALKERN.C. | |
73 | |
74 For information about AnaGram, visit http://www.parsifalsoft.com. | |
75 */ | |
76 | |
77 #include <math.h> | |
78 #include "evaldefs.h" // defines external interface | |
79 | |
80 | |
81 /* | |
82 * AnaGram, A System for Syntax Directed Programming | |
83 * File generated by: ... | |
84 * | |
85 * AnaGram Parsing Engine | |
86 * Copyright 1993-2002 Parsifal Software. All Rights Reserved. | |
87 * | |
88 * This software is provided 'as-is', without any express or implied | |
89 * warranty. In no event will the authors be held liable for any damages | |
90 * arising from the use of this software. | |
91 * | |
92 * Permission is granted to anyone to use this software for any purpose, | |
93 * including commercial applications, and to alter it and redistribute it | |
94 * freely, subject to the following restrictions: | |
95 * | |
96 * 1. The origin of this software must not be misrepresented; you must not | |
97 * claim that you wrote the original software. If you use this software | |
98 * in a product, an acknowledgment in the product documentation would be | |
99 * appreciated but is not required. | |
100 * 2. Altered source versions must be plainly marked as such, and must not be | |
101 * misrepresented as being the original software. | |
102 * 3. This notice may not be removed or altered from any source distribution. | |
103 */ | |
104 | |
105 #ifndef EVAL-E_H | |
106 #include "eval-e.h" | |
107 #endif | |
108 | |
109 #ifndef EVAL-E_H | |
110 #error Mismatched header file | |
111 #endif | |
112 | |
113 #include <ctype.h> | |
114 #include <stdio.h> | |
115 | |
116 #define RULE_CONTEXT (&((PCB).cs[(PCB).ssx])) | |
117 #define ERROR_CONTEXT ((PCB).cs[(PCB).error_frame_ssx]) | |
118 #define CONTEXT ((PCB).cs[(PCB).ssx]) | |
119 | |
120 | |
121 | |
122 evalKernel_pcb_type evalKernel_pcb; | |
123 #define PCB evalKernel_pcb | |
124 | |
125 /* Line -, eval-e.syn */ | |
126 #define SYNTAX_ERROR printf("%s in %s, line %d, column %d\n", \ | |
127 (PCB).error_message, TOKEN_NAMES[(PCB).error_frame_token], (PCB).line, (PCB).column) | |
128 | |
129 | |
130 #ifndef CONVERT_CASE | |
131 #define CONVERT_CASE(c) (c) | |
132 #endif | |
133 #ifndef TAB_SPACING | |
134 #define TAB_SPACING 8 | |
135 #endif | |
136 | |
137 #define ag_rp_1(k, x) (*locateVariable(k) = x) | |
138 | |
139 #define ag_rp_2(k, x) (*locateVariable(k) += x) | |
140 | |
141 #define ag_rp_3(k, x) (*locateVariable(k) -= x) | |
142 | |
143 #define ag_rp_4(k, x) (*locateVariable(k) *= x) | |
144 | |
145 #define ag_rp_5(k, x) (*locateVariable(k) /= x) | |
146 | |
147 #define ag_rp_6(c, x, y) (c?x:y) | |
148 | |
149 #define ag_rp_7(x, y) (x||y) | |
150 | |
151 #define ag_rp_8(x, y) (x&&y) | |
152 | |
153 #define ag_rp_9(x, y) (x==y) | |
154 | |
155 #define ag_rp_10(x, y) (x!=y) | |
156 | |
157 #define ag_rp_11(x, y) (x<y) | |
158 | |
159 #define ag_rp_12(x, y) (x<=y) | |
160 | |
161 #define ag_rp_13(x, y) (x>y) | |
162 | |
163 #define ag_rp_14(x, y) (x>=y) | |
164 | |
165 #define ag_rp_15(x, y) (x+y) | |
166 | |
167 #define ag_rp_16(x, y) (x-y) | |
168 | |
169 #define ag_rp_17(x, y) (x*y) | |
170 | |
171 #define ag_rp_18(x, y) (x/checkZero(y)) | |
172 | |
173 #define ag_rp_19(x, y) (pow(x,y)) | |
174 | |
175 #define ag_rp_20(k) (*locateVariable(k)) | |
176 | |
177 #define ag_rp_21(k, n) (callFunction(k,n)) | |
178 | |
179 #define ag_rp_22(x) (x) | |
180 | |
181 #define ag_rp_23(x) (-x) | |
182 | |
183 #define ag_rp_24(x) (x) | |
184 | |
185 #define ag_rp_25(x) (!x) | |
186 | |
187 #define ag_rp_26() (0) | |
188 | |
189 #define ag_rp_27(x) (pushArg(x), 1) | |
190 | |
191 #define ag_rp_28(k, x) (pushArg(x), k+1) | |
192 | |
193 #define ag_rp_29(x, e) (x*pow(10,e)) | |
194 | |
195 #define ag_rp_30(x, e) (x*pow(10,-e)) | |
196 | |
197 #define ag_rp_31(i, f) (i+f) | |
198 | |
199 #define ag_rp_32(f) (f) | |
200 | |
201 #define ag_rp_33(d) (d-'0') | |
202 | |
203 #define ag_rp_34(x, d) (10*x + d-'0') | |
204 | |
205 #define ag_rp_35(d) ((d-'0')/10.) | |
206 | |
207 #define ag_rp_36(d, f) ((d-'0' + f)/10.) | |
208 | |
209 #define ag_rp_37(d) (d-'0') | |
210 | |
211 #define ag_rp_38(x, d) (10*x + d-'0') | |
212 | |
213 #define ag_rp_39(c) (pushChar(c), 1) | |
214 | |
215 #define ag_rp_40(k, c) (pushChar(c), k+1) | |
216 | |
217 | |
218 #define READ_COUNTS | |
219 #define WRITE_COUNTS | |
220 #undef V | |
221 #define V(i,t) (*t (&(PCB).vs[(PCB).ssx + i])) | |
222 #undef VS | |
223 #define VS(i) (PCB).vs[(PCB).ssx + i] | |
224 | |
225 #ifndef GET_CONTEXT | |
226 #define GET_CONTEXT CONTEXT = (PCB).input_context | |
227 #endif | |
228 | |
229 typedef enum { | |
230 ag_action_1, | |
231 ag_action_2, | |
232 ag_action_3, | |
233 ag_action_4, | |
234 ag_action_5, | |
235 ag_action_6, | |
236 ag_action_7, | |
237 ag_action_8, | |
238 ag_action_9, | |
239 ag_action_10, | |
240 ag_action_11, | |
241 ag_action_12 | |
242 } ag_parser_action; | |
243 | |
244 | |
245 #ifndef NULL_VALUE_INITIALIZER | |
246 #define NULL_VALUE_INITIALIZER = { 0 } | |
247 #endif | |
248 | |
249 static evalKernel_vs_type const ag_null_value NULL_VALUE_INITIALIZER; | |
250 | |
251 static const unsigned char ag_rpx[] = { | |
252 0, 0, 0, 0, 0, 0, 0, 1, 2, 3, 4, 5, 0, 6, 0, 7, 0, 8, | |
253 0, 9, 10, 0, 11, 12, 13, 14, 0, 15, 16, 0, 17, 18, 0, 19, 0, 20, | |
254 21, 22, 23, 24, 25, 26, 0, 27, 28, 0, 0, 0, 0, 0, 0, 0, 0, 0, | |
255 0, 0, 0, 0, 0, 29, 30, 31, 0, 0, 0, 32, 33, 34, 35, 36, 37, 38, | |
256 39, 40 | |
257 }; | |
258 | |
259 static const unsigned char ag_key_itt[] = { | |
260 0 | |
261 }; | |
262 | |
263 static const unsigned short ag_key_pt[] = { | |
264 0 | |
265 }; | |
266 | |
267 static const unsigned char ag_key_ch[] = { | |
268 0, 42, 47,255, 47,255, 42,255, 42, 61,255, 42, 47, 61,255, 33, 38, 42, | |
269 43, 45, 47, 60, 61, 62,124,255, 42, 47,255, 33, 38, 42, 47, 60, 61, 62, | |
270 124,255, 33, 38, 42, 60, 61, 62,124,255, 33, 38, 60, 61, 62,124,255, 33, | |
271 38, 61,124,255, 38,124,255,124,255, 42, 61,255, 33, 38, 42, 43, 45, 47, | |
272 60, 61, 62,124,255 | |
273 }; | |
274 | |
275 static const unsigned char ag_key_act[] = { | |
276 0,0,0,4,2,4,3,4,0,0,4,0,0,0,4,3,3,2,3,3,2,3,3,3,3,4,0,0,4,3,3,3,2,3,3, | |
277 3,3,4,3,3,3,3,3,3,3,4,3,3,3,3,3,3,4,3,3,3,3,4,3,3,4,3,4,0,0,4,3,3,2,3, | |
278 3,3,3,3,3,3,4 | |
279 }; | |
280 | |
281 static const unsigned char ag_key_parm[] = { | |
282 0, 46, 51, 0, 0, 0, 50, 0, 93, 77, 0, 46, 51, 78, 0, 84, 82, 0, | |
283 75, 76, 0, 86, 83, 88, 81, 0, 46, 51, 0, 84, 82, 93, 0, 86, 83, 88, | |
284 81, 0, 84, 82, 93, 86, 83, 88, 81, 0, 84, 82, 86, 83, 88, 81, 0, 84, | |
285 82, 83, 81, 0, 82, 81, 0, 81, 0, 93, 77, 0, 84, 82, 0, 75, 76, 78, | |
286 86, 83, 88, 81, 0 | |
287 }; | |
288 | |
289 static const unsigned char ag_key_jmp[] = { | |
290 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 4, 8, | |
291 6, 8, 11, 10, 12, 14, 16, 0, 0, 0, 0, 18, 20, 22, 26, 24, 26, 28, | |
292 30, 0, 32, 34, 36, 38, 40, 42, 44, 0, 46, 48, 50, 52, 54, 56, 0, 58, | |
293 60, 62, 64, 0, 66, 68, 0, 70, 0, 0, 0, 0, 72, 74, 63, 76, 78, 80, | |
294 82, 84, 86, 88, 0 | |
295 }; | |
296 | |
297 static const unsigned char ag_key_index[] = { | |
298 4, 0, 6, 15, 0, 0, 0, 6, 6, 0, 29, 29, 4, 4, 4, 4, 29, 0, | |
299 0, 0, 0, 38, 46, 46, 46, 53, 58, 15, 61, 66, 0, 29, 29, 0, 38, 0, | |
300 4, 0, 4, 0, 4, 0, 0, 0, 4, 0, 4, 0, 4, 0, 4, 0, 4, 0, | |
301 4, 0, 4, 0, 4, 0, 4, 0, 0, 4, 0, 4, 0, 4, 0, 4, 0, 4, | |
302 0, 4, 4, 0, 0, 0, 29, 46, 46, 46, 46, 46, 46, 46, 46, 53, 58, 0, | |
303 0, 0, 29, 29, 4, 0, 0, 0 | |
304 }; | |
305 | |
306 static const unsigned char ag_key_ends[] = { | |
307 47,0, 61,0, 38,0, 61,0, 61,0, 61,0, 61,0, 61,0, 124,0, | |
308 61,0, 38,0, 42,0, 61,0, 61,0, 61,0, 124,0, 61,0, 38,0, 42,0, | |
309 61,0, 61,0, 61,0, 124,0, 61,0, 38,0, 61,0, 61,0, 61,0, 124,0, | |
310 61,0, 38,0, 61,0, 124,0, 38,0, 124,0, 124,0, 61,0, 38,0, | |
311 61,0, 61,0, 61,0, 61,0, 61,0, 61,0, 124,0, | |
312 }; | |
313 #define AG_TCV(x) (((int)(x) >= -1 && (int)(x) <= 255) ? ag_tcv[(x) + 1] : 0) | |
314 | |
315 static const unsigned char ag_tcv[] = { | |
316 6, 6, 69, 69, 69, 69, 69, 69, 69, 69, 68, 55, 68, 68, 68, 69, 69, 69, | |
317 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 68, 97, 69, | |
318 69, 69, 69, 69, 69, 96, 95, 91, 89, 98, 90, 61, 92, 64, 64, 64, 64, 64, | |
319 64, 64, 64, 64, 64, 79, 99, 85, 73, 87, 80, 69, 70, 70, 70, 70, 57, 70, | |
320 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, | |
321 70, 70, 69, 69, 69, 69, 70, 69, 70, 70, 70, 70, 57, 70, 70, 70, 70, 70, | |
322 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 69, 69, | |
323 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, | |
324 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, | |
325 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, | |
326 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, | |
327 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, | |
328 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, | |
329 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, | |
330 69, 69, 69, 69, 69 | |
331 }; | |
332 | |
333 #ifndef SYNTAX_ERROR | |
334 #define SYNTAX_ERROR fprintf(stderr,"%s, line %d, column %d\n", \ | |
335 (PCB).error_message, (PCB).line, (PCB).column) | |
336 #endif | |
337 | |
338 #ifndef FIRST_LINE | |
339 #define FIRST_LINE 1 | |
340 #endif | |
341 | |
342 #ifndef FIRST_COLUMN | |
343 #define FIRST_COLUMN 1 | |
344 #endif | |
345 | |
346 #ifndef PARSER_STACK_OVERFLOW | |
347 #define PARSER_STACK_OVERFLOW {fprintf(stderr, \ | |
348 "\nParser stack overflow, line %d, column %d\n",\ | |
349 (PCB).line, (PCB).column);} | |
350 #endif | |
351 | |
352 #ifndef REDUCTION_TOKEN_ERROR | |
353 #define REDUCTION_TOKEN_ERROR {fprintf(stderr, \ | |
354 "\nReduction token error, line %d, column %d\n", \ | |
355 (PCB).line, (PCB).column);} | |
356 #endif | |
357 | |
358 | |
359 typedef enum | |
360 {ag_accept_key, ag_set_key, ag_jmp_key, ag_end_key, ag_no_match_key, | |
361 ag_cf_accept_key, ag_cf_set_key, ag_cf_end_key} key_words; | |
362 | |
363 | |
364 #ifndef AG_NEWLINE | |
365 #define AG_NEWLINE 10 | |
366 #endif | |
367 | |
368 #ifndef AG_RETURN | |
369 #define AG_RETURN 13 | |
370 #endif | |
371 | |
372 #ifndef AG_FORMFEED | |
373 #define AG_FORMFEED 12 | |
374 #endif | |
375 | |
376 #ifndef AG_TABCHAR | |
377 #define AG_TABCHAR 9 | |
378 #endif | |
379 | |
380 static void ag_track(void) { | |
381 int ag_k = 0; | |
382 while (ag_k < (PCB).rx) { | |
383 int ag_ch = (PCB).lab[ag_k++]; | |
384 switch (ag_ch) { | |
385 case AG_NEWLINE: | |
386 (PCB).column = 1, (PCB).line++; | |
387 case AG_RETURN: | |
388 case AG_FORMFEED: | |
389 break; | |
390 case AG_TABCHAR: | |
391 (PCB).column += (TAB_SPACING) - ((PCB).column - 1) % (TAB_SPACING); | |
392 break; | |
393 default: | |
394 (PCB).column++; | |
395 } | |
396 } | |
397 ag_k = 0; | |
398 while ((PCB).rx < (PCB).fx) (PCB).lab[ag_k++] = (PCB).lab[(PCB).rx++]; | |
399 (PCB).fx = ag_k; | |
400 (PCB).rx = 0; | |
401 } | |
402 | |
403 | |
404 static void ag_prot(void) { | |
405 int ag_k; | |
406 ag_k = 128 - ++(PCB).btsx; | |
407 if (ag_k <= (PCB).ssx) { | |
408 (PCB).exit_flag = AG_STACK_ERROR_CODE; | |
409 PARSER_STACK_OVERFLOW; | |
410 return; | |
411 } | |
412 (PCB).bts[(PCB).btsx] = (PCB).sn; | |
413 (PCB).bts[ag_k] = (PCB).ssx; | |
414 (PCB).vs[ag_k] = (PCB).vs[(PCB).ssx]; | |
415 (PCB).ss[ag_k] = (PCB).ss[(PCB).ssx]; | |
416 } | |
417 | |
418 static void ag_undo(void) { | |
419 if ((PCB).drt == -1) return; | |
420 while ((PCB).btsx) { | |
421 int ag_k = 128 - (PCB).btsx; | |
422 (PCB).sn = (PCB).bts[(PCB).btsx--]; | |
423 (PCB).ssx = (PCB).bts[ag_k]; | |
424 (PCB).vs[(PCB).ssx] = (PCB).vs[ag_k]; | |
425 (PCB).ss[(PCB).ssx] = (PCB).ss[ag_k]; | |
426 } | |
427 (PCB).token_number = (evalKernel_token_type) (PCB).drt; | |
428 (PCB).ssx = (PCB).dssx; | |
429 (PCB).sn = (PCB).dsn; | |
430 (PCB).drt = -1; | |
431 } | |
432 | |
433 | |
434 static const unsigned char ag_tstt[] = { | |
435 99,98,97,96,90,89,70,68,64,61,57,55,51,46,6,0,1,71,72, | |
436 99,98,97,96,95,92,91,90,89,87,85,80,79,73,70,69,68,64,61,57,55,0,53,54, | |
437 99,98,97,96,95,92,91,90,89,87,85,80,79,73,70,69,68,64,61,57,55,50,0,48,49, | |
438 68,55,51,46,0,1, | |
439 99,98,97,96,90,89,70,64,61,57,6,0,2,3,4,5,7,8,10,16,19,21,23,26,31,32,33,34, | |
440 37,39,42,56,60,74,94, | |
441 99,98,97,96,95,92,91,90,89,87,85,80,79,73,70,69,68,64,61,57,0, | |
442 55,0, | |
443 99,98,97,96,95,92,91,90,89,87,85,80,79,73,70,69,68,64,61,57,55,0, | |
444 50,0, | |
445 64,0,62, | |
446 99,98,95,93,92,91,90,89,88,87,86,85,84,83,82,81,80,79,68,64,61,57,55,51,46, | |
447 6,0,63, | |
448 57,0, | |
449 97,96,90,89,70,68,64,61,57,55,51,46,0,1,71,72, | |
450 97,96,90,89,70,68,64,61,57,55,51,46,0,1,71,72, | |
451 97,96,90,89,70,68,64,61,57,55,51,46,0,1,71,72, | |
452 97,96,95,90,89,70,68,64,61,57,55,51,46,0,1,71,72, | |
453 99,98,95,93,92,91,90,89,88,87,86,85,84,83,82,81,80,79,68,55,51,46,6,0,1,71, | |
454 72, | |
455 97,96,90,89,70,64,61,57,0,2,3,32,33,37,39,42,56,60,74,94, | |
456 97,96,90,89,70,64,61,57,0,2,3,32,33,37,39,42,56,60,74,94, | |
457 97,96,90,89,70,64,61,57,0,2,3,32,33,37,39,42,56,60,74,94, | |
458 97,96,90,89,70,64,61,57,0,2,3,7,10,16,19,21,23,26,31,32,33,34,37,39,42,56, | |
459 60,74,94, | |
460 93,0,38, | |
461 92,91,0,35,36, | |
462 90,89,0,32,33, | |
463 88,87,86,85,0,27,28,29,30, | |
464 84,83,0,24,25, | |
465 82,0,22, | |
466 99,98,96,95,93,92,91,90,89,88,87,86,85,84,83,82,81,80,79,78,77,76,75,73,70, | |
467 68,64,57,55,51,46,6,0,1,71,72, | |
468 81,80,0,17,20, | |
469 96,78,77,76,75,73,0,11,12,13,14,15,39, | |
470 99,98,6,0,44,67, | |
471 64,0,62, | |
472 64,0,62, | |
473 90,89,64,0,58, | |
474 96,0,39, | |
475 95,0,41, | |
476 97,96,90,89,70,68,64,61,57,55,51,46,0,1,71,72, | |
477 97,96,90,89,70,64,61,57,0,2,3,32,33,34,37,39,42,56,60,74,94, | |
478 97,96,90,89,70,68,64,61,57,55,51,46,0,1,71,72, | |
479 97,96,90,89,70,64,61,57,0,2,3,32,33,34,37,39,42,56,60,74,94, | |
480 97,96,90,89,70,68,64,61,57,55,51,46,0,1,71,72, | |
481 97,96,90,89,70,64,61,57,0,2,3,32,33,34,37,39,42,56,60,74,94, | |
482 97,96,90,89,70,64,61,57,0,2,3,31,32,33,34,37,39,42,56,60,74,94, | |
483 97,96,90,89,70,64,61,57,0,2,3,31,32,33,34,37,39,42,56,60,74,94, | |
484 97,96,90,89,70,68,64,61,57,55,51,46,0,1,71,72, | |
485 97,96,90,89,70,64,61,57,0,2,3,26,31,32,33,34,37,39,42,56,60,74,94, | |
486 97,96,90,89,70,68,64,61,57,55,51,46,0,1,71,72, | |
487 97,96,90,89,70,64,61,57,0,2,3,26,31,32,33,34,37,39,42,56,60,74,94, | |
488 97,96,90,89,70,68,64,61,57,55,51,46,0,1,71,72, | |
489 97,96,90,89,70,64,61,57,0,2,3,26,31,32,33,34,37,39,42,56,60,74,94, | |
490 97,96,90,89,70,68,64,61,57,55,51,46,0,1,71,72, | |
491 97,96,90,89,70,64,61,57,0,2,3,26,31,32,33,34,37,39,42,56,60,74,94, | |
492 97,96,90,89,70,68,64,61,57,55,51,46,0,1,71,72, | |
493 97,96,90,89,70,64,61,57,0,2,3,23,26,31,32,33,34,37,39,42,56,60,74,94, | |
494 97,96,90,89,70,68,64,61,57,55,51,46,0,1,71,72, | |
495 97,96,90,89,70,64,61,57,0,2,3,23,26,31,32,33,34,37,39,42,56,60,74,94, | |
496 97,96,90,89,70,68,64,61,57,55,51,46,0,1,71,72, | |
497 97,96,90,89,70,64,61,57,0,2,3,21,23,26,31,32,33,34,37,39,42,56,60,74,94, | |
498 97,96,90,89,70,68,64,61,57,55,51,46,0,1,71,72, | |
499 97,96,90,89,70,64,61,57,0,2,3,19,21,23,26,31,32,33,34,37,39,42,56,60,74,94, | |
500 97,96,90,89,70,68,64,61,57,55,51,46,0,1,71,72, | |
501 97,96,90,89,70,64,61,57,0,2,3,7,10,16,19,21,23,26,31,32,33,34,37,39,42,56, | |
502 60,74,94, | |
503 97,96,95,90,89,70,64,61,57,0,2,3,7,10,16,19,21,23,26,31,32,33,34,37,39,40, | |
504 42,43,56,60,74,94, | |
505 97,96,90,89,70,68,64,61,57,55,51,46,0,1,71,72, | |
506 97,96,90,89,70,64,61,57,0,2,3,7,10,16,19,21,23,26,31,32,33,34,37,39,42,56, | |
507 60,74,94, | |
508 97,96,90,89,70,68,64,61,57,55,51,46,0,1,71,72, | |
509 97,96,90,89,70,64,61,57,0,2,3,7,10,16,19,21,23,26,31,32,33,34,37,39,42,56, | |
510 60,74,94, | |
511 97,96,90,89,70,68,64,61,57,55,51,46,0,1,71,72, | |
512 97,96,90,89,70,64,61,57,0,2,3,7,10,16,19,21,23,26,31,32,33,34,37,39,42,56, | |
513 60,74,94, | |
514 97,96,90,89,70,68,64,61,57,55,51,46,0,1,71,72, | |
515 97,96,90,89,70,64,61,57,0,2,3,7,10,16,19,21,23,26,31,32,33,34,37,39,42,56, | |
516 60,74,94, | |
517 97,96,90,89,70,68,64,61,57,55,51,46,0,1,71,72, | |
518 97,96,90,89,70,64,61,57,0,2,3,7,10,16,19,21,23,26,31,32,33,34,37,39,42,56, | |
519 60,74,94, | |
520 99,98,97,96,90,89,70,68,64,61,57,55,51,46,6,0,1,71,72, | |
521 99,98,97,96,90,89,70,68,64,61,57,55,51,46,6,0,1,71,72, | |
522 99,98,97,96,90,89,70,64,61,57,6,0,2,3,7,8,10,16,19,21,23,26,31,32,33,34,37, | |
523 39,42,56,60,74,94, | |
524 64,0,59, | |
525 64,0,59, | |
526 99,98,95,93,92,91,90,89,88,87,86,85,84,83,82,81,80,79,68,55,51,46,6,0,1,71, | |
527 72, | |
528 92,91,0,35,36, | |
529 92,91,0,35,36, | |
530 90,89,0,32,33, | |
531 90,89,0,32,33, | |
532 90,89,0,32,33, | |
533 90,89,0,32,33, | |
534 88,87,86,85,0,27,28,29,30, | |
535 88,87,86,85,0,27,28,29,30, | |
536 84,83,0,24,25, | |
537 82,0,22, | |
538 79,0,18, | |
539 98,0,44, | |
540 95,0,41, | |
541 64,0, | |
542 64,0, | |
543 97,96,90,89,70,68,64,61,57,55,51,46,0,1,71,72, | |
544 97,96,90,89,70,64,61,57,0,2,3,10,16,19,21,23,26,31,32,33,34,37,39,42,56,60, | |
545 74,94, | |
546 97,96,90,89,70,64,61,57,0,2,3,7,10,16,19,21,23,26,31,32,33,34,37,39,42,56, | |
547 60,74,94, | |
548 0 | |
549 }; | |
550 | |
551 | |
552 static unsigned const char ag_astt[1500] = { | |
553 8,8,8,8,8,8,8,1,8,8,8,1,1,1,8,7,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, | |
554 1,1,8,7,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,8,7,1,1,9,9,1,1,5,3, | |
555 5,5,1,1,1,1,2,2,1,2,5,7,1,1,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,9,9, | |
556 9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,5,3,7,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9, | |
557 9,9,9,9,9,5,3,7,1,7,2,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,10,1,5,5,5,5,5, | |
558 7,3,1,5,5,5,5,5,5,1,5,5,5,1,1,1,7,1,1,3,5,5,5,5,5,1,5,5,5,1,1,1,7,1,1,3,5, | |
559 5,5,5,5,1,5,5,5,1,1,1,7,1,1,3,5,5,5,5,5,5,1,5,5,5,1,1,1,7,1,1,3,5,5,5,5,5, | |
560 5,5,5,5,5,5,5,5,5,5,5,5,5,1,1,1,1,5,7,1,1,3,1,1,1,1,2,2,1,2,7,2,1,1,1,2,1, | |
561 1,1,1,1,1,1,1,1,1,2,2,1,2,7,2,1,1,1,2,1,1,1,1,1,1,1,1,1,1,2,2,1,2,7,2,1,1, | |
562 1,2,1,1,1,1,1,1,1,1,1,1,2,2,1,2,7,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, | |
563 1,5,1,1,1,5,1,1,1,1,5,1,1,1,1,1,1,5,1,1,1,1,1,1,5,1,1,1,5,1,5,5,5,5,5,5,5, | |
564 5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,10,1,10,10,1,1,1,5,7,1,1,3,1,1,5,1,1,1,1, | |
565 1,1,1,1,4,1,1,1,1,1,1,1,1,3,7,1,1,1,4,2,1,5,2,1,1,8,7,1,1,4,1,1,7,2,5,5,5, | |
566 5,5,1,5,5,5,1,1,1,7,1,1,3,1,1,1,1,2,2,1,2,7,1,1,1,1,2,1,1,1,1,1,1,1,5,5,5, | |
567 5,5,1,5,5,5,1,1,1,7,1,1,3,1,1,1,1,2,2,1,2,7,1,1,1,1,2,1,1,1,1,1,1,1,5,5,5, | |
568 5,5,1,5,5,5,1,1,1,7,1,1,3,1,1,1,1,2,2,1,2,7,1,1,1,1,2,1,1,1,1,1,1,1,1,1,1, | |
569 1,2,2,1,2,7,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,2,2,1,2,7,1,1,1,1,1,1,1,1,1, | |
570 1,1,1,1,5,5,5,5,5,1,5,5,5,1,1,1,7,1,1,3,1,1,1,1,2,2,1,2,7,1,1,1,1,1,1,1,1, | |
571 1,1,1,1,1,1,5,5,5,5,5,1,5,5,5,1,1,1,7,1,1,3,1,1,1,1,2,2,1,2,7,1,1,1,1,1,1, | |
572 1,1,1,1,1,1,1,1,5,5,5,5,5,1,5,5,5,1,1,1,7,1,1,3,1,1,1,1,2,2,1,2,7,1,1,1,1, | |
573 1,1,1,1,1,1,1,1,1,1,5,5,5,5,5,1,5,5,5,1,1,1,7,1,1,3,1,1,1,1,2,2,1,2,7,1,1, | |
574 1,1,1,1,1,1,1,1,1,1,1,1,5,5,5,5,5,1,5,5,5,1,1,1,7,1,1,3,1,1,1,1,2,2,1,2,7, | |
575 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,5,5,5,5,5,1,5,5,5,1,1,1,7,1,1,3,1,1,1,1,2,2, | |
576 1,2,7,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,5,5,5,5,5,1,5,5,5,1,1,1,7,1,1,3,1,1,1, | |
577 1,2,2,1,2,7,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,5,5,5,5,5,1,5,5,5,1,1,1,7,1,1, | |
578 3,1,1,1,1,2,2,1,2,7,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,5,5,5,5,5,1,5,5,5,1, | |
579 1,1,7,1,1,3,1,1,1,1,2,2,1,2,7,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, | |
580 4,1,1,2,2,1,2,7,1,1,2,2,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,5,5,5,5,5,1,5, | |
581 5,5,1,1,1,7,1,1,3,1,1,1,1,2,2,1,2,7,1,1,2,2,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, | |
582 1,5,5,5,5,5,1,5,5,5,1,1,1,7,1,1,3,1,1,1,1,2,2,1,2,7,1,1,2,2,1,1,1,1,1,1,1, | |
583 1,1,1,1,1,1,1,1,1,5,5,5,5,5,1,5,5,5,1,1,1,7,1,1,3,1,1,1,1,2,2,1,2,7,1,1,2, | |
584 2,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,5,5,5,5,5,1,5,5,5,1,1,1,7,1,1,3,1,1,1,1, | |
585 2,2,1,2,7,1,1,2,2,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,5,5,5,5,5,1,5,5,5,1,1,1, | |
586 7,1,1,3,1,1,1,1,2,2,1,2,7,1,1,2,2,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,5,5,5,5, | |
587 5,5,5,1,5,5,5,1,1,1,5,7,1,1,3,5,5,5,5,5,5,5,1,5,5,5,1,1,1,5,7,1,1,3,5,5,1, | |
588 1,1,1,2,2,1,2,5,7,1,1,3,3,3,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,2,7,1,2,7,1,5, | |
589 5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,1,1,1,1,5,7,1,1,3,1,1,4,1,1,1,1,4,1,1,1, | |
590 1,4,1,1,1,1,4,1,1,1,1,4,1,1,1,1,4,1,1,1,1,1,1,4,1,1,1,1,1,1,1,1,4,1,1,1,1, | |
591 1,1,4,1,1,1,4,1,1,7,1,1,5,1,1,7,2,10,4,10,4,5,5,5,5,5,1,5,5,5,1,1,1,7,1,1, | |
592 3,1,1,1,1,2,2,1,2,7,1,1,2,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,2,2,1,2, | |
593 7,1,1,2,2,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,11 | |
594 }; | |
595 | |
596 | |
597 static const unsigned char ag_pstt[] = { | |
598 4,4,4,4,4,4,4,3,4,4,4,3,1,2,4,0,3,3,4, | |
599 5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,6,1,5,6, | |
600 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,8,2,7,8, | |
601 125,125,1,2,127,125, | |
602 2,2,12,15,14,13,72,66,9,72,2,4,21,29,0,30,30,30,30,28,26,25,24,23,22,18,19, | |
603 22,21,20,17,11,10,27,16, | |
604 52,52,52,52,52,52,52,52,52,52,52,52,52,52,52,52,52,52,52,52,54, | |
605 55,6, | |
606 47,47,47,47,47,47,47,47,47,47,47,47,47,47,47,47,47,47,47,47,47,49, | |
607 50,8, | |
608 31,9,65, | |
609 62,62,62,62,62,62,62,62,62,62,62,62,62,62,62,62,62,62,62,67,32,62,62,62,62, | |
610 62,10,64, | |
611 33,56, | |
612 126,126,126,126,126,3,126,126,126,3,1,2,12,3,3,152, | |
613 126,126,126,126,126,3,126,126,126,3,1,2,13,3,3,144, | |
614 126,126,126,126,126,3,126,126,126,3,1,2,14,3,3,145, | |
615 126,126,126,126,126,126,3,126,126,126,3,1,2,15,3,3,151, | |
616 126,126,126,126,126,126,126,126,126,126,126,126,126,126,126,126,126,126,3,3, | |
617 1,2,126,16,3,3,149, | |
618 12,15,14,13,72,66,9,72,17,40,34,18,19,40,20,17,11,10,27,16, | |
619 12,15,14,13,72,66,9,72,18,39,34,18,19,39,20,17,11,10,27,16, | |
620 12,15,14,13,72,66,9,72,19,38,34,18,19,38,20,17,11,10,27,16, | |
621 12,15,14,13,72,66,9,72,20,21,29,35,35,28,26,25,24,23,22,18,19,22,21,20,17, | |
622 11,10,27,16, | |
623 36,32,37, | |
624 38,40,26,41,39, | |
625 14,13,21,43,42, | |
626 44,46,48,50,18,51,49,47,45, | |
627 52,54,16,55,53, | |
628 56,14,57, | |
629 126,126,126,126,126,126,126,126,126,126,126,126,126,126,126,126,126,126,126, | |
630 126,126,126,126,126,73,3,73,73,3,1,2,126,27,3,3,129, | |
631 58,60,12,61,59, | |
632 15,63,65,67,69,71,35,72,70,68,66,64,62, | |
633 73,74,1,30,75,75, | |
634 31,68,69, | |
635 31,63,61, | |
636 76,77,77,33,77, | |
637 15,35,62, | |
638 78,35,37, | |
639 126,126,126,126,126,3,126,126,126,3,1,2,36,3,3,148, | |
640 12,15,14,13,72,66,9,72,37,21,34,18,19,33,21,20,17,11,10,27,16, | |
641 126,126,126,126,126,3,126,126,126,3,1,2,38,3,3,147, | |
642 12,15,14,13,72,66,9,72,39,21,34,18,19,31,21,20,17,11,10,27,16, | |
643 126,126,126,126,126,3,126,126,126,3,1,2,40,3,3,146, | |
644 12,15,14,13,72,66,9,72,41,21,34,18,19,30,21,20,17,11,10,27,16, | |
645 12,15,14,13,72,66,9,72,42,21,34,79,18,19,79,21,20,17,11,10,27,16, | |
646 12,15,14,13,72,66,9,72,43,21,34,80,18,19,80,21,20,17,11,10,27,16, | |
647 126,126,126,126,126,3,126,126,126,3,1,2,44,3,3,143, | |
648 12,15,14,13,72,66,9,72,45,21,34,81,22,18,19,22,21,20,17,11,10,27,16, | |
649 126,126,126,126,126,3,126,126,126,3,1,2,46,3,3,142, | |
650 12,15,14,13,72,66,9,72,47,21,34,82,22,18,19,22,21,20,17,11,10,27,16, | |
651 126,126,126,126,126,3,126,126,126,3,1,2,48,3,3,141, | |
652 12,15,14,13,72,66,9,72,49,21,34,83,22,18,19,22,21,20,17,11,10,27,16, | |
653 126,126,126,126,126,3,126,126,126,3,1,2,50,3,3,140, | |
654 12,15,14,13,72,66,9,72,51,21,34,84,22,18,19,22,21,20,17,11,10,27,16, | |
655 126,126,126,126,126,3,126,126,126,3,1,2,52,3,3,139, | |
656 12,15,14,13,72,66,9,72,53,21,34,85,23,22,18,19,22,21,20,17,11,10,27,16, | |
657 126,126,126,126,126,3,126,126,126,3,1,2,54,3,3,138, | |
658 12,15,14,13,72,66,9,72,55,21,34,86,23,22,18,19,22,21,20,17,11,10,27,16, | |
659 126,126,126,126,126,3,126,126,126,3,1,2,56,3,3,137, | |
660 12,15,14,13,72,66,9,72,57,21,34,87,24,23,22,18,19,22,21,20,17,11,10,27,16, | |
661 126,126,126,126,126,3,126,126,126,3,1,2,58,3,3,136, | |
662 12,15,14,13,72,66,9,72,59,21,34,88,25,24,23,22,18,19,22,21,20,17,11,10,27, | |
663 16, | |
664 126,126,126,126,126,3,126,126,126,3,1,2,60,3,3,135, | |
665 12,15,14,13,72,66,9,72,61,21,29,89,89,28,26,25,24,23,22,18,19,22,21,20,17, | |
666 11,10,27,16, | |
667 12,15,41,14,13,72,66,9,72,62,21,29,43,43,28,26,25,24,23,22,18,19,22,21,20, | |
668 91,17,90,11,10,27,16, | |
669 126,126,126,126,126,3,126,126,126,3,1,2,63,3,3,133, | |
670 12,15,14,13,72,66,9,72,64,21,29,11,11,28,26,25,24,23,22,18,19,22,21,20,17, | |
671 11,10,27,16, | |
672 126,126,126,126,126,3,126,126,126,3,1,2,65,3,3,132, | |
673 12,15,14,13,72,66,9,72,66,21,29,10,10,28,26,25,24,23,22,18,19,22,21,20,17, | |
674 11,10,27,16, | |
675 126,126,126,126,126,3,126,126,126,3,1,2,67,3,3,131, | |
676 12,15,14,13,72,66,9,72,68,21,29,9,9,28,26,25,24,23,22,18,19,22,21,20,17,11, | |
677 10,27,16, | |
678 126,126,126,126,126,3,126,126,126,3,1,2,69,3,3,130, | |
679 12,15,14,13,72,66,9,72,70,21,29,8,8,28,26,25,24,23,22,18,19,22,21,20,17,11, | |
680 10,27,16, | |
681 126,126,126,126,126,3,126,126,126,3,1,2,71,3,3,128, | |
682 12,15,14,13,72,66,9,72,72,21,29,7,7,28,26,25,24,23,22,18,19,22,21,20,17,11, | |
683 10,27,16, | |
684 126,126,126,126,126,126,126,3,126,126,126,3,1,2,126,73,3,3,154, | |
685 126,126,126,126,126,126,126,3,126,126,126,3,1,2,126,74,3,3,153, | |
686 2,2,12,15,14,13,72,66,9,72,2,75,21,29,5,5,5,28,26,25,24,23,22,18,19,22,21, | |
687 20,17,11,10,27,16, | |
688 70,76,92, | |
689 70,77,93, | |
690 126,126,126,126,126,126,126,126,126,126,126,126,126,126,126,126,126,126,3,3, | |
691 1,2,126,78,3,3,150, | |
692 38,40,28,41,39, | |
693 38,40,27,41,39, | |
694 14,13,25,43,42, | |
695 14,13,24,43,42, | |
696 14,13,23,43,42, | |
697 14,13,22,43,42, | |
698 44,46,48,50,20,51,49,47,45, | |
699 44,46,48,50,19,51,49,47,45, | |
700 52,54,17,55,53, | |
701 56,15,57, | |
702 94,89,95, | |
703 74,42,96, | |
704 78,91,36, | |
705 71,60, | |
706 71,59, | |
707 126,126,126,126,126,3,126,126,126,3,1,2,94,3,3,134, | |
708 12,15,14,13,72,66,9,72,95,21,34,13,28,26,25,24,23,22,18,19,22,21,20,17,11, | |
709 10,27,16, | |
710 12,15,14,13,72,66,9,72,96,21,29,44,44,28,26,25,24,23,22,18,19,22,21,20,17, | |
711 11,10,27,16, | |
712 0 | |
713 }; | |
714 | |
715 | |
716 static const unsigned short ag_sbt[] = { | |
717 0, 19, 43, 68, 74, 109, 130, 132, 154, 156, 159, 187, 189, 205, | |
718 221, 237, 254, 281, 301, 321, 341, 370, 373, 378, 383, 392, 397, 400, | |
719 436, 441, 454, 460, 463, 466, 471, 474, 477, 493, 514, 530, 551, 567, | |
720 588, 610, 632, 648, 671, 687, 710, 726, 749, 765, 788, 804, 828, 844, | |
721 868, 884, 909, 925, 951, 967, 996,1028,1044,1073,1089,1118,1134,1163, | |
722 1179,1208,1224,1253,1272,1291,1324,1327,1330,1357,1362,1367,1372,1377, | |
723 1382,1387,1396,1405,1410,1413,1416,1419,1422,1424,1426,1442,1470,1499 | |
724 }; | |
725 | |
726 | |
727 static const unsigned short ag_sbe[] = { | |
728 15, 40, 65, 72, 85, 129, 131, 153, 155, 157, 185, 188, 201, 217, | |
729 233, 250, 277, 289, 309, 329, 349, 371, 375, 380, 387, 394, 398, 432, | |
730 438, 447, 457, 461, 464, 469, 472, 475, 489, 501, 526, 538, 563, 575, | |
731 596, 618, 644, 656, 683, 695, 722, 734, 761, 773, 800, 812, 840, 852, | |
732 880, 892, 921, 933, 963, 975,1005,1040,1052,1085,1097,1130,1142,1175, | |
733 1187,1220,1232,1268,1287,1302,1325,1328,1353,1359,1364,1369,1374,1379, | |
734 1384,1391,1400,1407,1411,1414,1417,1420,1423,1425,1438,1450,1478,1499 | |
735 }; | |
736 | |
737 | |
738 static const unsigned char ag_fl[] = { | |
739 2,2,0,1,1,3,1,3,3,3,3,3,1,5,1,3,1,3,1,3,3,1,3,3,3,3,1,3,3,1,3,3,1,3,1, | |
740 1,4,3,2,2,2,0,1,1,3,1,1,2,0,1,3,1,2,0,1,3,1,0,1,4,4,3,0,1,2,2,1,2,1,2, | |
741 1,2,1,2,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, | |
742 1,1,1,1,1,1,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,2,2, | |
743 2,2,2,2,2,2,2,2,2,2,2,2,2,2,2 | |
744 }; | |
745 | |
746 static const unsigned char ag_ptt[] = { | |
747 0, 4, 8, 8, 5, 5, 7, 7, 7, 7, 7, 7, 10, 10, 16, 16, 19, 19, | |
748 21, 21, 21, 23, 23, 23, 23, 23, 26, 26, 26, 31, 31, 31, 34, 34, 37, 37, | |
749 37, 37, 37, 37, 37, 40, 40, 43, 43, 1, 48, 48, 49, 49, 1, 53, 53, 54, | |
750 54, 1, 94, 58, 58, 94, 94, 56, 63, 63, 56, 56, 60, 60, 62, 62, 59, 59, | |
751 74, 74, 9, 9, 45, 45, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, | |
752 47, 47, 47, 47, 47, 47, 47, 47, 47, 52, 52, 52, 52, 52, 52, 52, 52, 52, | |
753 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 65, 65, 66, 66, 66, 71, 71, | |
754 72, 72, 11, 3, 12, 13, 14, 15, 18, 17, 20, 22, 24, 25, 27, 28, 29, 30, | |
755 32, 33, 35, 36, 38, 2, 41, 39, 42, 44, 67 | |
756 }; | |
757 | |
758 | |
759 static void ag_ra(void) | |
760 { | |
761 switch(ag_rpx[(PCB).ag_ap]) { | |
762 case 1: V(0,(double *)) = ag_rp_1(V(0,(int *)), V(2,(double *))); break; | |
763 case 2: V(0,(double *)) = ag_rp_2(V(0,(int *)), V(2,(double *))); break; | |
764 case 3: V(0,(double *)) = ag_rp_3(V(0,(int *)), V(2,(double *))); break; | |
765 case 4: V(0,(double *)) = ag_rp_4(V(0,(int *)), V(2,(double *))); break; | |
766 case 5: V(0,(double *)) = ag_rp_5(V(0,(int *)), V(2,(double *))); break; | |
767 case 6: V(0,(double *)) = ag_rp_6(V(0,(double *)), V(2,(double *)), V(4,(double *))); break; | |
768 case 7: V(0,(double *)) = ag_rp_7(V(0,(double *)), V(2,(double *))); break; | |
769 case 8: V(0,(double *)) = ag_rp_8(V(0,(double *)), V(2,(double *))); break; | |
770 case 9: V(0,(double *)) = ag_rp_9(V(0,(double *)), V(2,(double *))); break; | |
771 case 10: V(0,(double *)) = ag_rp_10(V(0,(double *)), V(2,(double *))); break; | |
772 case 11: V(0,(double *)) = ag_rp_11(V(0,(double *)), V(2,(double *))); break; | |
773 case 12: V(0,(double *)) = ag_rp_12(V(0,(double *)), V(2,(double *))); break; | |
774 case 13: V(0,(double *)) = ag_rp_13(V(0,(double *)), V(2,(double *))); break; | |
775 case 14: V(0,(double *)) = ag_rp_14(V(0,(double *)), V(2,(double *))); break; | |
776 case 15: V(0,(double *)) = ag_rp_15(V(0,(double *)), V(2,(double *))); break; | |
777 case 16: V(0,(double *)) = ag_rp_16(V(0,(double *)), V(2,(double *))); break; | |
778 case 17: V(0,(double *)) = ag_rp_17(V(0,(double *)), V(2,(double *))); break; | |
779 case 18: V(0,(double *)) = ag_rp_18(V(0,(double *)), V(2,(double *))); break; | |
780 case 19: V(0,(double *)) = ag_rp_19(V(0,(double *)), V(2,(double *))); break; | |
781 case 20: V(0,(double *)) = ag_rp_20(V(0,(int *))); break; | |
782 case 21: V(0,(double *)) = ag_rp_21(V(0,(int *)), V(2,(int *))); break; | |
783 case 22: V(0,(double *)) = ag_rp_22(V(1,(double *))); break; | |
784 case 23: V(0,(double *)) = ag_rp_23(V(1,(double *))); break; | |
785 case 24: V(0,(double *)) = ag_rp_24(V(1,(double *))); break; | |
786 case 25: V(0,(double *)) = ag_rp_25(V(1,(double *))); break; | |
787 case 26: V(0,(int *)) = ag_rp_26(); break; | |
788 case 27: V(0,(int *)) = ag_rp_27(V(0,(double *))); break; | |
789 case 28: V(0,(int *)) = ag_rp_28(V(0,(int *)), V(2,(double *))); break; | |
790 case 29: V(0,(double *)) = ag_rp_29(V(0,(double *)), V(3,(int *))); break; | |
791 case 30: V(0,(double *)) = ag_rp_30(V(0,(double *)), V(3,(int *))); break; | |
792 case 31: V(0,(double *)) = ag_rp_31(V(0,(double *)), V(2,(double *))); break; | |
793 case 32: V(0,(double *)) = ag_rp_32(V(1,(double *))); break; | |
794 case 33: V(0,(double *)) = ag_rp_33(V(0,(int *))); break; | |
795 case 34: V(0,(double *)) = ag_rp_34(V(0,(double *)), V(1,(int *))); break; | |
796 case 35: V(0,(double *)) = ag_rp_35(V(0,(int *))); break; | |
797 case 36: V(0,(double *)) = ag_rp_36(V(0,(int *)), V(1,(double *))); break; | |
798 case 37: V(0,(int *)) = ag_rp_37(V(0,(int *))); break; | |
799 case 38: V(0,(int *)) = ag_rp_38(V(0,(int *)), V(1,(int *))); break; | |
800 case 39: V(0,(int *)) = ag_rp_39(V(0,(int *))); break; | |
801 case 40: V(0,(int *)) = ag_rp_40(V(0,(int *)), V(1,(int *))); break; | |
802 } | |
803 } | |
804 | |
805 #define TOKEN_NAMES evalKernel_token_names | |
806 const char *const evalKernel_token_names[100] = { | |
807 "input string", | |
808 "white space", | |
809 "real", | |
810 "name", | |
811 "input string", | |
812 "expressions", | |
813 "eof", | |
814 "expression", | |
815 "", | |
816 "", | |
817 "conditional expression", | |
818 "'='", | |
819 "\"+=\"", | |
820 "\"-=\"", | |
821 "\"*=\"", | |
822 "\"/=\"", | |
823 "logical or expression", | |
824 "'\\?'", | |
825 "':'", | |
826 "logical and expression", | |
827 "\"||\"", | |
828 "equality expression", | |
829 "\"&&\"", | |
830 "relational expression", | |
831 "\"==\"", | |
832 "\"!=\"", | |
833 "additive expression", | |
834 "'<'", | |
835 "\"<=\"", | |
836 "'>'", | |
837 "\">=\"", | |
838 "multiplicative expression", | |
839 "'+'", | |
840 "'-'", | |
841 "factor", | |
842 "'*'", | |
843 "'/'", | |
844 "primary", | |
845 "\"**\"", | |
846 "'('", | |
847 "arguments", | |
848 "')'", | |
849 "'!'", | |
850 "argument list", | |
851 "','", | |
852 "", | |
853 "\"/*\"", | |
854 "", | |
855 "", | |
856 "", | |
857 "\"*/\"", | |
858 "\"//\"", | |
859 "", | |
860 "", | |
861 "", | |
862 "'\\n'", | |
863 "simple real", | |
864 "", | |
865 "", | |
866 "exponent", | |
867 "integer part", | |
868 "'.'", | |
869 "fraction part", | |
870 "", | |
871 "digit", | |
872 "letter", | |
873 "", | |
874 "", | |
875 "", | |
876 "", | |
877 "", | |
878 "", | |
879 "", | |
880 "'='", | |
881 "name", | |
882 "\"+=\"", | |
883 "\"-=\"", | |
884 "\"*=\"", | |
885 "\"/=\"", | |
886 "':'", | |
887 "'\\?'", | |
888 "\"||\"", | |
889 "\"&&\"", | |
890 "\"==\"", | |
891 "\"!=\"", | |
892 "'<'", | |
893 "\"<=\"", | |
894 "'>'", | |
895 "\">=\"", | |
896 "'+'", | |
897 "'-'", | |
898 "'*'", | |
899 "'/'", | |
900 "\"**\"", | |
901 "real", | |
902 "')'", | |
903 "'('", | |
904 "'!'", | |
905 "','", | |
906 "", | |
907 | |
908 }; | |
909 | |
910 | |
911 static const unsigned char ag_ctn[] = { | |
912 0,0, 1,1, 1,1, 0,0, 0,0, 0,0, 1,2, 0,0, 1,2, 56,1, 56,1, 94,1, | |
913 37,1, 0,0, 0,0, 0,0, 37,1, 37,1, 37,1, 37,1, 37,1, 34,1, 31,1, 26,1, | |
914 23,1, 21,1, 19,1, 37,1, 10,1, 7,1, 0,0, 62,1, 56,2, 94,2, 37,1, 37,2, | |
915 0,0, 34,2, 0,0, 31,2, 0,0, 31,2, 26,2, 26,2, 0,0, 23,2, 0,0, 23,2, | |
916 0,0, 23,2, 0,0, 23,2, 0,0, 21,2, 0,0, 21,2, 0,0, 19,2, 0,0, 16,2, | |
917 0,0, 10,2, 37,2, 0,0, 7,2, 0,0, 7,2, 0,0, 7,2, 0,0, 7,2, 0,0, | |
918 7,2, 9,1, 0,0, 5,2, 94,3, 94,3, 0,0, 31,1, 31,1, 26,1, 26,1, 26,1, | |
919 26,1, 23,1, 23,1, 21,1, 19,1, 10,3, 43,1, 37,3, 59,1, 59,1, 0,0, 10,4, | |
920 43,2 | |
921 }; | |
922 | |
923 #ifndef MISSING_FORMAT | |
924 #define MISSING_FORMAT "Missing %s" | |
925 #endif | |
926 #ifndef UNEXPECTED_FORMAT | |
927 #define UNEXPECTED_FORMAT "Unexpected %s" | |
928 #endif | |
929 #ifndef UNNAMED_TOKEN | |
930 #define UNNAMED_TOKEN "input" | |
931 #endif | |
932 | |
933 | |
934 static void ag_diagnose(void) { | |
935 int ag_snd = (PCB).sn; | |
936 int ag_k = ag_sbt[ag_snd]; | |
937 | |
938 if (*TOKEN_NAMES[ag_tstt[ag_k]] && ag_astt[ag_k + 1] == ag_action_8) { | |
939 sprintf((PCB).ag_msg, MISSING_FORMAT, TOKEN_NAMES[ag_tstt[ag_k]]); | |
940 } | |
941 else if (ag_astt[ag_sbe[(PCB).sn]] == ag_action_8 | |
942 && (ag_k = (int) ag_sbe[(PCB).sn] + 1) == (int) ag_sbt[(PCB).sn+1] - 1 | |
943 && *TOKEN_NAMES[ag_tstt[ag_k]]) { | |
944 sprintf((PCB).ag_msg, MISSING_FORMAT, TOKEN_NAMES[ag_tstt[ag_k]]); | |
945 } | |
946 else if ((PCB).token_number && *TOKEN_NAMES[(PCB).token_number]) { | |
947 sprintf((PCB).ag_msg, UNEXPECTED_FORMAT, TOKEN_NAMES[(PCB).token_number]); | |
948 } | |
949 else if (isprint((*(PCB).lab)) && (*(PCB).lab) != '\\') { | |
950 char buf[20]; | |
951 sprintf(buf, "\'%c\'", (char) (*(PCB).lab)); | |
952 sprintf((PCB).ag_msg, UNEXPECTED_FORMAT, buf); | |
953 } | |
954 else sprintf((PCB).ag_msg, UNEXPECTED_FORMAT, UNNAMED_TOKEN); | |
955 (PCB).error_message = (PCB).ag_msg; | |
956 | |
957 | |
958 { | |
959 int ag_sx, ag_t; | |
960 | |
961 ag_sx = (PCB).ssx; | |
962 (PCB).ss[ag_sx] = (PCB).sn; | |
963 do { | |
964 while (ag_sx && ag_ctn[2*(ag_snd = (PCB).ss[ag_sx])] == 0) ag_sx--; | |
965 if (ag_sx) { | |
966 ag_t = ag_ctn[2*ag_snd]; | |
967 ag_sx -= ag_ctn[2*ag_snd +1]; | |
968 ag_snd = (PCB).ss[ag_sx]; | |
969 } | |
970 else { | |
971 ag_snd = 0; | |
972 ag_t = ag_ptt[0]; | |
973 } | |
974 } while (ag_sx && *TOKEN_NAMES[ag_t]==0); | |
975 if (*TOKEN_NAMES[ag_t] == 0) ag_t = 0; | |
976 (PCB).error_frame_ssx = ag_sx; | |
977 (PCB).error_frame_token = (evalKernel_token_type) ag_t; | |
978 } | |
979 | |
980 | |
981 } | |
982 static int ag_action_1_r_proc(void); | |
983 static int ag_action_2_r_proc(void); | |
984 static int ag_action_3_r_proc(void); | |
985 static int ag_action_4_r_proc(void); | |
986 static int ag_action_1_s_proc(void); | |
987 static int ag_action_3_s_proc(void); | |
988 static int ag_action_1_proc(void); | |
989 static int ag_action_2_proc(void); | |
990 static int ag_action_3_proc(void); | |
991 static int ag_action_4_proc(void); | |
992 static int ag_action_5_proc(void); | |
993 static int ag_action_6_proc(void); | |
994 static int ag_action_7_proc(void); | |
995 static int ag_action_8_proc(void); | |
996 static int ag_action_9_proc(void); | |
997 static int ag_action_10_proc(void); | |
998 static int ag_action_11_proc(void); | |
999 static int ag_action_12_proc(void); | |
1000 | |
1001 | |
1002 static int (*const ag_r_procs_scan[])(void) = { | |
1003 ag_action_1_r_proc, | |
1004 ag_action_2_r_proc, | |
1005 ag_action_3_r_proc, | |
1006 ag_action_4_r_proc | |
1007 }; | |
1008 | |
1009 static int (*const ag_s_procs_scan[])(void) = { | |
1010 ag_action_1_s_proc, | |
1011 ag_action_2_r_proc, | |
1012 ag_action_3_s_proc, | |
1013 ag_action_4_r_proc | |
1014 }; | |
1015 | |
1016 static int (*const ag_gt_procs_scan[])(void) = { | |
1017 ag_action_1_proc, | |
1018 ag_action_2_proc, | |
1019 ag_action_3_proc, | |
1020 ag_action_4_proc, | |
1021 ag_action_5_proc, | |
1022 ag_action_6_proc, | |
1023 ag_action_7_proc, | |
1024 ag_action_8_proc, | |
1025 ag_action_9_proc, | |
1026 ag_action_10_proc, | |
1027 ag_action_11_proc, | |
1028 ag_action_12_proc | |
1029 }; | |
1030 | |
1031 | |
1032 static int ag_rns(int ag_t, int *ag_sx, int ag_snd) { | |
1033 while (1) { | |
1034 int ag_act, ag_k = ag_sbt[ag_snd], ag_lim = ag_sbt[ag_snd+1]; | |
1035 int ag_p; | |
1036 | |
1037 while (ag_k < ag_lim && ag_tstt[ag_k] != ag_t) ag_k++; | |
1038 if (ag_k == ag_lim) break; | |
1039 ag_act = ag_astt[ag_k]; | |
1040 ag_p = ag_pstt[ag_k]; | |
1041 if (ag_act == ag_action_2) return ag_p; | |
1042 if (ag_act == ag_action_10 || ag_act == ag_action_11) { | |
1043 (*ag_sx)--; | |
1044 return ag_snd; | |
1045 } | |
1046 if (ag_act != ag_action_3 && | |
1047 ag_act != ag_action_4) break; | |
1048 *ag_sx -= (ag_fl[ag_p] - 1); | |
1049 ag_snd = (PCB).ss[*ag_sx]; | |
1050 ag_t = ag_ptt[ag_p]; | |
1051 } | |
1052 return 0; | |
1053 } | |
1054 | |
1055 static int ag_jns(int ag_t) { | |
1056 int ag_k; | |
1057 | |
1058 ag_k = ag_sbt[(PCB).sn]; | |
1059 while (ag_tstt[ag_k] != ag_t && ag_tstt[ag_k]) ag_k++; | |
1060 while (1) { | |
1061 int ag_p = ag_pstt[ag_k]; | |
1062 int ag_sd; | |
1063 | |
1064 switch (ag_astt[ag_k]) { | |
1065 case ag_action_2: | |
1066 (PCB).ss[(PCB).ssx] = (PCB).sn; | |
1067 return ag_p; | |
1068 case ag_action_10: | |
1069 case ag_action_11: | |
1070 return (PCB).ss[(PCB).ssx--]; | |
1071 case ag_action_9: | |
1072 (PCB).ss[(PCB).ssx] = (PCB).sn; | |
1073 (PCB).ssx++; | |
1074 (PCB).sn = ag_p; | |
1075 ag_k = ag_sbt[(PCB).sn]; | |
1076 while (ag_tstt[ag_k] != ag_t && ag_tstt[ag_k]) ag_k++; | |
1077 continue; | |
1078 case ag_action_3: | |
1079 case ag_action_4: | |
1080 ag_sd = ag_fl[ag_p] - 1; | |
1081 if (ag_sd) (PCB).sn = (PCB).ss[(PCB).ssx -= ag_sd]; | |
1082 else (PCB).ss[(PCB).ssx] = (PCB).sn; | |
1083 ag_t = ag_ptt[ag_p]; | |
1084 ag_k = ag_sbt[(PCB).sn+1]; | |
1085 while (ag_tstt[--ag_k] != ag_t); | |
1086 continue; | |
1087 case ag_action_5: | |
1088 case ag_action_6: | |
1089 if (ag_fl[ag_p]) break; | |
1090 (PCB).sn = ag_rns(ag_ptt[ag_p],&(PCB).ssx, (PCB).sn); | |
1091 (PCB).ss[++(PCB).ssx] = (PCB).sn; | |
1092 ag_k = ag_sbt[(PCB).sn]; | |
1093 while (ag_tstt[ag_k] != ag_t && ag_tstt[ag_k]) ag_k++; | |
1094 continue; | |
1095 } | |
1096 break; | |
1097 } | |
1098 return 0; | |
1099 } | |
1100 | |
1101 | |
1102 static int ag_atx(int ag_t, int *ag_sx, int ag_snd) { | |
1103 int ag_k, ag_f; | |
1104 int ag_save_btsx = (PCB).btsx; | |
1105 int ag_flag = 1; | |
1106 | |
1107 while (1) { | |
1108 int ag_a; | |
1109 | |
1110 (PCB).bts[128 - ++(PCB).btsx] = *ag_sx; | |
1111 (PCB).ss[128 - (PCB).btsx] = (PCB).ss[*ag_sx]; | |
1112 (PCB).ss[*ag_sx] = ag_snd; | |
1113 ag_k = ag_sbt[ag_snd]; | |
1114 while (ag_tstt[ag_k] != ag_t && ag_tstt[ag_k]) ag_k++; | |
1115 ag_a = ag_astt[ag_k]; | |
1116 if (ag_a == ag_action_2 || | |
1117 ag_a == ag_action_3 || | |
1118 ag_a == ag_action_10 || | |
1119 ag_a == ag_action_11 || | |
1120 ag_a == ag_action_1 || | |
1121 ag_a == ag_action_4) break; | |
1122 if ((ag_a == ag_action_5 || | |
1123 ag_a == ag_action_6) && | |
1124 (ag_k = ag_fl[ag_f = ag_pstt[ag_k]]) == 0) { | |
1125 ag_snd = ag_rns(ag_ptt[ag_f],ag_sx, (PCB).ss[*ag_sx]); | |
1126 (*ag_sx)++; | |
1127 continue; | |
1128 } | |
1129 if (ag_a == ag_action_9) { | |
1130 ag_snd = ag_pstt[ag_k]; | |
1131 (*ag_sx)++; | |
1132 continue; | |
1133 } | |
1134 ag_flag = 0; | |
1135 break; | |
1136 } | |
1137 while ((PCB).btsx > ag_save_btsx) { | |
1138 *ag_sx = (PCB).bts[128 - (PCB).btsx]; | |
1139 (PCB).ss[*ag_sx] = (PCB).ss[128 - (PCB).btsx--]; | |
1140 } | |
1141 return ag_flag; | |
1142 } | |
1143 | |
1144 static int ag_tst_tkn(void) { | |
1145 int ag_rk, ag_sx, ag_snd; | |
1146 | |
1147 for (ag_rk = 0; ag_rk < (PCB).ag_lrss; ag_rk += 2) { | |
1148 ag_sx = (PCB).ag_rss[ag_rk]; | |
1149 if (ag_sx > (PCB).ssx) continue; | |
1150 ag_snd = (PCB).ag_rss[ag_rk + 1]; | |
1151 if (ag_sx > (PCB).ag_min_depth) continue; | |
1152 if (ag_atx((PCB).token_number, &ag_sx, ag_snd)) break; | |
1153 } | |
1154 return ag_rk; | |
1155 } | |
1156 | |
1157 static void ag_set_error_procs(void); | |
1158 | |
1159 static void ag_auto_resynch(void) { | |
1160 int ag_sx; | |
1161 (PCB).ss[(PCB).ssx] = (PCB).sn; | |
1162 if ((PCB).ag_error_depth && (PCB).ag_min_depth >= (PCB).ag_error_depth) { | |
1163 (PCB).ssx = (PCB).ag_error_depth; | |
1164 (PCB).sn = (PCB).ss[(PCB).ssx]; | |
1165 } | |
1166 else { | |
1167 ag_diagnose(); | |
1168 SYNTAX_ERROR; | |
1169 if ((PCB).exit_flag != AG_RUNNING_CODE) return; | |
1170 (PCB).ag_error_depth = (PCB).ag_min_depth = 0; | |
1171 (PCB).ag_lrss = 0; | |
1172 (PCB).ss[ag_sx = (PCB).ssx] = (PCB).sn; | |
1173 (PCB).ag_min_depth = (PCB).ag_rss[(PCB).ag_lrss++] = ag_sx; | |
1174 (PCB).ag_rss[(PCB).ag_lrss++] = (PCB).sn; | |
1175 while (ag_sx && (PCB).ag_lrss < 2*128) { | |
1176 int ag_t = 0, ag_x, ag_s, ag_sxs = ag_sx; | |
1177 | |
1178 while (ag_sx && (ag_t = ag_ctn[2*(PCB).sn]) == 0) (PCB).sn = (PCB).ss[--ag_sx]; | |
1179 if (ag_t) (PCB).sn = (PCB).ss[ag_sx -= ag_ctn[2*(PCB).sn +1]]; | |
1180 else { | |
1181 if (ag_sx == 0) (PCB).sn = 0; | |
1182 ag_t = ag_ptt[0]; | |
1183 } | |
1184 if ((ag_s = ag_rns(ag_t, &ag_sx, (PCB).sn)) == 0) break; | |
1185 for (ag_x = 0; ag_x < (PCB).ag_lrss; ag_x += 2) | |
1186 if ((PCB).ag_rss[ag_x] == ag_sx + 1 && (PCB).ag_rss[ag_x+1] == ag_s) break; | |
1187 if (ag_x == (PCB).ag_lrss) { | |
1188 (PCB).ag_rss[(PCB).ag_lrss++] = ++ag_sx; | |
1189 (PCB).ag_rss[(PCB).ag_lrss++] = (PCB).sn = ag_s; | |
1190 } | |
1191 else if (ag_sx >= ag_sxs) ag_sx--; | |
1192 } | |
1193 ag_set_error_procs(); | |
1194 } | |
1195 (PCB).ssx++; | |
1196 (PCB).sn = 97; | |
1197 (PCB).ag_rk1 = (PCB).ag_lrss; | |
1198 return; | |
1199 } | |
1200 | |
1201 static int ag_action_12_proc(void) { | |
1202 int ag_k, ag_rk; | |
1203 | |
1204 (PCB).ssx--; | |
1205 if ((PCB).ag_rk1 == (PCB).ag_lrss) { | |
1206 (PCB).ag_rk1 = ag_tst_tkn(); | |
1207 (PCB).ssx++; | |
1208 if ((PCB).token_number == 6) | |
1209 {(PCB).exit_flag = AG_SYNTAX_ERROR_CODE; return 0;} | |
1210 (PCB).ag_tk1 = (PCB).token_number; | |
1211 ag_track(); | |
1212 return 0; | |
1213 } | |
1214 ag_rk = ag_tst_tkn(); | |
1215 if (ag_rk < (PCB).ag_rk1) { | |
1216 ag_k = 0; | |
1217 ag_track(); | |
1218 } | |
1219 else { | |
1220 ag_k = 1; | |
1221 ag_rk = (PCB).ag_rk1; | |
1222 (PCB).token_number = (evalKernel_token_type) (PCB).ag_tk1; | |
1223 (PCB).rx = 0; | |
1224 } | |
1225 (PCB).ag_min_depth = (PCB).ssx = (PCB).ag_rss[ag_rk++]; | |
1226 (PCB).sn = (PCB).ss[(PCB).ssx] = (PCB).ag_rss[ag_rk]; | |
1227 (PCB).sn = ag_jns((PCB).token_number); | |
1228 if ((PCB).ag_error_depth == 0 || (PCB).ag_error_depth > (PCB).ssx) | |
1229 (PCB).ag_error_depth = (PCB).ssx; | |
1230 if (++(PCB).ssx >= 128) { | |
1231 (PCB).exit_flag = AG_STACK_ERROR_CODE; | |
1232 PARSER_STACK_OVERFLOW; | |
1233 return 0; | |
1234 } | |
1235 (PCB).ss[(PCB).ssx] = (PCB).sn; | |
1236 (PCB).ag_tmp_depth = (PCB).ag_min_depth; | |
1237 return ag_k; | |
1238 } | |
1239 | |
1240 | |
1241 static int ag_action_10_proc(void) { | |
1242 (PCB).btsx = 0, (PCB).drt = -1; | |
1243 ag_track(); | |
1244 return 0; | |
1245 } | |
1246 | |
1247 static int ag_action_11_proc(void) { | |
1248 (PCB).btsx = 0, (PCB).drt = -1; | |
1249 (*(int *) &(PCB).vs[(PCB).ssx]) = *(PCB).lab; | |
1250 (PCB).ssx--; | |
1251 ag_ra(); | |
1252 (PCB).ssx++; | |
1253 ag_track(); | |
1254 return 0; | |
1255 } | |
1256 | |
1257 static int ag_action_3_r_proc(void) { | |
1258 int ag_sd = ag_fl[(PCB).ag_ap] - 1; | |
1259 if (ag_sd) (PCB).sn = (PCB).ss[(PCB).ssx -= ag_sd]; | |
1260 (PCB).btsx = 0, (PCB).drt = -1; | |
1261 (PCB).reduction_token = (evalKernel_token_type) ag_ptt[(PCB).ag_ap]; | |
1262 ag_ra(); | |
1263 return (PCB).exit_flag == AG_RUNNING_CODE; | |
1264 } | |
1265 | |
1266 static int ag_action_3_s_proc(void) { | |
1267 int ag_sd = ag_fl[(PCB).ag_ap] - 1; | |
1268 if (ag_sd) (PCB).sn = (PCB).ss[(PCB).ssx -= ag_sd]; | |
1269 (PCB).btsx = 0, (PCB).drt = -1; | |
1270 (PCB).reduction_token = (evalKernel_token_type) ag_ptt[(PCB).ag_ap]; | |
1271 ag_ra(); | |
1272 return (PCB).exit_flag == AG_RUNNING_CODE; | |
1273 } | |
1274 | |
1275 static int ag_action_4_r_proc(void) { | |
1276 int ag_sd = ag_fl[(PCB).ag_ap] - 1; | |
1277 if (ag_sd) (PCB).sn = (PCB).ss[(PCB).ssx -= ag_sd]; | |
1278 (PCB).reduction_token = (evalKernel_token_type) ag_ptt[(PCB).ag_ap]; | |
1279 return 1; | |
1280 } | |
1281 | |
1282 static int ag_action_2_proc(void) { | |
1283 (PCB).btsx = 0, (PCB).drt = -1; | |
1284 if ((PCB).ssx >= 128) { | |
1285 (PCB).exit_flag = AG_STACK_ERROR_CODE; | |
1286 PARSER_STACK_OVERFLOW; | |
1287 } | |
1288 (*(int *) &(PCB).vs[(PCB).ssx]) = *(PCB).lab; | |
1289 (PCB).ss[(PCB).ssx] = (PCB).sn; | |
1290 (PCB).ssx++; | |
1291 (PCB).sn = (PCB).ag_ap; | |
1292 ag_track(); | |
1293 return 0; | |
1294 } | |
1295 | |
1296 static int ag_action_9_proc(void) { | |
1297 if ((PCB).drt == -1) { | |
1298 (PCB).drt=(PCB).token_number; | |
1299 (PCB).dssx=(PCB).ssx; | |
1300 (PCB).dsn=(PCB).sn; | |
1301 } | |
1302 ag_prot(); | |
1303 (PCB).ss[(PCB).ssx] = (PCB).sn; | |
1304 (PCB).ssx++; | |
1305 (PCB).sn = (PCB).ag_ap; | |
1306 (PCB).rx = 0; | |
1307 return (PCB).exit_flag == AG_RUNNING_CODE; | |
1308 } | |
1309 | |
1310 static int ag_action_2_r_proc(void) { | |
1311 (PCB).ssx++; | |
1312 (PCB).sn = (PCB).ag_ap; | |
1313 return 0; | |
1314 } | |
1315 | |
1316 static int ag_action_7_proc(void) { | |
1317 --(PCB).ssx; | |
1318 (PCB).exit_flag = AG_SUCCESS_CODE; | |
1319 (PCB).rx = 0; | |
1320 return 0; | |
1321 } | |
1322 | |
1323 static int ag_action_1_proc(void) { | |
1324 (PCB).exit_flag = AG_SUCCESS_CODE; | |
1325 ag_track(); | |
1326 return 0; | |
1327 } | |
1328 | |
1329 static int ag_action_1_r_proc(void) { | |
1330 (PCB).exit_flag = AG_SUCCESS_CODE; | |
1331 return 0; | |
1332 } | |
1333 | |
1334 static int ag_action_1_s_proc(void) { | |
1335 (PCB).exit_flag = AG_SUCCESS_CODE; | |
1336 return 0; | |
1337 } | |
1338 | |
1339 static int ag_action_4_proc(void) { | |
1340 int ag_sd = ag_fl[(PCB).ag_ap] - 1; | |
1341 (PCB).reduction_token = (evalKernel_token_type) ag_ptt[(PCB).ag_ap]; | |
1342 (PCB).btsx = 0, (PCB).drt = -1; | |
1343 (*(int *) &(PCB).vs[(PCB).ssx]) = *(PCB).lab; | |
1344 if (ag_sd) (PCB).sn = (PCB).ss[(PCB).ssx -= ag_sd]; | |
1345 else (PCB).ss[(PCB).ssx] = (PCB).sn; | |
1346 ag_track(); | |
1347 while ((PCB).exit_flag == AG_RUNNING_CODE) { | |
1348 unsigned ag_t1 = ag_sbe[(PCB).sn] + 1; | |
1349 unsigned ag_t2 = ag_sbt[(PCB).sn+1] - 1; | |
1350 do { | |
1351 unsigned ag_tx = (ag_t1 + ag_t2)/2; | |
1352 if (ag_tstt[ag_tx] < (unsigned char)(PCB).reduction_token) ag_t1 = ag_tx + 1; | |
1353 else ag_t2 = ag_tx; | |
1354 } while (ag_t1 < ag_t2); | |
1355 (PCB).ag_ap = ag_pstt[ag_t1]; | |
1356 if ((*(PCB).s_procs[ag_astt[ag_t1]])() == 0) break; | |
1357 } | |
1358 return 0; | |
1359 } | |
1360 | |
1361 static int ag_action_3_proc(void) { | |
1362 int ag_sd = ag_fl[(PCB).ag_ap] - 1; | |
1363 (PCB).btsx = 0, (PCB).drt = -1; | |
1364 (*(int *) &(PCB).vs[(PCB).ssx]) = *(PCB).lab; | |
1365 if (ag_sd) (PCB).sn = (PCB).ss[(PCB).ssx -= ag_sd]; | |
1366 else (PCB).ss[(PCB).ssx] = (PCB).sn; | |
1367 ag_track(); | |
1368 (PCB).reduction_token = (evalKernel_token_type) ag_ptt[(PCB).ag_ap]; | |
1369 ag_ra(); | |
1370 while ((PCB).exit_flag == AG_RUNNING_CODE) { | |
1371 unsigned ag_t1 = ag_sbe[(PCB).sn] + 1; | |
1372 unsigned ag_t2 = ag_sbt[(PCB).sn+1] - 1; | |
1373 do { | |
1374 unsigned ag_tx = (ag_t1 + ag_t2)/2; | |
1375 if (ag_tstt[ag_tx] < (unsigned char)(PCB).reduction_token) ag_t1 = ag_tx + 1; | |
1376 else ag_t2 = ag_tx; | |
1377 } while (ag_t1 < ag_t2); | |
1378 (PCB).ag_ap = ag_pstt[ag_t1]; | |
1379 if ((*(PCB).s_procs[ag_astt[ag_t1]])() == 0) break; | |
1380 } | |
1381 return 0; | |
1382 } | |
1383 | |
1384 static int ag_action_8_proc(void) { | |
1385 ag_undo(); | |
1386 (PCB).rx = 0; | |
1387 ag_auto_resynch(); | |
1388 return (PCB).exit_flag == AG_RUNNING_CODE; | |
1389 } | |
1390 | |
1391 static int ag_action_5_proc(void) { | |
1392 int ag_sd = ag_fl[(PCB).ag_ap]; | |
1393 (PCB).btsx = 0, (PCB).drt = -1; | |
1394 if (ag_sd) (PCB).sn = (PCB).ss[(PCB).ssx -= ag_sd]; | |
1395 else { | |
1396 (PCB).ss[(PCB).ssx] = (PCB).sn; | |
1397 } | |
1398 (PCB).rx = 0; | |
1399 (PCB).reduction_token = (evalKernel_token_type) ag_ptt[(PCB).ag_ap]; | |
1400 ag_ra(); | |
1401 while ((PCB).exit_flag == AG_RUNNING_CODE) { | |
1402 unsigned ag_t1 = ag_sbe[(PCB).sn] + 1; | |
1403 unsigned ag_t2 = ag_sbt[(PCB).sn+1] - 1; | |
1404 do { | |
1405 unsigned ag_tx = (ag_t1 + ag_t2)/2; | |
1406 if (ag_tstt[ag_tx] < (unsigned char)(PCB).reduction_token) ag_t1 = ag_tx + 1; | |
1407 else ag_t2 = ag_tx; | |
1408 } while (ag_t1 < ag_t2); | |
1409 (PCB).ag_ap = ag_pstt[ag_t1]; | |
1410 if ((*(PCB).r_procs[ag_astt[ag_t1]])() == 0) break; | |
1411 } | |
1412 return (PCB).exit_flag == AG_RUNNING_CODE; | |
1413 } | |
1414 | |
1415 static int ag_action_6_proc(void) { | |
1416 int ag_sd = ag_fl[(PCB).ag_ap]; | |
1417 (PCB).reduction_token = (evalKernel_token_type) ag_ptt[(PCB).ag_ap]; | |
1418 if ((PCB).drt == -1) { | |
1419 (PCB).drt=(PCB).token_number; | |
1420 (PCB).dssx=(PCB).ssx; | |
1421 (PCB).dsn=(PCB).sn; | |
1422 } | |
1423 if (ag_sd) { | |
1424 (PCB).sn = (PCB).ss[(PCB).ssx -= ag_sd]; | |
1425 } | |
1426 else { | |
1427 ag_prot(); | |
1428 (PCB).vs[(PCB).ssx] = ag_null_value; | |
1429 (PCB).ss[(PCB).ssx] = (PCB).sn; | |
1430 } | |
1431 (PCB).rx = 0; | |
1432 while ((PCB).exit_flag == AG_RUNNING_CODE) { | |
1433 unsigned ag_t1 = ag_sbe[(PCB).sn] + 1; | |
1434 unsigned ag_t2 = ag_sbt[(PCB).sn+1] - 1; | |
1435 do { | |
1436 unsigned ag_tx = (ag_t1 + ag_t2)/2; | |
1437 if (ag_tstt[ag_tx] < (unsigned char)(PCB).reduction_token) ag_t1 = ag_tx + 1; | |
1438 else ag_t2 = ag_tx; | |
1439 } while (ag_t1 < ag_t2); | |
1440 (PCB).ag_ap = ag_pstt[ag_t1]; | |
1441 if ((*(PCB).r_procs[ag_astt[ag_t1]])() == 0) break; | |
1442 } | |
1443 return (PCB).exit_flag == AG_RUNNING_CODE; | |
1444 } | |
1445 | |
1446 | |
1447 static void ag_check_depth(int ag_fl) { | |
1448 int ag_sx = (PCB).ssx - ag_fl; | |
1449 if ((PCB).ag_error_depth && ag_sx < (PCB).ag_tmp_depth) (PCB).ag_tmp_depth = ag_sx; | |
1450 } | |
1451 | |
1452 static int ag_action_3_er_proc(void) { | |
1453 ag_check_depth(ag_fl[(PCB).ag_ap] - 1); | |
1454 return ag_action_4_r_proc(); | |
1455 } | |
1456 | |
1457 static int ag_action_2_e_proc(void) { | |
1458 ag_action_2_proc(); | |
1459 (PCB).ag_min_depth = (PCB).ag_tmp_depth; | |
1460 return 0; | |
1461 } | |
1462 | |
1463 static int ag_action_4_e_proc(void) { | |
1464 ag_check_depth(ag_fl[(PCB).ag_ap] - 1); | |
1465 (PCB).ag_min_depth = (PCB).ag_tmp_depth; | |
1466 return ag_action_4_proc(); | |
1467 } | |
1468 | |
1469 static int ag_action_6_e_proc(void) { | |
1470 ag_check_depth(ag_fl[(PCB).ag_ap]); | |
1471 return ag_action_6_proc(); | |
1472 } | |
1473 | |
1474 static int ag_action_11_e_proc(void) { | |
1475 return ag_action_10_proc(); | |
1476 } | |
1477 | |
1478 static int (*ag_r_procs_error[])(void) = { | |
1479 ag_action_1_r_proc, | |
1480 ag_action_2_r_proc, | |
1481 ag_action_3_er_proc, | |
1482 ag_action_3_er_proc | |
1483 }; | |
1484 | |
1485 static int (*ag_s_procs_error[])(void) = { | |
1486 ag_action_1_s_proc, | |
1487 ag_action_2_r_proc, | |
1488 ag_action_3_er_proc, | |
1489 ag_action_3_er_proc | |
1490 }; | |
1491 | |
1492 static int (*ag_gt_procs_error[])(void) = { | |
1493 ag_action_1_proc, | |
1494 ag_action_2_e_proc, | |
1495 ag_action_4_e_proc, | |
1496 ag_action_4_e_proc, | |
1497 ag_action_6_e_proc, | |
1498 ag_action_6_e_proc, | |
1499 ag_action_7_proc, | |
1500 ag_action_8_proc, | |
1501 ag_action_9_proc, | |
1502 ag_action_10_proc, | |
1503 ag_action_11_e_proc, | |
1504 ag_action_12_proc | |
1505 }; | |
1506 | |
1507 static void ag_set_error_procs(void) { | |
1508 (PCB).gt_procs = ag_gt_procs_error; | |
1509 (PCB).r_procs = ag_r_procs_error; | |
1510 (PCB).s_procs = ag_s_procs_error; | |
1511 } | |
1512 | |
1513 | |
1514 void init_evalKernel(void) { | |
1515 unsigned ag_t1; | |
1516 ag_t1 = 0; | |
1517 (PCB).rx = (PCB).fx = 0; | |
1518 (PCB).gt_procs = ag_gt_procs_scan; | |
1519 (PCB).r_procs = ag_r_procs_scan; | |
1520 (PCB).s_procs = ag_s_procs_scan; | |
1521 (PCB).ag_error_depth = (PCB).ag_min_depth = (PCB).ag_tmp_depth = 0; | |
1522 (PCB).ag_resynch_active = 0; | |
1523 (PCB).ss[0] = (PCB).sn = (PCB).ssx = 0; | |
1524 (PCB).exit_flag = AG_RUNNING_CODE; | |
1525 (PCB).key_sp = NULL; | |
1526 (PCB).key_state = 0; | |
1527 (PCB).line = FIRST_LINE; | |
1528 (PCB).column = FIRST_COLUMN; | |
1529 (PCB).btsx = 0, (PCB).drt = -1; | |
1530 while (ag_tstt[ag_t1] == 0) { | |
1531 (PCB).ag_ap = ag_pstt[ag_t1]; | |
1532 (*(PCB).gt_procs[ag_astt[ag_t1]])(); | |
1533 ag_t1 = ag_sbt[(PCB).sn]; | |
1534 } | |
1535 } | |
1536 | |
1537 void evalKernel(void) { | |
1538 (PCB).lab[(PCB).fx++] = (PCB).input_code; | |
1539 while ((PCB).exit_flag == AG_RUNNING_CODE) { | |
1540 while (1) { | |
1541 const unsigned char *ag_p; | |
1542 int ag_ch; | |
1543 if ((PCB).rx >= (PCB).fx) return; | |
1544 ag_ch = CONVERT_CASE((PCB).lab[(PCB).rx++]); | |
1545 if ((PCB).key_sp) { | |
1546 if (ag_ch != *(PCB).key_sp++) { | |
1547 (PCB).rx = (PCB).save_index; | |
1548 (PCB).key_sp = NULL; | |
1549 (PCB).key_state = 0; | |
1550 break; | |
1551 } else if (*(PCB).key_sp) continue; | |
1552 if (ag_key_act[(PCB).key_state] == ag_cf_end_key) { | |
1553 int ag_k1; | |
1554 int ag_k2; | |
1555 if ((PCB).rx >= (PCB).fx) { | |
1556 (PCB).rx--; | |
1557 (PCB).key_sp--; | |
1558 return; | |
1559 } | |
1560 (PCB).key_sp = NULL; | |
1561 ag_k1 = ag_key_parm[(PCB).key_state]; | |
1562 ag_k2 = ag_key_pt[ag_k1]; | |
1563 if (ag_key_itt[ag_k2 + CONVERT_CASE((PCB).lab[(PCB).rx])]) | |
1564 (PCB).rx = (PCB).save_index; | |
1565 else { | |
1566 (PCB).token_number = (evalKernel_token_type) ag_key_pt[ag_k1+1]; | |
1567 (PCB).key_state = 0; | |
1568 } | |
1569 break; | |
1570 } | |
1571 else { | |
1572 (PCB).token_number = (evalKernel_token_type) ag_key_parm[(PCB).key_state]; | |
1573 (PCB).key_state = 0; | |
1574 (PCB).key_sp = NULL; | |
1575 } | |
1576 break; | |
1577 } | |
1578 if ((PCB).key_state == 0) { | |
1579 (PCB).token_number = (evalKernel_token_type) AG_TCV(ag_ch); | |
1580 if (((PCB).key_state = ag_key_index[(PCB).sn]) == 0) break; | |
1581 (PCB).save_index = 1; | |
1582 } | |
1583 ag_p = &ag_key_ch[(PCB).key_state]; | |
1584 if (ag_ch <= 255) while (*ag_p < ag_ch) ag_p++; | |
1585 if (*ag_p == ag_ch) { | |
1586 (PCB).key_state = (int)(ag_p - ag_key_ch); | |
1587 switch (ag_key_act[(PCB).key_state]) { | |
1588 case ag_cf_set_key: { | |
1589 int ag_k1; | |
1590 int ag_k2; | |
1591 if ((PCB).rx >= (PCB).fx) { | |
1592 (PCB).rx--; | |
1593 return; | |
1594 } | |
1595 ag_k1 = ag_key_parm[(PCB).key_state]; | |
1596 ag_k2 = ag_key_pt[ag_k1]; | |
1597 (PCB).key_state = ag_key_jmp[(PCB).key_state]; | |
1598 if (ag_key_itt[ag_k2 + CONVERT_CASE((PCB).lab[(PCB).rx])]) continue; | |
1599 (PCB).save_index = (PCB).rx; | |
1600 (PCB).token_number = (evalKernel_token_type) ag_key_pt[ag_k1+1]; | |
1601 continue; | |
1602 } | |
1603 case ag_set_key: | |
1604 (PCB).save_index = (PCB).rx; | |
1605 (PCB).token_number = (evalKernel_token_type) ag_key_parm[(PCB).key_state]; | |
1606 case ag_jmp_key: | |
1607 (PCB).key_state = ag_key_jmp[(PCB).key_state]; | |
1608 continue; | |
1609 case ag_cf_end_key: | |
1610 case ag_end_key: | |
1611 (PCB).key_sp = ag_key_ends + ag_key_jmp[(PCB).key_state]; | |
1612 continue; | |
1613 case ag_accept_key: | |
1614 (PCB).token_number = (evalKernel_token_type) ag_key_parm[(PCB).key_state]; | |
1615 (PCB).key_state = 0; | |
1616 break; | |
1617 case ag_cf_accept_key: { | |
1618 int ag_k1; | |
1619 int ag_k2; | |
1620 if ((PCB).rx >= (PCB).fx) { | |
1621 (PCB).rx--; | |
1622 return; | |
1623 } | |
1624 ag_k1 = ag_key_parm[(PCB).key_state]; | |
1625 ag_k2 = ag_key_pt[ag_k1]; | |
1626 if (ag_key_itt[ag_k2 + CONVERT_CASE((PCB).lab[(PCB).rx])]) | |
1627 (PCB).rx = (PCB).save_index; | |
1628 else { | |
1629 (PCB).token_number = (evalKernel_token_type) ag_key_pt[ag_k1+1]; | |
1630 (PCB).key_state = 0; | |
1631 } | |
1632 break; | |
1633 } | |
1634 } | |
1635 break; | |
1636 } else { | |
1637 (PCB).rx = (PCB).save_index; | |
1638 (PCB).key_state = 0; | |
1639 break; | |
1640 } | |
1641 } | |
1642 | |
1643 { | |
1644 unsigned ag_t1 = ag_sbt[(PCB).sn]; | |
1645 unsigned ag_t2 = ag_sbe[(PCB).sn] - 1; | |
1646 do { | |
1647 unsigned ag_tx = (ag_t1 + ag_t2)/2; | |
1648 if (ag_tstt[ag_tx] > (unsigned char)(PCB).token_number) | |
1649 ag_t1 = ag_tx + 1; | |
1650 else ag_t2 = ag_tx; | |
1651 } while (ag_t1 < ag_t2); | |
1652 if (ag_tstt[ag_t1] != (PCB).token_number) ag_t1 = ag_sbe[(PCB).sn]; | |
1653 (PCB).ag_ap = ag_pstt[ag_t1]; | |
1654 (*(PCB).gt_procs[ag_astt[ag_t1]])(); | |
1655 } | |
1656 } | |
1657 } | |
1658 | |
1659 |