Mercurial > ~dholland > hg > ag > index.cgi
comparison tests/agcl/oldagsrc/good/scr4d.c @ 0:13d2b8934445
Import AnaGram (near-)release tree into Mercurial.
author | David A. Holland |
---|---|
date | Sat, 22 Dec 2007 17:52:45 -0500 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:13d2b8934445 |
---|---|
1 /* | |
2 AnaGram Syntax Analyzer. Copyright (c) Jerome T. Holland, 1989, 1990, 1991. | |
3 All Rights Reserved. | |
4 */ | |
5 | |
6 #include HEADERS | |
7 #include PF | |
8 | |
9 #include STDLIB | |
10 #include DATA | |
11 #include ASSERT | |
12 #include MYALLOC | |
13 #include ARRAYS | |
14 #include SP | |
15 #include SCREEN | |
16 #include STK | |
17 #include SCR4D | |
18 #include SETJMP | |
19 #include STDARG | |
20 #include STDIO | |
21 #include WIN | |
22 /* #include DIRECT */ | |
23 #include DEMO | |
24 | |
25 dc *activate_window(dc *); | |
26 void bury_top_image(void); | |
27 int chdir_s1(char*); | |
28 dc *check_selection(dc *); | |
29 dc *clear_mode(dc *); | |
30 int display_line_number(int); | |
31 extern dc *edit_window; | |
32 void force_screen_real(void); | |
33 void hide_cursor(void); | |
34 dc *prt(dc*); | |
35 extern dc *quick_ref_display; | |
36 void remove_ghost(dc *); | |
37 dc *open_windows(dc *); | |
38 dc *resize_window_mode(dc *); | |
39 void set_work_dir(void); | |
40 void update_screen(dc *); | |
41 dc *window_move(dc *); | |
42 int wkb(void); | |
43 void xeq_qa(void); | |
44 | |
45 extern long current_date, expiration_date; | |
46 | |
47 | |
48 scr_pcb_type scr_pcb; | |
49 #define PCB scr_pcb | |
50 | |
51 #define GET_INPUT PCB.input_code = wkb() | |
52 #define PARSE_STACK_OVERFLOW myabort(); | |
53 #define SYNTAX_ERROR | |
54 | |
55 | |
56 extern rect mode_area; | |
57 extern rect position_area; | |
58 extern cint current_cursor; | |
59 | |
60 extern dc *active_dc; | |
61 extern dc *cmnd_map_display; | |
62 extern dc *file_pick_display; | |
63 extern dc *help_index; | |
64 extern dc *pick_list_display; | |
65 extern dc *quick_ref_display; | |
66 extern dc *window_menu_display; | |
67 | |
68 extern int n_windows; | |
69 extern char *string_base; | |
70 | |
71 extern char *current_mode_string; | |
72 | |
73 void sbeep(void); | |
74 | |
75 | |
76 /* | |
77 * AnaGram, A System for Syntax Directed Programming | |
78 * File generated by: ... | |
79 * | |
80 * AnaGram Parsing Engine | |
81 * Copyright 1993-2002 Parsifal Software. All Rights Reserved. | |
82 * | |
83 * This software is provided 'as-is', without any express or implied | |
84 * warranty. In no event will the authors be held liable for any damages | |
85 * arising from the use of this software. | |
86 * | |
87 * Permission is granted to anyone to use this software for any purpose, | |
88 * including commercial applications, and to alter it and redistribute it | |
89 * freely, subject to the following restrictions: | |
90 * | |
91 * 1. The origin of this software must not be misrepresented; you must not | |
92 * claim that you wrote the original software. If you use this software | |
93 * in a product, an acknowledgment in the product documentation would be | |
94 * appreciated but is not required. | |
95 * 2. Altered source versions must be plainly marked as such, and must not be | |
96 * misrepresented as being the original software. | |
97 * 3. This notice may not be removed or altered from any source distribution. | |
98 */ | |
99 | |
100 #ifndef SCR4D_H | |
101 #include "scr4d.h" | |
102 #endif | |
103 | |
104 #ifndef SCR4D_H | |
105 #error Mismatched header file | |
106 #endif | |
107 | |
108 #include <stdio.h> | |
109 | |
110 #define RULE_CONTEXT (&((PCB).cs[(PCB).ssx])) | |
111 #define ERROR_CONTEXT ((PCB).cs[(PCB).error_frame_ssx]) | |
112 #define CONTEXT ((PCB).cs[(PCB).ssx]) | |
113 | |
114 | |
115 #define CHANGE_REDUCTION(x) scr_change_reduction(scr_##x##_token) | |
116 int scr_change_reduction(scr_token_type); | |
117 | |
118 | |
119 #line - "scr4d.syn" | |
120 #define F1 315 | |
121 #define F2 316 | |
122 #define F3 317 | |
123 #define F4 318 | |
124 #define F5 319 | |
125 #define F6 320 | |
126 #define F7 321 | |
127 #define F8 322 | |
128 #define F9 323 | |
129 #define F10 324 | |
130 #define ALT_F1 360 | |
131 #define ALT_F2 361 | |
132 #define ALT_F3 362 | |
133 #define ALT_F4 363 | |
134 #define ALT_F5 364 | |
135 #define ALT_F6 365 | |
136 #define ALT_F7 366 | |
137 #define ALT_F8 367 | |
138 #define ALT_F9 368 | |
139 #define ALT_F10 369 | |
140 | |
141 #define move_code F2 | |
142 #define reduce ALT_F2 | |
143 #define left 331 | |
144 #define right 333 | |
145 | |
146 #line - "scr4d.c" | |
147 #line - "scr4d.syn" | |
148 #ifdef DEMO_FLAG | |
149 void restrict_usage(void); | |
150 | |
151 dc *check_expiration(void) { | |
152 long *ex = &expiration_date + 47; | |
153 long *cd = ¤t_date + 252; | |
154 if (ex[-47] < cd[-252]) restrict_usage(); | |
155 return NULL; | |
156 } | |
157 #else | |
158 dc *check_expiration(void) {return NULL;} | |
159 #endif | |
160 | |
161 #line - "scr4d.c" | |
162 #line - "scr4d.syn" | |
163 void set_mode(char *); | |
164 | |
165 dc *replace_window(dc *d, dc *new); | |
166 dc *pop_up_window(dc *d); | |
167 | |
168 #line - "scr4d.c" | |
169 #line - "scr4d.syn" | |
170 static int end_line_number_mode(int n){ | |
171 flash_str_fill(mode_area.pos,current_mode_string,0,mode_area.size.x); | |
172 return n; | |
173 } | |
174 #line - "scr4d.c" | |
175 #line - "scr4d.syn" | |
176 static dc *reset_position_window(dc *d) { | |
177 flash_str_fill(mode_area.pos,current_mode_string,0,mode_area.size.x); | |
178 current_cursor.x = -1; | |
179 return d; | |
180 } | |
181 | |
182 static int line_number_1(void) { | |
183 flash_str_fill(mode_area.pos,"Line Number",0,mode_area.size.x); | |
184 return 0; | |
185 } | |
186 | |
187 static int line_number_2(int n, int d) { | |
188 return display_line_number(10*n+d-48); | |
189 } | |
190 static int line_number_3(int n) { | |
191 return display_line_number(n/10); | |
192 } | |
193 | |
194 dc *find_help(char *); | |
195 dc *pop_up_window(dc *); | |
196 | |
197 static dc *key_assign(dc *dm, char *title) { | |
198 dc *d = find_help(title); | |
199 if (d == NULL) return beep(dm); | |
200 return pop_up_window(d); | |
201 } | |
202 #line - "scr4d.c" | |
203 #line - "scr4d.syn" | |
204 dc *pop_up_aux_win_menu(dc *); | |
205 dc *pop_up_aux_cmnd_menu(dc *); | |
206 | |
207 dc *first_clone(dc *); | |
208 | |
209 static dc *cycle_clone(dc *d) { | |
210 dc *c; | |
211 if (d->no_clone) return beep(d); | |
212 c = first_clone(d); | |
213 if (c != NULL) return pop_up_window(c); | |
214 return beep(d); | |
215 } | |
216 #line - "scr4d.c" | |
217 #line - "scr4d.syn" | |
218 extern char *search_key; | |
219 char *old_string; | |
220 int search_key_index; | |
221 | |
222 char *build_string(void); | |
223 extern int search_flag; | |
224 | |
225 static dc *save_search_key(dc *d) { | |
226 if (search_key != NULL) free(search_key); | |
227 search_flag--; | |
228 search_key = build_string(); | |
229 close_window(d); | |
230 hide_cursor(); | |
231 activate_window(map_window_plane[--nplanes].d); | |
232 return active_dc; | |
233 } | |
234 | |
235 extern char work_dir_name[]; | |
236 | |
237 void set_work_dir(void); | |
238 | |
239 static dc *chdir_s2(dc *d) { | |
240 tss(); | |
241 if (chdir_s1(string_base)) return beep(d); | |
242 rcs(); | |
243 search_flag--; | |
244 CHANGE_REDUCTION(new_directory); | |
245 set_work_dir(); | |
246 /* getcwd(work_dir_name, MAXPATH); */ | |
247 set_work_dir(); | |
248 close_window(d); | |
249 hide_cursor(); | |
250 activate_window(map_window_plane[--nplanes].d); | |
251 return active_dc; | |
252 } | |
253 | |
254 static dc *quit_search(dc *d) { | |
255 close_window(d); | |
256 rcs(); | |
257 search_flag--; | |
258 hide_cursor(); | |
259 activate_window(map_window_plane[--nplanes].d); | |
260 ok_ptr(active_dc->des); | |
261 active_dc->des->c_loc_doc.x = 0; | |
262 return active_dc; | |
263 } | |
264 #line - "scr4d.c" | |
265 #line - "scr4d.syn" | |
266 void search_key_line(void) { | |
267 tss(); | |
268 sss(string_base); | |
269 } | |
270 | |
271 static dc *search_key_right(dc *d) { | |
272 if( tis() <= d->des->c_loc_doc.x) { | |
273 int c; | |
274 if (search_key == NULL) return d; | |
275 c = old_string[search_key_index]; | |
276 if (c == 0) return d; | |
277 acs(c); | |
278 search_key_index++; | |
279 ok_ptr(d->des); | |
280 d->des->refresh++; | |
281 } | |
282 fiddle_window(d,right); | |
283 return d; | |
284 } | |
285 static dc *search_key_end(dc *d) { | |
286 ok_ptr(d->des); | |
287 | |
288 if( tis() <= d->des->c_loc_doc.x) { | |
289 int c = old_string[search_key_index]; | |
290 while (c) { | |
291 acs(c); | |
292 c = old_string[++search_key_index]; | |
293 } | |
294 d->des->refresh++; | |
295 } | |
296 d->des->c_loc_doc.x = tis(); | |
297 bound_cursor_hor(d->des); | |
298 return d; | |
299 } | |
300 | |
301 static dc *insert_text(dc *d, int c) { | |
302 wd *w; | |
303 | |
304 w = d->des; | |
305 ok_ptr(w); | |
306 its(c, w->c_loc_doc.x); | |
307 fiddle_window(d,right); | |
308 w->refresh++; | |
309 return d; | |
310 } | |
311 static dc *delete_char(dc *d) { | |
312 ok_ptr(d->des); | |
313 dcs(d->des->c_loc_doc.x); | |
314 d->des->refresh++; | |
315 return d; | |
316 } | |
317 | |
318 static dc *backspace_char(dc *d) { | |
319 wd *w; | |
320 | |
321 w = d->des; | |
322 if (w->c_loc_doc.x == 0) return d; | |
323 fiddle_window(d,left); | |
324 delete_char(d); | |
325 return d; | |
326 } | |
327 | |
328 #line - "scr4d.c" | |
329 #line - "scr4d.syn" | |
330 static dc *show_mode(dc *d, int t) { | |
331 char *ms = ""; | |
332 | |
333 ok_ptr(d); | |
334 switch (t) { | |
335 case move_code: | |
336 /* | |
337 if (d->move == NULL) { | |
338 PCB.reduction_token = scr_window_token; | |
339 beep(d); | |
340 break; | |
341 } | |
342 */ | |
343 ms = "Move Window"; | |
344 break; | |
345 case reduce: | |
346 /* | |
347 if (d->resize == NULL) { | |
348 beep(d); | |
349 PCB.reduction_token = scr_window_token; | |
350 break; | |
351 } | |
352 */ | |
353 ms = "Resize Window"; | |
354 break; | |
355 } | |
356 flash_str_fill(mode_area.pos,ms,0,mode_area.size.x); | |
357 return d; | |
358 } | |
359 | |
360 #line - "scr4d.c" | |
361 #line - "scr4d.syn" | |
362 cint ci(); | |
363 cint aci(); | |
364 cint sci(); | |
365 cint ulci(); | |
366 | |
367 extern int start_keys[]; | |
368 extern dc *error_display; | |
369 | |
370 void log_error(void); | |
371 | |
372 void pop_up_code_segment(char *, char *); | |
373 | |
374 dc *resize_window_mode(dc *d) { | |
375 set_mode("Resize Window"); | |
376 CHANGE_REDUCTION(resize_window); | |
377 return d; | |
378 } | |
379 | |
380 dc *window_move(dc *d) { | |
381 set_mode("Move Window"); | |
382 CHANGE_REDUCTION(move_window); | |
383 return d; | |
384 } | |
385 | |
386 static dc *naughty(void) { | |
387 force_screen_real(); | |
388 pop_up_code_segment("birb", ""); | |
389 wkb(); | |
390 return NULL; | |
391 } | |
392 | |
393 void deactivate_window(dc *); | |
394 | |
395 static dc *activate_cmnd_menu(void) { | |
396 dc *new; | |
397 force_screen_real(); | |
398 if (active_dc != NULL) { | |
399 if (active_dc != quick_ref_display) return active_dc; | |
400 deactivate_window(active_dc); | |
401 } | |
402 new = activate_window(cmnd_map_display); | |
403 if (nerrors) new = pop_up_window(error_display); | |
404 return new; | |
405 } | |
406 | |
407 | |
408 extern dc *search_key_window; | |
409 | |
410 | |
411 static dc *edit_search(void) { | |
412 cint loc; | |
413 cint corner; | |
414 dc *d; | |
415 rect w; | |
416 | |
417 d = active_dc; | |
418 loc = aci(d->act->c_loc_scr, ci(1,1)); | |
419 deactivate_window(d); | |
420 w = place_rect(display_area, search_key_window->des->b_size,22); | |
421 corner = w.pos; | |
422 search_key_window->des->b_loc_scr = ulci(loc,corner); | |
423 search_key_window->des->b_size = w.size; | |
424 activate_window(search_key_window); | |
425 return active_dc; | |
426 } | |
427 | |
428 static dc *init_search_window(void) { | |
429 ics(); | |
430 search_flag++; | |
431 ok_ptr(search_key_window->des); | |
432 search_key_window->des->c_loc_doc.x = 0; | |
433 search_key_index = 0; | |
434 old_string = search_key; | |
435 | |
436 return edit_search(); | |
437 } | |
438 | |
439 | |
440 int do_key(int x) { | |
441 PCB.input_code = x; | |
442 scr(); | |
443 if (PCB.exit_flag == AG_SYNTAX_ERROR_CODE) { | |
444 sbeep(); | |
445 PCB.exit_flag = AG_RUNNING_CODE; | |
446 } | |
447 return (PCB.exit_flag == AG_RUNNING_CODE); | |
448 } | |
449 | |
450 #line - "scr4d.c" | |
451 | |
452 #ifndef CONVERT_CASE | |
453 #define CONVERT_CASE(c) (c) | |
454 #endif | |
455 #ifndef TAB_SPACING | |
456 #define TAB_SPACING 8 | |
457 #endif | |
458 | |
459 #define ag_rp_1() (naughty()) | |
460 | |
461 #define ag_rp_2() (check_expiration()) | |
462 | |
463 #define ag_rp_3() (activate_cmnd_menu()) | |
464 | |
465 #define ag_rp_4() (pop_up_window(cmnd_map_display)) | |
466 | |
467 #define ag_rp_5() (pop_up_window(window_menu_display)) | |
468 | |
469 #define ag_rp_6() (pop_up_window(quick_ref_display)) | |
470 | |
471 #define ag_rp_7(w) (rcs(), search_flag--, quit_window(w)) | |
472 | |
473 #define ag_rp_8(w) (check_expiration(),w) | |
474 | |
475 #define ag_rp_9(w) (check_expiration(),w) | |
476 | |
477 #define ag_rp_10(d) ((*d->enter)(d)) | |
478 | |
479 #define ag_rp_11(n) (end_line_number_mode(n)) | |
480 | |
481 #define ag_rp_12(n) (end_line_number_mode(n)) | |
482 | |
483 #define ag_rp_13(n) (end_line_number_mode(n)) | |
484 | |
485 #define ag_rp_14() (line_number_1()) | |
486 | |
487 #define ag_rp_15(n, d) (line_number_2(n,d)) | |
488 | |
489 #define ag_rp_16(n) (line_number_3(n)) | |
490 | |
491 #define ag_rp_17(n) (line_number_3(n)) | |
492 | |
493 #define ag_rp_18(w) (quit_window(w)) | |
494 | |
495 #define ag_rp_19(w) (help_window(w)) | |
496 | |
497 #define ag_rp_20() (pop_up_window(help_index)) | |
498 | |
499 #define ag_rp_21(w) (key_assign(w,"Function Keys")) | |
500 | |
501 #define ag_rp_22(w) (key_assign(w,"Cursor Keys")) | |
502 | |
503 #define ag_rp_23(w) (prt(w)) | |
504 | |
505 #define ag_rp_24(w, k) (cursor(w,k)) | |
506 | |
507 #define ag_rp_25(w, k) (control(w,k)) | |
508 | |
509 #define ag_rp_26(w) (search_forward(w)) | |
510 | |
511 #define ag_rp_27(w) (search_reverse(w)) | |
512 | |
513 #define ag_rp_28(w, c) (alpha_access(w,c)) | |
514 | |
515 #define ag_rp_29(w, n) (reposition_cursor(w,n)) | |
516 | |
517 #define ag_rp_30(w, n) (backup_cursor(w,n)) | |
518 | |
519 #define ag_rp_31(w, n) (advance_cursor(w,n)) | |
520 | |
521 #define ag_rp_32(w) (reset_position_window(w)) | |
522 | |
523 #define ag_rp_33(w) (clone_window(w)) | |
524 | |
525 #define ag_rp_34(w) (cycle_clone(w)) | |
526 | |
527 #define ag_rp_35(w) (pop_up_aux_win_menu(w)) | |
528 | |
529 #define ag_rp_36(w) (pop_up_aux_cmnd_menu(w)) | |
530 | |
531 #define ag_rp_37(w) (open_windows(w)) | |
532 | |
533 #define ag_rp_38(w) (previous_window(w)) | |
534 | |
535 #define ag_rp_39(w) (bottom_window(w)) | |
536 | |
537 #define ag_rp_40(w) (bury_window(w)) | |
538 | |
539 #define ag_rp_41(sk) (save_search_key(sk)) | |
540 | |
541 #define ag_rp_42(sk) (save_search_key(sk)) | |
542 | |
543 #define ag_rp_43(sk) (save_search_key(sk)) | |
544 | |
545 #define ag_rp_44(sk) (save_search_key(sk)) | |
546 | |
547 #define ag_rp_45(sk) (quit_search(sk)) | |
548 | |
549 #define ag_rp_46() (init_search_window()) | |
550 | |
551 #define ag_rp_47(sk, k) (fiddle_window(sk,k)) | |
552 | |
553 #define ag_rp_48(sk) (search_key_right(sk)) | |
554 | |
555 #define ag_rp_49(sk, c) (insert_text(sk,c)) | |
556 | |
557 #define ag_rp_50(sk) (backspace_char(sk)) | |
558 | |
559 #define ag_rp_51(sk) (delete_char(sk)) | |
560 | |
561 #define ag_rp_52(sk, k) (fiddle_window(sk,k)) | |
562 | |
563 #define ag_rp_53(sk) (search_key_end(sk)) | |
564 | |
565 #define ag_rp_54(sk, k) (fiddle_window(sk,k)) | |
566 | |
567 #define ag_rp_55(sk, k) (fiddle_window(sk,k)) | |
568 | |
569 #define ag_rp_56(d) (d) | |
570 | |
571 #define ag_rp_57(d) (chdir_s2(d)) | |
572 | |
573 #define ag_rp_58() (edit_window) | |
574 | |
575 #define ag_rp_59(sk, k) (fiddle_window(sk,k)) | |
576 | |
577 #define ag_rp_60(sk) (search_key_right(sk)) | |
578 | |
579 #define ag_rp_61(sk, k) (fiddle_window(sk,k)) | |
580 | |
581 #define ag_rp_62(sk) (search_key_end(sk)) | |
582 | |
583 #define ag_rp_63(sk, c) (insert_text(sk,c)) | |
584 | |
585 #define ag_rp_64(sk) (backspace_char(sk)) | |
586 | |
587 #define ag_rp_65(sk) (delete_char(sk)) | |
588 | |
589 #define ag_rp_66(sk, k) (fiddle_window(sk,k)) | |
590 | |
591 #define ag_rp_67(sk, k) (fiddle_window(sk,k)) | |
592 | |
593 #define ag_rp_68(sk) (clear_mode(sk)) | |
594 | |
595 #define ag_rp_69(sk) (clear_mode(sk)) | |
596 | |
597 #define ag_rp_70(sk) (clear_mode(sk)) | |
598 | |
599 #define ag_rp_71(sk, k) (show_mode(sk,k)) | |
600 | |
601 #define ag_rp_72(sk, k) (move(sk,k)) | |
602 | |
603 #define ag_rp_73(sk, k) (show_mode(sk,k)) | |
604 | |
605 #define ag_rp_74(sk, k) (resize(sk,k)) | |
606 | |
607 #define ag_rp_75(sk, k) (show_mode(sk,k)) | |
608 | |
609 #define ag_rp_76(sk, k) (move(sk,k)) | |
610 | |
611 #define ag_rp_77(sk, k) (show_mode(sk,k)) | |
612 | |
613 #define ag_rp_78(sk, k) (resize(sk,k)) | |
614 | |
615 #define ag_rp_79(w, k) (show_mode(w,k)) | |
616 | |
617 #define ag_rp_80(w, k) (move(w,k)) | |
618 | |
619 #define ag_rp_81(w, k) (show_mode(w,k)) | |
620 | |
621 #define ag_rp_82(w, k) (resize(w,k)) | |
622 | |
623 | |
624 #define READ_COUNTS | |
625 #define WRITE_COUNTS | |
626 #undef V | |
627 #define V(i,t) (*t (&(PCB).vs[(PCB).ssx + i])) | |
628 #undef VS | |
629 #define VS(i) (PCB).vs[(PCB).ssx + i] | |
630 | |
631 #ifndef GET_CONTEXT | |
632 #define GET_CONTEXT CONTEXT = (PCB).input_context | |
633 #endif | |
634 | |
635 typedef enum { | |
636 ag_action_1, | |
637 ag_action_2, | |
638 ag_action_3, | |
639 ag_action_4, | |
640 ag_action_5, | |
641 ag_action_6, | |
642 ag_action_7, | |
643 ag_action_8, | |
644 ag_action_9, | |
645 ag_action_10, | |
646 ag_action_11, | |
647 ag_action_12 | |
648 } ag_parser_action; | |
649 | |
650 | |
651 #ifndef NULL_VALUE_INITIALIZER | |
652 #define NULL_VALUE_INITIALIZER = { 0 } | |
653 #endif | |
654 | |
655 static scr_vs_type const ag_null_value NULL_VALUE_INITIALIZER; | |
656 | |
657 static const unsigned char ag_rpx[] = { | |
658 0, 0, 0, 0, 1, 0, 0, 0, 2, 0, 0, 0, 0, 3, 4, 5, 6, 7, | |
659 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 0, | |
660 0, 0, 0, 25, 26, 27, 28, 0, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, | |
661 39, 40, 0, 41, 42, 0, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, | |
662 55, 0, 56, 57, 58, 59, 60, 61, 62, 0, 63, 64, 65, 66, 67, 0, 0, 68, | |
663 0, 0, 69, 0, 0, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82 | |
664 }; | |
665 #define AG_TCV(x) (((int)(x) >= 0 && (int)(x) <= 388) ? ag_tcv[(x)] : 0) | |
666 | |
667 static const unsigned char ag_tcv[] = { | |
668 0, 0, 0, 0, 0, 0, 0, 0, 29, 0, 0, 0, 0, 21, 0, 0, 0, 0, | |
669 0, 0, 0, 0, 0, 86, 0, 0, 87, 19, 0, 0, 0, 0, 90, 90, 90, 90, | |
670 90, 90, 90, 90, 90, 90, 90, 89, 90, 88, 90, 90, 28, 28, 28, 28, 28, 28, | |
671 28, 28, 28, 28, 90, 90, 90, 90, 90, 18, 90, 90, 90, 90, 90, 90, 90, 90, | |
672 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, | |
673 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, | |
674 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, | |
675 90, 90, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, | |
676 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, | |
677 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, | |
678 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, | |
679 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, | |
680 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, | |
681 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, | |
682 0, 0, 0, 0, 0, 67, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, | |
683 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 35, 0, 0, 0, 0, 0, 58, | |
684 0, 0, 0, 0, 0, 0, 27, 0, 0, 0, 0, 0, 0, 6, 0, 0, 0, 0, | |
685 0, 0, 0, 0, 0, 0, 0, 0, 0, 31, 77, 56, 53, 52, 51, 45, 50, 17, | |
686 11, 0, 0, 62, 57, 80, 0, 59, 0, 60, 0, 63, 55, 81, 0, 30, 33, 0, | |
687 0, 0, 0, 0, 0, 0, 0, 0, 34, 0, 0, 0, 0, 0, 0, 0, 0, 0, | |
688 32, 79, 0, 0, 0, 0, 46, 49, 47, 48, 0, 64, 65, 83, 85, 82, 0, 0, | |
689 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 84 | |
690 }; | |
691 | |
692 #ifndef SYNTAX_ERROR | |
693 #define SYNTAX_ERROR fprintf(stderr,"%s\n", (PCB).error_message) | |
694 #endif | |
695 | |
696 #ifndef PARSER_STACK_OVERFLOW | |
697 #define PARSER_STACK_OVERFLOW {fprintf(stderr, \ | |
698 "\nParser stack overflow\n");} | |
699 #endif | |
700 | |
701 #ifndef REDUCTION_TOKEN_ERROR | |
702 #define REDUCTION_TOKEN_ERROR {fprintf(stderr, \ | |
703 "\nReduction token error\n");} | |
704 #endif | |
705 | |
706 | |
707 static void near ag_prot(void) { | |
708 int ag_k; | |
709 ag_k = 128 - ++(PCB).btsx; | |
710 if (ag_k <= (PCB).ssx) { | |
711 (PCB).exit_flag = AG_STACK_ERROR_CODE; | |
712 PARSER_STACK_OVERFLOW; | |
713 return; | |
714 } | |
715 (PCB).bts[(PCB).btsx] = (PCB).sn; | |
716 (PCB).bts[ag_k] = (PCB).ssx; | |
717 (PCB).vs[ag_k] = (PCB).vs[(PCB).ssx]; | |
718 (PCB).ss[ag_k] = (PCB).ss[(PCB).ssx]; | |
719 } | |
720 | |
721 static void near ag_undo(void) { | |
722 if ((PCB).drt == -1) return; | |
723 while ((PCB).btsx) { | |
724 int ag_k = 128 - (PCB).btsx; | |
725 (PCB).sn = (PCB).bts[(PCB).btsx--]; | |
726 (PCB).ssx = (PCB).bts[ag_k]; | |
727 (PCB).vs[(PCB).ssx] = (PCB).vs[ag_k]; | |
728 (PCB).ss[(PCB).ssx] = (PCB).ss[ag_k]; | |
729 } | |
730 (PCB).token_number = (scr_token_type) (PCB).drt; | |
731 (PCB).ssx = (PCB).dssx; | |
732 (PCB).sn = (PCB).dsn; | |
733 (PCB).drt = -1; | |
734 } | |
735 | |
736 | |
737 | |
738 static const int ag_rtt[] = { | |
739 16, 7, 4, 0, 14, 66, 0 | |
740 }; | |
741 | |
742 static const unsigned char ag_tstt[] = { | |
743 58,27,11,6,0,1,2,3,4,7,8,9,10,12,13,16,20,37,38,39,71,72,73,74,75,76, | |
744 90,89,88,81,80,79,77,65,64,63,62,60,59,57,56,55,53,30,29,28,21,19,18,6,0,78, | |
745 90,89,88,81,80,79,77,65,64,63,62,60,59,57,56,55,53,30,29,28,21,19,18,6,0,78, | |
746 90,89,88,87,86,85,84,83,82,81,80,79,77,65,64,63,62,60,59,58,57,56,55,53,52, | |
747 51,50,49,48,47,46,45,35,34,33,32,31,28,27,21,19,18,17,11,6,0,78, | |
748 90,89,88,87,86,85,84,83,82,81,80,79,77,65,64,63,62,60,59,58,57,56,55,53,52, | |
749 51,50,49,48,47,46,45,35,34,33,32,31,28,27,21,19,18,17,11,6,0,78, | |
750 90,89,88,79,77,65,64,56,53,30,29,28,21,19,18,6,0, | |
751 90,89,88,79,77,65,64,63,62,60,59,30,29,28,18,6,0, | |
752 30,29,28,6,0, | |
753 90,89,88,79,77,65,64,30,29,28,18,6,0, | |
754 90,89,88,87,86,85,84,83,82,79,77,65,64,58,56,53,52,51,50,49,48,47,46,45,35, | |
755 34,33,32,31,28,27,21,19,18,17,11,6,0,40, | |
756 90,89,88,87,86,85,84,83,82,81,80,79,77,65,64,63,62,60,59,58,57,56,55,53,52, | |
757 51,50,49,48,47,46,45,35,34,33,32,31,28,27,21,19,18,17,11,6,0,36,40,78, | |
758 67,0,5,14,15,66,68,69,70, | |
759 90,89,88,79,77,58,56,53,52,51,50,49,48,47,46,45,35,34,33,32,31,28,27,21,18, | |
760 17,11,6,0,3,8,9,12,13,22,23,25,41,42,44,71,72,73, | |
761 90,89,88,81,80,79,77,65,64,63,62,60,59,57,55,30,29,28,19,18,6,0,78, | |
762 90,89,88,81,80,79,77,65,64,63,62,60,59,57,55,30,29,28,19,18,6,0,78, | |
763 90,89,88,79,77,65,64,30,29,28,19,18,6,0, | |
764 90,89,88,79,77,65,64,63,62,60,59,30,29,28,21,19,18,6,0, | |
765 90,89,88,79,77,65,64,30,29,28,18,6,0, | |
766 90,89,88,79,77,65,64,63,62,60,59,57,56,55,53,30,29,28,21,19,18,6,0, | |
767 89,88,57,55,30,29,28,21,19,6,0, | |
768 90,89,88,79,77,65,64,56,53,30,29,28,21,18,6,0, | |
769 0 | |
770 }; | |
771 | |
772 | |
773 static unsigned const char ag_astt[507] = { | |
774 2,2,2,2,7,0,1,2,1,0,1,1,2,1,1,1,1,1,1,1,1,1,2,1,1,2,5,5,5,10,10,5,5,5,5,10, | |
775 10,10,10,10,5,10,5,5,5,5,5,5,5,5,7,2,5,5,5,10,10,5,5,5,5,10,10,10,10,10,5, | |
776 10,5,5,5,5,5,5,5,5,7,2,5,5,5,5,5,5,5,5,5,10,10,5,5,5,5,10,10,10,10,5,10,5, | |
777 10,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,7,2,5,5,5,5,5,5,5,5,5,10,10, | |
778 5,5,5,5,10,10,10,10,5,10,5,10,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5, | |
779 7,2,5,5,5,5,5,5,5,5,5,5,5,5,5,3,5,5,7,5,5,5,5,5,5,5,10,10,10,10,5,5,5,5,5, | |
780 7,10,10,10,3,7,2,2,2,2,2,2,2,2,2,2,2,3,7,4,4,4,2,2,2,2,2,2,4,4,2,2,4,4,4,4, | |
781 4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,3,4,4,4,4,7,2,4,4,4,10,10,10,10,10,10,10,10, | |
782 4,4,10,10,10,10,10,10,4,10,4,10,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,10,4,4,4, | |
783 4,7,2,2,2,2,7,1,1,1,2,1,1,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2, | |
784 2,2,2,2,3,7,3,1,1,1,1,2,2,2,2,2,3,1,1,2,5,5,5,10,10,5,5,5,5,10,10,10,10,10, | |
785 10,5,5,5,5,5,5,7,2,5,5,5,10,10,5,5,5,5,10,10,10,10,10,10,5,5,5,5,5,5,7,2,5, | |
786 5,5,5,5,5,5,5,5,5,3,5,5,7,5,5,5,5,5,5,5,10,10,10,10,5,5,5,2,2,5,5,7,2,2,2, | |
787 2,2,2,2,2,2,2,2,3,7,5,5,5,5,5,5,5,10,10,10,10,2,5,2,5,5,5,5,5,2,5,5,7,2,2, | |
788 2,2,10,10,10,2,2,3,7,2,2,2,2,2,2,2,2,2,2,2,2,2,2,3,7,11 | |
789 }; | |
790 | |
791 | |
792 static const unsigned char ag_pstt[] = { | |
793 63,24,8,4,0,0,12,4,11,0,8,7,13,6,5,10,9,10,10,10,2,1,92,4,3,95, | |
794 91,91,91,97,97,91,91,91,91,97,97,97,97,97,91,97,91,91,91,91,91,91,91,91,1, | |
795 97, | |
796 90,90,90,99,99,90,90,90,90,99,99,99,99,99,90,99,90,90,90,90,90,90,90,90,2, | |
797 99, | |
798 94,94,94,94,94,94,94,94,94,105,105,94,94,94,94,105,105,105,105,94,105,94, | |
799 105,94,94,94,94,94,94,94,94,94,94,94,94,94,94,94,94,94,94,94,94,94,94,3, | |
800 105, | |
801 93,93,93,93,93,93,93,93,93,107,107,93,93,93,93,107,107,107,107,93,107,93, | |
802 107,93,93,93,93,93,93,93,93,93,93,93,93,93,93,93,93,93,93,93,93,93,93,4, | |
803 107, | |
804 10,10,10,10,10,10,10,10,10,10,10,10,10,73,10,10,5, | |
805 9,9,9,9,9,9,9,70,69,65,64,9,9,9,9,9,6, | |
806 27,26,25,7,7, | |
807 66,66,66,98,96,72,71,68,67,66,66,6,8, | |
808 19,19,19,39,39,39,39,39,39,19,19,39,39,19,19,19,19,19,19,19,19,19,19,19,19, | |
809 19,19,19,19,19,19,19,38,19,19,19,19,9,39, | |
810 18,18,18,34,34,34,34,34,34,34,34,18,18,34,34,34,34,34,34,18,34,18,34,18,18, | |
811 18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,28,18,18,18,18,10,34,34,34, | |
812 76,11,17,16,15,74,14,13,89, | |
813 42,42,42,106,104,63,41,40,55,54,53,52,51,50,49,48,33,32,31,30,29,42,24,20, | |
814 16,15,14,1,12,1,20,19,18,5,44,45,46,40,41,43,2,1,92, | |
815 88,88,88,101,101,88,88,88,88,101,101,101,101,101,101,88,88,88,88,88,88,13, | |
816 101, | |
817 87,87,87,103,103,87,87,87,87,103,103,103,103,103,103,87,87,87,87,87,87,14, | |
818 103, | |
819 12,12,12,12,12,12,12,12,12,12,81,12,12,15, | |
820 11,11,11,11,11,11,11,80,79,78,77,11,11,11,75,17,11,11,16, | |
821 82,82,82,102,100,86,85,84,83,82,82,2,17, | |
822 9,9,9,9,9,9,9,70,69,65,64,61,9,58,9,9,9,9,9,62,9,9,18, | |
823 23,22,22,23,27,26,25,21,47,7,19, | |
824 66,66,66,98,96,72,71,60,57,68,67,66,57,66,6,20, | |
825 0 | |
826 }; | |
827 | |
828 | |
829 static const unsigned short ag_sbt[] = { | |
830 0, 26, 52, 78, 125, 172, 189, 206, 211, 224, 263, 312, 321, 364, | |
831 387, 410, 424, 443, 456, 479, 490, 506 | |
832 }; | |
833 | |
834 | |
835 static const unsigned short ag_sbe[] = { | |
836 4, 50, 76, 123, 170, 188, 205, 210, 223, 261, 308, 313, 349, 385, | |
837 408, 423, 442, 455, 478, 489, 505, 506 | |
838 }; | |
839 | |
840 | |
841 static const unsigned char ag_fl[] = { | |
842 1,2,3,1,1,1,2,2,1,1,1,1,1,1,2,2,2,3,1,1,2,2,2,2,1,2,2,2,2,2,2,2,2,2,2, | |
843 1,1,1,2,2,2,2,2,2,2,2,2,3,2,2,2,2,2,2,2,2,1,2,2,1,2,2,2,1,2,2,2,2,2,2, | |
844 2,2,2,2,2,2,1,2,2,2,2,2,2,2,2,2,2,1,1,1,1,1,1,1,1,1,2,2,2,2,2,2,2,2,2, | |
845 2,2,2,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1 | |
846 }; | |
847 | |
848 static const unsigned char ag_ptt[] = { | |
849 0, 1, 1, 1, 1, 3, 3, 3, 10, 8, 8, 5, 5, 16, 16, 16, 16, 16, | |
850 2, 2, 16, 22, 23, 25, 9, 9, 9, 9, 16, 16, 16, 16, 16, 16, 16, 16, | |
851 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 37, | |
852 38, 39, 41, 41, 41, 42, 42, 42, 44, 12, 12, 12, 12, 12, 12, 12, 12, 12, | |
853 12, 12, 16, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 70, 70, 15, | |
854 73, 73, 13, 76, 76, 20, 72, 72, 71, 71, 69, 69, 68, 68, 75, 75, 74, 74, | |
855 78, 78, 78, 78, 78, 78, 78, 78, 36, 36, 40, 40, 40, 40, 40, 40, 40, 40 | |
856 }; | |
857 | |
858 static const unsigned char *ag_valid(int ag_k) { | |
859 const unsigned char *ag_tp = &ag_tstt[ag_sbt[(PCB).sn+1]]; | |
860 while (*--ag_tp != (unsigned char) ag_k) if (*ag_tp == 0) return NULL; | |
861 return ag_tp; | |
862 } | |
863 | |
864 int scr_change_reduction(scr_token_type ag_k) { | |
865 if (!ag_valid(ag_k)) return 0; | |
866 (PCB).reduction_token = ag_k; | |
867 return 1; | |
868 } | |
869 | |
870 static void near ag_default(const int *ag_tp) { | |
871 (PCB).ag_dsn = (PCB).sn; | |
872 (PCB).ag_dtl = ag_tp; | |
873 while (!ag_valid((scr_token_type) *ag_tp)) ag_tp++; | |
874 (PCB).reduction_token = (scr_token_type) *ag_tp; | |
875 } | |
876 | |
877 | |
878 | |
879 static void near ag_ra(void) | |
880 { | |
881 switch(ag_rpx[(PCB).ag_ap]) { | |
882 case 1: ag_rp_1(); break; | |
883 case 2: V(0,(dc * *)) = ag_rp_2(); break; | |
884 case 3: V(0,(dc * *)) = ag_rp_3(); break; | |
885 case 4: V(0,(dc * *)) = ag_rp_4(); break; | |
886 case 5: V(0,(dc * *)) = ag_rp_5(); break; | |
887 case 6: V(0,(dc * *)) = ag_rp_6(); break; | |
888 case 7: V(0,(dc * *)) = ag_rp_7(V(1,(dc * *))); break; | |
889 case 8: V(0,(dc * *)) = ag_rp_8(V(0,(dc * *))); break; | |
890 case 9: V(0,(dc * *)) = ag_rp_9(V(0,(dc * *))); break; | |
891 case 10: ag_default(&ag_rtt[0]); V(0,(dc * *)) = ag_rp_10(V(0,(dc * *))); break; | |
892 case 11: V(0,(int *)) = ag_rp_11(V(0,(int *))); break; | |
893 case 12: V(0,(int *)) = ag_rp_12(V(0,(int *))); break; | |
894 case 13: V(0,(int *)) = ag_rp_13(V(0,(int *))); break; | |
895 case 14: V(0,(int *)) = ag_rp_14(); break; | |
896 case 15: V(0,(int *)) = ag_rp_15(V(0,(int *)), V(1,(int *))); break; | |
897 case 16: V(0,(int *)) = ag_rp_16(V(0,(int *))); break; | |
898 case 17: V(0,(int *)) = ag_rp_17(V(0,(int *))); break; | |
899 case 18: V(0,(dc * *)) = ag_rp_18(V(0,(dc * *))); break; | |
900 case 19: V(0,(dc * *)) = ag_rp_19(V(0,(dc * *))); break; | |
901 case 20: V(0,(dc * *)) = ag_rp_20(); break; | |
902 case 21: V(0,(dc * *)) = ag_rp_21(V(0,(dc * *))); break; | |
903 case 22: V(0,(dc * *)) = ag_rp_22(V(0,(dc * *))); break; | |
904 case 23: V(0,(dc * *)) = ag_rp_23(V(0,(dc * *))); break; | |
905 case 24: V(0,(dc * *)) = ag_rp_24(V(0,(dc * *)), V(1,(int *))); break; | |
906 case 25: V(0,(dc * *)) = ag_rp_25(V(0,(dc * *)), V(1,(int *))); break; | |
907 case 26: V(0,(dc * *)) = ag_rp_26(V(0,(dc * *))); break; | |
908 case 27: V(0,(dc * *)) = ag_rp_27(V(0,(dc * *))); break; | |
909 case 28: V(0,(dc * *)) = ag_rp_28(V(0,(dc * *)), V(1,(int *))); break; | |
910 case 29: V(0,(dc * *)) = ag_rp_29(V(0,(dc * *)), V(1,(int *))); break; | |
911 case 30: V(0,(dc * *)) = ag_rp_30(V(0,(dc * *)), V(1,(int *))); break; | |
912 case 31: V(0,(dc * *)) = ag_rp_31(V(0,(dc * *)), V(1,(int *))); break; | |
913 case 32: V(0,(dc * *)) = ag_rp_32(V(0,(dc * *))); break; | |
914 case 33: V(0,(dc * *)) = ag_rp_33(V(0,(dc * *))); break; | |
915 case 34: V(0,(dc * *)) = ag_rp_34(V(0,(dc * *))); break; | |
916 case 35: V(0,(dc * *)) = ag_rp_35(V(0,(dc * *))); break; | |
917 case 36: V(0,(dc * *)) = ag_rp_36(V(0,(dc * *))); break; | |
918 case 37: V(0,(dc * *)) = ag_rp_37(V(0,(dc * *))); break; | |
919 case 38: V(0,(dc * *)) = ag_rp_38(V(0,(dc * *))); break; | |
920 case 39: V(0,(dc * *)) = ag_rp_39(V(0,(dc * *))); break; | |
921 case 40: V(0,(dc * *)) = ag_rp_40(V(0,(dc * *))); break; | |
922 case 41: V(0,(dc * *)) = ag_rp_41(V(0,(dc * *))); break; | |
923 case 42: V(0,(dc * *)) = ag_rp_42(V(0,(dc * *))); break; | |
924 case 43: V(0,(dc * *)) = ag_rp_43(V(0,(dc * *))); break; | |
925 case 44: V(0,(dc * *)) = ag_rp_44(V(0,(dc * *))); break; | |
926 case 45: V(0,(dc * *)) = ag_rp_45(V(0,(dc * *))); break; | |
927 case 46: V(0,(dc * *)) = ag_rp_46(); break; | |
928 case 47: V(0,(dc * *)) = ag_rp_47(V(0,(dc * *)), V(1,(int *))); break; | |
929 case 48: V(0,(dc * *)) = ag_rp_48(V(0,(dc * *))); break; | |
930 case 49: V(0,(dc * *)) = ag_rp_49(V(0,(dc * *)), V(1,(int *))); break; | |
931 case 50: V(0,(dc * *)) = ag_rp_50(V(0,(dc * *))); break; | |
932 case 51: V(0,(dc * *)) = ag_rp_51(V(0,(dc * *))); break; | |
933 case 52: V(0,(dc * *)) = ag_rp_52(V(0,(dc * *)), V(1,(int *))); break; | |
934 case 53: V(0,(dc * *)) = ag_rp_53(V(0,(dc * *))); break; | |
935 case 54: V(0,(dc * *)) = ag_rp_54(V(0,(dc * *)), V(1,(int *))); break; | |
936 case 55: V(0,(dc * *)) = ag_rp_55(V(0,(dc * *)), V(1,(int *))); break; | |
937 case 56: V(0,(dc * *)) = ag_rp_56(V(1,(dc * *))); break; | |
938 case 57: ag_default(&ag_rtt[4]); V(0,(dc * *)) = ag_rp_57(V(0,(dc * *))); break; | |
939 case 58: V(0,(dc * *)) = ag_rp_58(); break; | |
940 case 59: V(0,(dc * *)) = ag_rp_59(V(0,(dc * *)), V(1,(int *))); break; | |
941 case 60: V(0,(dc * *)) = ag_rp_60(V(0,(dc * *))); break; | |
942 case 61: V(0,(dc * *)) = ag_rp_61(V(0,(dc * *)), V(1,(int *))); break; | |
943 case 62: V(0,(dc * *)) = ag_rp_62(V(0,(dc * *))); break; | |
944 case 63: V(0,(dc * *)) = ag_rp_63(V(0,(dc * *)), V(1,(int *))); break; | |
945 case 64: V(0,(dc * *)) = ag_rp_64(V(0,(dc * *))); break; | |
946 case 65: V(0,(dc * *)) = ag_rp_65(V(0,(dc * *))); break; | |
947 case 66: V(0,(dc * *)) = ag_rp_66(V(0,(dc * *)), V(1,(int *))); break; | |
948 case 67: V(0,(dc * *)) = ag_rp_67(V(0,(dc * *)), V(1,(int *))); break; | |
949 case 68: V(0,(dc * *)) = ag_rp_68(V(0,(dc * *))); break; | |
950 case 69: V(0,(dc * *)) = ag_rp_69(V(0,(dc * *))); break; | |
951 case 70: V(0,(dc * *)) = ag_rp_70(V(0,(dc * *))); break; | |
952 case 71: V(0,(dc * *)) = ag_rp_71(V(0,(dc * *)), V(1,(int *))); break; | |
953 case 72: V(0,(dc * *)) = ag_rp_72(V(0,(dc * *)), V(1,(int *))); break; | |
954 case 73: V(0,(dc * *)) = ag_rp_73(V(0,(dc * *)), V(1,(int *))); break; | |
955 case 74: V(0,(dc * *)) = ag_rp_74(V(0,(dc * *)), V(1,(int *))); break; | |
956 case 75: V(0,(dc * *)) = ag_rp_75(V(0,(dc * *)), V(1,(int *))); break; | |
957 case 76: V(0,(dc * *)) = ag_rp_76(V(0,(dc * *)), V(1,(int *))); break; | |
958 case 77: V(0,(dc * *)) = ag_rp_77(V(0,(dc * *)), V(1,(int *))); break; | |
959 case 78: V(0,(dc * *)) = ag_rp_78(V(0,(dc * *)), V(1,(int *))); break; | |
960 case 79: V(0,(dc * *)) = ag_rp_79(V(0,(dc * *)), V(1,(int *))); break; | |
961 case 80: V(0,(dc * *)) = ag_rp_80(V(0,(dc * *)), V(1,(int *))); break; | |
962 case 81: V(0,(dc * *)) = ag_rp_81(V(0,(dc * *)), V(1,(int *))); break; | |
963 case 82: V(0,(dc * *)) = ag_rp_82(V(0,(dc * *)), V(1,(int *))); break; | |
964 } | |
965 } | |
966 | |
967 static int near ag_action_1_r_proc(void); | |
968 static int near ag_action_2_r_proc(void); | |
969 static int near ag_action_3_r_proc(void); | |
970 static int near ag_action_4_r_proc(void); | |
971 static int near ag_action_1_s_proc(void); | |
972 static int near ag_action_3_s_proc(void); | |
973 static int near ag_action_1_proc(void); | |
974 static int near ag_action_2_proc(void); | |
975 static int near ag_action_3_proc(void); | |
976 static int near ag_action_4_proc(void); | |
977 static int near ag_action_5_proc(void); | |
978 static int near ag_action_6_proc(void); | |
979 static int near ag_action_7_proc(void); | |
980 static int near ag_action_8_proc(void); | |
981 static int near ag_action_9_proc(void); | |
982 static int near ag_action_10_proc(void); | |
983 static int near ag_action_11_proc(void); | |
984 static int near ag_action_8_proc(void); | |
985 | |
986 | |
987 static int (near *const ag_r_procs_scan[])(void) = { | |
988 ag_action_1_r_proc, | |
989 ag_action_2_r_proc, | |
990 ag_action_3_r_proc, | |
991 ag_action_4_r_proc | |
992 }; | |
993 | |
994 static int (near *const ag_s_procs_scan[])(void) = { | |
995 ag_action_1_s_proc, | |
996 ag_action_2_r_proc, | |
997 ag_action_3_s_proc, | |
998 ag_action_4_r_proc | |
999 }; | |
1000 | |
1001 static int (near *const ag_gt_procs_scan[])(void) = { | |
1002 ag_action_1_proc, | |
1003 ag_action_2_proc, | |
1004 ag_action_3_proc, | |
1005 ag_action_4_proc, | |
1006 ag_action_5_proc, | |
1007 ag_action_6_proc, | |
1008 ag_action_7_proc, | |
1009 ag_action_8_proc, | |
1010 ag_action_9_proc, | |
1011 ag_action_10_proc, | |
1012 ag_action_11_proc, | |
1013 ag_action_8_proc | |
1014 }; | |
1015 | |
1016 | |
1017 static int near ag_action_10_proc(void) { | |
1018 (PCB).btsx = 0, (PCB).drt = -1; | |
1019 return 0; | |
1020 } | |
1021 | |
1022 static int near ag_action_11_proc(void) { | |
1023 (PCB).btsx = 0, (PCB).drt = -1; | |
1024 (*(int *) &(PCB).vs[(PCB).ssx]) = (PCB).input_code; | |
1025 (PCB).ssx--; | |
1026 ag_ra(); | |
1027 (PCB).ssx++; | |
1028 return 0; | |
1029 } | |
1030 | |
1031 static int near ag_action_3_r_proc(void) { | |
1032 int ag_sd = ag_fl[(PCB).ag_ap] - 1; | |
1033 if (ag_sd) (PCB).sn = (PCB).ss[(PCB).ssx -= ag_sd]; | |
1034 (PCB).btsx = 0, (PCB).drt = -1; | |
1035 (PCB).reduction_token = (scr_token_type) ag_ptt[(PCB).ag_ap]; | |
1036 ag_ra(); | |
1037 return (PCB).exit_flag == AG_RUNNING_CODE; | |
1038 } | |
1039 | |
1040 static int near ag_action_3_s_proc(void) { | |
1041 int ag_sd = ag_fl[(PCB).ag_ap] - 1; | |
1042 if (ag_sd) (PCB).sn = (PCB).ss[(PCB).ssx -= ag_sd]; | |
1043 (PCB).btsx = 0, (PCB).drt = -1; | |
1044 (PCB).reduction_token = (scr_token_type) ag_ptt[(PCB).ag_ap]; | |
1045 ag_ra(); | |
1046 return (PCB).exit_flag == AG_RUNNING_CODE; | |
1047 } | |
1048 | |
1049 static int near ag_action_4_r_proc(void) { | |
1050 int ag_sd = ag_fl[(PCB).ag_ap] - 1; | |
1051 if (ag_sd) (PCB).sn = (PCB).ss[(PCB).ssx -= ag_sd]; | |
1052 (PCB).reduction_token = (scr_token_type) ag_ptt[(PCB).ag_ap]; | |
1053 return 1; | |
1054 } | |
1055 | |
1056 static int near ag_action_2_proc(void) { | |
1057 (PCB).btsx = 0, (PCB).drt = -1; | |
1058 if ((PCB).ssx >= 128) { | |
1059 (PCB).exit_flag = AG_STACK_ERROR_CODE; | |
1060 PARSER_STACK_OVERFLOW; | |
1061 } | |
1062 (*(int *) &(PCB).vs[(PCB).ssx]) = (PCB).input_code; | |
1063 (PCB).ss[(PCB).ssx] = (PCB).sn; | |
1064 (PCB).ssx++; | |
1065 (PCB).sn = (PCB).ag_ap; | |
1066 return 0; | |
1067 } | |
1068 | |
1069 static int near ag_action_9_proc(void) { | |
1070 if ((PCB).drt == -1) { | |
1071 (PCB).drt=(PCB).token_number; | |
1072 (PCB).dssx=(PCB).ssx; | |
1073 (PCB).dsn=(PCB).sn; | |
1074 } | |
1075 ag_prot(); | |
1076 (PCB).ss[(PCB).ssx] = (PCB).sn; | |
1077 (PCB).ssx++; | |
1078 (PCB).sn = (PCB).ag_ap; | |
1079 return (PCB).exit_flag == AG_RUNNING_CODE; | |
1080 } | |
1081 | |
1082 static int near ag_action_2_r_proc(void) { | |
1083 (PCB).ssx++; | |
1084 (PCB).sn = (PCB).ag_ap; | |
1085 return 0; | |
1086 } | |
1087 | |
1088 static int near ag_action_7_proc(void) { | |
1089 --(PCB).ssx; | |
1090 (PCB).exit_flag = AG_SUCCESS_CODE; | |
1091 return 0; | |
1092 } | |
1093 | |
1094 static int near ag_action_1_proc(void) { | |
1095 (PCB).exit_flag = AG_SUCCESS_CODE; | |
1096 return 0; | |
1097 } | |
1098 | |
1099 static int near ag_action_1_r_proc(void) { | |
1100 (PCB).exit_flag = AG_SUCCESS_CODE; | |
1101 return 0; | |
1102 } | |
1103 | |
1104 static int near ag_action_1_s_proc(void) { | |
1105 (PCB).exit_flag = AG_SUCCESS_CODE; | |
1106 return 0; | |
1107 } | |
1108 | |
1109 static int near ag_action_4_proc(void) { | |
1110 int ag_sd = ag_fl[(PCB).ag_ap] - 1; | |
1111 (PCB).reduction_token = (scr_token_type) ag_ptt[(PCB).ag_ap]; | |
1112 (PCB).btsx = 0, (PCB).drt = -1; | |
1113 (*(int *) &(PCB).vs[(PCB).ssx]) = (PCB).input_code; | |
1114 if (ag_sd) (PCB).sn = (PCB).ss[(PCB).ssx -= ag_sd]; | |
1115 else (PCB).ss[(PCB).ssx] = (PCB).sn; | |
1116 while ((PCB).exit_flag == AG_RUNNING_CODE) { | |
1117 unsigned ag_t1 = ag_sbe[(PCB).sn] + 1; | |
1118 unsigned ag_t2 = ag_sbt[(PCB).sn+1] - 1; | |
1119 do { | |
1120 unsigned ag_tx = (ag_t1 + ag_t2)/2; | |
1121 if (ag_tstt[ag_tx] < (unsigned char)(PCB).reduction_token) ag_t1 = ag_tx + 1; | |
1122 else ag_t2 = ag_tx; | |
1123 } while (ag_t1 < ag_t2); | |
1124 if (ag_tstt[ag_t1] != (PCB).reduction_token) { | |
1125 (PCB).exit_flag = AG_REDUCTION_ERROR_CODE; | |
1126 REDUCTION_TOKEN_ERROR; break;} | |
1127 (PCB).ag_ap = ag_pstt[ag_t1]; | |
1128 if ((ag_s_procs_scan[ag_astt[ag_t1]])() == 0) break; | |
1129 } | |
1130 return 0; | |
1131 } | |
1132 | |
1133 static int near ag_action_3_proc(void) { | |
1134 int ag_sd = ag_fl[(PCB).ag_ap] - 1; | |
1135 (PCB).btsx = 0, (PCB).drt = -1; | |
1136 (*(int *) &(PCB).vs[(PCB).ssx]) = (PCB).input_code; | |
1137 if (ag_sd) (PCB).sn = (PCB).ss[(PCB).ssx -= ag_sd]; | |
1138 else (PCB).ss[(PCB).ssx] = (PCB).sn; | |
1139 (PCB).reduction_token = (scr_token_type) ag_ptt[(PCB).ag_ap]; | |
1140 ag_ra(); | |
1141 while ((PCB).exit_flag == AG_RUNNING_CODE) { | |
1142 unsigned ag_t1 = ag_sbe[(PCB).sn] + 1; | |
1143 unsigned ag_t2 = ag_sbt[(PCB).sn+1] - 1; | |
1144 do { | |
1145 unsigned ag_tx = (ag_t1 + ag_t2)/2; | |
1146 if (ag_tstt[ag_tx] < (unsigned char)(PCB).reduction_token) ag_t1 = ag_tx + 1; | |
1147 else ag_t2 = ag_tx; | |
1148 } while (ag_t1 < ag_t2); | |
1149 if (ag_tstt[ag_t1] != (PCB).reduction_token) { | |
1150 (PCB).exit_flag = AG_REDUCTION_ERROR_CODE; | |
1151 REDUCTION_TOKEN_ERROR; break;} | |
1152 (PCB).ag_ap = ag_pstt[ag_t1]; | |
1153 if ((ag_s_procs_scan[ag_astt[ag_t1]])() == 0) break; | |
1154 } | |
1155 return 0; | |
1156 } | |
1157 | |
1158 static int near ag_action_8_proc(void) { | |
1159 ag_undo(); | |
1160 (PCB).exit_flag = AG_SYNTAX_ERROR_CODE; | |
1161 SYNTAX_ERROR; | |
1162 | |
1163 return (PCB).exit_flag == AG_RUNNING_CODE; | |
1164 } | |
1165 | |
1166 static int near ag_action_5_proc(void) { | |
1167 int ag_sd = ag_fl[(PCB).ag_ap]; | |
1168 (PCB).btsx = 0, (PCB).drt = -1; | |
1169 if (ag_sd) (PCB).sn = (PCB).ss[(PCB).ssx -= ag_sd]; | |
1170 else { | |
1171 (PCB).ss[(PCB).ssx] = (PCB).sn; | |
1172 } | |
1173 (PCB).reduction_token = (scr_token_type) ag_ptt[(PCB).ag_ap]; | |
1174 ag_ra(); | |
1175 while ((PCB).exit_flag == AG_RUNNING_CODE) { | |
1176 unsigned ag_t1 = ag_sbe[(PCB).sn] + 1; | |
1177 unsigned ag_t2 = ag_sbt[(PCB).sn+1] - 1; | |
1178 do { | |
1179 unsigned ag_tx = (ag_t1 + ag_t2)/2; | |
1180 if (ag_tstt[ag_tx] < (unsigned char)(PCB).reduction_token) ag_t1 = ag_tx + 1; | |
1181 else ag_t2 = ag_tx; | |
1182 } while (ag_t1 < ag_t2); | |
1183 if (ag_tstt[ag_t1] != (PCB).reduction_token) { | |
1184 (PCB).exit_flag = AG_REDUCTION_ERROR_CODE; | |
1185 REDUCTION_TOKEN_ERROR; break;} | |
1186 (PCB).ag_ap = ag_pstt[ag_t1]; | |
1187 if ((ag_r_procs_scan[ag_astt[ag_t1]])() == 0) break; | |
1188 } | |
1189 return (PCB).exit_flag == AG_RUNNING_CODE; | |
1190 } | |
1191 | |
1192 static int near ag_action_6_proc(void) { | |
1193 int ag_sd = ag_fl[(PCB).ag_ap]; | |
1194 (PCB).reduction_token = (scr_token_type) ag_ptt[(PCB).ag_ap]; | |
1195 if ((PCB).drt == -1) { | |
1196 (PCB).drt=(PCB).token_number; | |
1197 (PCB).dssx=(PCB).ssx; | |
1198 (PCB).dsn=(PCB).sn; | |
1199 } | |
1200 if (ag_sd) { | |
1201 (PCB).sn = (PCB).ss[(PCB).ssx -= ag_sd]; | |
1202 } | |
1203 else { | |
1204 ag_prot(); | |
1205 (PCB).vs[(PCB).ssx] = ag_null_value; | |
1206 (PCB).ss[(PCB).ssx] = (PCB).sn; | |
1207 } | |
1208 while ((PCB).exit_flag == AG_RUNNING_CODE) { | |
1209 unsigned ag_t1 = ag_sbe[(PCB).sn] + 1; | |
1210 unsigned ag_t2 = ag_sbt[(PCB).sn+1] - 1; | |
1211 do { | |
1212 unsigned ag_tx = (ag_t1 + ag_t2)/2; | |
1213 if (ag_tstt[ag_tx] < (unsigned char)(PCB).reduction_token) ag_t1 = ag_tx + 1; | |
1214 else ag_t2 = ag_tx; | |
1215 } while (ag_t1 < ag_t2); | |
1216 if (ag_tstt[ag_t1] != (PCB).reduction_token) { | |
1217 (PCB).exit_flag = AG_REDUCTION_ERROR_CODE; | |
1218 REDUCTION_TOKEN_ERROR; break;} | |
1219 (PCB).ag_ap = ag_pstt[ag_t1]; | |
1220 if ((ag_r_procs_scan[ag_astt[ag_t1]])() == 0) break; | |
1221 } | |
1222 return (PCB).exit_flag == AG_RUNNING_CODE; | |
1223 } | |
1224 | |
1225 | |
1226 void init_scr(void) { | |
1227 unsigned ag_t1; | |
1228 ag_t1 = 0; | |
1229 (PCB).error_message = "Syntax Error"; | |
1230 (PCB).ss[0] = (PCB).sn = (PCB).ssx = 0; | |
1231 (PCB).exit_flag = AG_RUNNING_CODE; | |
1232 (PCB).btsx = 0, (PCB).drt = -1; | |
1233 while (ag_tstt[ag_t1] == 0) { | |
1234 (PCB).ag_ap = ag_pstt[ag_t1]; | |
1235 (ag_gt_procs_scan[ag_astt[ag_t1]])(); | |
1236 ag_t1 = ag_sbt[(PCB).sn]; | |
1237 } | |
1238 } | |
1239 | |
1240 void scr(void) { | |
1241 (PCB).token_number = (scr_token_type) AG_TCV((PCB).input_code); | |
1242 while (1) { | |
1243 unsigned ag_t1 = ag_sbt[(PCB).sn]; | |
1244 unsigned ag_t2 = ag_sbe[(PCB).sn] - 1; | |
1245 do { | |
1246 unsigned ag_tx = (ag_t1 + ag_t2)/2; | |
1247 if (ag_tstt[ag_tx] > (unsigned char)(PCB).token_number) | |
1248 ag_t1 = ag_tx + 1; | |
1249 else ag_t2 = ag_tx; | |
1250 } while (ag_t1 < ag_t2); | |
1251 if (ag_tstt[ag_t1] != (unsigned char)(PCB).token_number) | |
1252 ag_t1 = ag_sbe[(PCB).sn]; | |
1253 (PCB).ag_ap = ag_pstt[ag_t1]; | |
1254 if ((ag_gt_procs_scan[ag_astt[ag_t1]])() == 0) break; | |
1255 } | |
1256 } | |
1257 | |
1258 |