Mercurial > ~dholland > hg > ag > index.cgi
comparison anagram/agcore/engine.cgs @ 0:13d2b8934445
Import AnaGram (near-)release tree into Mercurial.
author | David A. Holland |
---|---|
date | Sat, 22 Dec 2007 17:52:45 -0500 |
parents | |
children | 1c9dac05d040 |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:13d2b8934445 |
---|---|
1 copyright | |
2 /* | |
3 * AnaGram, A System for Syntax Directed Programming | |
4 * File generated by: %s, built %s | |
5 * | |
6 * AnaGram Parsing Engine | |
7 * Copyright 1993-2002 Parsifal Software. All Rights Reserved. | |
8 * | |
9 * This software is provided 'as-is', without any express or implied | |
10 * warranty. In no event will the authors be held liable for any damages | |
11 * arising from the use of this software. | |
12 * | |
13 * Permission is granted to anyone to use this software for any purpose, | |
14 * including commercial applications, and to alter it and redistribute it | |
15 * freely, subject to the following restrictions: | |
16 * | |
17 * 1. The origin of this software must not be misrepresented; you must not | |
18 * claim that you wrote the original software. If you use this software | |
19 * in a product, an acknowledgment in the product documentation would be | |
20 * appreciated but is not required. | |
21 * 2. Altered source versions must be plainly marked as such, and must not be | |
22 * misrepresented as being the original software. | |
23 * 3. This notice may not be removed or altered from any source distribution. | |
24 */ | |
25 ## | |
26 broken | |
27 This copy of AnaGram appears to have been damaged or miscompiled. | |
28 New copies may be obtained via http://www.parsifalsoft.com. | |
29 ## | |
30 header, chain header | |
31 #include <stdio.h> | |
32 | |
33 #define RULE_CONTEXT (&((PCB).cs[(PCB).ssx])) | |
34 #define ERROR_CONTEXT ((PCB).cs[(PCB).error_frame_ssx]) | |
35 #define CONTEXT ((PCB).cs[(PCB).ssx]) | |
36 ## | |
37 function macro defs | |
38 | |
39 AG_GET_KEY_WORD ag_get_key_word(THISARGC#int ag_k) | |
40 AG_RNS ag_rns(THISARGC#int ag_t, int *ag_sx, int ag_snd) | |
41 AG_JNS ag_jns(THISARGC#int ag_t) | |
42 AG_ATX ag_atx(THISARGC#int ag_t, int *ag_sx, int ag_snd) | |
43 AG_CHECK_DEPTH ag_check_depth(THISARGC#int ag_fl) | |
44 AG_VALID ag_valid(THISARGC#int ag_k) | |
45 AG_DEFAULT ag_default(THISARGC#CONST int *ag_tp) | |
46 ## | |
47 function macro defs old style | |
48 | |
49 AG_GET_KEY_WORD ag_get_key_word(ag_k) int ag_k; | |
50 AG_RNS ag_rns(ag_t,*ag_sx, ag_snd) int ag_t,*ag_sx,ag_snd; | |
51 AG_JNS ag_jns(ag_t) int ag_t; | |
52 AG_ATX ag_atx(ag_t,*ag_sx,ag_snd) int ag_t,*ag_sx,ag_snd; | |
53 AG_CHECK_DEPTH ag_check_depth(ag_fl) int ag_fl; | |
54 AG_VALID ag_valid(ag_k) int ag_k; | |
55 AG_DEFAULT ag_default(ag_tp) int *ag_tp; | |
56 ## | |
57 pcbHeader | |
58 | |
59 typedef struct %s{ | |
60 %s token_number, reduction_token, error_frame_token; | |
61 int input_code; | |
62 %s input_value; | |
63 int line, column; | |
64 int ssx, sn, error_frame_ssx; | |
65 int drt, dssx, dsn; | |
66 int ss[%d]; | |
67 %s vs[%d]; | |
68 int ag_ap; | |
69 const char *error_message; | |
70 char read_flag; | |
71 char exit_flag; | |
72 ## | |
73 pcbTail | |
74 } %s; | |
75 | |
76 #ifndef PRULE_CONTEXT | |
77 #define PRULE_CONTEXT(pcb) (&((pcb).cs[(pcb).ssx])) | |
78 #define PERROR_CONTEXT(pcb) ((pcb).cs[(pcb).error_frame_ssx]) | |
79 #define PCONTEXT(pcb) ((pcb).cs[(pcb).ssx]) | |
80 #endif | |
81 | |
82 #ifndef AG_RUNNING_CODE | |
83 /* PCB.exit_flag values */ | |
84 #define AG_RUNNING_CODE 0 | |
85 #define AG_SUCCESS_CODE 1 | |
86 #define AG_SYNTAX_ERROR_CODE 2 | |
87 #define AG_REDUCTION_ERROR_CODE 3 | |
88 #define AG_STACK_ERROR_CODE 4 | |
89 #define AG_SEMANTIC_ERROR_CODE 5 | |
90 #endif | |
91 ## | |
92 wrap decls | |
93 | |
94 #undef VW | |
95 #define VW(i,t) *(t) (&(PCB).vs[(PCB).ssx + (i)]) | |
96 #undef VNO | |
97 #define VNO new(&(PCB).vs[(PCB).ssx]) | |
98 #undef VRO | |
99 #define VRO(to,v) ag_replace_object((to) &(PCB).vs[(PCB).ssx], v) | |
100 #undef VWD | |
101 #define VWD(i,t) ag_delete_object((t) &(PCB).vs[(PCB).ssx + (i)]); | |
102 #undef VDO | |
103 #define VDO(to, v) ag_delete_object((to) &(PCB).vs[(PCB).ssx], v) | |
104 | |
105 template <class NewObject, class OldObject> | |
106 static inline void ag_replace_object(AgObjectWrapper<OldObject> *p, const NewObject &o) { | |
107 delete p; | |
108 new(p) AgObjectWrapper<NewObject >(o); | |
109 } | |
110 | |
111 template <class Object> | |
112 static inline void ag_delete_object(AgObjectWrapper<Object> *p) { | |
113 delete p; | |
114 } | |
115 | |
116 template <class NewObject, class OldObject> | |
117 static inline const NewObject &ag_delete_object(AgObjectWrapper<OldObject> *p, const NewObject &o) { | |
118 delete p; | |
119 return o; | |
120 } | |
121 ## | |
122 wrapper def | |
123 | |
124 #ifndef AG_OBJECT_WRAPPER_DEFINED | |
125 #define AG_OBJECT_WRAPPER_DEFINED | |
126 | |
127 #ifndef AG_PLACEMENT_DELETE_REQUIRED | |
128 #if _MSC_VER >= 1200 || __INTEL_COMPILER | |
129 #define AG_PLACEMENT_DELETE_REQUIRED 1 | |
130 #endif | |
131 #endif | |
132 | |
133 template <class Object> | |
134 class AgObjectWrapper { | |
135 Object object; | |
136 public: | |
137 void operator delete(void *) {} | |
138 void *operator new(size_t, void *p) { return p;} | |
139 #if AG_PLACEMENT_DELETE_REQUIRED | |
140 void operator delete(void *, void *) { } | |
141 #endif | |
142 AgObjectWrapper(const Object &o) : object(o) {} | |
143 ~AgObjectWrapper() {} | |
144 operator Object &() {return object;} | |
145 }; | |
146 | |
147 #endif | |
148 | |
149 ## | |
150 declarations | |
151 #undef V | |
152 #define V(i,t) (*t (&(PCB).vs[(PCB).ssx + i])) | |
153 #undef VS | |
154 #define VS(i) (PCB).vs[(PCB).ssx + i] | |
155 | |
156 #ifndef GET_CONTEXT | |
157 #define GET_CONTEXT CONTEXT = (PCB).input_context | |
158 #endif | |
159 | |
160 typedef enum { | |
161 ag_shift_accept, | |
162 ag_go_to, | |
163 ag_shift_reduce, | |
164 ag_shift_simple_reduce, | |
165 ag_reduce_form, | |
166 ag_simple_reduce, | |
167 ag_accept, | |
168 ag_syn_error, | |
169 ag_null_go_to, | |
170 ag_skip, | |
171 ag_skip_reduce, | |
172 ag_recover | |
173 } ag_parser_action; | |
174 | |
175 ## | |
176 toupper | |
177 #ifndef CONVERT_CASE | |
178 | |
179 static int agConvertCase(int c) { | |
180 if (c >= 'a' && c <= 'z') return c ^ 0x20; | |
181 return c; | |
182 } | |
183 | |
184 #define CONVERT_CASE(c) agConvertCase(c) | |
185 | |
186 #endif | |
187 ## | |
188 toupper latin | |
189 #ifndef CONVERT_CASE | |
190 | |
191 static const char agCaseTable[31] = { | |
192 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, | |
193 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, | |
194 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0, | |
195 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20 | |
196 }; | |
197 | |
198 static int agConvertCase(int c) { | |
199 if (c >= 'a' && c <= 'z') return c ^= 0x20; | |
200 if (c >= 0xe0 && c < 0xff) c ^= agCaseTable[c-0xe0]; | |
201 return c; | |
202 } | |
203 | |
204 #define CONVERT_CASE(c) agConvertCase(c) | |
205 | |
206 #endif | |
207 ## | |
208 declare macros | |
209 AG_OVERFLOW \ | |
210 AG_TRACE_ERROR\ | |
211 (PCB).exit_flag = AG_STACK_ERROR_CODE;\ | |
212 PARSER_STACK_OVERFLOW; | |
213 | |
214 ag_shift_accept ag_action_1 | |
215 ag_go_to ag_action_2 | |
216 ag_shift_reduce ag_action_3 | |
217 ag_shift_simple_reduce ag_action_4 | |
218 ag_reduce_form ag_action_5 | |
219 ag_simple_reduce ag_action_6 | |
220 ag_accept ag_action_7 | |
221 ag_syn_error ag_action_8 | |
222 ag_null_go_to ag_action_9 | |
223 ag_skip ag_action_10 | |
224 ag_skip_reduce ag_action_11 | |
225 ag_recover ag_action_12 | |
226 | |
227 ag_shift_accept_proc ag_action_1_proc | |
228 ag_go_to_proc ag_action_2_proc | |
229 ag_shift_reduce_proc ag_action_3_proc | |
230 ag_simple_shift_reduce_proc ag_action_4_proc | |
231 ag_reduce_proc ag_action_5_proc | |
232 ag_simple_reduce_proc ag_action_6_proc | |
233 ag_accept_proc ag_action_7_proc | |
234 ag_error_proc ag_action_8_proc | |
235 ag_null_go_to_proc ag_action_9_proc | |
236 ag_skip_proc ag_action_10_proc | |
237 ag_skip_reduce_proc ag_action_11_proc | |
238 ag_recover_proc ag_action_12_proc | |
239 | |
240 ag_er_shift_accept_proc ag_action_1_er_proc | |
241 ag_er_go_to_proc ag_action_2_er_proc | |
242 ag_er_shift_reduce_proc ag_action_3_er_proc | |
243 ag_er_simple_shift_reduce_proc ag_action_4_er_proc | |
244 | |
245 ag_r_shift_accept_proc ag_action_1_r_proc | |
246 ag_r_go_to_proc ag_action_2_r_proc | |
247 ag_r_simple_shift_reduce_error_proc ag_action_3_er_proc | |
248 ag_s_shift_accept_proc ag_action_1_s_proc | |
249 | |
250 ag_go_to_error_proc ag_action_2_e_proc | |
251 ag_simple_shift_reduce_error_proc ag_action_4_e_proc | |
252 ag_simple_reduce_error_proc ag_action_6_e_proc | |
253 ag_skip_reduce_error_proc ag_action_11_e_proc | |
254 | |
255 ag_r_shift_reduce_proc ag_action_3_r_proc | |
256 ag_r_simple_shift_reduce_proc ag_action_4_r_proc | |
257 | |
258 ag_s_shift_reduce_proc ag_action_3_s_proc | |
259 ## | |
260 error trace | |
261 #ifndef AG_TRACE_FILE_NAME | |
262 #define AG_TRACE_FILE_NAME AG_TRACE_FILE | |
263 #endif | |
264 | |
265 STATIC#VOID NEAR#QUAL#ag_trace_error(THISARG) { | |
266 FILE *ag_file = fopen(AG_TRACE_FILE_NAME, "w"); | |
267 int i; | |
268 if (ag_file == NULL) return; | |
269 fprintf(ag_file, "%d\n", (PCB).ssx); | |
270 for (i = 0; i < (PCB).ssx; i++) fprintf(ag_file, "%d\n", (PCB).ss[i]); | |
271 fprintf(ag_file, "%d\n", (PCB).sn); | |
272 fprintf(ag_file, "%d\n", (PCB).token_number); | |
273 fclose(ag_file); | |
274 } | |
275 ## | |
276 read write counts | |
277 AG_READ_COUNTS { | |
278 FILE *ag_file = fopen(AG_COUNT_FILE, "r"); | |
279 int i; | |
280 | |
281 if (ag_file) { | |
282 long ag_file_id; | |
283 fscanf(ag_file, "%ld", &ag_file_id); | |
284 if (ag_file_id == AG_COUNT_FILE_ID) { | |
285 for (i = 0; i < AG_COUNT_FILE_RC; i++) | |
286 fscanf(ag_file,"%u", &(AG_RULE_COUNT[i])); | |
287 fclose(ag_file); | |
288 return; | |
289 } | |
290 } | |
291 for (i = 0; i < AG_COUNT_FILE_RC; i++) AG_RULE_COUNT[i] = 0; | |
292 } | |
293 | |
294 AG_WRITE_COUNTS { | |
295 FILE *ag_file = fopen(AG_COUNT_FILE, "w"); | |
296 int i; | |
297 | |
298 if (ag_file == NULL) return; | |
299 fprintf(ag_file, "%ld\n", AG_COUNT_FILE_ID); | |
300 for (i = 0; i < AG_COUNT_FILE_RC; i++) | |
301 fprintf(ag_file,"%u\n", AG_RULE_COUNT[i]); | |
302 fclose(ag_file); | |
303 } | |
304 ## | |
305 parse action macros | |
306 | |
307 AG_GT ag_gt_procs_scan | |
308 AG_SR ag_s_procs_scan | |
309 AG_RD ag_r_procs_scan | |
310 AG_INIT_RESYNCH | |
311 ## | |
312 error resynch macros | |
313 | |
314 AG_GT ag_gt_procs_scan | |
315 AG_SR ag_s_procs_scan | |
316 AG_RD ag_r_procs_scan | |
317 AG_ER ag_er_procs_scan | |
318 AG_INIT_RESYNCH | |
319 ## | |
320 init col | |
321 | |
322 #ifndef SYNTAX_ERROR | |
323 #define SYNTAX_ERROR fprintf(stderr,"%s, line %d, column %d\n", \ | |
324 (PCB).error_message, (PCB).line, (PCB).column) | |
325 #endif | |
326 | |
327 #ifndef FIRST_LINE | |
328 #define FIRST_LINE 1 | |
329 #endif | |
330 | |
331 #ifndef FIRST_COLUMN | |
332 #define FIRST_COLUMN 1 | |
333 #endif | |
334 | |
335 #ifndef PARSER_STACK_OVERFLOW | |
336 #define PARSER_STACK_OVERFLOW {fprintf(stderr, \ | |
337 "\nParser stack overflow, line %d, column %d\n",\ | |
338 (PCB).line, (PCB).column);} | |
339 #endif | |
340 | |
341 #ifndef REDUCTION_TOKEN_ERROR | |
342 #define REDUCTION_TOKEN_ERROR {fprintf(stderr, \ | |
343 "\nReduction token error, line %d, column %d\n", \ | |
344 (PCB).line, (PCB).column);} | |
345 #endif | |
346 | |
347 ## | |
348 init nocol | |
349 | |
350 #ifndef SYNTAX_ERROR | |
351 #define SYNTAX_ERROR fprintf(stderr,"%s\n", (PCB).error_message) | |
352 #endif | |
353 | |
354 #ifndef PARSER_STACK_OVERFLOW | |
355 #define PARSER_STACK_OVERFLOW {fprintf(stderr, \ | |
356 "\nParser stack overflow\n");} | |
357 #endif | |
358 | |
359 #ifndef REDUCTION_TOKEN_ERROR | |
360 #define REDUCTION_TOKEN_ERROR {fprintf(stderr, \ | |
361 "\nReduction token error\n");} | |
362 #endif | |
363 | |
364 ## | |
365 | |
366 backtrack off | |
367 | |
368 ## | |
369 backtrack off macros | |
370 | |
371 AG_STACK AG_SAVE_CONTEXT\ | |
372 (PCB).ss[(PCB).ssx] = (PCB).sn; | |
373 | |
374 AG_CHKOVFLO if ((PCB).ssx >= AG_PARSER_STACK_SIZE) {\ | |
375 AG_TRACE_ERROR\ | |
376 (PCB).exit_flag = AG_STACK_ERROR_CODE;\ | |
377 PARSER_STACK_OVERFLOW;\ | |
378 } | |
379 | |
380 AG_PROT if ((PCB).ssx >= AG_PARSER_STACK_SIZE) {\ | |
381 AG_TRACE_ERROR\ | |
382 (PCB).exit_flag = AG_STACK_ERROR_CODE;\ | |
383 PARSER_STACK_OVERFLOW;\ | |
384 } | |
385 | |
386 AG_PROTX if ((PCB).ssx >= AG_PARSER_STACK_SIZE) {\ | |
387 AG_TRACE_ERROR\ | |
388 (PCB).exit_flag = AG_STACK_ERROR_CODE;\ | |
389 PARSER_STACK_OVERFLOW;\ | |
390 } | |
391 | |
392 AG_SET_BACK | |
393 AG_UNDO | |
394 AG_CLEAR_BACK | |
395 AG_PROT_CONTEXT | |
396 AG_UNDO_CONTEXT | |
397 | |
398 ## | |
399 | |
400 backtrack on | |
401 | |
402 STATIC#VOID NEAR#QUAL#ag_prot(THISARG) { | |
403 int ag_k; | |
404 ag_k = AG_PARSER_STACK_SIZE - ++(PCB).btsx; | |
405 if (ag_k <= (PCB).ssx) { | |
406 AG_OVERFLOW | |
407 return; | |
408 } | |
409 (PCB).bts[(PCB).btsx] = (PCB).sn; | |
410 (PCB).bts[ag_k] = (PCB).ssx; | |
411 (PCB).vs[ag_k] = (PCB).vs[(PCB).ssx]; | |
412 (PCB).ss[ag_k] = (PCB).ss[(PCB).ssx]; | |
413 AG_PROT_CONTEXT | |
414 } | |
415 | |
416 STATIC#VOID NEAR#QUAL#ag_undo(THISARG) { | |
417 if ((PCB).drt == -1) return; | |
418 while ((PCB).btsx) { | |
419 int ag_k = AG_PARSER_STACK_SIZE - (PCB).btsx; | |
420 (PCB).sn = (PCB).bts[(PCB).btsx--]; | |
421 (PCB).ssx = (PCB).bts[ag_k]; | |
422 (PCB).vs[(PCB).ssx] = (PCB).vs[ag_k]; | |
423 (PCB).ss[(PCB).ssx] = (PCB).ss[ag_k]; | |
424 AG_UNDO_CONTEXT | |
425 } | |
426 (PCB).token_number = (AG_TOKEN_TYPE) (PCB).drt; | |
427 (PCB).ssx = (PCB).dssx; | |
428 (PCB).sn = (PCB).dsn; | |
429 (PCB).drt = -1; | |
430 } | |
431 | |
432 ## | |
433 | |
434 backtrack on macros | |
435 | |
436 AG_CLEAR_BACK (PCB).btsx = 0, (PCB).drt = -1; | |
437 | |
438 AG_SET_BACK if ((PCB).drt == -1) {\ | |
439 (PCB).drt=(PCB).token_number;\ | |
440 (PCB).dssx=(PCB).ssx;\ | |
441 (PCB).dsn=(PCB).sn;\ | |
442 } | |
443 | |
444 AG_CHKOVFLO if ((PCB).ssx >= AG_PARSER_STACK_SIZE) {\ | |
445 AG_TRACE_ERROR\ | |
446 (PCB).exit_flag = AG_STACK_ERROR_CODE;\ | |
447 PARSER_STACK_OVERFLOW;\ | |
448 } | |
449 | |
450 AG_STACK AG_SAVE_CONTEXT\ | |
451 (PCB).ss[(PCB).ssx] = (PCB).sn; | |
452 | |
453 AG_PROT if ((PCB).drt >= 0) ag_prot(PCBARG);\ | |
454 else if ((PCB).ssx >= AG_PARSER_STACK_SIZE) {\ | |
455 AG_TRACE_ERROR\ | |
456 (PCB).exit_flag = AG_STACK_ERROR_CODE;\ | |
457 PARSER_STACK_OVERFLOW;\ | |
458 } | |
459 | |
460 AG_PROTX ag_prot(PCBARG); | |
461 | |
462 ## | |
463 | |
464 error resynch undo | |
465 | |
466 AG_UNDO int ag_k = ag_sbt[(PCB).sn];\ | |
467 while (ag_tstt[ag_k] != AG_ERROR && ag_tstt[ag_k]) ag_k++;\ | |
468 if (ag_tstt[ag_k] == 0) ag_undo(PCBARG); | |
469 | |
470 ## | |
471 | |
472 undo macro | |
473 | |
474 AG_UNDO ag_undo(PCBARG); | |
475 | |
476 ## | |
477 | |
478 context macros | |
479 | |
480 AG_PROT_CONTEXT (PCB).cs[ag_k] = (PCB).cs[(PCB).ssx]; | |
481 AG_UNDO_CONTEXT (PCB).cs[(PCB).ssx] = (PCB).cs[ag_k]; | |
482 | |
483 ## | |
484 | |
485 no context macros | |
486 | |
487 AG_PROT_CONTEXT | |
488 AG_UNDO_CONTEXT | |
489 | |
490 ## | |
491 | |
492 trk char key col, trk char sink key col | |
493 | |
494 #ifndef AG_NEWLINE | |
495 #define AG_NEWLINE 10 | |
496 #endif | |
497 | |
498 #ifndef AG_RETURN | |
499 #define AG_RETURN 13 | |
500 #endif | |
501 | |
502 #ifndef AG_FORMFEED | |
503 #define AG_FORMFEED 12 | |
504 #endif | |
505 | |
506 #ifndef AG_TABCHAR | |
507 #define AG_TABCHAR 9 | |
508 #endif | |
509 | |
510 STATIC#VOID NEAR#QUAL#ag_track(THISARG) { | |
511 int ag_k = 0; | |
512 while (ag_k < (PCB).rx) { | |
513 int ag_ch = (PCB).lab[ag_k++]; | |
514 switch (ag_ch) { | |
515 case AG_NEWLINE: | |
516 (PCB).column = 1, (PCB).line++; | |
517 case AG_RETURN: | |
518 case AG_FORMFEED: | |
519 break; | |
520 case AG_TABCHAR: | |
521 (PCB).column += (TAB_SPACING) - ((PCB).column - 1) % (TAB_SPACING); | |
522 break; | |
523 default: | |
524 (PCB).column++; | |
525 } | |
526 } | |
527 ag_k = 0; | |
528 while ((PCB).rx < (PCB).fx) (PCB).lab[ag_k++] = (PCB).lab[(PCB).rx++]; | |
529 (PCB).fx = ag_k; | |
530 (PCB).rx = 0; | |
531 } | |
532 | |
533 ## | |
534 | |
535 trk macros char key col, trk macros char sink key col | |
536 | |
537 AG_TRK_PTR ag_track(PCBARG); | |
538 AG_INC_PTR {(PCB).rx = 1; ag_track(PCBARG);} | |
539 AG_INIT_TRK (PCB).line = FIRST_LINE;\ | |
540 (PCB).column = FIRST_COLUMN; | |
541 | |
542 ## | |
543 | |
544 trk char key, trk char sink key | |
545 | |
546 STATIC#VOID NEAR#QUAL#ag_track(THISARG) { | |
547 int ag_k = 0; | |
548 while ((PCB).rx < (PCB).fx) (PCB).lab[ag_k++] = (PCB).lab[(PCB).rx++]; | |
549 (PCB).fx = ag_k; | |
550 (PCB).rx = 0; | |
551 } | |
552 | |
553 ## | |
554 | |
555 trk macros char key, trk macros char sink key | |
556 | |
557 AG_INC_PTR {(PCB).rx = 1; ag_track(PCBARG);} | |
558 AG_TRK_PTR ag_track(PCBARG); | |
559 AG_INIT_TRK | |
560 | |
561 ## | |
562 | |
563 trk char col, trk char sink col | |
564 | |
565 #ifndef AG_NEWLINE | |
566 #define AG_NEWLINE 10 | |
567 #endif | |
568 | |
569 #ifndef AG_RETURN | |
570 #define AG_RETURN 13 | |
571 #endif | |
572 | |
573 #ifndef AG_FORMFEED | |
574 #define AG_FORMFEED 12 | |
575 #endif | |
576 | |
577 #ifndef AG_TABCHAR | |
578 #define AG_TABCHAR 9 | |
579 #endif | |
580 | |
581 STATIC#VOID NEAR#QUAL#ag_track(THISARG) { | |
582 switch ((PCB).input_code) { | |
583 case AG_NEWLINE: | |
584 (PCB).column = 1, (PCB).line++; | |
585 case AG_RETURN: | |
586 case AG_FORMFEED: | |
587 break; | |
588 case AG_TABCHAR: | |
589 (PCB).column += (TAB_SPACING) - ((PCB).column - 1) % (TAB_SPACING); | |
590 break; | |
591 default: | |
592 (PCB).column++; | |
593 } | |
594 (PCB).read_flag = 1; | |
595 } | |
596 | |
597 ## | |
598 | |
599 trk macros char col, trk macros char sink col | |
600 | |
601 AG_TRK_PTR ag_track(PCBARG); | |
602 AG_INC_PTR ag_track(PCBARG); | |
603 AG_INIT_TRK (PCB).line = FIRST_LINE;\ | |
604 (PCB).column = FIRST_COLUMN; | |
605 | |
606 ## | |
607 | |
608 trk char, trk token | |
609 | |
610 ## | |
611 | |
612 trk macros char, trk macros token | |
613 | |
614 AG_TRK_PTR {if ((PCB).read_flag == 0) (PCB).read_flag = 1;} | |
615 AG_INC_PTR {if ((PCB).read_flag == 0) (PCB).read_flag = 1;} | |
616 AG_INIT_TRK | |
617 | |
618 ## | |
619 | |
620 trk token col | |
621 | |
622 ## | |
623 | |
624 trk macros token col | |
625 AG_TRK_PTR {if ((PCB).read_flag == 0) (PCB).read_flag = 1;} | |
626 AG_INC_PTR {if ((PCB).read_flag == 0) (PCB).read_flag = 1;} | |
627 AG_INIT_TRK (PCB).line = FIRST_LINE;\ | |
628 (PCB).column = FIRST_COLUMN; | |
629 | |
630 ## | |
631 | |
632 init char key | |
633 | |
634 typedef enum | |
635 {ag_accept_key, ag_set_key, ag_jmp_key, ag_end_key, ag_no_match_key, | |
636 ag_cf_accept_key, ag_cf_set_key, ag_cf_end_key} key_words; | |
637 | |
638 #ifndef GET_INPUT | |
639 #define GET_INPUT ((PCB).input_code = getchar()) | |
640 #endif | |
641 | |
642 | |
643 STATIC#int NEAR#QUAL#ag_look_ahead(THISARG) { | |
644 if ((PCB).rx < (PCB).fx) { | |
645 return CONVERT_CASE((PCB).lab[(PCB).rx++]); | |
646 } | |
647 GET_INPUT; | |
648 (PCB).fx++; | |
649 return CONVERT_CASE((PCB).lab[(PCB).rx++] = (PCB).input_code); | |
650 } | |
651 | |
652 STATIC#VOID NEAR#QUAL#AG_GET_KEY_WORD { | |
653 int save_index = (PCB).rx; | |
654 CONST unsigned char *sp; | |
655 int ag_ch; | |
656 while (1) { | |
657 switch (ag_key_act[ag_k]) { | |
658 case ag_cf_end_key: | |
659 sp = ag_key_ends + ag_key_jmp[ag_k]; | |
660 do { | |
661 if ((ag_ch = *sp++) == 0) { | |
662 int ag_k1 = ag_key_parm[ag_k]; | |
663 int ag_k2 = ag_key_pt[ag_k1]; | |
664 if (ag_key_itt[ag_k2 + ag_look_ahead(PCBARG)]) goto ag_fail; | |
665 (PCB).rx--; | |
666 (PCB).token_number = (AG_TOKEN_TYPE) ag_key_pt[ag_k1 + 1]; | |
667 return; | |
668 } | |
669 } while (ag_look_ahead(PCBARG) == ag_ch); | |
670 goto ag_fail; | |
671 case ag_end_key: | |
672 sp = ag_key_ends + ag_key_jmp[ag_k]; | |
673 do { | |
674 if ((ag_ch = *sp++) == 0) { | |
675 (PCB).token_number = (AG_TOKEN_TYPE) ag_key_parm[ag_k]; | |
676 return; | |
677 } | |
678 } while (ag_look_ahead(PCBARG) == ag_ch); | |
679 case ag_no_match_key: | |
680 ag_fail: | |
681 (PCB).rx = save_index; | |
682 return; | |
683 case ag_cf_set_key: { | |
684 int ag_k1 = ag_key_parm[ag_k]; | |
685 int ag_k2 = ag_key_pt[ag_k1]; | |
686 ag_k = ag_key_jmp[ag_k]; | |
687 if (ag_key_itt[ag_k2 + (ag_ch = ag_look_ahead(PCBARG))]) break; | |
688 save_index = --(PCB).rx; | |
689 (PCB).token_number = (AG_TOKEN_TYPE) ag_key_pt[ag_k1+1]; | |
690 break; | |
691 } | |
692 case ag_set_key: | |
693 save_index = (PCB).rx; | |
694 (PCB).token_number = (AG_TOKEN_TYPE) ag_key_parm[ag_k]; | |
695 case ag_jmp_key: | |
696 ag_k = ag_key_jmp[ag_k]; | |
697 ag_ch = ag_look_ahead(PCBARG); | |
698 break; | |
699 case ag_accept_key: | |
700 (PCB).token_number = (AG_TOKEN_TYPE) ag_key_parm[ag_k]; | |
701 return; | |
702 case ag_cf_accept_key: { | |
703 int ag_k1 = ag_key_parm[ag_k]; | |
704 int ag_k2 = ag_key_pt[ag_k1]; | |
705 if (ag_key_itt[ag_k2 + ag_look_ahead(PCBARG)]) (PCB).rx = save_index; | |
706 else { | |
707 (PCB).rx--; | |
708 (PCB).token_number = (AG_TOKEN_TYPE) ag_key_pt[ag_k1+1]; | |
709 } | |
710 return; | |
711 } | |
712 default: | |
713 /* not reachable; here to suppress compiler warnings */ | |
714 goto ag_fail; | |
715 } | |
716 if (ag_ch <= 255) while (ag_key_ch[ag_k] < ag_ch) ag_k++; | |
717 if (ag_ch > 255 || ag_key_ch[ag_k] != ag_ch) { | |
718 (PCB).rx = save_index; | |
719 return; | |
720 } | |
721 } | |
722 } | |
723 | |
724 ## | |
725 | |
726 init macros char key | |
727 | |
728 AG_CHAR ((PCB).rx < (PCB).fx ? (PCB).lab[(PCB).rx-1] : (PCB).input_code) | |
729 AG_INIT_PTR (PCB).rx = (PCB).fx = 0; | |
730 AG_RST_PTR (PCB).rx = 0; | |
731 | |
732 ## | |
733 | |
734 init char sink key | |
735 | |
736 typedef enum | |
737 {ag_accept_key, ag_set_key, ag_jmp_key, ag_end_key, ag_no_match_key, | |
738 ag_cf_accept_key, ag_cf_set_key, ag_cf_end_key} key_words; | |
739 | |
740 ## | |
741 | |
742 init macros char sink key | |
743 | |
744 AG_CHAR ((PCB).rx < (PCB).fx ? (PCB).lab[(PCB).rx-1] : (PCB).input_code) | |
745 AG_INIT_PTR (PCB).rx = (PCB).fx = 0; | |
746 AG_RST_PTR (PCB).rx = 0; | |
747 | |
748 ## | |
749 | |
750 get char key | |
751 | |
752 AG_GET_TKN if ((PCB).rx < (PCB).fx) {\ | |
753 (PCB).input_code = (PCB).lab[(PCB).rx++];\ | |
754 (PCB).token_number = (AG_TOKEN_TYPE) AG_TCV((PCB).input_code);}\ | |
755 else {\ | |
756 GET_INPUT;\ | |
757 (PCB).lab[(PCB).fx++] = (PCB).input_code;\ | |
758 (PCB).token_number = (AG_TOKEN_TYPE) AG_TCV((PCB).input_code);\ | |
759 (PCB).rx++;\ | |
760 }\ | |
761 if (ag_key_index[(PCB).sn]) {\ | |
762 unsigned ag_k = ag_key_index[(PCB).sn];\ | |
763 int ag_ch = CONVERT_CASE((PCB).input_code);\ | |
764 if (ag_ch < 255) {\ | |
765 while (ag_key_ch[ag_k] < ag_ch) ag_k++;\ | |
766 if (ag_key_ch[ag_k] == ag_ch) ag_get_key_word(PCBARGC#ag_k);\ | |
767 }\ | |
768 } | |
769 | |
770 ## | |
771 | |
772 init char | |
773 | |
774 | |
775 #ifndef GET_INPUT | |
776 #define GET_INPUT ((PCB).input_code = getchar()) | |
777 #endif | |
778 | |
779 ## | |
780 | |
781 init macros char | |
782 | |
783 AG_CHAR (PCB).input_code; | |
784 AG_INIT_PTR (PCB).read_flag = 1; | |
785 AG_RST_PTR | |
786 | |
787 ## | |
788 | |
789 init char sink | |
790 | |
791 ## | |
792 | |
793 init macros char sink | |
794 | |
795 AG_CHAR (PCB).input_code; | |
796 AG_INIT_PTR | |
797 AG_RST_PTR | |
798 | |
799 ## | |
800 | |
801 init token | |
802 | |
803 ## | |
804 | |
805 init macros token | |
806 | |
807 AG_INIT_PTR (PCB).read_flag = 1; | |
808 AG_RST_PTR | |
809 | |
810 ## | |
811 | |
812 init token sink | |
813 | |
814 ## | |
815 | |
816 init macros token sink | |
817 | |
818 AG_INIT_PTR | |
819 AG_RST_PTR | |
820 | |
821 ## | |
822 | |
823 get token sink, get char sink | |
824 | |
825 ## | |
826 | |
827 trk token sink, trk char sink | |
828 | |
829 ## | |
830 | |
831 trk macros token sink, trk macros char sink | |
832 | |
833 AG_TRK_PTR | |
834 AG_INC_PTR | |
835 AG_INIT_TRK | |
836 | |
837 ## | |
838 | |
839 get char, get token | |
840 | |
841 AG_GET_TKN if ((PCB).read_flag) {\ | |
842 (PCB).read_flag = 0;\ | |
843 GET_INPUT;\ | |
844 };\ | |
845 (PCB).token_number = (AG_TOKEN_TYPE) AG_TCV((PCB).input_code); | |
846 | |
847 ## | |
848 | |
849 init ptr key | |
850 | |
851 #ifndef INPUT_CODE | |
852 #define INPUT_CODE(T) (T) | |
853 #endif | |
854 | |
855 typedef enum | |
856 {ag_accept_key, ag_set_key, ag_jmp_key, ag_end_key, ag_no_match_key, | |
857 ag_cf_accept_key, ag_cf_set_key, ag_cf_end_key} key_words; | |
858 | |
859 STATIC#VOID NEAR#QUAL#AG_GET_KEY_WORD { | |
860 int ag_save = (int) ((PCB).la_ptr - (PCB).pointer); | |
861 CONST unsigned char *ag_p; | |
862 int ag_ch; | |
863 while (1) { | |
864 switch (ag_key_act[ag_k]) { | |
865 case ag_cf_end_key: { | |
866 CONST unsigned char *sp = ag_key_ends + ag_key_jmp[ag_k]; | |
867 do { | |
868 if ((ag_ch = *sp++) == 0) { | |
869 int ag_k1 = ag_key_parm[ag_k]; | |
870 int ag_k2 = ag_key_pt[ag_k1]; | |
871 if (ag_key_itt[ag_k2 + CONVERT_CASE(*(PCB).la_ptr)]) goto ag_fail; | |
872 (PCB).token_number = (AG_TOKEN_TYPE) ag_key_pt[ag_k1 + 1]; | |
873 return; | |
874 } | |
875 } while (CONVERT_CASE(*(PCB).la_ptr++) == ag_ch); | |
876 goto ag_fail; | |
877 } | |
878 case ag_end_key: { | |
879 CONST unsigned char *sp = ag_key_ends + ag_key_jmp[ag_k]; | |
880 do { | |
881 if ((ag_ch = *sp++) == 0) { | |
882 (PCB).token_number = (AG_TOKEN_TYPE) ag_key_parm[ag_k]; | |
883 return; | |
884 } | |
885 } while (CONVERT_CASE(*(PCB).la_ptr++) == ag_ch); | |
886 } | |
887 case ag_no_match_key: | |
888 ag_fail: | |
889 (PCB).la_ptr = (PCB).pointer + ag_save; | |
890 return; | |
891 case ag_cf_set_key: { | |
892 int ag_k1 = ag_key_parm[ag_k]; | |
893 int ag_k2 = ag_key_pt[ag_k1]; | |
894 ag_k = ag_key_jmp[ag_k]; | |
895 if (ag_key_itt[ag_k2 + CONVERT_CASE(*(PCB).la_ptr)]) break; | |
896 ag_save = (int) ((PCB).la_ptr - (PCB).pointer); | |
897 (PCB).token_number = (AG_TOKEN_TYPE) ag_key_pt[ag_k1+1]; | |
898 break; | |
899 } | |
900 case ag_set_key: | |
901 ag_save = (int) ((PCB).la_ptr - (PCB).pointer); | |
902 (PCB).token_number = (AG_TOKEN_TYPE) ag_key_parm[ag_k]; | |
903 case ag_jmp_key: | |
904 ag_k = ag_key_jmp[ag_k]; | |
905 break; | |
906 case ag_accept_key: | |
907 (PCB).token_number = (AG_TOKEN_TYPE) ag_key_parm[ag_k]; | |
908 return; | |
909 case ag_cf_accept_key: { | |
910 int ag_k1 = ag_key_parm[ag_k]; | |
911 int ag_k2 = ag_key_pt[ag_k1]; | |
912 if (ag_key_itt[ag_k2 + CONVERT_CASE(*(PCB).la_ptr)]) | |
913 (PCB).la_ptr = (PCB).pointer + ag_save; | |
914 else (PCB).token_number = (AG_TOKEN_TYPE) ag_key_pt[ag_k1+1]; | |
915 return; | |
916 } | |
917 } | |
918 ag_ch = CONVERT_CASE(*(PCB).la_ptr++); | |
919 ag_p = &ag_key_ch[ag_k]; | |
920 if (ag_ch <= 255) while (*ag_p < ag_ch) ag_p++; | |
921 if (ag_ch > 255 || *ag_p != ag_ch) { | |
922 (PCB).la_ptr = (PCB).pointer + ag_save; | |
923 return; | |
924 } | |
925 ag_k = (int) (ag_p - ag_key_ch); | |
926 } | |
927 } | |
928 | |
929 ## | |
930 | |
931 init macros ptr key | |
932 | |
933 AG_CHAR *(PCB).pointer | |
934 AG_INIT_PTR (PCB).la_ptr = (PCB).pointer; | |
935 AG_RST_PTR (PCB).la_ptr = (PCB).pointer; | |
936 | |
937 ## | |
938 | |
939 trk ptr key | |
940 | |
941 ## | |
942 | |
943 trk macros ptr key | |
944 | |
945 AG_TRK_PTR (PCB).pointer = (PCB).la_ptr; | |
946 AG_INC_PTR (PCB).la_ptr = ++(PCB).pointer; | |
947 AG_INIT_TRK | |
948 | |
949 ## | |
950 | |
951 trk ptr key col | |
952 | |
953 #ifndef AG_NEWLINE | |
954 #define AG_NEWLINE 10 | |
955 #endif | |
956 | |
957 #ifndef AG_RETURN | |
958 #define AG_RETURN 13 | |
959 #endif | |
960 | |
961 #ifndef AG_FORMFEED | |
962 #define AG_FORMFEED 12 | |
963 #endif | |
964 | |
965 #ifndef AG_TABCHAR | |
966 #define AG_TABCHAR 9 | |
967 #endif | |
968 | |
969 STATIC#VOID NEAR#QUAL#ag_track(THISARG) { | |
970 int ag_k = (int) ((PCB).la_ptr - (PCB).pointer); | |
971 while (ag_k--) { | |
972 switch (*(PCB).pointer++) { | |
973 case AG_NEWLINE: | |
974 (PCB).column = 1, (PCB).line++; | |
975 case AG_RETURN: | |
976 case AG_FORMFEED: | |
977 break; | |
978 case AG_TABCHAR: | |
979 (PCB).column += (TAB_SPACING) - ((PCB).column - 1) % (TAB_SPACING); | |
980 break; | |
981 default: | |
982 (PCB).column++; | |
983 } | |
984 } | |
985 } | |
986 | |
987 ## | |
988 | |
989 trk macros ptr key col | |
990 | |
991 AG_TRK_PTR ag_track(PCBARG); | |
992 AG_INIT_TRK (PCB).line = FIRST_LINE;\ | |
993 (PCB).column = FIRST_COLUMN; | |
994 | |
995 AG_INC_PTR {(PCB).la_ptr = (PCB).pointer + 1; ag_track(PCBARG);} | |
996 | |
997 ## | |
998 | |
999 get ptr key | |
1000 | |
1001 AG_GET_TKN (PCB).token_number = (AG_TOKEN_TYPE) AG_TCV(INPUT_CODE(*(PCB).la_ptr));\ | |
1002 (PCB).la_ptr++;\ | |
1003 if (ag_key_index[(PCB).sn]) {\ | |
1004 unsigned ag_k = ag_key_index[(PCB).sn];\ | |
1005 int ag_ch = CONVERT_CASE(INPUT_CODE(*(PCB).pointer));\ | |
1006 if (ag_ch <= 255) {\ | |
1007 while (ag_key_ch[ag_k] < ag_ch) ag_k++;\ | |
1008 if (ag_key_ch[ag_k] == ag_ch) ag_get_key_word(PCB_TYPE_CAST#PCBARGC#ag_k);\ | |
1009 }\ | |
1010 } | |
1011 | |
1012 ## | |
1013 | |
1014 init ptr | |
1015 | |
1016 #ifndef INPUT_CODE | |
1017 #define INPUT_CODE(T) (T) | |
1018 #endif | |
1019 | |
1020 ## | |
1021 | |
1022 init macros ptr | |
1023 | |
1024 AG_RST_PTR (PCB).la_ptr = (PCB).pointer; | |
1025 AG_INIT_PTR (PCB).la_ptr = (PCB).pointer; | |
1026 AG_CHAR *(PCB).pointer | |
1027 | |
1028 ## | |
1029 | |
1030 trk ptr | |
1031 | |
1032 ## | |
1033 | |
1034 trk macros ptr | |
1035 | |
1036 AG_TRK_PTR (PCB).pointer = (PCB).la_ptr; | |
1037 AG_INC_PTR (PCB).la_ptr = ++(PCB).pointer; | |
1038 AG_INIT_TRK | |
1039 | |
1040 ## | |
1041 | |
1042 trk ptr col | |
1043 | |
1044 #ifndef AG_NEWLINE | |
1045 #define AG_NEWLINE 10 | |
1046 #endif | |
1047 | |
1048 #ifndef AG_RETURN | |
1049 #define AG_RETURN 13 | |
1050 #endif | |
1051 | |
1052 #ifndef AG_FORMFEED | |
1053 #define AG_FORMFEED 12 | |
1054 #endif | |
1055 | |
1056 #ifndef AG_TABCHAR | |
1057 #define AG_TABCHAR 9 | |
1058 #endif | |
1059 | |
1060 STATIC#VOID NEAR#QUAL#ag_track(THISARG) { | |
1061 int ag_k = (int) ((PCB).la_ptr - (PCB).pointer); | |
1062 while (ag_k--) { | |
1063 switch (*(PCB).pointer++) { | |
1064 case AG_NEWLINE: | |
1065 (PCB).column = 1, (PCB).line++; | |
1066 case AG_RETURN: | |
1067 case AG_FORMFEED: | |
1068 break; | |
1069 case AG_TABCHAR: | |
1070 (PCB).column += (TAB_SPACING) - ((PCB).column - 1) % (TAB_SPACING); | |
1071 break; | |
1072 default: | |
1073 (PCB).column++; | |
1074 } | |
1075 } | |
1076 } | |
1077 | |
1078 ## | |
1079 | |
1080 trk macros ptr col | |
1081 | |
1082 AG_TRK_PTR ag_track(PCBARG); | |
1083 AG_INC_PTR {(PCB).la_ptr = (PCB).pointer + 1; ag_track(PCBARG);} | |
1084 AG_INIT_TRK (PCB).line = FIRST_LINE;\ | |
1085 (PCB).column = FIRST_COLUMN; | |
1086 | |
1087 ## | |
1088 | |
1089 get ptr | |
1090 | |
1091 AG_GET_TKN (PCB).token_number = (AG_TOKEN_TYPE) AG_TCV(INPUT_CODE(*(PCB).la_ptr));\ | |
1092 (PCB).la_ptr++; | |
1093 | |
1094 ## | |
1095 | |
1096 jns proc | |
1097 | |
1098 STATIC#int NEAR#QUAL#AG_RNS { | |
1099 while (1) { | |
1100 int ag_act, ag_k = ag_sbt[ag_snd], ag_lim = ag_sbt[ag_snd+1]; | |
1101 int ag_p; | |
1102 | |
1103 while (ag_k < ag_lim && ag_tstt[ag_k] != ag_t) ag_k++; | |
1104 if (ag_k == ag_lim) break; | |
1105 ag_act = ag_astt[ag_k]; | |
1106 ag_p = ag_pstt[ag_k]; | |
1107 if (ag_act == ag_go_to) return ag_p; | |
1108 if (ag_act == ag_skip || ag_act == ag_skip_reduce) { | |
1109 (*ag_sx)--; | |
1110 return ag_snd; | |
1111 } | |
1112 if (ag_act != ag_shift_reduce && | |
1113 ag_act != ag_shift_simple_reduce) break; | |
1114 *ag_sx -= (ag_fl[ag_p] - 1); | |
1115 ag_snd = (PCB).ss[*ag_sx]; | |
1116 ag_t = ag_ptt[ag_p]; | |
1117 } | |
1118 return 0; | |
1119 } | |
1120 | |
1121 STATIC#int NEAR#QUAL#AG_JNS { | |
1122 int ag_k; | |
1123 | |
1124 ag_k = ag_sbt[(PCB).sn]; | |
1125 while (ag_tstt[ag_k] != ag_t && ag_tstt[ag_k]) ag_k++; | |
1126 while (1) { | |
1127 int ag_p = ag_pstt[ag_k]; | |
1128 int ag_sd; | |
1129 | |
1130 switch (ag_astt[ag_k]) { | |
1131 case ag_go_to: | |
1132 AG_STACK | |
1133 return ag_p; | |
1134 case ag_skip: | |
1135 case ag_skip_reduce: | |
1136 return (PCB).ss[(PCB).ssx--]; | |
1137 case ag_null_go_to: | |
1138 AG_STACK | |
1139 (PCB).ssx++; | |
1140 (PCB).sn = ag_p; | |
1141 ag_k = ag_sbt[(PCB).sn]; | |
1142 while (ag_tstt[ag_k] != ag_t && ag_tstt[ag_k]) ag_k++; | |
1143 continue; | |
1144 case ag_shift_reduce: | |
1145 case ag_shift_simple_reduce: | |
1146 ag_sd = ag_fl[ag_p] - 1; | |
1147 if (ag_sd) (PCB).sn = (PCB).ss[(PCB).ssx -= ag_sd]; | |
1148 else AG_STACK | |
1149 ag_t = ag_ptt[ag_p]; | |
1150 ag_k = ag_sbt[(PCB).sn+1]; | |
1151 while (ag_tstt[--ag_k] != ag_t); | |
1152 continue; | |
1153 case ag_reduce_form: | |
1154 case ag_simple_reduce: | |
1155 if (ag_fl[ag_p]) break; | |
1156 (PCB).sn = ag_rns(PCBARGC#ag_ptt[ag_p],&(PCB).ssx, (PCB).sn); | |
1157 (PCB).ss[++(PCB).ssx] = (PCB).sn; | |
1158 ag_k = ag_sbt[(PCB).sn]; | |
1159 while (ag_tstt[ag_k] != ag_t && ag_tstt[ag_k]) ag_k++; | |
1160 continue; | |
1161 } | |
1162 break; | |
1163 } | |
1164 return 0; | |
1165 } | |
1166 | |
1167 ## | |
1168 | |
1169 no resynch | |
1170 | |
1171 AG_RESYNCH (PCB).exit_flag = AG_SYNTAX_ERROR_CODE;\ | |
1172 AG_DIAGNOSE\ | |
1173 SYNTAX_ERROR;\ | |
1174 AG_INC_PTR | |
1175 | |
1176 ## | |
1177 | |
1178 error resynch token sink mode | |
1179 | |
1180 STATIC#VOID NEAR#QUAL#ag_error_resynch(THISARG) { | |
1181 int ag_k; | |
1182 int ag_ssx = (PCB).ssx; | |
1183 | |
1184 AG_DIAGNOSE | |
1185 SYNTAX_ERROR; | |
1186 if ((PCB).exit_flag != AG_RUNNING_CODE) return; | |
1187 while (1) { | |
1188 ag_k = ag_sbt[(PCB).sn]; | |
1189 while (ag_tstt[ag_k] != AG_ERROR && ag_tstt[ag_k]) ag_k++; | |
1190 if (ag_tstt[ag_k] || (PCB).ssx == 0) break; | |
1191 DELETE_OBJECT | |
1192 } | |
1193 if (ag_tstt[ag_k] == 0) { | |
1194 (PCB).sn = (PCB).ss[(PCB).ssx = ag_ssx]; | |
1195 (PCB).exit_flag = AG_SYNTAX_ERROR_CODE; | |
1196 return; | |
1197 } | |
1198 ag_k = ag_sbt[(PCB).sn]; | |
1199 while (ag_tstt[ag_k] != AG_ERROR && ag_tstt[ag_k]) ag_k++; | |
1200 (PCB).ag_ap = ag_pstt[ag_k]; | |
1201 (AG_ER[ag_astt[ag_k]])(PCBARG); | |
1202 (PCB).ss[(PCB).ssx++] = (PCB).sn; | |
1203 (PCB).sn = AG_ERROR_STATE; | |
1204 return; | |
1205 } | |
1206 | |
1207 STATIC#int NEAR#QUAL#ag_recover_proc(THISARG) { | |
1208 int ag_t, ag_k = ag_sbt[(PCB).ss[(PCB).ssx-1]]; | |
1209 | |
1210 while (ag_tstt[ag_k] != (AG_TSTT_CAST) (PCB).token_number && ag_tstt[ag_k]) ag_k++; | |
1211 ag_t = ag_tstt[ag_k]; | |
1212 if (ag_t && ag_astt[ag_k] != ag_skip){ | |
1213 (PCB).sn = (PCB).ss[--(PCB).ssx]; | |
1214 AG_RST_PTR | |
1215 return 1; | |
1216 } | |
1217 if ((PCB).token_number == AG_EOF) | |
1218 {(PCB).exit_flag = AG_SYNTAX_ERROR_CODE; return 0;} | |
1219 AG_TRK_PTR | |
1220 return 0; | |
1221 } | |
1222 | |
1223 ## | |
1224 | |
1225 error resynch | |
1226 | |
1227 STATIC#VOID NEAR#QUAL#ag_error_resynch(THISARG) { | |
1228 int ag_k; | |
1229 int ag_ssx = (PCB).ssx; | |
1230 | |
1231 AG_DIAGNOSE | |
1232 SYNTAX_ERROR; | |
1233 if ((PCB).exit_flag != AG_RUNNING_CODE) return; | |
1234 while (1) { | |
1235 ag_k = ag_sbt[(PCB).sn]; | |
1236 while (ag_tstt[ag_k] != AG_ERROR && ag_tstt[ag_k]) ag_k++; | |
1237 if (ag_tstt[ag_k] || (PCB).ssx == 0) break; | |
1238 DELETE_OBJECT | |
1239 } | |
1240 if (ag_tstt[ag_k] == 0) { | |
1241 (PCB).sn = PCB.ss[(PCB).ssx = ag_ssx]; | |
1242 (PCB).exit_flag = AG_SYNTAX_ERROR_CODE; | |
1243 return; | |
1244 } | |
1245 ag_k = ag_sbt[(PCB).sn]; | |
1246 while (ag_tstt[ag_k] != AG_ERROR && ag_tstt[ag_k]) ag_k++; | |
1247 (PCB).ag_ap = ag_pstt[ag_k]; | |
1248 (AG_ER[ag_astt[ag_k]])(PCBARG); | |
1249 while (1) { | |
1250 ag_k = ag_sbt[(PCB).sn]; | |
1251 while (ag_tstt[ag_k] != (AG_TSTT_CAST) (PCB).token_number && ag_tstt[ag_k]) | |
1252 ag_k++; | |
1253 if (ag_tstt[ag_k] && ag_astt[ag_k] != ag_skip) break; | |
1254 if ((PCB).token_number == AG_EOF) | |
1255 {(PCB).exit_flag = AG_SYNTAX_ERROR_CODE; return;} | |
1256 AG_INC_PTR | |
1257 AG_GET_TKN | |
1258 } | |
1259 AG_RST_PTR | |
1260 } | |
1261 ## | |
1262 | |
1263 auto resynch macros | |
1264 | |
1265 AG_GT *(PCB).gt_procs | |
1266 AG_SR *(PCB).s_procs | |
1267 AG_RD *(PCB).r_procs | |
1268 | |
1269 AG_INIT_RESYNCH (PCB).gt_procs = ag_gt_procs_scan;\ | |
1270 (PCB).r_procs = ag_r_procs_scan;\ | |
1271 (PCB).s_procs = ag_s_procs_scan;\ | |
1272 (PCB).ag_error_depth = (PCB).ag_min_depth = (PCB).ag_tmp_depth = 0;\ | |
1273 (PCB).ag_resynch_active = 0; | |
1274 | |
1275 ## | |
1276 | |
1277 auto resynch defs | |
1278 | |
1279 int ag_error_depth, ag_min_depth, ag_tmp_depth; | |
1280 int ag_rss[2*AG_PARSER_STACK_SIZE], ag_lrss; | |
1281 | |
1282 ## | |
1283 | |
1284 auto resynch event defs | |
1285 | |
1286 int ag_error_depth, ag_min_depth, ag_tmp_depth; | |
1287 int ag_rss[2*AG_PARSER_STACK_SIZE], ag_lrss; | |
1288 int ag_rk1, ag_tk1; | |
1289 | |
1290 ## | |
1291 | |
1292 auto resynch token sink mode | |
1293 | |
1294 STATIC#int NEAR#QUAL#AG_ATX { | |
1295 int ag_k, ag_f; | |
1296 int ag_save_btsx = (PCB).btsx; | |
1297 int ag_flag = 1; | |
1298 | |
1299 while (1) { | |
1300 int ag_a; | |
1301 | |
1302 (PCB).bts[AG_PARSER_STACK_SIZE - ++(PCB).btsx] = *ag_sx; | |
1303 (PCB).ss[AG_PARSER_STACK_SIZE - (PCB).btsx] = (PCB).ss[*ag_sx]; | |
1304 (PCB).ss[*ag_sx] = ag_snd; | |
1305 ag_k = ag_sbt[ag_snd]; | |
1306 while (ag_tstt[ag_k] != ag_t && ag_tstt[ag_k]) ag_k++; | |
1307 ag_a = ag_astt[ag_k]; | |
1308 if (ag_a == ag_go_to || | |
1309 ag_a == ag_shift_reduce || | |
1310 ag_a == ag_skip || | |
1311 ag_a == ag_skip_reduce || | |
1312 ag_a == ag_shift_accept || | |
1313 ag_a == ag_shift_simple_reduce) break; | |
1314 if ((ag_a == ag_reduce_form || | |
1315 ag_a == ag_simple_reduce) && | |
1316 (ag_k = ag_fl[ag_f = ag_pstt[ag_k]]) == 0) { | |
1317 ag_snd = ag_rns(PCBARGC#ag_ptt[ag_f],ag_sx, (PCB).ss[*ag_sx]); | |
1318 (*ag_sx)++; | |
1319 continue; | |
1320 } | |
1321 if (ag_a == ag_null_go_to) { | |
1322 ag_snd = ag_pstt[ag_k]; | |
1323 (*ag_sx)++; | |
1324 continue; | |
1325 } | |
1326 ag_flag = 0; | |
1327 break; | |
1328 } | |
1329 while ((PCB).btsx > ag_save_btsx) { | |
1330 *ag_sx = (PCB).bts[AG_PARSER_STACK_SIZE - (PCB).btsx]; | |
1331 (PCB).ss[*ag_sx] = (PCB).ss[AG_PARSER_STACK_SIZE - (PCB).btsx--]; | |
1332 } | |
1333 return ag_flag; | |
1334 } | |
1335 | |
1336 STATIC#int NEAR#QUAL#ag_tst_tkn(THISARG) { | |
1337 int ag_rk, ag_sx, ag_snd; | |
1338 | |
1339 for (ag_rk = 0; ag_rk < (PCB).ag_lrss; ag_rk += 2) { | |
1340 ag_sx = (PCB).ag_rss[ag_rk]; | |
1341 if (ag_sx > (PCB).ssx) continue; | |
1342 ag_snd = (PCB).ag_rss[ag_rk + 1]; | |
1343 if (ag_sx > (PCB).ag_min_depth) continue; | |
1344 if (ag_atx(PCBARGC#(PCB).token_number, &ag_sx, ag_snd)) break; | |
1345 } | |
1346 return ag_rk; | |
1347 } | |
1348 | |
1349 STATIC#VOID NEAR#QUAL#ag_set_error_procs(THISARG); | |
1350 | |
1351 STATIC#VOID NEAR#QUAL#ag_auto_resynch(THISARG) { | |
1352 int ag_sx; | |
1353 MY_DELETE_WRAPPERS | |
1354 (PCB).ss[(PCB).ssx] = (PCB).sn; | |
1355 if ((PCB).ag_error_depth && (PCB).ag_min_depth >= (PCB).ag_error_depth) { | |
1356 (PCB).ssx = (PCB).ag_error_depth; | |
1357 (PCB).sn = (PCB).ss[(PCB).ssx]; | |
1358 } | |
1359 else { | |
1360 AG_DIAGNOSE | |
1361 SYNTAX_ERROR; | |
1362 if ((PCB).exit_flag != AG_RUNNING_CODE) return; | |
1363 (PCB).ag_error_depth = (PCB).ag_min_depth = 0; | |
1364 (PCB).ag_lrss = 0; | |
1365 (PCB).ss[ag_sx = (PCB).ssx] = (PCB).sn; | |
1366 (PCB).ag_min_depth = (PCB).ag_rss[(PCB).ag_lrss++] = ag_sx; | |
1367 (PCB).ag_rss[(PCB).ag_lrss++] = (PCB).sn; | |
1368 while (ag_sx && (PCB).ag_lrss < 2*AG_PARSER_STACK_SIZE) { | |
1369 int ag_t = 0, ag_x, ag_s, ag_sxs = ag_sx; | |
1370 | |
1371 while (ag_sx && (ag_t = ag_ctn[2*(PCB).sn]) == 0) (PCB).sn = (PCB).ss[--ag_sx]; | |
1372 if (ag_t) (PCB).sn = (PCB).ss[ag_sx -= ag_ctn[2*(PCB).sn +1]]; | |
1373 else { | |
1374 if (ag_sx == 0) (PCB).sn = 0; | |
1375 ag_t = ag_ptt[0]; | |
1376 } | |
1377 if ((ag_s = ag_rns(PCBARGC#ag_t, &ag_sx, (PCB).sn)) == 0) break; | |
1378 for (ag_x = 0; ag_x < (PCB).ag_lrss; ag_x += 2) | |
1379 if ((PCB).ag_rss[ag_x] == ag_sx + 1 && (PCB).ag_rss[ag_x+1] == ag_s) break; | |
1380 if (ag_x == (PCB).ag_lrss) { | |
1381 (PCB).ag_rss[(PCB).ag_lrss++] = ++ag_sx; | |
1382 (PCB).ag_rss[(PCB).ag_lrss++] = (PCB).sn = ag_s; | |
1383 } | |
1384 else if (ag_sx >= ag_sxs) ag_sx--; | |
1385 } | |
1386 ag_set_error_procs(PCBARG); | |
1387 } | |
1388 (PCB).ssx++; | |
1389 (PCB).sn = AG_ERROR_STATE; | |
1390 (PCB).ag_rk1 = (PCB).ag_lrss; | |
1391 return; | |
1392 } | |
1393 | |
1394 STATIC#int NEAR#QUAL#ag_recover_proc(THISARG) { | |
1395 int ag_k, ag_rk; | |
1396 | |
1397 (PCB).ssx--; | |
1398 if ((PCB).ag_rk1 == (PCB).ag_lrss) { | |
1399 (PCB).ag_rk1 = ag_tst_tkn(PCBARG); | |
1400 (PCB).ssx++; | |
1401 if ((PCB).token_number == AG_EOF) | |
1402 {(PCB).exit_flag = AG_SYNTAX_ERROR_CODE; return 0;} | |
1403 (PCB).ag_tk1 = (PCB).token_number; | |
1404 AG_TRK_PTR | |
1405 return 0; | |
1406 } | |
1407 ag_rk = ag_tst_tkn(PCBARG); | |
1408 if (ag_rk < (PCB).ag_rk1) { | |
1409 ag_k = 0; | |
1410 AG_TRK_PTR | |
1411 } | |
1412 else { | |
1413 ag_k = 1; | |
1414 ag_rk = (PCB).ag_rk1; | |
1415 (PCB).token_number = (AG_TOKEN_TYPE) (PCB).ag_tk1; | |
1416 AG_RST_PTR | |
1417 } | |
1418 (PCB).ag_min_depth = (PCB).ssx = (PCB).ag_rss[ag_rk++]; | |
1419 (PCB).sn = (PCB).ss[(PCB).ssx] = (PCB).ag_rss[ag_rk]; | |
1420 (PCB).sn = ag_jns(PCBARGC#(PCB).token_number); | |
1421 if ((PCB).ag_error_depth == 0 || (PCB).ag_error_depth > (PCB).ssx) | |
1422 (PCB).ag_error_depth = (PCB).ssx; | |
1423 if (++(PCB).ssx >= AG_PARSER_STACK_SIZE) { | |
1424 AG_OVERFLOW | |
1425 return 0; | |
1426 } | |
1427 AG_STACK | |
1428 (PCB).ag_tmp_depth = (PCB).ag_min_depth; | |
1429 return ag_k; | |
1430 } | |
1431 | |
1432 ## | |
1433 | |
1434 auto resynch | |
1435 | |
1436 | |
1437 STATIC#int NEAR#QUAL#AG_ATX { | |
1438 int ag_k, ag_f; | |
1439 int ag_save_btsx = (PCB).btsx; | |
1440 int ag_flag = 1; | |
1441 | |
1442 while (1) { | |
1443 int ag_a; | |
1444 | |
1445 (PCB).bts[AG_PARSER_STACK_SIZE - ++(PCB).btsx] = *ag_sx; | |
1446 (PCB).ss[AG_PARSER_STACK_SIZE - (PCB).btsx] = (PCB).ss[*ag_sx]; | |
1447 (PCB).ss[*ag_sx] = ag_snd; | |
1448 ag_k = ag_sbt[ag_snd]; | |
1449 while (ag_tstt[ag_k] != ag_t && ag_tstt[ag_k]) ag_k++; | |
1450 ag_a = ag_astt[ag_k]; | |
1451 if (ag_a == ag_go_to || | |
1452 ag_a == ag_shift_reduce || | |
1453 ag_a == ag_skip || | |
1454 ag_a == ag_skip_reduce || | |
1455 ag_a == ag_shift_accept || | |
1456 ag_a == ag_shift_simple_reduce) break; | |
1457 if ((ag_a == ag_reduce_form || | |
1458 ag_a == ag_simple_reduce) && | |
1459 (ag_k = ag_fl[ag_f = ag_pstt[ag_k]]) == 0) { | |
1460 ag_snd = ag_rns(PCBARGC#ag_ptt[ag_f],ag_sx, (PCB).ss[*ag_sx]); | |
1461 (*ag_sx)++; | |
1462 continue; | |
1463 } | |
1464 if (ag_a == ag_null_go_to) { | |
1465 ag_snd = ag_pstt[ag_k]; | |
1466 (*ag_sx)++; | |
1467 continue; | |
1468 } | |
1469 ag_flag = 0; | |
1470 break; | |
1471 } | |
1472 while ((PCB).btsx > ag_save_btsx) { | |
1473 *ag_sx = (PCB).bts[AG_PARSER_STACK_SIZE - (PCB).btsx]; | |
1474 (PCB).ss[*ag_sx] = (PCB).ss[AG_PARSER_STACK_SIZE - (PCB).btsx--]; | |
1475 } | |
1476 return ag_flag; | |
1477 } | |
1478 | |
1479 | |
1480 STATIC#int NEAR#QUAL#ag_tst_tkn(THISARG) { | |
1481 int ag_rk, ag_sx, ag_snd = (PCB).sn; | |
1482 | |
1483 AG_GET_TKN | |
1484 for (ag_rk = 0; ag_rk < (PCB).ag_lrss; ag_rk += 2) { | |
1485 ag_sx = (PCB).ag_rss[ag_rk]; | |
1486 if (ag_sx > (PCB).ssx || ag_sx > (PCB).ag_min_depth) continue; | |
1487 (PCB).sn = (PCB).ag_rss[ag_rk + 1]; | |
1488 if (ag_atx(PCBARGC#(PCB).token_number, &ag_sx, (PCB).sn)) break; | |
1489 } | |
1490 (PCB).sn = ag_snd; | |
1491 return ag_rk; | |
1492 } | |
1493 | |
1494 STATIC#VOID NEAR#QUAL#ag_set_error_procs(THISARG); | |
1495 | |
1496 STATIC#VOID NEAR#QUAL#ag_auto_resynch(THISARG) { | |
1497 int ag_sx, ag_rk; | |
1498 int ag_rk1, ag_rk2, ag_tk1; | |
1499 MY_DELETE_WRAPPERS | |
1500 (PCB).ss[(PCB).ssx] = (PCB).sn; | |
1501 if ((PCB).ag_error_depth && (PCB).ag_min_depth >= (PCB).ag_error_depth) { | |
1502 (PCB).ssx = (PCB).ag_error_depth; | |
1503 (PCB).sn = (PCB).ss[(PCB).ssx]; | |
1504 } | |
1505 else { | |
1506 AG_DIAGNOSE | |
1507 SYNTAX_ERROR; | |
1508 if ((PCB).exit_flag != AG_RUNNING_CODE) return; | |
1509 (PCB).ag_error_depth = (PCB).ag_min_depth = 0; | |
1510 (PCB).ag_lrss = 0; | |
1511 (PCB).ss[ag_sx = (PCB).ssx] = (PCB).sn; | |
1512 (PCB).ag_min_depth = (PCB).ag_rss[(PCB).ag_lrss++] = ag_sx; | |
1513 (PCB).ag_rss[(PCB).ag_lrss++] = (PCB).sn; | |
1514 while (ag_sx && (PCB).ag_lrss < 2*AG_PARSER_STACK_SIZE) { | |
1515 int ag_t = 0, ag_x, ag_s, ag_sxs = ag_sx; | |
1516 | |
1517 while (ag_sx && (ag_t = ag_ctn[2*(PCB).sn]) == 0) (PCB).sn = (PCB).ss[--ag_sx]; | |
1518 if (ag_t) (PCB).sn = (PCB).ss[ag_sx -= ag_ctn[2*(PCB).sn +1]]; | |
1519 else { | |
1520 if (ag_sx == 0) (PCB).sn = 0; | |
1521 ag_t = ag_ptt[0]; | |
1522 } | |
1523 if ((ag_s = ag_rns(PCBARGC#ag_t, &ag_sx, (PCB).sn)) == 0) break; | |
1524 for (ag_x = 0; ag_x < (PCB).ag_lrss; ag_x += 2) | |
1525 if ((PCB).ag_rss[ag_x] == ag_sx + 1 && (PCB).ag_rss[ag_x+1] == ag_s) break; | |
1526 if (ag_x == (PCB).ag_lrss) { | |
1527 (PCB).ag_rss[(PCB).ag_lrss++] = ++ag_sx; | |
1528 (PCB).ag_rss[(PCB).ag_lrss++] = (PCB).sn = ag_s; | |
1529 } | |
1530 else if (ag_sx >= ag_sxs) ag_sx--; | |
1531 } | |
1532 ag_set_error_procs(PCBARG); | |
1533 } | |
1534 AG_RST_PTR | |
1535 if ((PCB).ssx > (PCB).ag_min_depth) (PCB).ag_min_depth = (PCB).ssx; | |
1536 while (1) { | |
1537 ag_rk1 = ag_tst_tkn(PCBARG); | |
1538 if ((PCB).token_number == AG_EOF) | |
1539 {(PCB).exit_flag = AG_SYNTAX_ERROR_CODE; return;} | |
1540 if (ag_rk1 < (PCB).ag_lrss) break; | |
1541 AG_INC_PTR | |
1542 } | |
1543 ag_tk1 = (PCB).token_number; | |
1544 AG_TRK_PTR | |
1545 ag_rk2 = ag_tst_tkn(PCBARG); | |
1546 if (ag_rk2 < ag_rk1) {ag_rk = ag_rk2; AG_TRK_PTR} | |
1547 else {ag_rk = ag_rk1; (PCB).token_number = (AG_TOKEN_TYPE) ag_tk1; AG_RST_PTR} | |
1548 (PCB).ag_min_depth = (PCB).ssx = (PCB).ag_rss[ag_rk++]; | |
1549 (PCB).sn = (PCB).ss[(PCB).ssx] = (PCB).ag_rss[ag_rk]; | |
1550 (PCB).sn = ag_jns(PCBARGC#(PCB).token_number); | |
1551 if ((PCB).ag_error_depth == 0 || (PCB).ag_error_depth > (PCB).ssx) | |
1552 (PCB).ag_error_depth = (PCB).ssx; | |
1553 if (++(PCB).ssx >= AG_PARSER_STACK_SIZE) { | |
1554 AG_OVERFLOW | |
1555 return; | |
1556 } | |
1557 AG_STACK | |
1558 (PCB).ag_tmp_depth = (PCB).ag_min_depth; | |
1559 AG_RST_PTR | |
1560 return; | |
1561 } | |
1562 | |
1563 ## | |
1564 | |
1565 error parse procs | |
1566 | |
1567 STATIC#VOID NEAR#QUAL#AG_CHECK_DEPTH { | |
1568 int ag_sx = (PCB).ssx - ag_fl; | |
1569 if ((PCB).ag_error_depth && ag_sx < (PCB).ag_tmp_depth) (PCB).ag_tmp_depth = ag_sx; | |
1570 } | |
1571 | |
1572 STATIC#int NEAR#QUAL#ag_r_simple_shift_reduce_error_proc(THISARG) { | |
1573 ag_check_depth(PCBARGC#ag_fl[(PCB).ag_ap] - 1); | |
1574 return ag_r_simple_shift_reduce_proc(PCBARG); | |
1575 } | |
1576 | |
1577 STATIC#int NEAR#QUAL#ag_go_to_error_proc(THISARG) { | |
1578 ag_go_to_proc(PCBARG); | |
1579 (PCB).ag_min_depth = (PCB).ag_tmp_depth; | |
1580 return 0; | |
1581 } | |
1582 | |
1583 STATIC#int NEAR#QUAL#ag_simple_shift_reduce_error_proc(THISARG) { | |
1584 ag_check_depth(PCBARGC#ag_fl[(PCB).ag_ap] - 1); | |
1585 (PCB).ag_min_depth = (PCB).ag_tmp_depth; | |
1586 return ag_simple_shift_reduce_proc(PCBARG); | |
1587 } | |
1588 | |
1589 STATIC#int NEAR#QUAL#ag_simple_reduce_error_proc(THISARG) { | |
1590 ag_check_depth(PCBARGC#ag_fl[(PCB).ag_ap]); | |
1591 return ag_simple_reduce_proc(PCBARG); | |
1592 } | |
1593 | |
1594 STATIC#int NEAR#QUAL#ag_skip_reduce_error_proc(THISARG) { | |
1595 return ag_skip_proc(PCBARG); | |
1596 } | |
1597 | |
1598 STATIC#int (NEAR#*QUAL#ag_r_procs_error[])(THISARG) = { | |
1599 ag_r_shift_accept_proc, | |
1600 ag_r_go_to_proc, | |
1601 ag_r_simple_shift_reduce_error_proc, | |
1602 ag_r_simple_shift_reduce_error_proc | |
1603 }; | |
1604 | |
1605 STATIC#int (NEAR#*QUAL#ag_s_procs_error[])(THISARG) = { | |
1606 ag_s_shift_accept_proc, | |
1607 ag_r_go_to_proc, | |
1608 ag_r_simple_shift_reduce_error_proc, | |
1609 ag_r_simple_shift_reduce_error_proc | |
1610 }; | |
1611 | |
1612 STATIC#int (NEAR#*QUAL#ag_gt_procs_error[])(THISARG) = { | |
1613 ag_shift_accept_proc, | |
1614 ag_go_to_error_proc, | |
1615 ag_simple_shift_reduce_error_proc, | |
1616 ag_simple_shift_reduce_error_proc, | |
1617 ag_simple_reduce_error_proc, | |
1618 ag_simple_reduce_error_proc, | |
1619 ag_accept_proc, | |
1620 ag_error_proc, | |
1621 ag_null_go_to_proc, | |
1622 ag_skip_proc, | |
1623 ag_skip_reduce_error_proc, | |
1624 AG_RECOVER | |
1625 }; | |
1626 | |
1627 STATIC#VOID NEAR#QUAL#ag_set_error_procs(THISARG) { | |
1628 (PCB).gt_procs = ag_gt_procs_error; | |
1629 (PCB).r_procs = ag_r_procs_error; | |
1630 (PCB).s_procs = ag_s_procs_error; | |
1631 } | |
1632 | |
1633 ## | |
1634 | |
1635 diagnose context | |
1636 | |
1637 { | |
1638 int ag_sx, ag_t; | |
1639 | |
1640 ag_sx = (PCB).ssx; | |
1641 (PCB).ss[ag_sx] = (PCB).sn; | |
1642 do { | |
1643 while (ag_sx && ag_ctn[2*(ag_snd = (PCB).ss[ag_sx])] == 0) ag_sx--; | |
1644 if (ag_sx) { | |
1645 ag_t = ag_ctn[2*ag_snd]; | |
1646 ag_sx -= ag_ctn[2*ag_snd +1]; | |
1647 ag_snd = (PCB).ss[ag_sx]; | |
1648 } | |
1649 else { | |
1650 ag_snd = 0; | |
1651 ag_t = ag_ptt[0]; | |
1652 } | |
1653 } while (ag_sx && *TOKEN_NAMES[ag_t]==0); | |
1654 if (*TOKEN_NAMES[ag_t] == 0) ag_t = 0; | |
1655 (PCB).error_frame_ssx = ag_sx; | |
1656 (PCB).error_frame_token = (AG_TOKEN_TYPE) ag_t; | |
1657 } | |
1658 | |
1659 ## | |
1660 | |
1661 diagnose defs | |
1662 | |
1663 #ifndef MISSING_FORMAT | |
1664 #define MISSING_FORMAT "Missing %s" | |
1665 #endif | |
1666 #ifndef UNEXPECTED_FORMAT | |
1667 #define UNEXPECTED_FORMAT "Unexpected %s" | |
1668 #endif | |
1669 #ifndef UNNAMED_TOKEN | |
1670 #define UNNAMED_TOKEN "input" | |
1671 #endif | |
1672 | |
1673 ## | |
1674 | |
1675 diagnose char | |
1676 | |
1677 STATIC#VOID NEAR#QUAL#ag_diagnose(THISARG) { | |
1678 int ag_snd = (PCB).sn; | |
1679 int ag_k = ag_sbt[ag_snd]; | |
1680 | |
1681 if (*TOKEN_NAMES[ag_tstt[ag_k]] && ag_astt[ag_k + 1] == ag_syn_error) { | |
1682 sprintf((PCB).ag_msg, MISSING_FORMAT, TOKEN_NAMES[ag_tstt[ag_k]]); | |
1683 } | |
1684 else if (ag_astt[ag_sbe[(PCB).sn]] == ag_action_8 | |
1685 && (ag_k = (int) ag_sbe[(PCB).sn] + 1) == (int) ag_sbt[(PCB).sn+1] - 1 | |
1686 && *TOKEN_NAMES[ag_tstt[ag_k]]) { | |
1687 sprintf((PCB).ag_msg, MISSING_FORMAT, TOKEN_NAMES[ag_tstt[ag_k]]); | |
1688 } | |
1689 else if ((PCB).token_number && *TOKEN_NAMES[(PCB).token_number]) { | |
1690 sprintf((PCB).ag_msg, UNEXPECTED_FORMAT, TOKEN_NAMES[(PCB).token_number]); | |
1691 } | |
1692 else if (isprint(AG_INPUT_CODE) && AG_INPUT_CODE != '\\') { | |
1693 char buf[20]; | |
1694 sprintf(buf, "\'%c\'", (char) AG_INPUT_CODE); | |
1695 sprintf((PCB).ag_msg, UNEXPECTED_FORMAT, buf); | |
1696 } | |
1697 else sprintf((PCB).ag_msg, UNEXPECTED_FORMAT, UNNAMED_TOKEN); | |
1698 (PCB).error_message = (PCB).ag_msg; | |
1699 | |
1700 ## | |
1701 | |
1702 diagnose token | |
1703 | |
1704 STATIC#VOID NEAR#QUAL#ag_diagnose(THISARG) { | |
1705 int ag_snd = (PCB).sn; | |
1706 CONST char *ag_p; | |
1707 int ag_k = ag_sbt[ag_snd]; | |
1708 | |
1709 if (*(ag_p = TOKEN_NAMES[ag_tstt[ag_k++]]) != 0 && | |
1710 ag_astt[ag_k] == ag_syn_error) { | |
1711 sprintf((PCB).ag_msg, MISSING_FORMAT, ag_p); | |
1712 } | |
1713 else if ((ag_k = (int) ag_sbe[(PCB).sn] + 1) == (int) ag_sbt[(PCB).sn+1] - 1 | |
1714 && *TOKEN_NAMES[ag_tstt[ag_k]]) { | |
1715 sprintf((PCB).ag_msg, MISSING_FORMAT, TOKEN_NAMES[ag_tstt[ag_k]]); | |
1716 } | |
1717 else { | |
1718 ag_p = TOKEN_NAMES[(PCB).token_number]; | |
1719 if ((PCB).token_number == 0 || *ag_p == 0) ag_p = UNNAMED_TOKEN; | |
1720 sprintf((PCB).ag_msg, UNEXPECTED_FORMAT, ag_p); | |
1721 | |
1722 } | |
1723 (PCB).error_message = (PCB).ag_msg; | |
1724 | |
1725 ## | |
1726 | |
1727 reduce loop | |
1728 | |
1729 ## | |
1730 | |
1731 reduce macros | |
1732 | |
1733 AG_REDUCE \ | |
1734 AG_COUNT_RULE_P\ | |
1735 (PCB).reduction_token = (AG_TOKEN_TYPE) ag_ptt[(PCB).ag_ap];\ | |
1736 ag_ra(PCBARG); | |
1737 | |
1738 AG_SIMPLE_REDUCE \ | |
1739 AG_COUNT_RULE_P\ | |
1740 (PCB).reduction_token = (AG_TOKEN_TYPE) ag_ptt[(PCB).ag_ap]; | |
1741 | |
1742 AG_NSR_SR while ((PCB).exit_flag == AG_RUNNING_CODE) {\ | |
1743 unsigned ag_t1 = ag_sbe[(PCB).sn] + 1;\ | |
1744 unsigned ag_t2 = ag_sbt[(PCB).sn+1] - 1;\ | |
1745 do {\ | |
1746 unsigned ag_tx = (ag_t1 + ag_t2)/2;\ | |
1747 if (ag_tstt[ag_tx] < (AG_TSTT_CAST)(PCB).reduction_token) ag_t1 = ag_tx + 1;\ | |
1748 else ag_t2 = ag_tx;\ | |
1749 } while (ag_t1 < ag_t2);\ | |
1750 (PCB).ag_ap = ag_pstt[ag_t1];\ | |
1751 if ((AG_SR[ag_astt[ag_t1]])(PCBARG) == 0) break;\ | |
1752 } | |
1753 | |
1754 AG_NSR_RD while ((PCB).exit_flag == AG_RUNNING_CODE) {\ | |
1755 unsigned ag_t1 = ag_sbe[(PCB).sn] + 1;\ | |
1756 unsigned ag_t2 = ag_sbt[(PCB).sn+1] - 1;\ | |
1757 do {\ | |
1758 unsigned ag_tx = (ag_t1 + ag_t2)/2;\ | |
1759 if (ag_tstt[ag_tx] < (AG_TSTT_CAST)(PCB).reduction_token) ag_t1 = ag_tx + 1;\ | |
1760 else ag_t2 = ag_tx;\ | |
1761 } while (ag_t1 < ag_t2);\ | |
1762 (PCB).ag_ap = ag_pstt[ag_t1];\ | |
1763 if ((AG_RD[ag_astt[ag_t1]])(PCBARG) == 0) break;\ | |
1764 } | |
1765 | |
1766 ## | |
1767 | |
1768 reduce loop vars | |
1769 | |
1770 CONST int *ag_dtl; | |
1771 int ag_dsn; | |
1772 | |
1773 ## | |
1774 | |
1775 reduce loop checking | |
1776 | |
1777 STATIC#AG_TSTT_TYPE LOCUS *QUAL#AG_VALID { | |
1778 AG_TSTT_TYPE LOCUS *ag_tp = &ag_tstt[ag_sbt[(PCB).sn+1]]; | |
1779 while (*--ag_tp != (AG_TSTT_CAST) ag_k) if (*ag_tp == 0) return NULL; | |
1780 return ag_tp; | |
1781 } | |
1782 | |
1783 int AG_CHANGE_REDUCTION { | |
1784 if (!ag_valid(PCBARGC#ag_k)) return 0; | |
1785 (PCB).reduction_token = ag_k; | |
1786 return 1; | |
1787 } | |
1788 | |
1789 STATIC#VOID NEAR#QUAL#AG_DEFAULT { | |
1790 (PCB).ag_dsn = (PCB).sn; | |
1791 (PCB).ag_dtl = ag_tp; | |
1792 while (!ag_valid(PCBARGC#(AG_TOKEN_TYPE) *ag_tp)) ag_tp++; | |
1793 (PCB).reduction_token = (AG_TOKEN_TYPE) *ag_tp; | |
1794 } | |
1795 | |
1796 ## | |
1797 | |
1798 reduce macros checking | |
1799 | |
1800 AG_REDUCE \ | |
1801 AG_COUNT_RULE_P\ | |
1802 (PCB).reduction_token = (AG_TOKEN_TYPE) ag_ptt[(PCB).ag_ap];\ | |
1803 ag_ra(PCBARG); | |
1804 | |
1805 AG_SIMPLE_REDUCE \ | |
1806 AG_COUNT_RULE_P\ | |
1807 (PCB).reduction_token = (AG_TOKEN_TYPE) ag_ptt[(PCB).ag_ap]; | |
1808 | |
1809 AG_NSR_SR while ((PCB).exit_flag == AG_RUNNING_CODE) {\ | |
1810 unsigned ag_t1 = ag_sbe[(PCB).sn] + 1;\ | |
1811 unsigned ag_t2 = ag_sbt[(PCB).sn+1] - 1;\ | |
1812 do {\ | |
1813 unsigned ag_tx = (ag_t1 + ag_t2)/2;\ | |
1814 if (ag_tstt[ag_tx] < (AG_TSTT_CAST)(PCB).reduction_token) ag_t1 = ag_tx + 1;\ | |
1815 else ag_t2 = ag_tx;\ | |
1816 } while (ag_t1 < ag_t2);\ | |
1817 if (ag_tstt[ag_t1] != (PCB).reduction_token) {\ | |
1818 (PCB).exit_flag = AG_REDUCTION_ERROR_CODE; AG_TRACE_ERROR\ | |
1819 REDUCTION_TOKEN_ERROR; break;}\ | |
1820 (PCB).ag_ap = ag_pstt[ag_t1];\ | |
1821 if ((AG_SR[ag_astt[ag_t1]])(PCBARG) == 0) break;\ | |
1822 } | |
1823 | |
1824 AG_NSR_RD while ((PCB).exit_flag == AG_RUNNING_CODE) {\ | |
1825 unsigned ag_t1 = ag_sbe[(PCB).sn] + 1;\ | |
1826 unsigned ag_t2 = ag_sbt[(PCB).sn+1] - 1;\ | |
1827 do {\ | |
1828 unsigned ag_tx = (ag_t1 + ag_t2)/2;\ | |
1829 if (ag_tstt[ag_tx] < (AG_TSTT_CAST)(PCB).reduction_token) ag_t1 = ag_tx + 1;\ | |
1830 else ag_t2 = ag_tx;\ | |
1831 } while (ag_t1 < ag_t2);\ | |
1832 if (ag_tstt[ag_t1] != (PCB).reduction_token) {\ | |
1833 (PCB).exit_flag = AG_REDUCTION_ERROR_CODE; AG_TRACE_ERROR\ | |
1834 REDUCTION_TOKEN_ERROR; break;}\ | |
1835 (PCB).ag_ap = ag_pstt[ag_t1];\ | |
1836 if ((AG_RD[ag_astt[ag_t1]])(PCBARG) == 0) break;\ | |
1837 } | |
1838 | |
1839 ## | |
1840 | |
1841 reduction choices | |
1842 | |
1843 int AG_CHOICES { | |
1844 int ag_k, ag_n; | |
1845 if ((PCB).ag_dsn != (PCB).sn) { | |
1846 *ag_tp = ag_ptt[(PCB).ag_ap]; | |
1847 return 1; | |
1848 } | |
1849 for (ag_k = ag_n = 0; (PCB).ag_dtl[ag_k]; ag_k++) { | |
1850 if (!ag_valid(PCBARGC#(AG_TOKEN_TYPE) (PCB).ag_dtl[ag_k])) continue; | |
1851 ag_tp[ag_n++] = (PCB).ag_dtl[ag_k]; | |
1852 } | |
1853 return ag_n; | |
1854 } | |
1855 | |
1856 ## | |
1857 | |
1858 parse procs | |
1859 | |
1860 STATIC#int NEAR#QUAL#ag_skip_proc(THISARG) { | |
1861 int ag_t = (PCB).token_number; | |
1862 AG_COUNT_RULE_P | |
1863 AG_CLEAR_BACK | |
1864 do { | |
1865 AG_COUNT_RULE_P | |
1866 AG_TRK_PTR | |
1867 AG_GET_TKN | |
1868 } while ((PCB).token_number == (AG_TOKEN_TYPE) ag_t); | |
1869 AG_RST_PTR | |
1870 return 1; | |
1871 } | |
1872 | |
1873 STATIC#int NEAR#QUAL#ag_skip_reduce_proc(THISARG) { | |
1874 int ag_t = (PCB).token_number; | |
1875 | |
1876 AG_COUNT_RULE_P | |
1877 AG_CLEAR_BACK | |
1878 do { | |
1879 AG_GET_VALUE | |
1880 (PCB).ssx--; | |
1881 AG_TRK_PTR | |
1882 ag_ra(PCBARG); | |
1883 if ((PCB).exit_flag != AG_RUNNING_CODE) return 0; | |
1884 (PCB).ssx++; | |
1885 AG_GET_TKN | |
1886 } | |
1887 while ((PCB).token_number == (AG_TOKEN_TYPE) ag_t); | |
1888 AG_RST_PTR | |
1889 return 1; | |
1890 } | |
1891 | |
1892 STATIC#int NEAR#QUAL#ag_r_shift_reduce_proc(THISARG) { | |
1893 int ag_sd = ag_fl[(PCB).ag_ap] - 1; | |
1894 if (ag_sd) (PCB).sn = (PCB).ss[(PCB).ssx -= ag_sd]; | |
1895 AG_CLEAR_BACK | |
1896 AG_REDUCE | |
1897 return (PCB).exit_flag == AG_RUNNING_CODE; | |
1898 } | |
1899 | |
1900 STATIC#int NEAR#QUAL#ag_s_shift_reduce_proc(THISARG) { | |
1901 int ag_sd = ag_fl[(PCB).ag_ap] - 1; | |
1902 if (ag_sd) (PCB).sn = (PCB).ss[(PCB).ssx -= ag_sd]; | |
1903 AG_CLEAR_BACK | |
1904 AG_REDUCE | |
1905 return (PCB).exit_flag == AG_RUNNING_CODE; | |
1906 } | |
1907 | |
1908 STATIC#int NEAR#QUAL#ag_r_simple_shift_reduce_proc(THISARG) { | |
1909 int ag_sd = ag_fl[(PCB).ag_ap] - 1; | |
1910 if (ag_sd) (PCB).sn = (PCB).ss[(PCB).ssx -= ag_sd]; | |
1911 AG_SIMPLE_REDUCE | |
1912 return 1; | |
1913 } | |
1914 | |
1915 STATIC#int NEAR#QUAL#ag_go_to_proc(THISARG) { | |
1916 AG_CLEAR_BACK | |
1917 AG_CHKOVFLO | |
1918 AG_GET_VALUE | |
1919 AG_STACK | |
1920 (PCB).ssx++; | |
1921 (PCB).sn = (PCB).ag_ap; | |
1922 AG_TRK_PTR | |
1923 return 0; | |
1924 } | |
1925 | |
1926 STATIC#int NEAR#QUAL#ag_null_go_to_proc(THISARG) { | |
1927 AG_SET_BACK | |
1928 AG_PROTX | |
1929 AG_NULL | |
1930 AG_STACK | |
1931 (PCB).ssx++; | |
1932 (PCB).sn = (PCB).ag_ap; | |
1933 AG_RST_PTR | |
1934 return (PCB).exit_flag == AG_RUNNING_CODE; | |
1935 } | |
1936 | |
1937 STATIC#int NEAR#QUAL#ag_r_go_to_proc(THISARG) { | |
1938 (PCB).ssx++; | |
1939 (PCB).sn = (PCB).ag_ap; | |
1940 return 0; | |
1941 } | |
1942 | |
1943 STATIC#int NEAR#QUAL#ag_accept_proc(THISARG) { | |
1944 --(PCB).ssx; | |
1945 AG_RST_PTR | |
1946 AG_COUNT_RULE_Z | |
1947 (PCB).exit_flag = AG_SUCCESS_CODE; | |
1948 return 0; | |
1949 } | |
1950 | |
1951 STATIC#int NEAR#QUAL#ag_shift_accept_proc(THISARG) { | |
1952 AG_TRK_PTR | |
1953 AG_COUNT_RULE_Z | |
1954 (PCB).exit_flag = AG_SUCCESS_CODE; | |
1955 return 0; | |
1956 } | |
1957 | |
1958 STATIC#int NEAR#QUAL#ag_r_shift_accept_proc(THISARG) { | |
1959 AG_COUNT_RULE_Z | |
1960 (PCB).exit_flag = AG_SUCCESS_CODE; | |
1961 return 0; | |
1962 } | |
1963 | |
1964 STATIC#int NEAR#QUAL#ag_s_shift_accept_proc(THISARG) { | |
1965 AG_COUNT_RULE_Z | |
1966 (PCB).exit_flag = AG_SUCCESS_CODE; | |
1967 return 0; | |
1968 } | |
1969 | |
1970 STATIC#int NEAR#QUAL#ag_simple_shift_reduce_proc(THISARG) { | |
1971 int ag_sd = ag_fl[(PCB).ag_ap] - 1; | |
1972 AG_SIMPLE_REDUCE | |
1973 AG_CLEAR_BACK | |
1974 AG_GET_VALUE | |
1975 if (ag_sd) (PCB).sn = (PCB).ss[(PCB).ssx -= ag_sd]; | |
1976 else AG_STACK | |
1977 AG_TRK_PTR | |
1978 AG_NSR_SR | |
1979 return 0; | |
1980 } | |
1981 | |
1982 STATIC#int NEAR#QUAL#ag_shift_reduce_proc(THISARG) { | |
1983 int ag_sd = ag_fl[(PCB).ag_ap] - 1; | |
1984 AG_CLEAR_BACK | |
1985 AG_GET_VALUE | |
1986 if (ag_sd) (PCB).sn = (PCB).ss[(PCB).ssx -= ag_sd]; | |
1987 else AG_STACK | |
1988 AG_TRK_PTR | |
1989 AG_REDUCE | |
1990 AG_NSR_SR | |
1991 return 0; | |
1992 } | |
1993 | |
1994 STATIC#int NEAR#QUAL#ag_error_proc(THISARG) { | |
1995 AG_UNDO | |
1996 AG_TRACE_ERROR | |
1997 AG_RST_PTR | |
1998 AG_RESYNCH | |
1999 return (PCB).exit_flag == AG_RUNNING_CODE; | |
2000 } | |
2001 | |
2002 STATIC#int NEAR#QUAL#ag_reduce_proc(THISARG) { | |
2003 int ag_sd = ag_fl[(PCB).ag_ap]; | |
2004 AG_CLEAR_BACK | |
2005 if (ag_sd) (PCB).sn = (PCB).ss[(PCB).ssx -= ag_sd]; | |
2006 else { | |
2007 AG_STACK | |
2008 } | |
2009 AG_RST_PTR | |
2010 AG_REDUCE | |
2011 AG_NSR_RD | |
2012 return (PCB).exit_flag == AG_RUNNING_CODE; | |
2013 } | |
2014 | |
2015 STATIC#int NEAR#QUAL#ag_simple_reduce_proc(THISARG) { | |
2016 int ag_sd = ag_fl[(PCB).ag_ap]; | |
2017 AG_SIMPLE_REDUCE | |
2018 AG_SET_BACK | |
2019 if (ag_sd) { | |
2020 (PCB).sn = (PCB).ss[(PCB).ssx -= ag_sd]; | |
2021 } | |
2022 else { | |
2023 AG_PROTX | |
2024 AG_NULL | |
2025 AG_STACK | |
2026 } | |
2027 AG_RST_PTR | |
2028 AG_NSR_RD | |
2029 return (PCB).exit_flag == AG_RUNNING_CODE; | |
2030 } | |
2031 | |
2032 ## | |
2033 | |
2034 error token parse procs | |
2035 | |
2036 STATIC#int NEAR#QUAL#ag_er_go_to_proc(THISARG) { | |
2037 AG_CLEAR_BACK | |
2038 AG_GET_VALUE | |
2039 (PCB).ssx++; | |
2040 (PCB).sn = (PCB).ag_ap; | |
2041 return 0; | |
2042 } | |
2043 | |
2044 STATIC#int NEAR#QUAL#ag_er_shift_accept_proc(THISARG) { | |
2045 AG_CLEAR_BACK | |
2046 AG_COUNT_RULE_Z | |
2047 (PCB).exit_flag = AG_SUCCESS_CODE; | |
2048 return 0; | |
2049 } | |
2050 | |
2051 STATIC#int NEAR#QUAL#ag_er_simple_shift_reduce_proc(THISARG) { | |
2052 int ag_sd = ag_fl[(PCB).ag_ap] - 1; | |
2053 AG_CLEAR_BACK | |
2054 AG_SIMPLE_REDUCE | |
2055 if (ag_sd) (PCB).sn = (PCB).ss[(PCB).ssx -= ag_sd]; | |
2056 else (PCB).ss[(PCB).ssx] = (PCB).sn; | |
2057 AG_NSR_SR | |
2058 return 0; | |
2059 } | |
2060 | |
2061 STATIC#int NEAR#QUAL#ag_er_shift_reduce_proc(THISARG) { | |
2062 int ag_sd = ag_fl[(PCB).ag_ap] - 1; | |
2063 AG_CLEAR_BACK | |
2064 if (ag_sd) (PCB).sn = (PCB).ss[(PCB).ssx -= ag_sd]; | |
2065 else (PCB).ss[(PCB).ssx] = (PCB).sn; | |
2066 AG_REDUCE | |
2067 AG_NSR_SR | |
2068 return 0; | |
2069 } | |
2070 | |
2071 ## | |
2072 | |
2073 parse engine | |
2074 | |
2075 AG_INIT_PARSE { | |
2076 AG_INIT_PTR | |
2077 AG_INIT_ERROR_MESSAGE | |
2078 AG_INIT_RESYNCH | |
2079 (PCB).ss[0] = (PCB).sn = (PCB).ssx = 0; | |
2080 (PCB).exit_flag = AG_RUNNING_CODE; | |
2081 AG_INIT_TRK | |
2082 AG_CLEAR_BACK | |
2083 } | |
2084 | |
2085 AG_PARSE { | |
2086 AG_INITIALIZE; | |
2087 (PCB).exit_flag = AG_RUNNING_CODE; | |
2088 while ((PCB).exit_flag == AG_RUNNING_CODE) { | |
2089 unsigned ag_t1 = ag_sbt[(PCB).sn]; | |
2090 if (ag_tstt[ag_t1]) { | |
2091 unsigned ag_t2 = ag_sbe[(PCB).sn] - 1; | |
2092 AG_GET_TKN | |
2093 do { | |
2094 unsigned ag_tx = (ag_t1 + ag_t2)/2; | |
2095 if (ag_tstt[ag_tx] > (AG_TSTT_CAST)(PCB).token_number) | |
2096 ag_t1 = ag_tx + 1; | |
2097 else ag_t2 = ag_tx; | |
2098 } while (ag_t1 < ag_t2); | |
2099 if (ag_tstt[ag_t1] != (AG_TSTT_CAST)(PCB).token_number) | |
2100 ag_t1 = ag_sbe[(PCB).sn]; | |
2101 } | |
2102 (PCB).ag_ap = ag_pstt[ag_t1]; | |
2103 (AG_GT[ag_astt[ag_t1]])(PCB_TYPE_CAST#PCBARG); | |
2104 } | |
2105 } | |
2106 | |
2107 ## | |
2108 | |
2109 reduce proc defs | |
2110 | |
2111 STATIC#int NEAR#ag_r_shift_accept_proc(THISARG); | |
2112 STATIC#int NEAR#ag_r_go_to_proc(THISARG); | |
2113 STATIC#int NEAR#ag_r_shift_reduce_proc(THISARG); | |
2114 STATIC#int NEAR#ag_r_simple_shift_reduce_proc(THISARG); | |
2115 STATIC#int NEAR#ag_s_shift_accept_proc(THISARG); | |
2116 STATIC#int NEAR#ag_s_shift_reduce_proc(THISARG); | |
2117 STATIC#int NEAR#ag_shift_accept_proc(THISARG); | |
2118 STATIC#int NEAR#ag_go_to_proc(THISARG); | |
2119 STATIC#int NEAR#ag_shift_reduce_proc(THISARG); | |
2120 STATIC#int NEAR#ag_simple_shift_reduce_proc(THISARG); | |
2121 STATIC#int NEAR#ag_reduce_proc(THISARG); | |
2122 STATIC#int NEAR#ag_simple_reduce_proc(THISARG); | |
2123 STATIC#int NEAR#ag_accept_proc(THISARG); | |
2124 STATIC#int NEAR#ag_error_proc(THISARG); | |
2125 STATIC#int NEAR#ag_null_go_to_proc(THISARG); | |
2126 STATIC#int NEAR#ag_skip_proc(THISARG); | |
2127 STATIC#int NEAR#ag_skip_reduce_proc(THISARG); | |
2128 STATIC#int NEAR#AG_RECOVER(THISARG); | |
2129 | |
2130 | |
2131 STATIC#int (NEAR#*CONST QUAL#ag_r_procs_scan[])(THISARG) = { | |
2132 ag_r_shift_accept_proc, | |
2133 ag_r_go_to_proc, | |
2134 ag_r_shift_reduce_proc, | |
2135 ag_r_simple_shift_reduce_proc | |
2136 }; | |
2137 | |
2138 STATIC#int (NEAR#*CONST QUAL#ag_s_procs_scan[])(THISARG) = { | |
2139 ag_s_shift_accept_proc, | |
2140 ag_r_go_to_proc, | |
2141 ag_s_shift_reduce_proc, | |
2142 ag_r_simple_shift_reduce_proc | |
2143 }; | |
2144 | |
2145 STATIC#int (NEAR#*CONST QUAL#ag_gt_procs_scan[])(THISARG) = { | |
2146 ag_shift_accept_proc, | |
2147 ag_go_to_proc, | |
2148 ag_shift_reduce_proc, | |
2149 ag_simple_shift_reduce_proc, | |
2150 ag_reduce_proc, | |
2151 ag_simple_reduce_proc, | |
2152 ag_accept_proc, | |
2153 ag_error_proc, | |
2154 ag_null_go_to_proc, | |
2155 ag_skip_proc, | |
2156 ag_skip_reduce_proc, | |
2157 AG_RECOVER | |
2158 }; | |
2159 | |
2160 ## | |
2161 | |
2162 reduce proc error defs | |
2163 | |
2164 STATIC#int NEAR#ag_er_shift_accept_proc(THISARG); | |
2165 STATIC#int NEAR#ag_er_go_to_proc(THISARG); | |
2166 STATIC#int NEAR#ag_er_shift_reduce_proc(THISARG); | |
2167 STATIC#int NEAR#ag_er_simple_shift_reduce_proc(THISARG); | |
2168 | |
2169 STATIC#int (NEAR#*CONST QUAL#ag_er_procs_scan[])(THISARG) = { | |
2170 ag_er_shift_accept_proc, | |
2171 ag_er_go_to_proc, | |
2172 ag_er_shift_reduce_proc, | |
2173 ag_er_simple_shift_reduce_proc | |
2174 }; | |
2175 | |
2176 | |
2177 | |
2178 ## | |
2179 | |
2180 chain parse procs | |
2181 | |
2182 STATIC#int NEAR#QUAL#ag_skip_proc(THISARG) { | |
2183 AG_COUNT_RULE_P | |
2184 AG_CLEAR_BACK | |
2185 AG_TRK_PTR | |
2186 return 0; | |
2187 } | |
2188 | |
2189 STATIC#int NEAR#QUAL#ag_skip_reduce_proc(THISARG) { | |
2190 AG_CLEAR_BACK | |
2191 AG_GET_VALUE | |
2192 (PCB).ssx--; | |
2193 AG_COUNT_RULE_P | |
2194 ag_ra(PCBARG); | |
2195 (PCB).ssx++; | |
2196 AG_TRK_PTR | |
2197 return 0; | |
2198 } | |
2199 | |
2200 STATIC#int NEAR#QUAL#ag_r_shift_reduce_proc(THISARG) { | |
2201 int ag_sd = ag_fl[(PCB).ag_ap] - 1; | |
2202 if (ag_sd) (PCB).sn = (PCB).ss[(PCB).ssx -= ag_sd]; | |
2203 AG_CLEAR_BACK | |
2204 AG_REDUCE | |
2205 return (PCB).exit_flag == AG_RUNNING_CODE; | |
2206 } | |
2207 | |
2208 STATIC#int NEAR#QUAL#ag_s_shift_reduce_proc(THISARG) { | |
2209 int ag_sd = ag_fl[(PCB).ag_ap] - 1; | |
2210 if (ag_sd) (PCB).sn = (PCB).ss[(PCB).ssx -= ag_sd]; | |
2211 AG_CLEAR_BACK | |
2212 AG_REDUCE | |
2213 return (PCB).exit_flag == AG_RUNNING_CODE; | |
2214 } | |
2215 | |
2216 STATIC#int NEAR#QUAL#ag_r_simple_shift_reduce_proc(THISARG) { | |
2217 int ag_sd = ag_fl[(PCB).ag_ap] - 1; | |
2218 if (ag_sd) (PCB).sn = (PCB).ss[(PCB).ssx -= ag_sd]; | |
2219 AG_SIMPLE_REDUCE | |
2220 return 1; | |
2221 } | |
2222 | |
2223 STATIC#int NEAR#QUAL#ag_go_to_proc(THISARG) { | |
2224 AG_CLEAR_BACK | |
2225 AG_CHKOVFLO | |
2226 AG_GET_VALUE | |
2227 AG_STACK | |
2228 (PCB).ssx++; | |
2229 (PCB).sn = (PCB).ag_ap; | |
2230 AG_TRK_PTR | |
2231 return 0; | |
2232 } | |
2233 | |
2234 STATIC#int NEAR#QUAL#ag_null_go_to_proc(THISARG) { | |
2235 AG_SET_BACK | |
2236 AG_PROTX | |
2237 AG_STACK | |
2238 (PCB).ssx++; | |
2239 (PCB).sn = (PCB).ag_ap; | |
2240 AG_RST_PTR | |
2241 return (PCB).exit_flag == AG_RUNNING_CODE; | |
2242 } | |
2243 | |
2244 STATIC#int NEAR#QUAL#ag_r_go_to_proc(THISARG) { | |
2245 (PCB).ssx++; | |
2246 (PCB).sn = (PCB).ag_ap; | |
2247 return 0; | |
2248 } | |
2249 | |
2250 STATIC#int NEAR#QUAL#ag_accept_proc(THISARG) { | |
2251 --(PCB).ssx; | |
2252 AG_COUNT_RULE_Z | |
2253 (PCB).exit_flag = AG_SUCCESS_CODE; | |
2254 AG_RST_PTR | |
2255 return 0; | |
2256 } | |
2257 | |
2258 STATIC#int NEAR#QUAL#ag_shift_accept_proc(THISARG) { | |
2259 (PCB).exit_flag = AG_SUCCESS_CODE; | |
2260 AG_COUNT_RULE_Z | |
2261 AG_TRK_PTR | |
2262 return 0; | |
2263 } | |
2264 | |
2265 STATIC#int NEAR#QUAL#ag_r_shift_accept_proc(THISARG) { | |
2266 AG_COUNT_RULE_Z | |
2267 (PCB).exit_flag = AG_SUCCESS_CODE; | |
2268 return 0; | |
2269 } | |
2270 | |
2271 STATIC#int NEAR#QUAL#ag_s_shift_accept_proc(THISARG) { | |
2272 AG_COUNT_RULE_Z | |
2273 (PCB).exit_flag = AG_SUCCESS_CODE; | |
2274 return 0; | |
2275 } | |
2276 | |
2277 STATIC#int NEAR#QUAL#ag_simple_shift_reduce_proc(THISARG) { | |
2278 int ag_sd = ag_fl[(PCB).ag_ap] - 1; | |
2279 AG_SIMPLE_REDUCE | |
2280 AG_CLEAR_BACK | |
2281 AG_GET_VALUE | |
2282 if (ag_sd) (PCB).sn = (PCB).ss[(PCB).ssx -= ag_sd]; | |
2283 else AG_STACK | |
2284 AG_TRK_PTR | |
2285 AG_NSR_SR | |
2286 return 0; | |
2287 } | |
2288 | |
2289 STATIC#int NEAR#QUAL#ag_shift_reduce_proc(THISARG) { | |
2290 int ag_sd = ag_fl[(PCB).ag_ap] - 1; | |
2291 AG_CLEAR_BACK | |
2292 AG_GET_VALUE | |
2293 if (ag_sd) (PCB).sn = (PCB).ss[(PCB).ssx -= ag_sd]; | |
2294 else AG_STACK | |
2295 AG_TRK_PTR | |
2296 AG_REDUCE | |
2297 AG_NSR_SR | |
2298 return 0; | |
2299 } | |
2300 | |
2301 STATIC#int NEAR#QUAL#ag_error_proc(THISARG) { | |
2302 AG_UNDO | |
2303 AG_TRACE_ERROR | |
2304 AG_RST_PTR | |
2305 AG_RESYNCH | |
2306 return (PCB).exit_flag == AG_RUNNING_CODE; | |
2307 } | |
2308 | |
2309 STATIC#int NEAR#QUAL#ag_reduce_proc(THISARG) { | |
2310 int ag_sd = ag_fl[(PCB).ag_ap]; | |
2311 AG_CLEAR_BACK | |
2312 if (ag_sd) (PCB).sn = (PCB).ss[(PCB).ssx -= ag_sd]; | |
2313 else { | |
2314 AG_STACK | |
2315 } | |
2316 AG_RST_PTR | |
2317 AG_REDUCE | |
2318 AG_NSR_RD | |
2319 return (PCB).exit_flag == AG_RUNNING_CODE; | |
2320 } | |
2321 | |
2322 STATIC#int NEAR#QUAL#ag_simple_reduce_proc(THISARG) { | |
2323 int ag_sd = ag_fl[(PCB).ag_ap]; | |
2324 AG_SIMPLE_REDUCE | |
2325 AG_SET_BACK | |
2326 if (ag_sd) { | |
2327 (PCB).sn = (PCB).ss[(PCB).ssx -= ag_sd]; | |
2328 } | |
2329 else { | |
2330 AG_PROTX | |
2331 AG_NULL | |
2332 AG_STACK | |
2333 } | |
2334 AG_RST_PTR | |
2335 AG_NSR_RD | |
2336 return (PCB).exit_flag == AG_RUNNING_CODE; | |
2337 } | |
2338 | |
2339 ## | |
2340 | |
2341 chain error token parse procs | |
2342 | |
2343 STATIC#int NEAR#QUAL#ag_er_go_to_proc(THISARG) { | |
2344 AG_CLEAR_BACK | |
2345 AG_GET_VALUE | |
2346 (PCB).ssx++; | |
2347 (PCB).sn = (PCB).ag_ap; | |
2348 return 0; | |
2349 } | |
2350 | |
2351 STATIC#int NEAR#QUAL#ag_er_shift_accept_proc(THISARG) { | |
2352 AG_CLEAR_BACK | |
2353 (PCB).exit_flag = AG_SUCCESS_CODE; | |
2354 AG_COUNT_RULE_Z | |
2355 return 0; | |
2356 } | |
2357 | |
2358 STATIC#int NEAR#QUAL#ag_er_simple_shift_reduce_proc(THISARG) { | |
2359 int ag_sd = ag_fl[(PCB).ag_ap] - 1; | |
2360 AG_CLEAR_BACK | |
2361 AG_SIMPLE_REDUCE | |
2362 if (ag_sd) (PCB).sn = (PCB).ss[(PCB).ssx -= ag_sd]; | |
2363 else (PCB).ss[(PCB).ssx] = (PCB).sn; | |
2364 AG_NSR_SR | |
2365 return 0; | |
2366 } | |
2367 | |
2368 STATIC#int NEAR#QUAL#ag_er_shift_reduce_proc(THISARG) { | |
2369 int ag_sd = ag_fl[(PCB).ag_ap] - 1; | |
2370 AG_CLEAR_BACK | |
2371 if (ag_sd) (PCB).sn = (PCB).ss[(PCB).ssx -= ag_sd]; | |
2372 else (PCB).ss[(PCB).ssx] = (PCB).sn; | |
2373 AG_REDUCE | |
2374 AG_NSR_SR | |
2375 return 0; | |
2376 } | |
2377 | |
2378 ## | |
2379 | |
2380 chain parse engine | |
2381 | |
2382 | |
2383 AG_INIT_PARSE { | |
2384 unsigned ag_t1; | |
2385 ag_t1 = 0; | |
2386 AG_INIT_PTR | |
2387 AG_INIT_ERROR_MESSAGE | |
2388 AG_INIT_RESYNCH | |
2389 (PCB).ss[0] = (PCB).sn = (PCB).ssx = 0; | |
2390 (PCB).exit_flag = AG_RUNNING_CODE; | |
2391 AG_INIT_TRK | |
2392 AG_CLEAR_BACK | |
2393 while (ag_tstt[ag_t1] == 0) { | |
2394 (PCB).ag_ap = ag_pstt[ag_t1]; | |
2395 (AG_GT[ag_astt[ag_t1]])(PCB_TYPE_CAST#PCBARG); | |
2396 ag_t1 = ag_sbt[(PCB).sn]; | |
2397 } | |
2398 } | |
2399 | |
2400 AG_PARSE { | |
2401 (PCB).token_number = (AG_TOKEN_TYPE) AG_TCV((PCB).input_code); | |
2402 while (1) { | |
2403 unsigned ag_t1 = ag_sbt[(PCB).sn]; | |
2404 unsigned ag_t2 = ag_sbe[(PCB).sn] - 1; | |
2405 do { | |
2406 unsigned ag_tx = (ag_t1 + ag_t2)/2; | |
2407 if (ag_tstt[ag_tx] > (AG_TSTT_CAST)(PCB).token_number) | |
2408 ag_t1 = ag_tx + 1; | |
2409 else ag_t2 = ag_tx; | |
2410 } while (ag_t1 < ag_t2); | |
2411 if (ag_tstt[ag_t1] != (AG_TSTT_CAST)(PCB).token_number) | |
2412 ag_t1 = ag_sbe[(PCB).sn]; | |
2413 (PCB).ag_ap = ag_pstt[ag_t1]; | |
2414 if ((AG_GT[ag_astt[ag_t1]])(PCB_TYPE_CAST#PCBARG) == 0) break; | |
2415 } | |
2416 } | |
2417 | |
2418 ## | |
2419 | |
2420 chain key parse engine | |
2421 | |
2422 AG_INIT_PARSE { | |
2423 unsigned ag_t1; | |
2424 ag_t1 = 0; | |
2425 AG_INIT_PTR | |
2426 AG_INIT_ERROR_MESSAGE | |
2427 AG_INIT_RESYNCH | |
2428 (PCB).ss[0] = (PCB).sn = (PCB).ssx = 0; | |
2429 (PCB).exit_flag = AG_RUNNING_CODE; | |
2430 (PCB).key_sp = NULL; | |
2431 (PCB).key_state = 0; | |
2432 AG_INIT_TRK | |
2433 AG_CLEAR_BACK | |
2434 while (ag_tstt[ag_t1] == 0) { | |
2435 (PCB).ag_ap = ag_pstt[ag_t1]; | |
2436 (AG_GT[ag_astt[ag_t1]])(PCB_TYPE_CAST#PCBARG); | |
2437 ag_t1 = ag_sbt[(PCB).sn]; | |
2438 } | |
2439 } | |
2440 | |
2441 AG_PARSE { | |
2442 (PCB).lab[(PCB).fx++] = (PCB).input_code; | |
2443 while ((PCB).exit_flag == AG_RUNNING_CODE) { | |
2444 while (1) { | |
2445 CONST unsigned char *ag_p; | |
2446 int ag_ch; | |
2447 if ((PCB).rx >= (PCB).fx) return; | |
2448 ag_ch = CONVERT_CASE((PCB).lab[(PCB).rx++]); | |
2449 if ((PCB).key_sp) { | |
2450 if (ag_ch != *(PCB).key_sp++) { | |
2451 (PCB).rx = (PCB).save_index; | |
2452 (PCB).key_sp = NULL; | |
2453 (PCB).key_state = 0; | |
2454 break; | |
2455 } else if (*(PCB).key_sp) continue; | |
2456 if (ag_key_act[(PCB).key_state] == ag_cf_end_key) { | |
2457 int ag_k1; | |
2458 int ag_k2; | |
2459 if ((PCB).rx >= (PCB).fx) { | |
2460 (PCB).rx--; | |
2461 (PCB).key_sp--; | |
2462 return; | |
2463 } | |
2464 (PCB).key_sp = NULL; | |
2465 ag_k1 = ag_key_parm[(PCB).key_state]; | |
2466 ag_k2 = ag_key_pt[ag_k1]; | |
2467 if (ag_key_itt[ag_k2 + CONVERT_CASE((PCB).lab[(PCB).rx])]) | |
2468 (PCB).rx = (PCB).save_index; | |
2469 else { | |
2470 (PCB).token_number = (AG_TOKEN_TYPE) ag_key_pt[ag_k1+1]; | |
2471 (PCB).key_state = 0; | |
2472 } | |
2473 break; | |
2474 } | |
2475 else { | |
2476 (PCB).token_number = (AG_TOKEN_TYPE) ag_key_parm[(PCB).key_state]; | |
2477 (PCB).key_state = 0; | |
2478 (PCB).key_sp = NULL; | |
2479 } | |
2480 break; | |
2481 } | |
2482 if ((PCB).key_state == 0) { | |
2483 (PCB).token_number = (AG_TOKEN_TYPE) AG_TCV(ag_ch); | |
2484 if (((PCB).key_state = ag_key_index[(PCB).sn]) == 0) break; | |
2485 (PCB).save_index = 1; | |
2486 } | |
2487 ag_p = &ag_key_ch[(PCB).key_state]; | |
2488 if (ag_ch <= 255) while (*ag_p < ag_ch) ag_p++; | |
2489 if (*ag_p == ag_ch) { | |
2490 (PCB).key_state = (int)(ag_p - ag_key_ch); | |
2491 switch (ag_key_act[(PCB).key_state]) { | |
2492 case ag_cf_set_key: { | |
2493 int ag_k1; | |
2494 int ag_k2; | |
2495 if ((PCB).rx >= (PCB).fx) { | |
2496 (PCB).rx--; | |
2497 return; | |
2498 } | |
2499 ag_k1 = ag_key_parm[(PCB).key_state]; | |
2500 ag_k2 = ag_key_pt[ag_k1]; | |
2501 (PCB).key_state = ag_key_jmp[(PCB).key_state]; | |
2502 if (ag_key_itt[ag_k2 + CONVERT_CASE((PCB).lab[(PCB).rx])]) continue; | |
2503 (PCB).save_index = (PCB).rx; | |
2504 (PCB).token_number = (AG_TOKEN_TYPE) ag_key_pt[ag_k1+1]; | |
2505 continue; | |
2506 } | |
2507 case ag_set_key: | |
2508 (PCB).save_index = (PCB).rx; | |
2509 (PCB).token_number = (AG_TOKEN_TYPE) ag_key_parm[(PCB).key_state]; | |
2510 case ag_jmp_key: | |
2511 (PCB).key_state = ag_key_jmp[(PCB).key_state]; | |
2512 continue; | |
2513 case ag_cf_end_key: | |
2514 case ag_end_key: | |
2515 (PCB).key_sp = ag_key_ends + ag_key_jmp[(PCB).key_state]; | |
2516 continue; | |
2517 case ag_accept_key: | |
2518 (PCB).token_number = (AG_TOKEN_TYPE) ag_key_parm[(PCB).key_state]; | |
2519 (PCB).key_state = 0; | |
2520 break; | |
2521 case ag_cf_accept_key: { | |
2522 int ag_k1; | |
2523 int ag_k2; | |
2524 if ((PCB).rx >= (PCB).fx) { | |
2525 (PCB).rx--; | |
2526 return; | |
2527 } | |
2528 ag_k1 = ag_key_parm[(PCB).key_state]; | |
2529 ag_k2 = ag_key_pt[ag_k1]; | |
2530 if (ag_key_itt[ag_k2 + CONVERT_CASE((PCB).lab[(PCB).rx])]) | |
2531 (PCB).rx = (PCB).save_index; | |
2532 else { | |
2533 (PCB).token_number = (AG_TOKEN_TYPE) ag_key_pt[ag_k1+1]; | |
2534 (PCB).key_state = 0; | |
2535 } | |
2536 break; | |
2537 } | |
2538 } | |
2539 break; | |
2540 } else { | |
2541 (PCB).rx = (PCB).save_index; | |
2542 (PCB).key_state = 0; | |
2543 break; | |
2544 } | |
2545 } | |
2546 | |
2547 { | |
2548 unsigned ag_t1 = ag_sbt[(PCB).sn]; | |
2549 unsigned ag_t2 = ag_sbe[(PCB).sn] - 1; | |
2550 do { | |
2551 unsigned ag_tx = (ag_t1 + ag_t2)/2; | |
2552 if (ag_tstt[ag_tx] > (AG_TSTT_CAST)(PCB).token_number) | |
2553 ag_t1 = ag_tx + 1; | |
2554 else ag_t2 = ag_tx; | |
2555 } while (ag_t1 < ag_t2); | |
2556 if (ag_tstt[ag_t1] != (PCB).token_number) ag_t1 = ag_sbe[(PCB).sn]; | |
2557 (PCB).ag_ap = ag_pstt[ag_t1]; | |
2558 (AG_GT[ag_astt[ag_t1]])(PCB_TYPE_CAST#PCBARG); | |
2559 } | |
2560 } | |
2561 } | |
2562 | |
2563 ## | |
2564 | |
2565 | |
2566 c plus plus definitions | |
2567 | |
2568 STATIC#int NEAR#QUAL#ag_accept_proc(THISARG); | |
2569 STATIC#int NEAR#QUAL#AG_ATX; | |
2570 STATIC#VOID NEAR#QUAL#ag_auto_resynch(THISARG); | |
2571 STATIC#VOID NEAR#QUAL#AG_CHECK_DEPTH; | |
2572 STATIC#VOID NEAR#QUAL#AG_DEFAULT; | |
2573 STATIC#VOID NEAR#QUAL#ag_diagnose(THISARG); | |
2574 STATIC#int NEAR#QUAL#ag_error_proc(THISARG); | |
2575 STATIC#VOID NEAR#QUAL#ag_error_resynch(THISARG); | |
2576 STATIC#VOID NEAR#QUAL#AG_GET_KEY_WORD; | |
2577 STATIC#int NEAR#QUAL#ag_go_to_error_proc(THISARG); | |
2578 STATIC#int NEAR#QUAL#ag_go_to_proc(THISARG); | |
2579 STATIC#int NEAR#QUAL#AG_JNS; | |
2580 STATIC#int NEAR#QUAL#ag_look_ahead(THISARG); | |
2581 STATIC#int NEAR#QUAL#ag_null_go_to_proc(THISARG); | |
2582 STATIC#VOID NEAR#QUAL#ag_prot(THISARG); | |
2583 STATIC#int NEAR#QUAL#ag_recover_proc(THISARG); | |
2584 STATIC#int NEAR#QUAL#ag_reduce_proc(THISARG); | |
2585 STATIC#int NEAR#QUAL#AG_RNS; | |
2586 STATIC#int NEAR#QUAL#ag_r_go_to_proc(THISARG); | |
2587 STATIC#int NEAR#QUAL#ag_r_shift_accept_proc(THISARG); | |
2588 STATIC#int NEAR#QUAL#ag_r_shift_reduce_proc(THISARG); | |
2589 STATIC#int NEAR#QUAL#ag_r_simple_shift_reduce_error_proc(THISARG); | |
2590 STATIC#int NEAR#QUAL#ag_r_simple_shift_reduce_proc(THISARG); | |
2591 STATIC#VOID NEAR#QUAL#ag_set_error_procs(THISARG); | |
2592 STATIC#int NEAR#QUAL#ag_shift_accept_proc(THISARG); | |
2593 STATIC#int NEAR#QUAL#ag_shift_reduce_proc(THISARG); | |
2594 STATIC#int NEAR#QUAL#ag_simple_reduce_error_proc(THISARG); | |
2595 STATIC#int NEAR#QUAL#ag_simple_reduce_proc(THISARG); | |
2596 STATIC#int NEAR#QUAL#ag_simple_shift_reduce_error_proc(THISARG); | |
2597 STATIC#int NEAR#QUAL#ag_simple_shift_reduce_proc(THISARG); | |
2598 STATIC#int NEAR#QUAL#ag_skip_proc(THISARG); | |
2599 STATIC#int NEAR#QUAL#ag_skip_reduce_error_proc(THISARG); | |
2600 STATIC#int NEAR#QUAL#ag_skip_reduce_proc(THISARG); | |
2601 STATIC#int NEAR#QUAL#ag_s_shift_accept_proc(THISARG); | |
2602 STATIC#int NEAR#QUAL#ag_s_shift_reduce_proc(THISARG); | |
2603 STATIC#VOID NEAR#QUAL#ag_trace_error(THISARG); | |
2604 STATIC#VOID NEAR#QUAL#ag_track(THISARG); | |
2605 STATIC#int NEAR#QUAL#ag_tst_tkn(THISARG); | |
2606 STATIC#VOID NEAR#QUAL#ag_undo(THISARG); | |
2607 | |
2608 STATIC#int (NEAR#*QUAL#ag_r_procs_error[])(THISARG); | |
2609 STATIC#int (NEAR#*QUAL#ag_s_procs_error[])(THISARG); | |
2610 STATIC#int (NEAR#*QUAL#ag_gt_procs_error[])(THISARG); | |
2611 STATIC#AG_TSTT_TYPE LOCUS *QUAL#AG_VALID; | |
2612 | |
2613 ## | |
2614 | |
2615 value proc | |
2616 | |
2617 %s %s_value(%s) { | |
2618 %s returnValue; | |
2619 returnValue = %s; | |
2620 return returnValue; | |
2621 } | |
2622 | |
2623 ## | |
2624 | |
2625 fin | |
2626 ## |