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