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