Mercurial > ~dholland > hg > ag > index.cgi
comparison tests/agcl/parsifal/good/ss-kb.cpp @ 0:13d2b8934445
Import AnaGram (near-)release tree into Mercurial.
author | David A. Holland |
---|---|
date | Sat, 22 Dec 2007 17:52:45 -0500 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:13d2b8934445 |
---|---|
1 | |
2 /* | |
3 * AnaGram, A System for Syntax Directed Programming | |
4 * File generated by: ... | |
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 #ifndef SS-KB_H | |
27 #include "ss-kb.h" | |
28 #endif | |
29 | |
30 #ifndef SS-KB_H | |
31 #error Mismatched header file | |
32 #endif | |
33 | |
34 #include <stdio.h> | |
35 | |
36 #define RULE_CONTEXT (&((PCB).cs[(PCB).ssx])) | |
37 #define ERROR_CONTEXT ((PCB).cs[(PCB).error_frame_ssx]) | |
38 #define CONTEXT ((PCB).cs[(PCB).ssx]) | |
39 | |
40 | |
41 | |
42 ss-kb_pcb_type ss-kb_pcb; | |
43 #define PCB ss-kb_pcb | |
44 #define CHANGE_REDUCTION(x) ss-kb_change_reduction(ss-kb_##x##_token) | |
45 int ss-kb_change_reduction(ss-kb_token_type); | |
46 | |
47 #define REDUCTION_CHOICES(x) ss-kb_reduction_choices(x) | |
48 int ss-kb_reduction_choices(int *ag_tp); | |
49 | |
50 /* Line -, ss-kb.syn */ | |
51 #include "ssd.h" | |
52 | |
53 char text_buffer[100]; | |
54 int text_index; | |
55 pair<int> text_cursor = {INPUT_LINE, 1}; | |
56 | |
57 #define GET_INPUT {int c;\ | |
58 PCB.input_code = ((c=getch()) != 0 ? c : getch()+256);} | |
59 | |
60 #define SYNTAX_ERROR | |
61 | |
62 #define STATUS(x,y) PCB.reduction_token = (x)?kb_##y##_token:kb_not_##y##_token | |
63 | |
64 void beep(void) { | |
65 sound(440); | |
66 delay(75); | |
67 nosound(); | |
68 } | |
69 | |
70 void accept_text(message *m, char *t) { | |
71 display_message(m); | |
72 init_text_edit(t); | |
73 } | |
74 | |
75 void backspace_char(void) { | |
76 if (text_cursor.col == 1) return; | |
77 text_cursor_left(); | |
78 delete_char(); | |
79 } | |
80 | |
81 int check_digits(void){ | |
82 char *tb = text_buffer + 1; | |
83 int n; | |
84 for (n = 0; *tb;) n = 10*n + *tb++ - '0'; | |
85 if (n > 7) CHANGE_REDUCTION(bad_digits_spec); | |
86 return n; | |
87 } | |
88 | |
89 void delete_cell(void) { | |
90 cell_pointer cp = ss[ac.ssc.row][ac.ssc.col]; | |
91 if (cp) free(cp); | |
92 ss[ac.ssc.row][ac.ssc.col] = NULL; | |
93 update_cell(ac.scc, ac.ssc); | |
94 set_active_cell(); | |
95 } | |
96 | |
97 void delete_char(void) { | |
98 strcpy(&text_buffer[text_cursor.col], &text_buffer[text_cursor.col+1]); | |
99 display_field( | |
100 text_cursor, | |
101 SCREEN_WIDTH - text_cursor.col, | |
102 LEFT, | |
103 TEXT_COLOR, | |
104 "%s", | |
105 &text_buffer[text_cursor.col] | |
106 ); | |
107 set_cursor(text_cursor); | |
108 } | |
109 | |
110 void delete_column(void) { | |
111 int i,j; | |
112 new_column = ac.ssc.col; | |
113 for (i = 0; i < MAXROWS; i++) if (ss[i][new_column]) free(ss[i][new_column]); | |
114 for (i = new_column; i < max_col; i++) | |
115 for (j = 0; j <= max_row; j++) | |
116 ss[j][i] = ss[j][i+1]; | |
117 for (j = 0; j <= max_row; j++) ss[j][max_col] = NULL; | |
118 max_col--; | |
119 inserted_columns = -1; | |
120 relabel(0,new_column); | |
121 new_column = inserted_columns = 0; | |
122 } | |
123 | |
124 void delete_row(void) { | |
125 int i,j; | |
126 new_row = ac.ssc.row; | |
127 for (i = 0; i < MAXCOLS; i++) if (ss[new_row][i]) free(ss[new_row][i]); | |
128 for (i = new_row; i < max_row; i++) | |
129 for (j = 0; j <= max_col; j++) | |
130 ss[i][j] = ss[i+1][j]; | |
131 for (j = 0; j <= max_col; j++) ss[max_row][j] = NULL; | |
132 max_row--; | |
133 inserted_rows = -1; | |
134 relabel(new_row,0); | |
135 new_row = inserted_rows = 0; | |
136 } | |
137 | |
138 void init_cell_edit(void) { | |
139 cell_pointer cp = ss[ac.ssc.row][ac.ssc.col]; | |
140 if (cp) strcpy(text_buffer+1, cp->text); | |
141 else text_buffer[1] = 0; | |
142 text_cursor.col = strlen(text_buffer+1) + 1; | |
143 textattr(TEXT_COLOR); | |
144 _setcursortype(_NORMALCURSOR); | |
145 input_msg.msg = text_buffer+1; | |
146 display_message(&input_msg); | |
147 set_cursor(text_cursor); | |
148 } | |
149 | |
150 void init_text_edit(char *c) { | |
151 if (c) strcpy(text_buffer+1, c); | |
152 text_cursor.col = strlen(text_buffer+1) + 1; | |
153 textattr(TEXT_COLOR); | |
154 _setcursortype(_NORMALCURSOR); | |
155 input_msg.msg = text_buffer+1; | |
156 display_message(&input_msg); | |
157 set_cursor(text_cursor); | |
158 } | |
159 | |
160 void init_text_input(int c) { | |
161 textattr(TEXT_COLOR); | |
162 _setcursortype(_NORMALCURSOR); | |
163 text_buffer[text_cursor.col = 1] = c; | |
164 set_cursor(text_cursor); | |
165 putch(c); | |
166 text_buffer[++text_cursor.col] = 0; | |
167 } | |
168 | |
169 void insert_char(int c){ | |
170 int n = strlen(&text_buffer[text_cursor.col]); | |
171 memmove(&text_buffer[text_cursor.col+1], &text_buffer[text_cursor.col], n+1); | |
172 text_buffer[81] = 0; | |
173 text_buffer[text_cursor.col++] = c; | |
174 putch(c); | |
175 display_field(text_cursor, n, LEFT, TEXT_COLOR, &text_buffer[text_cursor.col]); | |
176 set_cursor(text_cursor); | |
177 } | |
178 | |
179 void insert_column(void) { | |
180 int i,j; | |
181 if (max_col + 1 >= MAXCOLS) { | |
182 for (i = 0; i < MAXROWS; i++) if (ss[i][max_col]) free(ss[i][max_col]); | |
183 } | |
184 max_col++; | |
185 new_column = ac.ssc.col; | |
186 for (i = max_col; i > new_column; i--) | |
187 for (j = 0; j <= max_row; j++) | |
188 ss[j][i] = ss[j][i-1]; | |
189 for (j = 0; j < MAXROWS; j++) ss[j][new_column] = NULL; | |
190 inserted_columns = 1; | |
191 relabel(0,new_column); | |
192 new_column = inserted_columns = 0; | |
193 } | |
194 | |
195 void insert_row(void) { | |
196 int i,j; | |
197 if (max_row + 1 >= MAXROWS) { | |
198 for (i = 0; i < MAXCOLS; i++) if (ss[max_row][i]) free(ss[max_row][i]); | |
199 } | |
200 max_row++; | |
201 new_row = ac.ssc.row; | |
202 for (i = max_row; i > new_row; i--) | |
203 for (j = 0; j <= max_col; j++) | |
204 ss[i][j] = ss[i-1][j]; | |
205 for (j = 0; j < MAXCOLS; j++) ss[new_row][j] = NULL; | |
206 inserted_rows = 1; | |
207 relabel(new_row,0); | |
208 new_row = inserted_rows = 0; | |
209 } | |
210 | |
211 void recalc(void) { | |
212 int i,j; | |
213 recalc_flag = 1; | |
214 circular_flag = 0; | |
215 for (i = 0; i <= max_row; i++) for (j = 0; j <= max_col; j++) { | |
216 cell_pointer cp = ss[i][j]; | |
217 | |
218 if (cp == NULL || cp->type != formula) continue; | |
219 if (cp->recalc == recalc_count) eval(cp); | |
220 } | |
221 recalc_count += 2; | |
222 recalc_flag = 0; | |
223 update_screen(); | |
224 set_active_cell(); | |
225 } | |
226 | |
227 void relabel(int row, int col) { | |
228 int i,j; | |
229 | |
230 n_changes++; | |
231 for (i = row; i <= max_row; i++) for (j = col; j <= max_col; j++) { | |
232 cell_pointer cp = ss[i][j]; | |
233 | |
234 if (cp == NULL || cp->type != formula) continue; | |
235 relabel_formula(cp); | |
236 } | |
237 update_screen(); | |
238 set_active_cell(); | |
239 } | |
240 | |
241 void set_cell_text(void) { | |
242 char *tb = text_buffer + 1; | |
243 cell_pointer cp = realloc( | |
244 ss[ac.ssc.row][ac.ssc.col], | |
245 sizeof(cell_descriptor) + strlen(tb) | |
246 ); | |
247 n_changes++; | |
248 assert(cp); | |
249 if (ac.ssc.row > max_row) max_row = ac.ssc.row; | |
250 if (ac.ssc.col > max_col) max_col = ac.ssc.col; | |
251 strcpy(cp->text, tb); | |
252 cp->error = 0; | |
253 ss[ac.ssc.row][ac.ssc.col] = cp; | |
254 cp->recalc = recalc_count; | |
255 _setcursortype(_NOCURSOR); | |
256 eval(cp); | |
257 if (cp->type != text && autocalc_flag) recalc(); | |
258 else { | |
259 update_cell(ac.scc, ac.ssc); | |
260 set_active_cell(); | |
261 } | |
262 } | |
263 | |
264 void text_cursor_end(void) { | |
265 while (text_buffer[text_cursor.col]) { | |
266 text_cursor.col++; | |
267 } | |
268 set_cursor(text_cursor); | |
269 } | |
270 | |
271 void text_cursor_home(void) { | |
272 if (text_cursor.col == 1) return; | |
273 text_cursor.col = 1; | |
274 set_cursor(text_cursor); | |
275 } | |
276 | |
277 void text_cursor_left(void) { | |
278 if (text_cursor.col == 1) return; | |
279 text_cursor.col--; | |
280 set_cursor(text_cursor); | |
281 } | |
282 | |
283 void text_cursor_right(void) { | |
284 if (text_buffer[text_cursor.col] == 0) return; | |
285 if (text_cursor.col >= SCREEN_WIDTH) return; | |
286 text_cursor.col++; | |
287 set_cursor(text_cursor); | |
288 } | |
289 | |
290 void toggle_formula_display(void) { | |
291 formula_flag = !formula_flag; | |
292 display_message(&form_msg); | |
293 update_screen(); | |
294 set_active_cell(); | |
295 } | |
296 | |
297 | |
298 #ifndef CONVERT_CASE | |
299 #define CONVERT_CASE(c) (c) | |
300 #endif | |
301 #ifndef TAB_SPACING | |
302 #define TAB_SPACING 8 | |
303 #endif | |
304 | |
305 static void ag_rp_1(void) { | |
306 /* Line -, ss-kb.syn */ | |
307 display_message(&file_error_msg); | |
308 } | |
309 | |
310 static void ag_rp_2(void) { | |
311 /* Line -, ss-kb.syn */ | |
312 accept_text(&goto_msg,""); | |
313 } | |
314 | |
315 static void ag_rp_3(void) { | |
316 /* Line -, ss-kb.syn */ | |
317 accept_text(&load_from_msg, file_name); | |
318 } | |
319 | |
320 static void ag_rp_4(void) { | |
321 /* Line -, ss-kb.syn */ | |
322 accept_text(&nonexistent_msg, file_name); | |
323 } | |
324 | |
325 static void ag_rp_5(void) { | |
326 /* Line -, ss-kb.syn */ | |
327 display_message(&file_exists_msg); | |
328 } | |
329 | |
330 static void ag_rp_6(void) { | |
331 /* Line -, ss-kb.syn */ | |
332 display_message(&changes_msg); | |
333 } | |
334 | |
335 static void ag_rp_7(void) { | |
336 /* Line -, ss-kb.syn */ | |
337 accept_text(&save_to_msg, file_name); | |
338 } | |
339 | |
340 static void ag_rp_8(void) { | |
341 /* Line -, ss-kb.syn */ | |
342 accept_text(&print_to_msg, file_name); | |
343 } | |
344 | |
345 static void ag_rp_9(void) { | |
346 /* Line -, ss-kb.syn */ | |
347 accept_text(&block_msg,""); | |
348 } | |
349 | |
350 static void ag_rp_10(void) { | |
351 /* Line -, ss-kb.syn */ | |
352 accept_text(&decimals_msg, ""); | |
353 } | |
354 | |
355 static void ag_rp_11(void) { | |
356 /* Line -, ss-kb.syn */ | |
357 accept_text(&bad_decimals_msg,NULL); | |
358 } | |
359 | |
360 static void ag_rp_12(void) { | |
361 /* Line -, ss-kb.syn */ | |
362 update_status(); | |
363 } | |
364 | |
365 static void ag_rp_13(void) { | |
366 /* Line -, ss-kb.syn */ | |
367 recalc(); | |
368 } | |
369 | |
370 static void ag_rp_14(void) { | |
371 /* Line -, ss-kb.syn */ | |
372 toggle_formula_display(); | |
373 } | |
374 | |
375 static void ag_rp_15(void) { | |
376 /* Line -, ss-kb.syn */ | |
377 autocalc_flag = !autocalc_flag; | |
378 } | |
379 | |
380 static void ag_rp_16(void) { | |
381 /* Line -, ss-kb.syn */ | |
382 set_cell_text(); | |
383 } | |
384 | |
385 static void ag_rp_17(void) { | |
386 /* Line -, ss-kb.syn */ | |
387 delete_cell(); | |
388 } | |
389 | |
390 static void ag_rp_18(void) { | |
391 /* Line -, ss-kb.syn */ | |
392 page_up(); | |
393 } | |
394 | |
395 static void ag_rp_19(void) { | |
396 /* Line -, ss-kb.syn */ | |
397 page_down(); | |
398 } | |
399 | |
400 static void ag_rp_20(void) { | |
401 /* Line -, ss-kb.syn */ | |
402 scroll_left(); | |
403 } | |
404 | |
405 static void ag_rp_21(void) { | |
406 /* Line -, ss-kb.syn */ | |
407 scroll_right(); | |
408 } | |
409 | |
410 static void ag_rp_22(void) { | |
411 /* Line -, ss-kb.syn */ | |
412 home(); | |
413 } | |
414 | |
415 static void ag_rp_23(void) { | |
416 /* Line -, ss-kb.syn */ | |
417 end(); | |
418 } | |
419 | |
420 static void ag_rp_24(void) { | |
421 /* Line -, ss-kb.syn */ | |
422 cursor_up(); | |
423 } | |
424 | |
425 static void ag_rp_25(void) { | |
426 /* Line -, ss-kb.syn */ | |
427 cursor_down(); | |
428 } | |
429 | |
430 static void ag_rp_26(void) { | |
431 /* Line -, ss-kb.syn */ | |
432 cursor_left(); | |
433 } | |
434 | |
435 static void ag_rp_27(void) { | |
436 /* Line -, ss-kb.syn */ | |
437 cursor_right(); | |
438 } | |
439 | |
440 static void ag_rp_28(void) { | |
441 /* Line -, ss-kb.syn */ | |
442 quit(); | |
443 } | |
444 | |
445 static void ag_rp_29(void) { | |
446 /* Line -, ss-kb.syn */ | |
447 insert_column(); | |
448 } | |
449 | |
450 static void ag_rp_30(void) { | |
451 /* Line -, ss-kb.syn */ | |
452 delete_column(); | |
453 } | |
454 | |
455 static void ag_rp_31(void) { | |
456 /* Line -, ss-kb.syn */ | |
457 insert_row(); | |
458 } | |
459 | |
460 static void ag_rp_32(void) { | |
461 /* Line -, ss-kb.syn */ | |
462 delete_row(); | |
463 } | |
464 | |
465 static void ag_rp_33(void) { | |
466 /* Line -, ss-kb.syn */ | |
467 print(); | |
468 } | |
469 | |
470 static void ag_rp_34(void) { | |
471 /* Line -, ss-kb.syn */ | |
472 set_conversion(currency); | |
473 } | |
474 | |
475 static void ag_rp_35(void) { | |
476 /* Line -, ss-kb.syn */ | |
477 set_conversion(general); | |
478 } | |
479 | |
480 static void ag_rp_36(int n) { | |
481 /* Line -, ss-kb.syn */ | |
482 set_decimals(n); | |
483 } | |
484 | |
485 static void ag_rp_37(int h) { | |
486 /* Line -, ss-kb.syn */ | |
487 set_alignment(h); | |
488 } | |
489 | |
490 static int ag_rp_38(void) { | |
491 /* Line -, ss-kb.syn */ | |
492 return LEFT; | |
493 } | |
494 | |
495 static int ag_rp_39(void) { | |
496 /* Line -, ss-kb.syn */ | |
497 return CENTER; | |
498 } | |
499 | |
500 static int ag_rp_40(void) { | |
501 /* Line -, ss-kb.syn */ | |
502 return RIGHT; | |
503 } | |
504 | |
505 static int ag_rp_41(void) { | |
506 /* Line -, ss-kb.syn */ | |
507 return check_digits(); | |
508 } | |
509 | |
510 static int ag_rp_42(void) { | |
511 /* Line -, ss-kb.syn */ | |
512 return check_digits(); | |
513 } | |
514 | |
515 static void ag_rp_43(void) { | |
516 /* Line -, ss-kb.syn */ | |
517 go(); | |
518 } | |
519 | |
520 static void ag_rp_44(void) { | |
521 /* Line -, ss-kb.syn */ | |
522 accept_text(&col_width_msg,""); | |
523 } | |
524 | |
525 static void ag_rp_45(void) { | |
526 /* Line -, ss-kb.syn */ | |
527 set_column_width(); | |
528 } | |
529 | |
530 static void ag_rp_46(void) { | |
531 /* Line -, ss-kb.syn */ | |
532 parse_cell_name(); | |
533 } | |
534 | |
535 static void ag_rp_47(void) { | |
536 /* Line -, ss-kb.syn */ | |
537 parse_cell_name(); | |
538 } | |
539 | |
540 static void ag_rp_48(void) { | |
541 /* Line -, ss-kb.syn */ | |
542 ; | |
543 } | |
544 | |
545 static void ag_rp_49(void) { | |
546 /* Line -, ss-kb.syn */ | |
547 ; | |
548 } | |
549 | |
550 static void ag_rp_50(void) { | |
551 /* Line -, ss-kb.syn */ | |
552 parse_block(); | |
553 } | |
554 | |
555 static void ag_rp_51(void) { | |
556 /* Line -, ss-kb.syn */ | |
557 parse_block(); | |
558 } | |
559 | |
560 static void ag_rp_52(void) { | |
561 /* Line -, ss-kb.syn */ | |
562 ; | |
563 } | |
564 | |
565 static void ag_rp_53(void) { | |
566 /* Line -, ss-kb.syn */ | |
567 ; | |
568 } | |
569 | |
570 static void ag_rp_54(void) { | |
571 /* Line -, ss-kb.syn */ | |
572 STATUS(n_changes, changed); | |
573 } | |
574 | |
575 static void ag_rp_55(void) { | |
576 /* Line -, ss-kb.syn */ | |
577 ; | |
578 } | |
579 | |
580 static void ag_rp_56(void) { | |
581 /* Line -, ss-kb.syn */ | |
582 load_file(); | |
583 } | |
584 | |
585 static void ag_rp_57(void) { | |
586 /* Line -, ss-kb.syn */ | |
587 check_file_name(); | |
588 } | |
589 | |
590 static void ag_rp_58(void) { | |
591 /* Line -, ss-kb.syn */ | |
592 write_file(); | |
593 } | |
594 | |
595 static void ag_rp_59(void) { | |
596 /* Line -, ss-kb.syn */ | |
597 write_file(); | |
598 } | |
599 | |
600 static void ag_rp_60(void) { | |
601 /* Line -, ss-kb.syn */ | |
602 clear(); | |
603 } | |
604 | |
605 static void ag_rp_61(void) { | |
606 /* Line -, ss-kb.syn */ | |
607 display_message(&clear_spreadsheet); | |
608 } | |
609 | |
610 static void ag_rp_62(void) { | |
611 /* Line -, ss-kb.syn */ | |
612 display_menu(&main_menu); | |
613 } | |
614 | |
615 static void ag_rp_63(void) { | |
616 /* Line -, ss-kb.syn */ | |
617 display_menu(&spreadsheet_menu); | |
618 } | |
619 | |
620 static void ag_rp_64(void) { | |
621 /* Line -, ss-kb.syn */ | |
622 display_menu(&column_menu); | |
623 } | |
624 | |
625 static void ag_rp_65(void) { | |
626 /* Line -, ss-kb.syn */ | |
627 display_menu(&row_menu); | |
628 } | |
629 | |
630 static void ag_rp_66(void) { | |
631 /* Line -, ss-kb.syn */ | |
632 display_menu(&utility_menu); | |
633 } | |
634 | |
635 static void ag_rp_67(void) { | |
636 /* Line -, ss-kb.syn */ | |
637 display_menu(&format_menu); | |
638 } | |
639 | |
640 static void ag_rp_68(void) { | |
641 /* Line -, ss-kb.syn */ | |
642 display_menu(&label_menu); | |
643 } | |
644 | |
645 static void ag_rp_69(void) { | |
646 /* Line -, ss-kb.syn */ | |
647 pm_msg(); | |
648 } | |
649 | |
650 static void ag_rp_70(void) { | |
651 /* Line -, ss-kb.syn */ | |
652 print_wide = !print_wide, pm_msg(); | |
653 } | |
654 | |
655 static void ag_rp_71(void) { | |
656 /* Line -, ss-kb.syn */ | |
657 (print_border = !print_border),pm_msg(); | |
658 } | |
659 | |
660 static void ag_rp_72(void) { | |
661 /* Line -, ss-kb.syn */ | |
662 print_block=TRUE,print_from=first_cell,print_to=last_cell,pm_msg(); | |
663 } | |
664 | |
665 static void ag_rp_73(void) { | |
666 /* Line -, ss-kb.syn */ | |
667 init_cell_edit(); | |
668 } | |
669 | |
670 static void ag_rp_74(void) { | |
671 /* Line -, ss-kb.syn */ | |
672 init_cell_edit(); | |
673 } | |
674 | |
675 static void ag_rp_75(int c) { | |
676 /* Line -, ss-kb.syn */ | |
677 init_text_input(c); | |
678 } | |
679 | |
680 static void ag_rp_76(void) { | |
681 /* Line -, ss-kb.syn */ | |
682 init_text_input('ä'); | |
683 } | |
684 | |
685 static void ag_rp_77(void) { | |
686 /* Line -, ss-kb.syn */ | |
687 init_text_input('ã'); | |
688 } | |
689 | |
690 static void ag_rp_78(int c) { | |
691 /* Line -, ss-kb.syn */ | |
692 insert_char(c); | |
693 } | |
694 | |
695 static void ag_rp_79(void) { | |
696 /* Line -, ss-kb.syn */ | |
697 insert_char(228); | |
698 } | |
699 | |
700 static void ag_rp_80(void) { | |
701 /* Line -, ss-kb.syn */ | |
702 insert_char(227); | |
703 } | |
704 | |
705 static void ag_rp_81(int d) { | |
706 /* Line -, ss-kb.syn */ | |
707 insert_char(d); | |
708 } | |
709 | |
710 static void ag_rp_82(void) { | |
711 /* Line -, ss-kb.syn */ | |
712 backspace_char(); | |
713 } | |
714 | |
715 static void ag_rp_83(void) { | |
716 /* Line -, ss-kb.syn */ | |
717 delete_char(); | |
718 } | |
719 | |
720 static void ag_rp_84(void) { | |
721 /* Line -, ss-kb.syn */ | |
722 text_cursor_left(); | |
723 } | |
724 | |
725 static void ag_rp_85(void) { | |
726 /* Line -, ss-kb.syn */ | |
727 text_cursor_right(); | |
728 } | |
729 | |
730 static void ag_rp_86(void) { | |
731 /* Line -, ss-kb.syn */ | |
732 text_cursor_home(); | |
733 } | |
734 | |
735 static void ag_rp_87(void) { | |
736 /* Line -, ss-kb.syn */ | |
737 text_cursor_end(); | |
738 } | |
739 | |
740 static void ag_rp_88(void) { | |
741 /* Line -, ss-kb.syn */ | |
742 beep(); | |
743 } | |
744 | |
745 | |
746 #define READ_COUNTS | |
747 #define WRITE_COUNTS | |
748 #undef V | |
749 #define V(i,t) (*t (&(PCB).vs[(PCB).ssx + i])) | |
750 #undef VS | |
751 #define VS(i) (PCB).vs[(PCB).ssx + i] | |
752 | |
753 #ifndef GET_CONTEXT | |
754 #define GET_CONTEXT CONTEXT = (PCB).input_context | |
755 #endif | |
756 | |
757 typedef enum { | |
758 ag_action_1, | |
759 ag_action_2, | |
760 ag_action_3, | |
761 ag_action_4, | |
762 ag_action_5, | |
763 ag_action_6, | |
764 ag_action_7, | |
765 ag_action_8, | |
766 ag_action_9, | |
767 ag_action_10, | |
768 ag_action_11, | |
769 ag_action_12 | |
770 } ag_parser_action; | |
771 | |
772 | |
773 #ifndef NULL_VALUE_INITIALIZER | |
774 #define NULL_VALUE_INITIALIZER = 0 | |
775 #endif | |
776 | |
777 static int const ag_null_value NULL_VALUE_INITIALIZER; | |
778 | |
779 static const unsigned char ag_rpx[] = { | |
780 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 0, 0, 0, 13, 14, | |
781 15, 16, 0, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 0, 0, 0, 0, | |
782 28, 0, 0, 29, 30, 0, 31, 32, 0, 33, 0, 0, 0, 0, 0, 34, 35, 36, | |
783 37, 38, 39, 40, 41, 42, 0, 0, 0, 0, 43, 44, 45, 0, 46, 47, 48, 49, | |
784 50, 51, 52, 53, 0, 0, 0, 0, 0, 0, 0, 0, 54, 55, 0, 0, 56, 0, | |
785 0, 0, 0, 57, 58, 59, 0, 60, 0, 61, 62, 63, 64, 65, 66, 67, 68, 69, | |
786 70, 71, 72, 73, 74, 75, 76, 77, 0, 78, 79, 80, 0, 0, 81, 0, 82, 83, | |
787 84, 85, 86, 87, 88 | |
788 }; | |
789 #define AG_TCV(x) (((int)(x) >= 0 && (int)(x) <= 388) ? ag_tcv[(x)] : 0) | |
790 | |
791 static const unsigned char ag_tcv[] = { | |
792 16,104,104,104,104,104,104,104,103,104,104,104,104, 24,104,104, 99,104, | |
793 104, 98,104,104,104,104,104,104,104, 25,104,104,104,104,105,105,105,105, | |
794 105,105,105,105,105,105,105,105,105,105,105, 90,102,102,102,102,102,102, | |
795 102,102,102,102,105,105,105,105,105,105,105, 21, 94, 55, 46, 96, 19, 57, | |
796 105, 45,105,105, 61,105,106, 51, 92, 74, 62, 77,105, 91,105, 69,105, 82, | |
797 105,105,105,105,105,105,105, 21, 94, 55, 46, 96, 19, 57,105, 45,105,105, | |
798 61,105,106, 51, 92, 74, 62, 77,105, 91,105, 69,105, 82,105,105,105,105, | |
799 105,105,104,104,104,104,104,104,104,104,104,104,104,104,104,104,104,104, | |
800 104,104,104,104,104,104,104,104,104,104,104,104,104,104,104,104,104,104, | |
801 104,104,104,104,104,104,104,104,104,104,104,104,104,104,104,104,104,104, | |
802 104,104,104,104,104,104,104,104,104,104,104,104,104,104,104,104,104,104, | |
803 104,104,104,104,104,104,104,104,104,104,104,104,104,104,104,104,104,104, | |
804 104,104,104,104,104,104,104,104,104,104,104,104,104,104,104,104,104,104, | |
805 104,104,104,104,104,104,104,104,104,104,104,104,104,104,104,104,104,104, | |
806 104,104,104,104,104,104,104,104,104,104,104,104,104,104,104,104,104,104, | |
807 104,104,104,104,104,104,104,104,104,104,104,104,104,104,104,104,104,104, | |
808 104,104,104,104,104,104,104,104,104,104,104,104,104, 75,104,104,104,104, | |
809 104,104,104,104,104,104,104,104,104, 65, 95,104,104,104,104,104,104,104, | |
810 104,104,104, 31, 33, 27,104, 35,104, 36,104, 32, 34, 28,104, 66,104,104, | |
811 104,104,104,104,104,104,104,104,104,104,104,104,104,104,104,104,104,104, | |
812 104,104,104,104,104,104,104,104,104,104,104, 29, 30,104,104,104,104,104, | |
813 104,104,104,104,104,104,104,104,104,104,104 | |
814 }; | |
815 | |
816 #ifndef SYNTAX_ERROR | |
817 #define SYNTAX_ERROR fprintf(stderr,"%s\n", (PCB).error_message) | |
818 #endif | |
819 | |
820 #ifndef PARSER_STACK_OVERFLOW | |
821 #define PARSER_STACK_OVERFLOW {fprintf(stderr, \ | |
822 "\nParser stack overflow\n");} | |
823 #endif | |
824 | |
825 #ifndef REDUCTION_TOKEN_ERROR | |
826 #define REDUCTION_TOKEN_ERROR {fprintf(stderr, \ | |
827 "\nReduction token error\n");} | |
828 #endif | |
829 | |
830 | |
831 #ifndef GET_INPUT | |
832 #define GET_INPUT ((PCB).input_code = getchar()) | |
833 #endif | |
834 | |
835 | |
836 static void ag_prot(void) { | |
837 int ag_k; | |
838 ag_k = 128 - ++(PCB).btsx; | |
839 if (ag_k <= (PCB).ssx) { | |
840 (PCB).exit_flag = AG_STACK_ERROR_CODE; | |
841 PARSER_STACK_OVERFLOW; | |
842 return; | |
843 } | |
844 (PCB).bts[(PCB).btsx] = (PCB).sn; | |
845 (PCB).bts[ag_k] = (PCB).ssx; | |
846 (PCB).vs[ag_k] = (PCB).vs[(PCB).ssx]; | |
847 (PCB).ss[ag_k] = (PCB).ss[(PCB).ssx]; | |
848 } | |
849 | |
850 static void ag_undo(void) { | |
851 if ((PCB).drt == -1) return; | |
852 while ((PCB).btsx) { | |
853 int ag_k = 128 - (PCB).btsx; | |
854 (PCB).sn = (PCB).bts[(PCB).btsx--]; | |
855 (PCB).ssx = (PCB).bts[ag_k]; | |
856 (PCB).vs[(PCB).ssx] = (PCB).vs[ag_k]; | |
857 (PCB).ss[(PCB).ssx] = (PCB).ss[ag_k]; | |
858 } | |
859 (PCB).token_number = (ss-kb_token_type) (PCB).drt; | |
860 (PCB).ssx = (PCB).dssx; | |
861 (PCB).sn = (PCB).dsn; | |
862 (PCB).drt = -1; | |
863 } | |
864 | |
865 | |
866 | |
867 static const int ag_rtt[] = { | |
868 58, 63, 0, 58, 63, 0, 47, 68, 0, 67, 70, 0, 67, 70, 0, 67, 70, 0, | |
869 67, 70, 0, 56, 71, 0, 56, 71, 0, 56, 71, 0, 56, 71, 0, 80, 79, 0, | |
870 86, 85, 0, 84, 87, 0, 84, 87, 0 | |
871 }; | |
872 | |
873 static const unsigned char ag_tstt[] = { | |
874 106,105,102,99,98,96,95,94,92,91,90,82,77,75,74,69,66,65,62,61,57,55,51,46, | |
875 45,42,36,35,34,33,32,31,30,29,28,27,21,19,0,12,13,14,15,17,18,20,22,26, | |
876 37,38,39,40,41,43,44,47,48,49,50,53,54,59,68,72,89, | |
877 103,102,66,36,35,32,31,25,24,0,64, | |
878 106,105,104,103,102,99,98,96,95,94,92,91,90,82,77,75,74,69,66,65,62,61,57, | |
879 55,51,46,45,36,35,34,33,32,31,30,29,28,27,25,24,21,19,16,0,73,79,80,83, | |
880 62,61,55,0,60, | |
881 61,57,55,19,0, | |
882 106,105,104,103,102,99,98,96,95,94,92,91,90,82,77,75,74,69,66,65,62,61,57, | |
883 55,51,46,45,36,35,34,33,32,31,30,29,28,27,25,24,21,19,16,0, | |
884 92,77,61,55,0, | |
885 106,94,69,61,51,0, | |
886 25,0, | |
887 46,45,0, | |
888 69,46,45,0, | |
889 106,105,103,102,99,98,96,94,92,91,90,82,77,74,69,66,62,61,57,55,51,46,45,36, | |
890 35,32,31,25,24,21,19,0,23, | |
891 96,91,77,74,62,57,55,46,21,19,0, | |
892 62,19,0, | |
893 106,105,102,99,98,96,95,94,92,91,90,82,77,75,74,69,66,65,62,61,57,55,51,46, | |
894 45,42,36,35,34,33,32,31,30,29,28,27,21,19,16,0,13,14,17,18,20,22,26,37, | |
895 38,39,40,41,43,44,47,48,49,50,53,54,59,68,72,89, | |
896 103,102,66,42,36,35,32,31,25,24,0,101, | |
897 106,105,104,103,102,99,98,96,95,94,92,91,90,82,77,75,74,69,66,65,62,61,57, | |
898 55,51,46,45,36,35,34,33,32,31,30,29,28,27,25,24,21,19,16,0,6, | |
899 106,105,103,102,99,98,96,94,92,91,90,82,77,74,69,66,62,61,57,55,51,46,45,36, | |
900 35,32,31,25,24,21,19,0,9,56,71, | |
901 103,102,66,36,35,32,31,24,0,10,58,63, | |
902 106,105,103,102,99,98,96,94,92,91,90,82,77,74,69,66,62,61,57,55,51,46,45,36, | |
903 35,32,31,25,24,21,19,0,9,56,71, | |
904 106,105,103,102,99,98,96,94,92,91,90,82,77,74,69,66,62,61,57,55,51,46,45,36, | |
905 35,32,31,25,24,21,19,0,9,56,71, | |
906 106,105,103,102,99,98,96,94,92,91,90,82,77,74,69,66,62,61,57,55,51,46,45,36, | |
907 35,32,31,24,21,19,0,7,78, | |
908 106,105,104,103,102,99,98,96,95,94,92,91,90,82,77,75,74,69,66,65,62,61,57, | |
909 55,51,46,45,36,35,34,33,32,31,30,29,28,27,25,24,21,19,16,0,73,79,80,83, | |
910 106,105,103,102,99,98,96,94,92,91,90,82,77,74,69,66,62,61,57,55,51,46,45,36, | |
911 35,32,31,25,24,21,19,0,9,56,71, | |
912 106,105,103,102,99,98,96,94,92,91,90,82,77,74,69,66,62,61,57,55,51,46,45,36, | |
913 35,32,31,24,21,19,0,8,52, | |
914 106,105,103,102,99,98,96,94,92,91,90,82,77,74,69,66,62,61,57,55,51,46,45,42, | |
915 36,35,32,31,25,24,21,19,0,101, | |
916 106,105,103,102,99,98,96,94,92,91,90,82,77,74,69,66,62,61,57,55,51,46,45,36, | |
917 35,32,31,25,24,21,19,0,2, | |
918 106,105,104,103,102,99,98,96,95,94,92,91,90,82,77,75,74,69,66,65,62,61,57, | |
919 55,51,46,45,36,35,34,33,32,31,30,29,28,27,25,24,21,19,16,0, | |
920 106,105,103,102,99,98,96,94,92,91,90,82,77,74,69,66,62,61,57,55,51,46,45,36, | |
921 35,32,31,25,24,21,19,0,23, | |
922 106,105,103,102,99,98,96,94,92,91,90,82,77,74,69,66,62,61,57,55,51,46,45,36, | |
923 35,32,31,25,24,21,19,0,23, | |
924 103,102,66,36,35,32,31,24,0,11, | |
925 103,102,66,36,35,32,31,24,0,64, | |
926 106,105,103,102,99,98,96,94,92,91,90,82,77,74,69,66,62,61,57,55,51,46,45,36, | |
927 35,32,31,25,24,21,19,0,9,56,71, | |
928 106,105,103,102,99,98,96,94,92,91,90,82,77,74,69,66,62,61,57,55,51,46,45,36, | |
929 35,32,31,24,21,19,0,23,84,85,86,87, | |
930 106,105,103,102,99,98,96,94,92,91,90,82,77,74,69,66,62,61,57,55,51,46,45,36, | |
931 35,32,31,24,21,19,0,3,76, | |
932 106,105,103,102,99,98,96,94,92,91,90,82,77,74,69,66,62,61,57,55,51,46,45,36, | |
933 35,32,31,24,21,19,0,23,85,86, | |
934 106,105,103,102,99,98,96,94,92,91,90,82,77,74,69,66,62,61,57,55,51,46,45,36, | |
935 35,32,31,25,24,21,19,0,23,67,70, | |
936 106,105,103,102,99,98,96,94,92,91,90,82,77,74,69,66,62,61,57,55,51,46,45,36, | |
937 35,32,31,24,21,19,0,7,78, | |
938 106,105,103,102,99,98,96,94,92,91,90,82,77,74,69,66,62,61,57,55,51,46,45,42, | |
939 36,35,32,31,25,24,21,19,0,101, | |
940 106,105,103,102,99,98,96,94,92,91,90,82,77,74,69,66,62,61,57,55,51,46,45,42, | |
941 36,35,32,31,25,24,21,19,0,101, | |
942 103,102,66,36,35,32,31,24,0,64, | |
943 103,102,66,42,36,35,32,31,24,0,101, | |
944 106,105,103,102,99,98,96,94,92,91,90,82,77,74,69,66,62,61,57,55,51,46,45,42, | |
945 36,35,32,31,24,21,19,0,101, | |
946 0,1, | |
947 106,105,104,103,102,99,98,96,95,94,92,91,90,82,77,75,74,69,66,65,62,61,57, | |
948 55,51,46,45,36,35,34,33,32,31,30,29,28,27,25,24,21,19,16,0,5, | |
949 106,105,103,102,99,98,96,94,92,91,90,82,77,74,69,66,62,61,57,55,51,46,45,36, | |
950 35,32,31,24,21,19,0,23,85,86, | |
951 106,105,104,103,102,99,98,96,95,94,92,91,90,82,77,75,74,69,66,65,62,61,57, | |
952 55,51,46,45,36,35,34,33,32,31,30,29,28,27,25,24,21,19,16,0,5, | |
953 106,105,103,102,99,98,96,94,92,91,90,82,77,74,69,66,62,61,57,55,51,46,45,36, | |
954 35,32,31,25,24,21,19,0,23, | |
955 106,105,103,102,99,98,96,94,92,91,90,82,77,74,69,66,62,61,57,55,51,46,45,42, | |
956 36,35,32,31,25,24,21,19,0,101, | |
957 103,102,66,42,36,35,32,31,24,0,101, | |
958 106,105,104,103,102,99,98,96,95,94,92,91,90,82,77,75,74,69,66,65,62,61,57, | |
959 55,51,46,45,36,35,34,33,32,31,30,29,28,27,25,24,21,19,0, | |
960 106,105,104,103,102,99,98,96,95,94,92,91,90,82,77,75,74,69,66,65,62,61,57, | |
961 55,51,46,45,36,35,34,33,32,31,30,29,28,27,25,24,21,19,16,0, | |
962 106,105,103,102,99,98,96,94,92,91,90,82,77,74,69,66,62,61,57,55,51,46,45,36, | |
963 35,32,31,24,21,19,0,4, | |
964 106,105,104,103,102,99,98,96,95,94,92,91,90,82,77,75,74,69,66,65,62,61,57, | |
965 55,51,46,45,36,35,34,33,32,31,30,29,28,27,25,24,21,19,16,0, | |
966 106,105,103,102,99,98,96,94,92,91,90,82,77,74,69,66,62,61,57,55,51,46,45,42, | |
967 36,35,32,31,25,24,21,19,0,101, | |
968 106,105,103,102,99,98,96,94,92,91,90,82,77,74,69,66,62,61,57,55,51,46,45,36, | |
969 35,32,31,24,21,19,0,7,78, | |
970 106,105,103,102,99,98,96,94,92,91,90,82,77,74,69,66,62,61,57,55,51,46,45,36, | |
971 35,32,31,24,21,19,0,3,76, | |
972 106,105,103,102,99,98,96,94,92,91,90,82,77,74,69,66,62,61,57,55,51,46,45,36, | |
973 35,32,31,24,21,19,0,8,52, | |
974 | |
975 }; | |
976 | |
977 | |
978 static unsigned const char ag_astt[1647] = { | |
979 2,2,2,2,2,2,2,2,2,2,2,2,2,1,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2, | |
980 2,7,0,2,1,1,2,1,1,1,2,2,2,2,2,2,2,1,2,1,1,1,1,1,1,1,1,1,8,8,8,8,8,8,8,8,8, | |
981 7,1,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4, | |
982 4,4,4,4,4,4,4,7,3,3,1,2,2,2,2,7,1,2,1,1,1,7,3,3,3,3,3,3,3,3,3,3,3,3,3,2,3, | |
983 3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,7,2,1,1,2,5,10,1,10, | |
984 10,1,7,3,7,2,2,5,2,2,2,5,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8, | |
985 8,8,8,8,8,8,7,1,2,2,2,3,2,1,2,3,2,2,5,3,2,5,2,2,2,2,2,2,2,2,2,2,2,2,2,1,2, | |
986 2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,3,7,2,3,2,1,1,1,2,2,2,2,2,2, | |
987 2,1,2,1,1,1,1,1,1,1,1,1,2,10,2,2,2,2,2,2,3,2,7,3,4,4,4,4,4,4,4,4,4,4,4,4,4, | |
988 4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,7,1,4,4,4,4,4,4, | |
989 4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,7,1,2,1,4,4,4,4,4,4,4,4, | |
990 7,1,1,1,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,7,1, | |
991 2,1,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,7,1,2,1, | |
992 4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,7,1,3,4,4,4,4, | |
993 4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4, | |
994 4,7,1,1,1,2,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4, | |
995 7,1,2,1,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,7,1,2, | |
996 10,10,2,10,10,10,10,10,10,10,10,10,10,10,10,2,10,10,10,10,10,10,10,2,2,2,2, | |
997 2,3,2,10,10,7,3,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4, | |
998 4,4,7,1,3,3,3,3,3,3,3,3,3,3,3,3,3,1,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3, | |
999 3,3,3,3,3,3,3,3,3,7,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8, | |
1000 8,8,8,8,7,1,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8, | |
1001 7,1,4,4,4,4,4,4,4,4,7,1,8,8,8,8,8,8,8,8,7,1,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4, | |
1002 4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,7,1,2,1,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8, | |
1003 8,8,8,8,8,8,8,8,8,8,8,8,8,7,1,3,1,2,1,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4, | |
1004 4,4,4,4,4,4,4,4,4,4,4,4,7,1,3,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8, | |
1005 8,8,8,8,8,8,8,8,7,1,1,3,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8, | |
1006 8,8,8,8,8,8,7,1,2,1,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4, | |
1007 4,4,4,7,1,3,10,10,2,10,10,10,10,10,10,10,10,10,10,10,10,2,10,10,10,10,10, | |
1008 10,10,2,2,2,2,2,2,2,10,10,7,3,10,10,2,10,10,10,10,10,10,10,10,10,10,10,10, | |
1009 2,10,10,10,10,10,10,10,2,2,2,2,2,2,2,10,10,7,3,8,8,8,8,8,8,8,8,7,1,2,10,2, | |
1010 2,2,2,2,2,2,7,3,10,10,2,10,10,10,10,10,10,10,10,10,10,10,10,2,10,10,10,10, | |
1011 10,10,10,2,2,2,2,2,2,10,10,7,3,7,1,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4, | |
1012 4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,7,1,8,8,8,8,8,8,8,8,8,8,8,8,8, | |
1013 8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,7,1,2,1,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4, | |
1014 4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,7,1,8,8,8,8,8,8,8,8,8, | |
1015 8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,7,1,10,10,2,10,10,10,10,10,10, | |
1016 10,10,10,10,10,10,2,10,10,10,10,10,10,10,2,2,2,2,2,2,2,10,10,7,3,2,10,2,2, | |
1017 2,2,2,2,2,7,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3, | |
1018 3,3,3,3,3,3,3,3,3,3,3,7,1,1,1,1,1,1,1,1,1,1,1,1,1,2,1,1,1,1,1,1,1,1,1,1,1, | |
1019 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,7,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4, | |
1020 4,4,4,4,4,4,4,4,4,4,4,7,1,1,1,1,1,1,1,1,1,1,1,1,1,1,3,1,1,1,1,1,1,1,1,1,1, | |
1021 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,7,10,10,2,10,10,10,10,10,10,10,10,10, | |
1022 10,10,10,2,10,10,10,10,10,10,10,2,2,2,2,2,2,2,10,10,7,3,4,4,4,4,4,4,4,4,4, | |
1023 4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,7,1,3,4,4,4,4,4,4,4,4,4,4,4,4,4, | |
1024 4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,7,1,3,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4, | |
1025 4,4,4,4,4,4,4,4,4,4,4,4,4,7,1,3 | |
1026 }; | |
1027 | |
1028 | |
1029 static const unsigned char ag_pstt[] = { | |
1030 113,113,113,115,114,113,111,113,113,113,100,113,113,2,113,113,21,16,113,113, | |
1031 113,113,113,113,113,12,31,30,29,28,27,26,25,24,23,22,113,113,0,0,12,14, | |
1032 14,16,13,12,11,21,12,12,12,12,36,12,10,12,9,8,7,6,4,3,1,2,5, | |
1033 15,15,15,15,15,15,15,15,15,1,15, | |
1034 84,84,84,84,84,84,84,84,84,84,84,84,84,84,84,84,84,84,84,84,84,84,84,84,84, | |
1035 84,84,84,84,84,84,84,84,84,84,84,84,84,84,84,84,84,2,76,76,16,85, | |
1036 57,55,56,3,17, | |
1037 106,19,20,18,4, | |
1038 98,98,98,98,98,98,98,98,98,98,98,98,98,97,98,98,98,98,98,98,98,98,98,98,98, | |
1039 98,98,98,98,98,98,98,98,98,98,98,98,98,98,98,98,98,5, | |
1040 107,21,22,99,47, | |
1041 108,23,108,109,24,7, | |
1042 44,8, | |
1043 43,42,50, | |
1044 65,40,39,49, | |
1045 25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25, | |
1046 25,25,25,25,25,25,11,25, | |
1047 112,104,101,77,103,26,102,63,18,105,46, | |
1048 61,17,48, | |
1049 113,113,113,115,114,113,111,113,113,113,100,113,113,2,113,113,21,16,113,113, | |
1050 113,113,113,113,113,12,31,30,29,28,27,26,25,24,23,22,113,113,15,14,12, | |
1051 14,16,13,12,11,21,12,12,12,12,36,12,10,12,9,8,7,6,4,3,1,2,5, | |
1052 124,122,125,130,127,126,129,128,67,66,15,123, | |
1053 6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6, | |
1054 6,6,6,6,16,27, | |
1055 9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,17,29,54,28, | |
1056 10,10,10,10,10,10,10,10,18,31,32,30, | |
1057 9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,19,29,52,28, | |
1058 9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,20,29,51,28, | |
1059 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,21,33,80, | |
1060 84,84,84,84,84,84,84,84,84,84,84,84,84,84,84,84,84,84,84,84,84,84,84,84,84, | |
1061 84,84,84,84,84,84,84,84,84,84,84,84,84,84,84,84,84,22,34,34,16,85, | |
1062 9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,23,29,110,28, | |
1063 8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,24,35,45, | |
1064 117,117,124,117,119,118,117,117,117,117,117,117,117,117,117,125,117,117,117, | |
1065 117,117,117,117,130,127,126,129,128,20,19,117,117,25,120, | |
1066 2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,26,36, | |
1067 82,82,82,82,82,82,82,82,82,82,82,82,82,37,82,82,82,82,82,82,82,82,82,82,82, | |
1068 82,82,82,82,82,82,82,82,82,82,82,82,82,82,82,82,82,27, | |
1069 38,38,38,38,38,38,38,38,38,38,38,38,38,38,38,38,38,38,38,38,38,38,38,38,38, | |
1070 38,38,38,38,38,38,28,38, | |
1071 39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39,39, | |
1072 39,39,39,39,39,39,29,39, | |
1073 11,11,11,11,11,11,11,11,30,40, | |
1074 41,41,41,41,41,41,41,41,31,41, | |
1075 9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,32,29,53,28, | |
1076 42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42, | |
1077 42,42,42,42,42,33,42,86,44,94,43, | |
1078 3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,34,45,79, | |
1079 42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42, | |
1080 42,42,42,42,42,35,42,46,90, | |
1081 48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48, | |
1082 48,48,48,48,48,48,36,48,64,47, | |
1083 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,37,33,83, | |
1084 117,117,124,117,119,118,117,117,117,117,117,117,117,117,117,125,117,117,117, | |
1085 117,117,117,117,130,127,126,129,128,75,74,117,117,38,120, | |
1086 117,117,124,117,119,118,117,117,117,117,117,117,117,117,117,125,117,117,117, | |
1087 117,117,117,117,130,127,126,129,128,73,72,117,117,39,120, | |
1088 49,49,49,49,49,49,49,49,40,49, | |
1089 124,122,125,130,127,126,129,128,58,41,123, | |
1090 117,117,124,117,119,118,117,117,117,117,117,117,117,117,117,125,117,117,117, | |
1091 117,117,117,117,130,127,126,129,128,93,117,117,42,120, | |
1092 43,50, | |
1093 5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5, | |
1094 5,5,5,5,44,51, | |
1095 42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42, | |
1096 42,42,42,42,42,45,42,88,52, | |
1097 5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5, | |
1098 5,5,5,5,46,53, | |
1099 54,54,54,54,54,54,54,54,54,54,54,54,54,54,54,54,54,54,54,54,54,54,54,54,54, | |
1100 54,54,54,54,54,54,47,54, | |
1101 117,117,124,117,119,118,117,117,117,117,117,117,117,117,117,125,117,117,117, | |
1102 117,117,117,117,130,127,126,129,128,69,68,117,117,48,120, | |
1103 124,122,125,130,127,126,129,128,59,49,123, | |
1104 96,96,96,96,96,96,96,96,96,96,96,96,96,96,96,96,96,96,96,96,96,96,96,96,96, | |
1105 96,96,96,96,96,96,96,96,96,96,96,96,96,96,96,96,50, | |
1106 55,55,55,55,55,55,55,55,55,55,55,55,55,95,55,55,55,55,55,55,55,55,55,55,55, | |
1107 55,55,55,55,55,55,55,55,55,55,55,55,55,55,55,55,55,51, | |
1108 4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,52,56, | |
1109 57,57,57,57,57,57,57,57,57,57,57,57,57,91,57,57,57,57,57,57,57,57,57,57,57, | |
1110 57,57,57,57,57,57,57,57,57,57,57,57,57,57,57,57,57,53, | |
1111 117,117,124,117,119,118,117,117,117,117,117,117,117,117,117,125,117,117,117, | |
1112 117,117,117,117,130,127,126,129,128,71,70,117,117,54,120, | |
1113 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,55,33,87, | |
1114 3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,56,45,89, | |
1115 8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,57,35,92, | |
1116 | |
1117 }; | |
1118 | |
1119 | |
1120 static const unsigned short ag_sbt[] = { | |
1121 0, 65, 76, 123, 128, 133, 176, 181, 187, 189, 192, 196, 229, 240, | |
1122 243, 307, 319, 363, 398, 410, 445, 480, 513, 560, 595, 628, 662, 695, | |
1123 738, 771, 804, 814, 824, 859, 895, 928, 962, 997,1030,1064,1098,1108, | |
1124 1119,1152,1154,1198,1232,1276,1309,1343,1354,1396,1439,1471,1514,1548, | |
1125 1581,1614,1647 | |
1126 }; | |
1127 | |
1128 | |
1129 static const unsigned short ag_sbe[] = { | |
1130 38, 74, 118, 126, 132, 175, 180, 186, 188, 191, 195, 227, 239, 242, | |
1131 282, 317, 361, 394, 406, 441, 476, 510, 555, 591, 625, 660, 693, 737, | |
1132 769, 802, 812, 822, 855, 889, 925, 958, 993,1027,1062,1096,1106,1117, | |
1133 1150,1152,1196,1228,1274,1307,1341,1352,1395,1438,1469,1513,1546,1578, | |
1134 1611,1644,1647 | |
1135 }; | |
1136 | |
1137 | |
1138 static const unsigned char ag_fl[] = { | |
1139 1,0,0,0,0,0,0,0,0,0,0,0,1,1,2,2,1,2,2,3,3,1,1,1,1,1,1,1,1,1,1,1,1,1,1, | |
1140 1,1,1,1,2,2,1,2,2,2,3,1,1,1,1,1,3,3,4,3,1,1,1,3,4,1,2,1,2,4,2,3,3,2,2, | |
1141 3,3,3,3,3,3,2,2,1,4,3,1,3,4,0,1,2,5,2,4,2,4,5,2,1,3,3,2,2,2,1,2,2,2,2, | |
1142 2,2,2,2,2,3,1,2,1,1,1,0,2,2,2,2,0,2,2,1,1,1,1,1,1,1 | |
1143 }; | |
1144 | |
1145 static const unsigned char ag_ptt[] = { | |
1146 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 14, 15, 15, 12, 13, 13, | |
1147 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, | |
1148 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 49, 49, 49, 49, 49, 40, 40, 40, | |
1149 40, 60, 60, 60, 58, 58, 17, 17, 26, 26, 43, 68, 47, 47, 67, 67, 67, 67, | |
1150 56, 56, 56, 56, 41, 72, 72, 37, 38, 73, 73, 73, 83, 80, 78, 78, 76, 76, | |
1151 52, 52, 52, 86, 84, 84, 84, 39, 39, 89, 20, 53, 44, 48, 18, 54, 59, 50, | |
1152 50, 50, 50, 22, 22, 22, 22, 22, 23, 23, 23, 23, 23, 64, 64, 64,101,101, | |
1153 101,101,101,101,101 | |
1154 }; | |
1155 | |
1156 static const unsigned char *ag_valid(int ag_k) { | |
1157 const unsigned char *ag_tp = &ag_tstt[ag_sbt[(PCB).sn+1]]; | |
1158 while (*--ag_tp != (unsigned char) ag_k) if (*ag_tp == 0) return NULL; | |
1159 return ag_tp; | |
1160 } | |
1161 | |
1162 int ss-kb_change_reduction(ss-kb_token_type ag_k) { | |
1163 if (!ag_valid(ag_k)) return 0; | |
1164 (PCB).reduction_token = ag_k; | |
1165 return 1; | |
1166 } | |
1167 | |
1168 static void ag_default(const int *ag_tp) { | |
1169 (PCB).ag_dsn = (PCB).sn; | |
1170 (PCB).ag_dtl = ag_tp; | |
1171 while (!ag_valid((ss-kb_token_type) *ag_tp)) ag_tp++; | |
1172 (PCB).reduction_token = (ss-kb_token_type) *ag_tp; | |
1173 } | |
1174 | |
1175 | |
1176 int ss-kb_reduction_choices(int *ag_tp) { | |
1177 int ag_k, ag_n; | |
1178 if ((PCB).ag_dsn != (PCB).sn) { | |
1179 *ag_tp = ag_ptt[(PCB).ag_ap]; | |
1180 return 1; | |
1181 } | |
1182 for (ag_k = ag_n = 0; (PCB).ag_dtl[ag_k]; ag_k++) { | |
1183 if (!ag_valid((ss-kb_token_type) (PCB).ag_dtl[ag_k])) continue; | |
1184 ag_tp[ag_n++] = (PCB).ag_dtl[ag_k]; | |
1185 } | |
1186 return ag_n; | |
1187 } | |
1188 | |
1189 | |
1190 | |
1191 static void ag_ra(void) | |
1192 { | |
1193 switch(ag_rpx[(PCB).ag_ap]) { | |
1194 case 1: ag_rp_1(); break; | |
1195 case 2: ag_rp_2(); break; | |
1196 case 3: ag_rp_3(); break; | |
1197 case 4: ag_rp_4(); break; | |
1198 case 5: ag_rp_5(); break; | |
1199 case 6: ag_rp_6(); break; | |
1200 case 7: ag_rp_7(); break; | |
1201 case 8: ag_rp_8(); break; | |
1202 case 9: ag_rp_9(); break; | |
1203 case 10: ag_rp_10(); break; | |
1204 case 11: ag_rp_11(); break; | |
1205 case 12: ag_rp_12(); break; | |
1206 case 13: ag_rp_13(); break; | |
1207 case 14: ag_rp_14(); break; | |
1208 case 15: ag_rp_15(); break; | |
1209 case 16: ag_rp_16(); break; | |
1210 case 17: ag_rp_17(); break; | |
1211 case 18: ag_rp_18(); break; | |
1212 case 19: ag_rp_19(); break; | |
1213 case 20: ag_rp_20(); break; | |
1214 case 21: ag_rp_21(); break; | |
1215 case 22: ag_rp_22(); break; | |
1216 case 23: ag_rp_23(); break; | |
1217 case 24: ag_rp_24(); break; | |
1218 case 25: ag_rp_25(); break; | |
1219 case 26: ag_rp_26(); break; | |
1220 case 27: ag_rp_27(); break; | |
1221 case 28: ag_rp_28(); break; | |
1222 case 29: ag_rp_29(); break; | |
1223 case 30: ag_rp_30(); break; | |
1224 case 31: ag_rp_31(); break; | |
1225 case 32: ag_rp_32(); break; | |
1226 case 33: ag_rp_33(); break; | |
1227 case 34: ag_rp_34(); break; | |
1228 case 35: ag_rp_35(); break; | |
1229 case 36: ag_rp_36(VS(2)); break; | |
1230 case 37: ag_rp_37(VS(1)); break; | |
1231 case 38: VS(0) = ag_rp_38(); break; | |
1232 case 39: VS(0) = ag_rp_39(); break; | |
1233 case 40: VS(0) = ag_rp_40(); break; | |
1234 case 41: ag_default(&ag_rtt[0]); VS(0) = ag_rp_41(); break; | |
1235 case 42: ag_default(&ag_rtt[3]); VS(0) = ag_rp_42(); break; | |
1236 case 43: ag_rp_43(); break; | |
1237 case 44: ag_rp_44(); break; | |
1238 case 45: ag_default(&ag_rtt[6]); ag_rp_45(); break; | |
1239 case 46: ag_default(&ag_rtt[9]); ag_rp_46(); break; | |
1240 case 47: ag_default(&ag_rtt[12]); ag_rp_48(); break; | |
1241 case 48: ag_default(&ag_rtt[15]); ag_rp_47(); break; | |
1242 case 49: ag_default(&ag_rtt[18]); ag_rp_49(); break; | |
1243 case 50: ag_default(&ag_rtt[21]); ag_rp_50(); break; | |
1244 case 51: ag_default(&ag_rtt[24]); ag_rp_52(); break; | |
1245 case 52: ag_default(&ag_rtt[27]); ag_rp_51(); break; | |
1246 case 53: ag_default(&ag_rtt[30]); ag_rp_53(); break; | |
1247 case 54: ag_rp_54(); break; | |
1248 case 55: ag_default(&ag_rtt[33]); ag_rp_55(); break; | |
1249 case 56: ag_rp_56(); break; | |
1250 case 57: ag_default(&ag_rtt[36]); ag_rp_57(); break; | |
1251 case 58: ag_default(&ag_rtt[39]); ag_rp_58(); break; | |
1252 case 59: ag_default(&ag_rtt[42]); ag_rp_59(); break; | |
1253 case 60: ag_rp_60(); break; | |
1254 case 61: ag_rp_61(); break; | |
1255 case 62: ag_rp_62(); break; | |
1256 case 63: ag_rp_63(); break; | |
1257 case 64: ag_rp_64(); break; | |
1258 case 65: ag_rp_65(); break; | |
1259 case 66: ag_rp_66(); break; | |
1260 case 67: ag_rp_67(); break; | |
1261 case 68: ag_rp_68(); break; | |
1262 case 69: ag_rp_69(); break; | |
1263 case 70: ag_rp_70(); break; | |
1264 case 71: ag_rp_71(); break; | |
1265 case 72: ag_rp_72(); break; | |
1266 case 73: ag_rp_73(); break; | |
1267 case 74: ag_rp_74(); break; | |
1268 case 75: ag_rp_75(VS(0)); break; | |
1269 case 76: ag_rp_76(); break; | |
1270 case 77: ag_rp_77(); break; | |
1271 case 78: ag_rp_78(VS(1)); break; | |
1272 case 79: ag_rp_79(); break; | |
1273 case 80: ag_rp_80(); break; | |
1274 case 81: ag_rp_81(VS(1)); break; | |
1275 case 82: ag_rp_82(); break; | |
1276 case 83: ag_rp_83(); break; | |
1277 case 84: ag_rp_84(); break; | |
1278 case 85: ag_rp_85(); break; | |
1279 case 86: ag_rp_86(); break; | |
1280 case 87: ag_rp_87(); break; | |
1281 case 88: ag_rp_88(); break; | |
1282 } | |
1283 } | |
1284 | |
1285 static int ag_action_1_r_proc(void); | |
1286 static int ag_action_2_r_proc(void); | |
1287 static int ag_action_3_r_proc(void); | |
1288 static int ag_action_4_r_proc(void); | |
1289 static int ag_action_1_s_proc(void); | |
1290 static int ag_action_3_s_proc(void); | |
1291 static int ag_action_1_proc(void); | |
1292 static int ag_action_2_proc(void); | |
1293 static int ag_action_3_proc(void); | |
1294 static int ag_action_4_proc(void); | |
1295 static int ag_action_5_proc(void); | |
1296 static int ag_action_6_proc(void); | |
1297 static int ag_action_7_proc(void); | |
1298 static int ag_action_8_proc(void); | |
1299 static int ag_action_9_proc(void); | |
1300 static int ag_action_10_proc(void); | |
1301 static int ag_action_11_proc(void); | |
1302 static int ag_action_8_proc(void); | |
1303 | |
1304 | |
1305 static int (*const ag_r_procs_scan[])(void) = { | |
1306 ag_action_1_r_proc, | |
1307 ag_action_2_r_proc, | |
1308 ag_action_3_r_proc, | |
1309 ag_action_4_r_proc | |
1310 }; | |
1311 | |
1312 static int (*const ag_s_procs_scan[])(void) = { | |
1313 ag_action_1_s_proc, | |
1314 ag_action_2_r_proc, | |
1315 ag_action_3_s_proc, | |
1316 ag_action_4_r_proc | |
1317 }; | |
1318 | |
1319 static int (*const ag_gt_procs_scan[])(void) = { | |
1320 ag_action_1_proc, | |
1321 ag_action_2_proc, | |
1322 ag_action_3_proc, | |
1323 ag_action_4_proc, | |
1324 ag_action_5_proc, | |
1325 ag_action_6_proc, | |
1326 ag_action_7_proc, | |
1327 ag_action_8_proc, | |
1328 ag_action_9_proc, | |
1329 ag_action_10_proc, | |
1330 ag_action_11_proc, | |
1331 ag_action_8_proc | |
1332 }; | |
1333 | |
1334 | |
1335 static int ag_action_1_er_proc(void); | |
1336 static int ag_action_2_er_proc(void); | |
1337 static int ag_action_3_er_proc(void); | |
1338 static int ag_action_4_er_proc(void); | |
1339 | |
1340 static int (*const ag_er_procs_scan[])(void) = { | |
1341 ag_action_1_er_proc, | |
1342 ag_action_2_er_proc, | |
1343 ag_action_3_er_proc, | |
1344 ag_action_4_er_proc | |
1345 }; | |
1346 | |
1347 | |
1348 static void ag_error_resynch(void) { | |
1349 int ag_k; | |
1350 int ag_ssx = (PCB).ssx; | |
1351 | |
1352 SYNTAX_ERROR; | |
1353 if ((PCB).exit_flag != AG_RUNNING_CODE) return; | |
1354 while (1) { | |
1355 ag_k = ag_sbt[(PCB).sn]; | |
1356 while (ag_tstt[ag_k] != 42 && ag_tstt[ag_k]) ag_k++; | |
1357 if (ag_tstt[ag_k] || (PCB).ssx == 0) break; | |
1358 (PCB).sn = (PCB).ss[--(PCB).ssx]; | |
1359 } | |
1360 if (ag_tstt[ag_k] == 0) { | |
1361 (PCB).sn = PCB.ss[(PCB).ssx = ag_ssx]; | |
1362 (PCB).exit_flag = AG_SYNTAX_ERROR_CODE; | |
1363 return; | |
1364 } | |
1365 ag_k = ag_sbt[(PCB).sn]; | |
1366 while (ag_tstt[ag_k] != 42 && ag_tstt[ag_k]) ag_k++; | |
1367 (PCB).ag_ap = ag_pstt[ag_k]; | |
1368 (ag_er_procs_scan[ag_astt[ag_k]])(); | |
1369 while (1) { | |
1370 ag_k = ag_sbt[(PCB).sn]; | |
1371 while (ag_tstt[ag_k] != (unsigned char) (PCB).token_number && ag_tstt[ag_k]) | |
1372 ag_k++; | |
1373 if (ag_tstt[ag_k] && ag_astt[ag_k] != ag_action_10) break; | |
1374 if ((PCB).token_number == 16) | |
1375 {(PCB).exit_flag = AG_SYNTAX_ERROR_CODE; return;} | |
1376 {if ((PCB).read_flag == 0) (PCB).read_flag = 1;} | |
1377 if ((PCB).read_flag) { | |
1378 (PCB).read_flag = 0; | |
1379 GET_INPUT; | |
1380 }; | |
1381 (PCB).token_number = (ss-kb_token_type) AG_TCV((PCB).input_code); | |
1382 } | |
1383 } | |
1384 | |
1385 | |
1386 static int ag_action_10_proc(void) { | |
1387 int ag_t = (PCB).token_number; | |
1388 (PCB).btsx = 0, (PCB).drt = -1; | |
1389 do { | |
1390 {if ((PCB).read_flag == 0) (PCB).read_flag = 1;} | |
1391 if ((PCB).read_flag) { | |
1392 (PCB).read_flag = 0; | |
1393 GET_INPUT; | |
1394 }; | |
1395 (PCB).token_number = (ss-kb_token_type) AG_TCV((PCB).input_code); | |
1396 } while ((PCB).token_number == (ss-kb_token_type) ag_t); | |
1397 return 1; | |
1398 } | |
1399 | |
1400 static int ag_action_11_proc(void) { | |
1401 int ag_t = (PCB).token_number; | |
1402 | |
1403 (PCB).btsx = 0, (PCB).drt = -1; | |
1404 do { | |
1405 (PCB).vs[(PCB).ssx] = (PCB).input_code; | |
1406 (PCB).ssx--; | |
1407 {if ((PCB).read_flag == 0) (PCB).read_flag = 1;} | |
1408 ag_ra(); | |
1409 if ((PCB).exit_flag != AG_RUNNING_CODE) return 0; | |
1410 (PCB).ssx++; | |
1411 if ((PCB).read_flag) { | |
1412 (PCB).read_flag = 0; | |
1413 GET_INPUT; | |
1414 }; | |
1415 (PCB).token_number = (ss-kb_token_type) AG_TCV((PCB).input_code); | |
1416 } | |
1417 while ((PCB).token_number == (ss-kb_token_type) ag_t); | |
1418 return 1; | |
1419 } | |
1420 | |
1421 static int ag_action_3_r_proc(void) { | |
1422 int ag_sd = ag_fl[(PCB).ag_ap] - 1; | |
1423 if (ag_sd) (PCB).sn = (PCB).ss[(PCB).ssx -= ag_sd]; | |
1424 (PCB).btsx = 0, (PCB).drt = -1; | |
1425 (PCB).reduction_token = (ss-kb_token_type) ag_ptt[(PCB).ag_ap]; | |
1426 ag_ra(); | |
1427 return (PCB).exit_flag == AG_RUNNING_CODE; | |
1428 } | |
1429 | |
1430 static int ag_action_3_s_proc(void) { | |
1431 int ag_sd = ag_fl[(PCB).ag_ap] - 1; | |
1432 if (ag_sd) (PCB).sn = (PCB).ss[(PCB).ssx -= ag_sd]; | |
1433 (PCB).btsx = 0, (PCB).drt = -1; | |
1434 (PCB).reduction_token = (ss-kb_token_type) ag_ptt[(PCB).ag_ap]; | |
1435 ag_ra(); | |
1436 return (PCB).exit_flag == AG_RUNNING_CODE; | |
1437 } | |
1438 | |
1439 static int ag_action_4_r_proc(void) { | |
1440 int ag_sd = ag_fl[(PCB).ag_ap] - 1; | |
1441 if (ag_sd) (PCB).sn = (PCB).ss[(PCB).ssx -= ag_sd]; | |
1442 (PCB).reduction_token = (ss-kb_token_type) ag_ptt[(PCB).ag_ap]; | |
1443 return 1; | |
1444 } | |
1445 | |
1446 static int ag_action_2_proc(void) { | |
1447 (PCB).btsx = 0, (PCB).drt = -1; | |
1448 if ((PCB).ssx >= 128) { | |
1449 (PCB).exit_flag = AG_STACK_ERROR_CODE; | |
1450 PARSER_STACK_OVERFLOW; | |
1451 } | |
1452 (PCB).vs[(PCB).ssx] = (PCB).input_code; | |
1453 (PCB).ss[(PCB).ssx] = (PCB).sn; | |
1454 (PCB).ssx++; | |
1455 (PCB).sn = (PCB).ag_ap; | |
1456 {if ((PCB).read_flag == 0) (PCB).read_flag = 1;} | |
1457 return 0; | |
1458 } | |
1459 | |
1460 static int ag_action_9_proc(void) { | |
1461 if ((PCB).drt == -1) { | |
1462 (PCB).drt=(PCB).token_number; | |
1463 (PCB).dssx=(PCB).ssx; | |
1464 (PCB).dsn=(PCB).sn; | |
1465 } | |
1466 ag_prot(); | |
1467 (PCB).vs[(PCB).ssx] = ag_null_value; | |
1468 (PCB).ss[(PCB).ssx] = (PCB).sn; | |
1469 (PCB).ssx++; | |
1470 (PCB).sn = (PCB).ag_ap; | |
1471 return (PCB).exit_flag == AG_RUNNING_CODE; | |
1472 } | |
1473 | |
1474 static int ag_action_2_r_proc(void) { | |
1475 (PCB).ssx++; | |
1476 (PCB).sn = (PCB).ag_ap; | |
1477 return 0; | |
1478 } | |
1479 | |
1480 static int ag_action_7_proc(void) { | |
1481 --(PCB).ssx; | |
1482 (PCB).exit_flag = AG_SUCCESS_CODE; | |
1483 return 0; | |
1484 } | |
1485 | |
1486 static int ag_action_1_proc(void) { | |
1487 {if ((PCB).read_flag == 0) (PCB).read_flag = 1;} | |
1488 (PCB).exit_flag = AG_SUCCESS_CODE; | |
1489 return 0; | |
1490 } | |
1491 | |
1492 static int ag_action_1_r_proc(void) { | |
1493 (PCB).exit_flag = AG_SUCCESS_CODE; | |
1494 return 0; | |
1495 } | |
1496 | |
1497 static int ag_action_1_s_proc(void) { | |
1498 (PCB).exit_flag = AG_SUCCESS_CODE; | |
1499 return 0; | |
1500 } | |
1501 | |
1502 static int ag_action_4_proc(void) { | |
1503 int ag_sd = ag_fl[(PCB).ag_ap] - 1; | |
1504 (PCB).reduction_token = (ss-kb_token_type) ag_ptt[(PCB).ag_ap]; | |
1505 (PCB).btsx = 0, (PCB).drt = -1; | |
1506 (PCB).vs[(PCB).ssx] = (PCB).input_code; | |
1507 if (ag_sd) (PCB).sn = (PCB).ss[(PCB).ssx -= ag_sd]; | |
1508 else (PCB).ss[(PCB).ssx] = (PCB).sn; | |
1509 {if ((PCB).read_flag == 0) (PCB).read_flag = 1;} | |
1510 while ((PCB).exit_flag == AG_RUNNING_CODE) { | |
1511 unsigned ag_t1 = ag_sbe[(PCB).sn] + 1; | |
1512 unsigned ag_t2 = ag_sbt[(PCB).sn+1] - 1; | |
1513 do { | |
1514 unsigned ag_tx = (ag_t1 + ag_t2)/2; | |
1515 if (ag_tstt[ag_tx] < (unsigned char)(PCB).reduction_token) ag_t1 = ag_tx + 1; | |
1516 else ag_t2 = ag_tx; | |
1517 } while (ag_t1 < ag_t2); | |
1518 if (ag_tstt[ag_t1] != (PCB).reduction_token) { | |
1519 (PCB).exit_flag = AG_REDUCTION_ERROR_CODE; | |
1520 REDUCTION_TOKEN_ERROR; break;} | |
1521 (PCB).ag_ap = ag_pstt[ag_t1]; | |
1522 if ((ag_s_procs_scan[ag_astt[ag_t1]])() == 0) break; | |
1523 } | |
1524 return 0; | |
1525 } | |
1526 | |
1527 static int ag_action_3_proc(void) { | |
1528 int ag_sd = ag_fl[(PCB).ag_ap] - 1; | |
1529 (PCB).btsx = 0, (PCB).drt = -1; | |
1530 (PCB).vs[(PCB).ssx] = (PCB).input_code; | |
1531 if (ag_sd) (PCB).sn = (PCB).ss[(PCB).ssx -= ag_sd]; | |
1532 else (PCB).ss[(PCB).ssx] = (PCB).sn; | |
1533 {if ((PCB).read_flag == 0) (PCB).read_flag = 1;} | |
1534 (PCB).reduction_token = (ss-kb_token_type) ag_ptt[(PCB).ag_ap]; | |
1535 ag_ra(); | |
1536 while ((PCB).exit_flag == AG_RUNNING_CODE) { | |
1537 unsigned ag_t1 = ag_sbe[(PCB).sn] + 1; | |
1538 unsigned ag_t2 = ag_sbt[(PCB).sn+1] - 1; | |
1539 do { | |
1540 unsigned ag_tx = (ag_t1 + ag_t2)/2; | |
1541 if (ag_tstt[ag_tx] < (unsigned char)(PCB).reduction_token) ag_t1 = ag_tx + 1; | |
1542 else ag_t2 = ag_tx; | |
1543 } while (ag_t1 < ag_t2); | |
1544 if (ag_tstt[ag_t1] != (PCB).reduction_token) { | |
1545 (PCB).exit_flag = AG_REDUCTION_ERROR_CODE; | |
1546 REDUCTION_TOKEN_ERROR; break;} | |
1547 (PCB).ag_ap = ag_pstt[ag_t1]; | |
1548 if ((ag_s_procs_scan[ag_astt[ag_t1]])() == 0) break; | |
1549 } | |
1550 return 0; | |
1551 } | |
1552 | |
1553 static int ag_action_8_proc(void) { | |
1554 int ag_k = ag_sbt[(PCB).sn]; | |
1555 while (ag_tstt[ag_k] != 42 && ag_tstt[ag_k]) ag_k++; | |
1556 if (ag_tstt[ag_k] == 0) ag_undo(); | |
1557 ag_error_resynch(); | |
1558 return (PCB).exit_flag == AG_RUNNING_CODE; | |
1559 } | |
1560 | |
1561 static int ag_action_5_proc(void) { | |
1562 int ag_sd = ag_fl[(PCB).ag_ap]; | |
1563 (PCB).btsx = 0, (PCB).drt = -1; | |
1564 if (ag_sd) (PCB).sn = (PCB).ss[(PCB).ssx -= ag_sd]; | |
1565 else { | |
1566 (PCB).ss[(PCB).ssx] = (PCB).sn; | |
1567 } | |
1568 (PCB).reduction_token = (ss-kb_token_type) ag_ptt[(PCB).ag_ap]; | |
1569 ag_ra(); | |
1570 while ((PCB).exit_flag == AG_RUNNING_CODE) { | |
1571 unsigned ag_t1 = ag_sbe[(PCB).sn] + 1; | |
1572 unsigned ag_t2 = ag_sbt[(PCB).sn+1] - 1; | |
1573 do { | |
1574 unsigned ag_tx = (ag_t1 + ag_t2)/2; | |
1575 if (ag_tstt[ag_tx] < (unsigned char)(PCB).reduction_token) ag_t1 = ag_tx + 1; | |
1576 else ag_t2 = ag_tx; | |
1577 } while (ag_t1 < ag_t2); | |
1578 if (ag_tstt[ag_t1] != (PCB).reduction_token) { | |
1579 (PCB).exit_flag = AG_REDUCTION_ERROR_CODE; | |
1580 REDUCTION_TOKEN_ERROR; break;} | |
1581 (PCB).ag_ap = ag_pstt[ag_t1]; | |
1582 if ((ag_r_procs_scan[ag_astt[ag_t1]])() == 0) break; | |
1583 } | |
1584 return (PCB).exit_flag == AG_RUNNING_CODE; | |
1585 } | |
1586 | |
1587 static int ag_action_6_proc(void) { | |
1588 int ag_sd = ag_fl[(PCB).ag_ap]; | |
1589 (PCB).reduction_token = (ss-kb_token_type) ag_ptt[(PCB).ag_ap]; | |
1590 if ((PCB).drt == -1) { | |
1591 (PCB).drt=(PCB).token_number; | |
1592 (PCB).dssx=(PCB).ssx; | |
1593 (PCB).dsn=(PCB).sn; | |
1594 } | |
1595 if (ag_sd) { | |
1596 (PCB).sn = (PCB).ss[(PCB).ssx -= ag_sd]; | |
1597 } | |
1598 else { | |
1599 ag_prot(); | |
1600 (PCB).vs[(PCB).ssx] = ag_null_value; | |
1601 (PCB).ss[(PCB).ssx] = (PCB).sn; | |
1602 } | |
1603 while ((PCB).exit_flag == AG_RUNNING_CODE) { | |
1604 unsigned ag_t1 = ag_sbe[(PCB).sn] + 1; | |
1605 unsigned ag_t2 = ag_sbt[(PCB).sn+1] - 1; | |
1606 do { | |
1607 unsigned ag_tx = (ag_t1 + ag_t2)/2; | |
1608 if (ag_tstt[ag_tx] < (unsigned char)(PCB).reduction_token) ag_t1 = ag_tx + 1; | |
1609 else ag_t2 = ag_tx; | |
1610 } while (ag_t1 < ag_t2); | |
1611 if (ag_tstt[ag_t1] != (PCB).reduction_token) { | |
1612 (PCB).exit_flag = AG_REDUCTION_ERROR_CODE; | |
1613 REDUCTION_TOKEN_ERROR; break;} | |
1614 (PCB).ag_ap = ag_pstt[ag_t1]; | |
1615 if ((ag_r_procs_scan[ag_astt[ag_t1]])() == 0) break; | |
1616 } | |
1617 return (PCB).exit_flag == AG_RUNNING_CODE; | |
1618 } | |
1619 | |
1620 | |
1621 static int ag_action_2_er_proc(void) { | |
1622 (PCB).btsx = 0, (PCB).drt = -1; | |
1623 (PCB).vs[(PCB).ssx] = (PCB).input_code; | |
1624 (PCB).ssx++; | |
1625 (PCB).sn = (PCB).ag_ap; | |
1626 return 0; | |
1627 } | |
1628 | |
1629 static int ag_action_1_er_proc(void) { | |
1630 (PCB).btsx = 0, (PCB).drt = -1; | |
1631 (PCB).exit_flag = AG_SUCCESS_CODE; | |
1632 return 0; | |
1633 } | |
1634 | |
1635 static int ag_action_4_er_proc(void) { | |
1636 int ag_sd = ag_fl[(PCB).ag_ap] - 1; | |
1637 (PCB).btsx = 0, (PCB).drt = -1; | |
1638 (PCB).reduction_token = (ss-kb_token_type) ag_ptt[(PCB).ag_ap]; | |
1639 if (ag_sd) (PCB).sn = (PCB).ss[(PCB).ssx -= ag_sd]; | |
1640 else (PCB).ss[(PCB).ssx] = (PCB).sn; | |
1641 while ((PCB).exit_flag == AG_RUNNING_CODE) { | |
1642 unsigned ag_t1 = ag_sbe[(PCB).sn] + 1; | |
1643 unsigned ag_t2 = ag_sbt[(PCB).sn+1] - 1; | |
1644 do { | |
1645 unsigned ag_tx = (ag_t1 + ag_t2)/2; | |
1646 if (ag_tstt[ag_tx] < (unsigned char)(PCB).reduction_token) ag_t1 = ag_tx + 1; | |
1647 else ag_t2 = ag_tx; | |
1648 } while (ag_t1 < ag_t2); | |
1649 if (ag_tstt[ag_t1] != (PCB).reduction_token) { | |
1650 (PCB).exit_flag = AG_REDUCTION_ERROR_CODE; | |
1651 REDUCTION_TOKEN_ERROR; break;} | |
1652 (PCB).ag_ap = ag_pstt[ag_t1]; | |
1653 if ((ag_s_procs_scan[ag_astt[ag_t1]])() == 0) break; | |
1654 } | |
1655 return 0; | |
1656 } | |
1657 | |
1658 static int ag_action_3_er_proc(void) { | |
1659 int ag_sd = ag_fl[(PCB).ag_ap] - 1; | |
1660 (PCB).btsx = 0, (PCB).drt = -1; | |
1661 if (ag_sd) (PCB).sn = (PCB).ss[(PCB).ssx -= ag_sd]; | |
1662 else (PCB).ss[(PCB).ssx] = (PCB).sn; | |
1663 (PCB).reduction_token = (ss-kb_token_type) ag_ptt[(PCB).ag_ap]; | |
1664 ag_ra(); | |
1665 while ((PCB).exit_flag == AG_RUNNING_CODE) { | |
1666 unsigned ag_t1 = ag_sbe[(PCB).sn] + 1; | |
1667 unsigned ag_t2 = ag_sbt[(PCB).sn+1] - 1; | |
1668 do { | |
1669 unsigned ag_tx = (ag_t1 + ag_t2)/2; | |
1670 if (ag_tstt[ag_tx] < (unsigned char)(PCB).reduction_token) ag_t1 = ag_tx + 1; | |
1671 else ag_t2 = ag_tx; | |
1672 } while (ag_t1 < ag_t2); | |
1673 if (ag_tstt[ag_t1] != (PCB).reduction_token) { | |
1674 (PCB).exit_flag = AG_REDUCTION_ERROR_CODE; | |
1675 REDUCTION_TOKEN_ERROR; break;} | |
1676 (PCB).ag_ap = ag_pstt[ag_t1]; | |
1677 if ((ag_s_procs_scan[ag_astt[ag_t1]])() == 0) break; | |
1678 } | |
1679 return 0; | |
1680 } | |
1681 | |
1682 | |
1683 void init_ss-kb(void) { | |
1684 (PCB).read_flag = 1; | |
1685 (PCB).error_message = "Syntax Error"; | |
1686 (PCB).ss[0] = (PCB).sn = (PCB).ssx = 0; | |
1687 (PCB).exit_flag = AG_RUNNING_CODE; | |
1688 (PCB).btsx = 0, (PCB).drt = -1; | |
1689 } | |
1690 | |
1691 void ss-kb(void) { | |
1692 init_ss-kb(); | |
1693 (PCB).exit_flag = AG_RUNNING_CODE; | |
1694 while ((PCB).exit_flag == AG_RUNNING_CODE) { | |
1695 unsigned ag_t1 = ag_sbt[(PCB).sn]; | |
1696 if (ag_tstt[ag_t1]) { | |
1697 unsigned ag_t2 = ag_sbe[(PCB).sn] - 1; | |
1698 if ((PCB).read_flag) { | |
1699 (PCB).read_flag = 0; | |
1700 GET_INPUT; | |
1701 }; | |
1702 (PCB).token_number = (ss-kb_token_type) AG_TCV((PCB).input_code); | |
1703 do { | |
1704 unsigned ag_tx = (ag_t1 + ag_t2)/2; | |
1705 if (ag_tstt[ag_tx] > (unsigned char)(PCB).token_number) | |
1706 ag_t1 = ag_tx + 1; | |
1707 else ag_t2 = ag_tx; | |
1708 } while (ag_t1 < ag_t2); | |
1709 if (ag_tstt[ag_t1] != (unsigned char)(PCB).token_number) | |
1710 ag_t1 = ag_sbe[(PCB).sn]; | |
1711 } | |
1712 (PCB).ag_ap = ag_pstt[ag_t1]; | |
1713 (ag_gt_procs_scan[ag_astt[ag_t1]])(); | |
1714 } | |
1715 } | |
1716 | |
1717 |