1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260
|
#ifndef lint
static char yysccsid[] = "@(#)yaccpar 1.8 (Berkeley) 01/20/90";
#endif
#define YYBYACC 1
#line 2 "parse.y"
#include <stdio.h>
#include <ctype.h>
#include <X11/Intrinsic.h>
#include <Xm/Xm.h>
#ifdef VMS
#include "../util/VMSparam.h"
#else
#include <sys/param.h>
#endif /*VMS*/
#include "textBuf.h"
#include "nedit.h"
#include "interpret.h"
#include "parse.h"
/* Macros to add error processing to AddOp and AddSym calls */
#define ADD_OP(op) if (!AddOp(op, &ErrMsg)) return 1
#define ADD_SYM(sym) if (!AddSym(sym, &ErrMsg)) return 1
#define ADD_IMMED(val) if (!AddImmediate(val, &ErrMsg)) return 1
#define ADD_BR_OFF(to) if (!AddBranchOffset(to, &ErrMsg)) return 1
#define SET_BR_OFF(from, to) *((int *)from) = to - from
/* Max. length for a string constant (... there shouldn't be a maximum) */
#define MAX_STRING_CONST_LEN 5000
static int yylex(void);
static int follow(char expect, int yes, int no);
static int follow2(char expect1, int yes1, char expect2, int yes2, int no);
static Symbol *matchesActionRoutine(char **inPtr);
static char *ErrMsg;
static char *InPtr;
#line 36 "parse.y"
typedef union {
Symbol *sym;
Inst *inst;
int nArgs;
} YYSTYPE;
#line 45 "y.tab.c"
#define NUMBER 257
#define STRING 258
#define SYMBOL 259
#define IF 260
#define WHILE 261
#define ELSE 262
#define FOR 263
#define BREAK 264
#define CONTINUE 265
#define RETURN 266
#define ADDEQ 267
#define SUBEQ 268
#define MULEQ 269
#define DIVEQ 270
#define MODEQ 271
#define ANDEQ 272
#define OREQ 273
#define CONCAT 274
#define OR 275
#define AND 276
#define GT 277
#define GE 278
#define LT 279
#define LE 280
#define EQ 281
#define NE 282
#define UNARY_MINUS 283
#define NOT 284
#define INCR 285
#define DECR 286
#define POW 287
#define YYERRCODE 256
short yylhs[] = { -1,
0, 0, 0, 11, 11, 10, 10, 12, 12, 12,
12, 12, 12, 12, 12, 12, 13, 13, 13, 13,
13, 13, 13, 13, 13, 13, 13, 13, 13, 8,
3, 3, 3, 1, 1, 1, 15, 15, 16, 16,
16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
16, 16, 16, 16, 16, 4, 14, 5, 2, 2,
6, 7, 9, 9,
};
short yylen[] = { 2,
2, 5, 1, 5, 1, 1, 2, 3, 6, 9,
6, 10, 3, 3, 4, 3, 3, 3, 3, 3,
3, 3, 3, 3, 4, 2, 2, 2, 2, 1,
0, 1, 3, 0, 1, 3, 1, 2, 1, 1,
1, 4, 3, 3, 3, 3, 3, 3, 3, 2,
3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
2, 2, 2, 2, 2, 1, 1, 1, 0, 1,
1, 1, 0, 2,
};
short yydefred[] = { 0,
3, 0, 0, 0, 0, 66, 67, 0, 0, 0,
0, 0, 73, 74, 0, 0, 0, 6, 0, 0,
0, 27, 29, 0, 0, 73, 73, 39, 40, 0,
0, 0, 0, 0, 73, 0, 0, 0, 26, 28,
0, 0, 0, 0, 0, 0, 0, 0, 0, 7,
73, 0, 0, 0, 0, 0, 0, 0, 0, 63,
65, 0, 0, 0, 62, 64, 0, 0, 73, 0,
72, 71, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 32,
25, 0, 73, 0, 43, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 2, 73, 0, 0, 0, 0, 42, 0,
0, 33, 73, 0, 5, 11, 0, 0, 68, 73,
0, 0, 0, 73, 73, 10, 0, 0, 12,
};
short yydgoto[] = { 2,
54, 56, 99, 15, 140, 87, 88, 16, 3, 17,
134, 135, 19, 20, 55, 38,
};
short yysindex[] = { -250,
0, 0, 290, 3, -14, 0, 0, 26, 31, 610,
-232, -211, 0, 0, 30, -159, -42, 0, 40, 35,
256, 0, 0, 256, 256, 0, 0, 0, 0, 6,
256, 256, -193, -188, 0, 256, 786, 889, 0, 0,
225, 256, 256, 256, 256, 256, 256, 256, 256, 0,
0, -255, 256, -9, 256, 36, 889, 69, 69, 0,
0, 256, -194, -194, 0, 0, 69, 908, 0, 889,
0, 0, 256, 256, 256, 256, 256, 256, 256, 256,
256, 256, 256, 256, 256, 256, 256, 256, -113, 59,
256, 256, 256, 256, 256, 256, 256, 69, -22, 0,
0, 256, 0, 8, 0, 69, 926, -29, -3, -3,
-3, -3, -3, -3, -32, -32, -194, -194, -194, -194,
889, 889, 0, 0, 256, -255, 256, 327, 0, 327,
60, 0, 0, -168, 0, 0, -255, 225, 0, 0,
21, -70, 327, 0, 0, 0, 327, 69, 0,
};
short yyrindex[] = { 423,
0, 0, 0, -40, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 120, 0, 0, 0,
0, 0, 0, 47, 84, 0, 0, 0, 0, 86,
0, 0, 0, 0, 0, 0, 0, 197, 0, 0,
0, 84, 0, 0, 0, 0, 0, 0, 0, 0,
0, -21, 10, 0, 51, 0, -38, 1, 9, 0,
0, 47, 122, 161, 0, 0, 17, 0, 0, 681,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
15, 19, 57, 58, 62, 63, 133, 45, 0, 0,
0, 0, 0, 0, 0, 53, 871, 866, 557, 570,
749, 781, 820, 834, 493, 525, 346, 385, 421, 457,
717, 876, 0, 0, 77, 0, 74, 0, 0, 0,
0, 0, 0, 89, 0, 0, 94, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 61, 0,
};
short yygindex[] = { 0,
75, -35, 4, 0, 0, 0, 0, 0, 1146, -41,
-119, 16, -50, 0, 37, 1219,
};
#define YYTABLESIZE 1346
short yytable[] = { 89,
13, 100, 70, 4, 85, 1, 90, 85, 14, 83,
136, 123, 83, 81, 84, 82, 16, 84, 18, 17,
70, 126, 31, 146, 18, 25, 39, 149, 19, 11,
12, 101, 50, 85, 102, 26, 125, 31, 83, 81,
27, 82, 24, 84, 8, 62, 37, 40, 129, 51,
17, 102, 15, 17, 145, 18, 18, 53, 18, 19,
4, 144, 19, 21, 126, 65, 20, 21, 17, 42,
66, 22, 23, 18, 52, 132, 103, 19, 14, 91,
92, 93, 94, 95, 96, 97, 100, 34, 9, 131,
34, 35, 86, 139, 35, 41, 142, 20, 21, 124,
20, 21, 22, 23, 50, 22, 23, 43, 44, 45,
46, 47, 48, 49, 36, 20, 21, 36, 137, 1,
22, 23, 41, 41, 69, 13, 41, 41, 41, 41,
41, 50, 41, 14, 31, 69, 104, 31, 127, 0,
141, 16, 24, 0, 41, 4, 5, 6, 0, 7,
8, 9, 10, 18, 0, 0, 0, 50, 50, 50,
0, 50, 50, 50, 50, 50, 50, 0, 50, 8,
61, 11, 12, 24, 0, 0, 24, 15, 0, 0,
50, 0, 0, 0, 0, 4, 0, 0, 4, 5,
6, 24, 7, 8, 9, 10, 0, 61, 61, 0,
61, 61, 61, 61, 61, 61, 37, 61, 0, 41,
0, 0, 0, 9, 11, 12, 4, 5, 6, 61,
7, 8, 9, 10, 0, 0, 30, 30, 30, 30,
30, 30, 30, 0, 14, 0, 37, 37, 0, 0,
37, 0, 11, 12, 0, 50, 0, 75, 76, 77,
78, 79, 80, 0, 86, 37, 0, 86, 0, 13,
13, 13, 13, 13, 13, 13, 13, 14, 14, 14,
14, 14, 14, 14, 14, 16, 16, 16, 16, 16,
16, 16, 16, 86, 61, 13, 13, 22, 23, 0,
60, 61, 0, 14, 14, 36, 0, 0, 0, 14,
31, 16, 16, 8, 8, 8, 8, 8, 8, 8,
8, 15, 15, 15, 15, 15, 15, 15, 15, 4,
4, 4, 4, 4, 4, 4, 4, 0, 0, 8,
8, 0, 0, 0, 0, 0, 14, 15, 15, 0,
0, 0, 41, 41, 41, 4, 4, 9, 9, 9,
0, 9, 9, 9, 9, 46, 0, 0, 0, 0,
41, 41, 41, 41, 41, 41, 41, 41, 0, 41,
0, 0, 41, 9, 9, 0, 0, 0, 50, 50,
50, 0, 46, 46, 0, 46, 46, 46, 46, 46,
46, 0, 46, 0, 47, 0, 50, 50, 50, 50,
50, 50, 50, 50, 46, 50, 50, 50, 0, 0,
0, 0, 13, 0, 0, 0, 0, 61, 61, 61,
0, 47, 47, 0, 47, 47, 47, 47, 47, 47,
48, 47, 73, 0, 0, 61, 61, 61, 61, 61,
61, 61, 61, 47, 61, 61, 61, 0, 0, 133,
0, 0, 0, 37, 37, 37, 0, 48, 48, 0,
48, 48, 48, 48, 48, 48, 49, 48, 0, 46,
0, 0, 0, 0, 0, 0, 0, 0, 0, 48,
37, 37, 37, 4, 5, 6, 0, 7, 8, 9,
10, 0, 0, 49, 49, 0, 49, 49, 49, 49,
49, 49, 44, 49, 0, 0, 0, 0, 47, 11,
12, 0, 28, 29, 30, 49, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
44, 0, 44, 44, 45, 44, 44, 44, 0, 32,
33, 34, 0, 0, 48, 73, 0, 0, 4, 5,
6, 44, 7, 8, 9, 10, 0, 0, 0, 0,
0, 0, 45, 0, 45, 45, 51, 45, 45, 45,
0, 0, 0, 0, 11, 12, 0, 0, 0, 52,
49, 0, 0, 45, 0, 4, 5, 6, 0, 7,
8, 9, 10, 0, 51, 0, 51, 51, 0, 0,
51, 0, 46, 46, 46, 0, 0, 52, 0, 52,
52, 11, 12, 52, 0, 51, 44, 0, 0, 35,
46, 46, 46, 46, 46, 46, 46, 46, 52, 46,
46, 46, 0, 0, 0, 0, 0, 0, 0, 0,
0, 47, 47, 47, 0, 0, 0, 0, 45, 36,
0, 0, 0, 0, 31, 0, 0, 0, 0, 47,
47, 47, 47, 47, 47, 47, 47, 0, 47, 47,
47, 0, 0, 0, 0, 0, 0, 48, 48, 48,
51, 73, 73, 73, 0, 73, 73, 73, 73, 0,
38, 0, 0, 52, 0, 48, 48, 48, 48, 48,
48, 48, 48, 0, 48, 48, 48, 73, 73, 0,
0, 0, 0, 49, 49, 49, 0, 0, 0, 0,
38, 38, 0, 0, 38, 0, 59, 0, 0, 0,
0, 49, 49, 49, 49, 49, 49, 49, 49, 38,
49, 49, 49, 0, 0, 0, 0, 0, 0, 44,
44, 44, 0, 0, 0, 0, 59, 59, 53, 0,
59, 0, 0, 0, 0, 0, 0, 44, 44, 44,
44, 44, 44, 44, 44, 59, 44, 44, 44, 0,
0, 45, 45, 45, 0, 0, 53, 0, 53, 53,
54, 0, 53, 0, 0, 69, 0, 0, 0, 45,
45, 45, 45, 45, 45, 45, 45, 53, 45, 45,
45, 0, 0, 51, 51, 51, 0, 0, 54, 0,
54, 54, 0, 0, 54, 36, 52, 52, 52, 55,
31, 51, 51, 51, 51, 51, 51, 51, 51, 54,
51, 51, 51, 56, 52, 52, 52, 52, 52, 52,
52, 52, 0, 52, 52, 52, 0, 55, 0, 55,
55, 0, 0, 55, 0, 0, 28, 29, 30, 0,
0, 56, 53, 56, 56, 57, 0, 56, 55, 0,
58, 0, 0, 0, 0, 60, 0, 0, 0, 0,
0, 0, 56, 32, 33, 34, 0, 0, 0, 0,
0, 0, 0, 57, 54, 57, 57, 0, 0, 57,
58, 58, 0, 0, 58, 60, 60, 0, 0, 60,
0, 0, 0, 0, 57, 85, 74, 0, 0, 58,
83, 81, 0, 82, 60, 84, 0, 38, 38, 38,
0, 0, 0, 55, 85, 74, 0, 0, 105, 83,
81, 0, 82, 0, 84, 0, 0, 56, 0, 0,
0, 0, 85, 74, 38, 38, 38, 83, 81, 0,
82, 0, 84, 59, 59, 59, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 57,
0, 0, 0, 0, 58, 0, 0, 0, 0, 0,
59, 59, 59, 0, 0, 53, 53, 53, 0, 0,
0, 0, 73, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 53, 53, 53, 53, 53, 53, 53,
53, 73, 53, 53, 53, 0, 0, 54, 54, 54,
0, 0, 28, 29, 30, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 54, 54, 54, 54, 54,
54, 54, 54, 0, 54, 54, 54, 0, 0, 32,
33, 34, 0, 0, 0, 0, 55, 55, 55, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
56, 56, 56, 0, 55, 55, 55, 55, 55, 55,
55, 55, 0, 55, 55, 55, 0, 0, 56, 56,
56, 56, 56, 56, 56, 56, 0, 56, 56, 56,
0, 0, 57, 57, 57, 0, 0, 58, 58, 58,
0, 0, 60, 60, 60, 0, 0, 0, 0, 0,
57, 57, 0, 0, 0, 58, 58, 0, 0, 57,
57, 57, 0, 0, 58, 58, 58, 0, 41, 60,
60, 60, 0, 71, 72, 75, 76, 77, 78, 79,
80, 58, 59, 0, 0, 86, 0, 0, 0, 0,
67, 0, 71, 72, 75, 76, 77, 78, 79, 80,
0, 0, 0, 0, 86, 0, 98, 0, 0, 0,
0, 0, 75, 76, 77, 78, 79, 80, 0, 0,
0, 0, 86, 0, 106, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 57, 0, 0, 0, 0, 128, 63,
64, 0, 0, 0, 68, 70, 0, 0, 0, 0,
57, 0, 0, 0, 0, 0, 0, 0, 0, 130,
0, 70, 0, 70, 0, 0, 0, 0, 138, 0,
0, 0, 0, 0, 0, 143, 0, 0, 0, 147,
148, 107, 108, 109, 110, 111, 112, 113, 114, 115,
116, 117, 118, 119, 120, 121, 122, 0, 0, 70,
70, 70, 70, 70, 70, 70, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 57, 0, 70,
};
short yycheck[] = { 41,
0, 52, 41, 259, 37, 256, 42, 37, 0, 42,
130, 125, 42, 43, 47, 45, 0, 47, 3, 10,
59, 44, 44, 143, 10, 40, 259, 147, 10, 285,
286, 41, 17, 37, 44, 10, 59, 59, 42, 43,
10, 45, 40, 47, 0, 40, 10, 259, 41, 10,
41, 44, 0, 44, 125, 41, 41, 21, 44, 41,
0, 41, 44, 61, 44, 259, 10, 10, 59, 40,
259, 10, 10, 59, 40, 126, 41, 59, 10, 43,
44, 45, 46, 47, 48, 49, 137, 41, 0, 125,
44, 41, 287, 262, 44, 10, 138, 41, 41, 41,
44, 44, 41, 41, 89, 44, 44, 267, 268, 269,
270, 271, 272, 273, 41, 59, 59, 44, 59, 0,
59, 59, 37, 38, 41, 125, 41, 42, 43, 44,
45, 10, 47, 125, 41, 59, 62, 44, 102, -1,
137, 125, 10, -1, 59, 259, 260, 261, -1, 263,
264, 265, 266, 138, -1, -1, -1, 142, 37, 38,
-1, 40, 41, 42, 43, 44, 45, -1, 47, 125,
10, 285, 286, 41, -1, -1, 44, 125, -1, -1,
59, -1, -1, -1, -1, 125, -1, -1, 259, 260,
261, 59, 263, 264, 265, 266, -1, 37, 38, -1,
40, 41, 42, 43, 44, 45, 10, 47, -1, 124,
-1, -1, -1, 125, 285, 286, 259, 260, 261, 59,
263, 264, 265, 266, -1, -1, 267, 268, 269, 270,
271, 272, 273, -1, 10, -1, 40, 41, -1, -1,
44, -1, 285, 286, -1, 124, -1, 277, 278, 279,
280, 281, 282, -1, 287, 59, -1, 287, -1, 259,
260, 261, 262, 263, 264, 265, 266, 259, 260, 261,
262, 263, 264, 265, 266, 259, 260, 261, 262, 263,
264, 265, 266, 287, 124, 285, 286, 285, 286, -1,
285, 286, -1, 285, 286, 40, -1, -1, -1, 10,
45, 285, 286, 259, 260, 261, 262, 263, 264, 265,
266, 259, 260, 261, 262, 263, 264, 265, 266, 259,
260, 261, 262, 263, 264, 265, 266, -1, -1, 285,
286, -1, -1, -1, -1, -1, 10, 285, 286, -1,
-1, -1, 257, 258, 259, 285, 286, 259, 260, 261,
-1, 263, 264, 265, 266, 10, -1, -1, -1, -1,
275, 276, 277, 278, 279, 280, 281, 282, -1, 284,
-1, -1, 287, 285, 286, -1, -1, -1, 257, 258,
259, -1, 37, 38, -1, 40, 41, 42, 43, 44,
45, -1, 47, -1, 10, -1, 275, 276, 277, 278,
279, 280, 281, 282, 59, 284, 285, 286, -1, -1,
-1, -1, 123, -1, -1, -1, -1, 257, 258, 259,
-1, 37, 38, -1, 40, 41, 42, 43, 44, 45,
10, 47, 10, -1, -1, 275, 276, 277, 278, 279,
280, 281, 282, 59, 284, 285, 286, -1, -1, 123,
-1, -1, -1, 257, 258, 259, -1, 37, 38, -1,
40, 41, 42, 43, 44, 45, 10, 47, -1, 124,
-1, -1, -1, -1, -1, -1, -1, -1, -1, 59,
284, 285, 286, 259, 260, 261, -1, 263, 264, 265,
266, -1, -1, 37, 38, -1, 40, 41, 42, 43,
44, 45, 10, 47, -1, -1, -1, -1, 124, 285,
286, -1, 257, 258, 259, 59, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
38, -1, 40, 41, 10, 43, 44, 45, -1, 284,
285, 286, -1, -1, 124, 123, -1, -1, 259, 260,
261, 59, 263, 264, 265, 266, -1, -1, -1, -1,
-1, -1, 38, -1, 40, 41, 10, 43, 44, 45,
-1, -1, -1, -1, 285, 286, -1, -1, -1, 10,
124, -1, -1, 59, -1, 259, 260, 261, -1, 263,
264, 265, 266, -1, 38, -1, 40, 41, -1, -1,
44, -1, 257, 258, 259, -1, -1, 38, -1, 40,
41, 285, 286, 44, -1, 59, 124, -1, -1, 10,
275, 276, 277, 278, 279, 280, 281, 282, 59, 284,
285, 286, -1, -1, -1, -1, -1, -1, -1, -1,
-1, 257, 258, 259, -1, -1, -1, -1, 124, 40,
-1, -1, -1, -1, 45, -1, -1, -1, -1, 275,
276, 277, 278, 279, 280, 281, 282, -1, 284, 285,
286, -1, -1, -1, -1, -1, -1, 257, 258, 259,
124, 259, 260, 261, -1, 263, 264, 265, 266, -1,
10, -1, -1, 124, -1, 275, 276, 277, 278, 279,
280, 281, 282, -1, 284, 285, 286, 285, 286, -1,
-1, -1, -1, 257, 258, 259, -1, -1, -1, -1,
40, 41, -1, -1, 44, -1, 10, -1, -1, -1,
-1, 275, 276, 277, 278, 279, 280, 281, 282, 59,
284, 285, 286, -1, -1, -1, -1, -1, -1, 257,
258, 259, -1, -1, -1, -1, 40, 41, 10, -1,
44, -1, -1, -1, -1, -1, -1, 275, 276, 277,
278, 279, 280, 281, 282, 59, 284, 285, 286, -1,
-1, 257, 258, 259, -1, -1, 38, -1, 40, 41,
10, -1, 44, -1, -1, 10, -1, -1, -1, 275,
276, 277, 278, 279, 280, 281, 282, 59, 284, 285,
286, -1, -1, 257, 258, 259, -1, -1, 38, -1,
40, 41, -1, -1, 44, 40, 257, 258, 259, 10,
45, 275, 276, 277, 278, 279, 280, 281, 282, 59,
284, 285, 286, 10, 275, 276, 277, 278, 279, 280,
281, 282, -1, 284, 285, 286, -1, 38, -1, 40,
41, -1, -1, 44, -1, -1, 257, 258, 259, -1,
-1, 38, 124, 40, 41, 10, -1, 44, 59, -1,
10, -1, -1, -1, -1, 10, -1, -1, -1, -1,
-1, -1, 59, 284, 285, 286, -1, -1, -1, -1,
-1, -1, -1, 38, 124, 40, 41, -1, -1, 44,
40, 41, -1, -1, 44, 40, 41, -1, -1, 44,
-1, -1, -1, -1, 59, 37, 38, -1, -1, 59,
42, 43, -1, 45, 59, 47, -1, 257, 258, 259,
-1, -1, -1, 124, 37, 38, -1, -1, 41, 42,
43, -1, 45, -1, 47, -1, -1, 124, -1, -1,
-1, -1, 37, 38, 284, 285, 286, 42, 43, -1,
45, -1, 47, 257, 258, 259, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, 124,
-1, -1, -1, -1, 124, -1, -1, -1, -1, -1,
284, 285, 286, -1, -1, 257, 258, 259, -1, -1,
-1, -1, 124, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, 275, 276, 277, 278, 279, 280, 281,
282, 124, 284, 285, 286, -1, -1, 257, 258, 259,
-1, -1, 257, 258, 259, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, 275, 276, 277, 278, 279,
280, 281, 282, -1, 284, 285, 286, -1, -1, 284,
285, 286, -1, -1, -1, -1, 257, 258, 259, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
257, 258, 259, -1, 275, 276, 277, 278, 279, 280,
281, 282, -1, 284, 285, 286, -1, -1, 275, 276,
277, 278, 279, 280, 281, 282, -1, 284, 285, 286,
-1, -1, 257, 258, 259, -1, -1, 257, 258, 259,
-1, -1, 257, 258, 259, -1, -1, -1, -1, -1,
275, 276, -1, -1, -1, 275, 276, -1, -1, 284,
285, 286, -1, -1, 284, 285, 286, -1, 13, 284,
285, 286, -1, 275, 276, 277, 278, 279, 280, 281,
282, 26, 27, -1, -1, 287, -1, -1, -1, -1,
35, -1, 275, 276, 277, 278, 279, 280, 281, 282,
-1, -1, -1, -1, 287, -1, 51, -1, -1, -1,
-1, -1, 277, 278, 279, 280, 281, 282, -1, -1,
-1, -1, 287, -1, 69, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, 25, -1, -1, -1, -1, 103, 31,
32, -1, -1, -1, 36, 37, -1, -1, -1, -1,
42, -1, -1, -1, -1, -1, -1, -1, -1, 124,
-1, 53, -1, 55, -1, -1, -1, -1, 133, -1,
-1, -1, -1, -1, -1, 140, -1, -1, -1, 144,
145, 73, 74, 75, 76, 77, 78, 79, 80, 81,
82, 83, 84, 85, 86, 87, 88, -1, -1, 91,
92, 93, 94, 95, 96, 97, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, 125, -1, 127,
};
#define YYFINAL 2
#ifndef YYDEBUG
#define YYDEBUG 0
#endif
#define YYMAXTOKEN 287
#if YYDEBUG
char *yyname[] = {
"end-of-file",0,0,0,0,0,0,0,0,0,"'\\n'",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,"'%'","'&'",0,"'('","')'","'*'","'+'","','","'-'",0,"'/'",0,0,0,0,0,
0,0,0,0,0,0,"';'",0,"'='",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,"'{'","'|'",
"'}'",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,"NUMBER","STRING","SYMBOL","IF","WHILE","ELSE",
"FOR","BREAK","CONTINUE","RETURN","ADDEQ","SUBEQ","MULEQ","DIVEQ","MODEQ",
"ANDEQ","OREQ","CONCAT","OR","AND","GT","GE","LT","LE","EQ","NE","UNARY_MINUS",
"NOT","INCR","DECR","POW",
};
char *yyrule[] = {
"$accept : program",
"program : blank stmts",
"program : blank '{' blank stmts '}'",
"program : error",
"block : '{' blank stmts '}' blank",
"block : stmt",
"stmts : stmt",
"stmts : stmts stmt",
"stmt : simpstmt '\\n' blank",
"stmt : IF '(' cond ')' blank block",
"stmt : IF '(' cond ')' blank block else blank block",
"stmt : while '(' cond ')' blank block",
"stmt : for '(' comastmts ';' cond ';' comastmts ')' blank block",
"stmt : BREAK '\\n' blank",
"stmt : CONTINUE '\\n' blank",
"stmt : RETURN expr '\\n' blank",
"stmt : RETURN '\\n' blank",
"simpstmt : SYMBOL '=' expr",
"simpstmt : evalsym ADDEQ expr",
"simpstmt : evalsym SUBEQ expr",
"simpstmt : evalsym MULEQ expr",
"simpstmt : evalsym DIVEQ expr",
"simpstmt : evalsym MODEQ expr",
"simpstmt : evalsym ANDEQ expr",
"simpstmt : evalsym OREQ expr",
"simpstmt : SYMBOL '(' arglist ')'",
"simpstmt : INCR SYMBOL",
"simpstmt : SYMBOL INCR",
"simpstmt : DECR SYMBOL",
"simpstmt : SYMBOL DECR",
"evalsym : SYMBOL",
"comastmts :",
"comastmts : simpstmt",
"comastmts : comastmts ',' simpstmt",
"arglist :",
"arglist : expr",
"arglist : arglist ',' expr",
"expr : numexpr",
"expr : expr numexpr",
"numexpr : NUMBER",
"numexpr : STRING",
"numexpr : SYMBOL",
"numexpr : SYMBOL '(' arglist ')'",
"numexpr : '(' numexpr ')'",
"numexpr : numexpr '+' numexpr",
"numexpr : numexpr '-' numexpr",
"numexpr : numexpr '*' numexpr",
"numexpr : numexpr '/' numexpr",
"numexpr : numexpr '%' numexpr",
"numexpr : numexpr POW numexpr",
"numexpr : '-' numexpr",
"numexpr : numexpr GT numexpr",
"numexpr : numexpr GE numexpr",
"numexpr : numexpr LT numexpr",
"numexpr : numexpr LE numexpr",
"numexpr : numexpr EQ numexpr",
"numexpr : numexpr NE numexpr",
"numexpr : numexpr '&' numexpr",
"numexpr : numexpr '|' numexpr",
"numexpr : numexpr and numexpr",
"numexpr : numexpr or numexpr",
"numexpr : NOT numexpr",
"numexpr : INCR SYMBOL",
"numexpr : SYMBOL INCR",
"numexpr : DECR SYMBOL",
"numexpr : SYMBOL DECR",
"while : WHILE",
"for : FOR",
"else : ELSE",
"cond :",
"cond : numexpr",
"and : AND",
"or : OR",
"blank :",
"blank : blank '\\n'",
};
#endif
#define yyclearin (yychar=(-1))
#define yyerrok (yyerrflag=0)
#ifdef YYSTACKSIZE
#ifndef YYMAXDEPTH
#define YYMAXDEPTH YYSTACKSIZE
#endif
#else
#ifdef YYMAXDEPTH
#define YYSTACKSIZE YYMAXDEPTH
#else
#define YYSTACKSIZE 500
#define YYMAXDEPTH 500
#endif
#endif
int yydebug;
int yynerrs;
int yyerrflag;
int yychar;
short *yyssp;
YYSTYPE *yyvsp;
YYSTYPE yyval;
YYSTYPE yylval;
short yyss[YYSTACKSIZE];
YYSTYPE yyvs[YYSTACKSIZE];
#define yystacksize YYSTACKSIZE
#line 175 "parse.y"
/* User Subroutines Section */
/*
** Parse a null terminated string and create a program from it (this is the
** parser entry point). The program created by this routine can be
** executed using ExecuteProgram. Returns program on success, or NULL
** on failure. If the command failed, the error message is returned
** as a pointer to a static string in msg, and the length of the string up
** to where parsing failed in stoppedAt.
*/
Program *ParseMacro(char *expr, char **msg, char **stoppedAt)
{
Program *prog;
BeginCreatingProgram();
/* call yyparse to parse the string and check for success. If the parse
failed, return the error message and string index (the grammar aborts
parsing at the first error) */
InPtr = expr;
if (yyparse()) {
*msg = ErrMsg;
*stoppedAt = InPtr;
FreeProgram(FinishCreatingProgram());
return NULL;
}
/* get the newly created program */
prog = FinishCreatingProgram();
/* parse succeeded */
*msg = "";
*stoppedAt = InPtr;
return prog;
}
static int yylex(void)
{
int i, len;
Symbol *s;
static int stringConstIndex = 0;
static DataValue value = {0, {0}};
static char escape[] = "\\\"ntbrfav";
static char replace[] = "\\\"\n\t\b\r\f\a\v";
/* skip whitespace and backslash-newline combinations which are
also considered whitespace */
for (;;) {
if (*InPtr == '\\' && *(InPtr + 1) == '\n')
InPtr += 2;
else if (*InPtr == ' ' || *InPtr == '\t')
InPtr++;
else
break;
}
/* skip comments */
if (*InPtr == '#')
while (*InPtr != '\n' && *InPtr != '\0') InPtr++;
/* return end of input at the end of the string */
if (*InPtr == '\0') {
return 0;
}
/* process number tokens */
if (isdigit(*InPtr)) { /* number */
char name[28];
sscanf(InPtr, "%d%n", &value.val.n, &len);
sprintf(name, "const %d", value.val.n);
InPtr += len;
value.tag = INT_TAG;
if ((yylval.sym=LookupSymbol(name)) == NULL)
yylval.sym = InstallSymbol(name, CONST_SYM, value);
return NUMBER;
}
/* process symbol tokens. "define" is a special case not handled
by this parser, considered end of input. Another special case
is action routine names which are allowed to contain '-' despite
the ambiguity, handled in matchesActionRoutine. */
if (isalpha(*InPtr) || *InPtr == '$') {
if ((s=matchesActionRoutine(&InPtr)) == NULL) {
char symName[MAX_SYM_LEN+1], *p = symName;
*p++ = *InPtr++;
while (isalnum(*InPtr) || *InPtr=='_') {
if (p >= symName + MAX_SYM_LEN)
InPtr++;
else
*p++ = *InPtr++;
}
*p = '\0';
if (!strcmp(symName, "while")) return WHILE;
if (!strcmp(symName, "if")) return IF;
if (!strcmp(symName, "else")) return ELSE;
if (!strcmp(symName, "for")) return FOR;
if (!strcmp(symName, "break")) return BREAK;
if (!strcmp(symName, "continue")) return CONTINUE;
if (!strcmp(symName, "return")) return RETURN;
if (!strcmp(symName, "define")) {
InPtr -= 6;
return 0;
}
if ((s=LookupSymbol(symName)) == NULL) {
s = InstallSymbol(symName, symName[0]=='$' ? (isdigit(symName[1]) ?
ARG_SYM : GLOBAL_SYM) : LOCAL_SYM, value);
s->value.tag = NO_TAG;
}
}
yylval.sym = s;
return SYMBOL;
}
/* process quoted strings w/ embedded escape sequences */
if (*InPtr == '\"') {
char string[MAX_STRING_CONST_LEN], *p = string;
char stringName[25];
InPtr++;
while (*InPtr != '\0' && *InPtr != '\"' && *InPtr != '\n') {
if (p >= string + MAX_STRING_CONST_LEN) {
InPtr++;
continue;
}
if (*InPtr == '\\') {
InPtr++;
if (*InPtr == '\n') {
InPtr++;
continue;
}
for (i=0; escape[i]!='\0'; i++) {
if (escape[i] == '\0') {
*p++= *InPtr++;
break;
} else if (escape[i] == *InPtr) {
*p++ = replace[i];
InPtr++;
break;
}
}
} else
*p++= *InPtr++;
}
*p = '\0';
InPtr++;
value.val.str = AllocString(p-string+1);
strcpy(value.val.str, string);
value.tag = STRING_TAG;
sprintf(stringName, "string #%d", stringConstIndex++);
yylval.sym = InstallSymbol(stringName, CONST_SYM, value);
return STRING;
}
/* process remaining two character tokens or return single char as token */
switch(*InPtr++) {
case '>': return follow('=', GE, GT);
case '<': return follow('=', LE, LT);
case '=': return follow('=', EQ, '=');
case '!': return follow('=', NE, NOT);
case '+': return follow2('+', INCR, '=', ADDEQ, '+');
case '-': return follow2('-', DECR, '=', SUBEQ, '-');
case '|': return follow2('|', OR, '=', OREQ, '|');
case '&': return follow2('&', AND, '=', ANDEQ, '&');
case '*': return follow2('*', POW, '=', MULEQ, '*');
case '/': return follow('=', DIVEQ, '/');
case '%': return follow('=', MODEQ, '%');
case '^': return POW;
default: return *(InPtr-1);
}
}
/*
** look ahead for >=, etc.
*/
static int follow(char expect, int yes, int no)
{
if (*InPtr++ == expect)
return yes;
InPtr--;
return no;
}
static int follow2(char expect1, int yes1, char expect2, int yes2, int no)
{
char next = *InPtr++;
if (next == expect1)
return yes1;
if (next == expect2)
return yes2;
InPtr--;
return no;
}
/*
** Look (way) ahead for hyphenated routine names which begin at inPtr. A
** hyphenated name is allowed if it is pre-defined in the global symbol
** table. If a matching name exists, returns the symbol, and update "inPtr".
**
** I know this is horrible language design, but existing nedit action routine
** names contain hyphens. Handling them here in the lexical analysis process
** is much easier than trying to deal with it in the parser itself. (sorry)
*/
static Symbol *matchesActionRoutine(char **inPtr)
{
char *c, *symPtr;
int hasDash = False;
char symbolName[MAX_SYM_LEN+1];
Symbol *s;
symPtr = symbolName;
for (c = *inPtr; isalnum(*c) || *c=='_' || (*c=='-'&&isalnum(*(c+1))); c++){
if (*c == '-')
hasDash = True;
*symPtr++ = *c;
}
if (!hasDash)
return NULL;
*symPtr = '\0';
s = LookupSymbol(symbolName);
if (s != NULL)
*inPtr = c;
return s;
}
/*
** Called by yacc to report errors (just stores for returning when
** parsing is aborted. The error token action is to immediate abort
** parsing, so this message is immediately reported to the caller
** of ParseExpr)
*/
yyerror(char *s)
{
ErrMsg = s;
}
#line 787 "y.tab.c"
#define YYABORT goto yyabort
#define YYACCEPT goto yyaccept
#define YYERROR goto yyerrlab
int
yyparse()
{
register int yym, yyn, yystate;
#if YYDEBUG
register char *yys;
extern char *getenv();
if (yys = getenv("YYDEBUG"))
{
yyn = *yys;
if (yyn >= '0' && yyn <= '9')
yydebug = yyn - '0';
}
#endif
yynerrs = 0;
yyerrflag = 0;
yychar = (-1);
yyssp = yyss;
yyvsp = yyvs;
*yyssp = yystate = 0;
yyloop:
if (yyn = yydefred[yystate]) goto yyreduce;
if (yychar < 0)
{
if ((yychar = yylex()) < 0) yychar = 0;
#if YYDEBUG
if (yydebug)
{
yys = 0;
if (yychar <= YYMAXTOKEN) yys = yyname[yychar];
if (!yys) yys = "illegal-symbol";
printf("yydebug: state %d, reading %d (%s)\n", yystate,
yychar, yys);
}
#endif
}
if ((yyn = yysindex[yystate]) && (yyn += yychar) >= 0 &&
yyn <= YYTABLESIZE && yycheck[yyn] == yychar)
{
#if YYDEBUG
if (yydebug)
printf("yydebug: state %d, shifting to state %d\n",
yystate, yytable[yyn]);
#endif
if (yyssp >= yyss + yystacksize - 1)
{
goto yyoverflow;
}
*++yyssp = yystate = yytable[yyn];
*++yyvsp = yylval;
yychar = (-1);
if (yyerrflag > 0) --yyerrflag;
goto yyloop;
}
if ((yyn = yyrindex[yystate]) && (yyn += yychar) >= 0 &&
yyn <= YYTABLESIZE && yycheck[yyn] == yychar)
{
yyn = yytable[yyn];
goto yyreduce;
}
if (yyerrflag) goto yyinrecovery;
#ifdef lint
goto yynewerror;
#endif
yynewerror:
yyerror("syntax error");
#ifdef lint
goto yyerrlab;
#endif
yyerrlab:
++yynerrs;
yyinrecovery:
if (yyerrflag < 3)
{
yyerrflag = 3;
for (;;)
{
if ((yyn = yysindex[*yyssp]) && (yyn += YYERRCODE) >= 0 &&
yyn <= YYTABLESIZE && yycheck[yyn] == YYERRCODE)
{
#if YYDEBUG
if (yydebug)
printf("yydebug: state %d, error recovery shifting\
to state %d\n", *yyssp, yytable[yyn]);
#endif
if (yyssp >= yyss + yystacksize - 1)
{
goto yyoverflow;
}
*++yyssp = yystate = yytable[yyn];
*++yyvsp = yylval;
goto yyloop;
}
else
{
#if YYDEBUG
if (yydebug)
printf("yydebug: error recovery discarding state %d\n",
*yyssp);
#endif
if (yyssp <= yyss) goto yyabort;
--yyssp;
--yyvsp;
}
}
}
else
{
if (yychar == 0) goto yyabort;
#if YYDEBUG
if (yydebug)
{
yys = 0;
if (yychar <= YYMAXTOKEN) yys = yyname[yychar];
if (!yys) yys = "illegal-symbol";
printf("yydebug: state %d, error recovery discards token %d (%s)\n",
yystate, yychar, yys);
}
#endif
yychar = (-1);
goto yyloop;
}
yyreduce:
#if YYDEBUG
if (yydebug)
printf("yydebug: state %d, reducing by rule %d (%s)\n",
yystate, yyn, yyrule[yyn]);
#endif
yym = yylen[yyn];
yyval = yyvsp[1-yym];
switch (yyn)
{
case 1:
#line 61 "parse.y"
{ ADD_OP(OP_RETURN_NO_VAL); return 0; }
break;
case 2:
#line 62 "parse.y"
{ ADD_OP(OP_RETURN_NO_VAL); return 0; }
break;
case 3:
#line 63 "parse.y"
{ return 1; }
break;
case 9:
#line 72 "parse.y"
{ SET_BR_OFF((Inst *)yyvsp[-3].inst, GetPC()); }
break;
case 10:
#line 74 "parse.y"
{ SET_BR_OFF(yyvsp[-6].inst, (yyvsp[-2].inst+1)); SET_BR_OFF(yyvsp[-2].inst, GetPC()); }
break;
case 11:
#line 75 "parse.y"
{ ADD_OP(OP_BRANCH); ADD_BR_OFF(yyvsp[-5].inst);
SET_BR_OFF(yyvsp[-3].inst, GetPC()); FillLoopAddrs(GetPC(), yyvsp[-5].inst); }
break;
case 12:
#line 78 "parse.y"
{ FillLoopAddrs(GetPC()+2+(yyvsp[-3].inst-(yyvsp[-5].inst+1)), GetPC());
SwapCode(yyvsp[-5].inst+1, yyvsp[-3].inst, GetPC());
ADD_OP(OP_BRANCH); ADD_BR_OFF(yyvsp[-7].inst); SET_BR_OFF(yyvsp[-5].inst, GetPC()); }
break;
case 13:
#line 82 "parse.y"
{ ADD_OP(OP_BRANCH); ADD_BR_OFF(0); AddBreakAddr(GetPC()-1); }
break;
case 14:
#line 84 "parse.y"
{ ADD_OP(OP_BRANCH); ADD_BR_OFF(0); AddContinueAddr(GetPC()-1); }
break;
case 15:
#line 85 "parse.y"
{ ADD_OP(OP_RETURN); }
break;
case 16:
#line 86 "parse.y"
{ ADD_OP(OP_RETURN_NO_VAL); }
break;
case 17:
#line 88 "parse.y"
{ ADD_OP(OP_ASSIGN); ADD_SYM(yyvsp[-2].sym); }
break;
case 18:
#line 89 "parse.y"
{ ADD_OP(OP_ADD); ADD_OP(OP_ASSIGN); ADD_SYM(yyvsp[-2].sym); }
break;
case 19:
#line 90 "parse.y"
{ ADD_OP(OP_SUB); ADD_OP(OP_ASSIGN); ADD_SYM(yyvsp[-2].sym); }
break;
case 20:
#line 91 "parse.y"
{ ADD_OP(OP_MUL); ADD_OP(OP_ASSIGN); ADD_SYM(yyvsp[-2].sym); }
break;
case 21:
#line 92 "parse.y"
{ ADD_OP(OP_DIV); ADD_OP(OP_ASSIGN); ADD_SYM(yyvsp[-2].sym); }
break;
case 22:
#line 93 "parse.y"
{ ADD_OP(OP_MOD); ADD_OP(OP_ASSIGN); ADD_SYM(yyvsp[-2].sym); }
break;
case 23:
#line 94 "parse.y"
{ ADD_OP(OP_BIT_AND); ADD_OP(OP_ASSIGN);
ADD_SYM(yyvsp[-2].sym); }
break;
case 24:
#line 96 "parse.y"
{ ADD_OP(OP_BIT_OR); ADD_OP(OP_ASSIGN);
ADD_SYM(yyvsp[-2].sym); }
break;
case 25:
#line 98 "parse.y"
{ ADD_OP(OP_SUBR_CALL);
ADD_SYM(PromoteToGlobal(yyvsp[-3].sym)); ADD_IMMED((void *)yyvsp[-1].nArgs); }
break;
case 26:
#line 100 "parse.y"
{ ADD_OP(OP_PUSH_SYM); ADD_SYM(yyvsp[0].sym); ADD_OP(OP_INCR);
ADD_OP(OP_ASSIGN); ADD_SYM(yyvsp[0].sym); }
break;
case 27:
#line 102 "parse.y"
{ ADD_OP(OP_PUSH_SYM); ADD_SYM(yyvsp[-1].sym); ADD_OP(OP_INCR);
ADD_OP(OP_ASSIGN); ADD_SYM(yyvsp[-1].sym); }
break;
case 28:
#line 104 "parse.y"
{ ADD_OP(OP_PUSH_SYM); ADD_SYM(yyvsp[0].sym); ADD_OP(OP_DECR);
ADD_OP(OP_ASSIGN); ADD_SYM(yyvsp[0].sym); }
break;
case 29:
#line 106 "parse.y"
{ ADD_OP(OP_PUSH_SYM); ADD_SYM(yyvsp[-1].sym); ADD_OP(OP_DECR);
ADD_OP(OP_ASSIGN); ADD_SYM(yyvsp[-1].sym); }
break;
case 30:
#line 109 "parse.y"
{ yyval.sym = yyvsp[0].sym; ADD_OP(OP_PUSH_SYM); ADD_SYM(yyvsp[0].sym); }
break;
case 31:
#line 111 "parse.y"
{ yyval.inst = GetPC(); }
break;
case 32:
#line 112 "parse.y"
{ yyval.inst = GetPC(); }
break;
case 33:
#line 113 "parse.y"
{ yyval.inst = GetPC(); }
break;
case 34:
#line 115 "parse.y"
{ yyval.nArgs = 0;}
break;
case 35:
#line 116 "parse.y"
{ yyval.nArgs = 1; }
break;
case 36:
#line 117 "parse.y"
{ yyval.nArgs = yyvsp[-2].nArgs + 1; }
break;
case 38:
#line 120 "parse.y"
{ ADD_OP(OP_CONCAT); }
break;
case 39:
#line 122 "parse.y"
{ ADD_OP(OP_PUSH_SYM); ADD_SYM(yyvsp[0].sym); }
break;
case 40:
#line 123 "parse.y"
{ ADD_OP(OP_PUSH_SYM); ADD_SYM(yyvsp[0].sym); }
break;
case 41:
#line 124 "parse.y"
{ ADD_OP(OP_PUSH_SYM); ADD_SYM(yyvsp[0].sym); }
break;
case 42:
#line 125 "parse.y"
{ ADD_OP(OP_SUBR_CALL);
ADD_SYM(PromoteToGlobal(yyvsp[-3].sym)); ADD_IMMED((void *)yyvsp[-1].nArgs);
ADD_OP(OP_FETCH_RET_VAL);}
break;
case 44:
#line 129 "parse.y"
{ ADD_OP(OP_ADD); }
break;
case 45:
#line 130 "parse.y"
{ ADD_OP(OP_SUB); }
break;
case 46:
#line 131 "parse.y"
{ ADD_OP(OP_MUL); }
break;
case 47:
#line 132 "parse.y"
{ ADD_OP(OP_DIV); }
break;
case 48:
#line 133 "parse.y"
{ ADD_OP(OP_MOD); }
break;
case 49:
#line 134 "parse.y"
{ ADD_OP(OP_POWER); }
break;
case 50:
#line 135 "parse.y"
{ ADD_OP(OP_NEGATE); }
break;
case 51:
#line 136 "parse.y"
{ ADD_OP(OP_GT); }
break;
case 52:
#line 137 "parse.y"
{ ADD_OP(OP_GE); }
break;
case 53:
#line 138 "parse.y"
{ ADD_OP(OP_LT); }
break;
case 54:
#line 139 "parse.y"
{ ADD_OP(OP_LE); }
break;
case 55:
#line 140 "parse.y"
{ ADD_OP(OP_EQ); }
break;
case 56:
#line 141 "parse.y"
{ ADD_OP(OP_NE); }
break;
case 57:
#line 142 "parse.y"
{ ADD_OP(OP_BIT_AND); }
break;
case 58:
#line 143 "parse.y"
{ ADD_OP(OP_BIT_OR); }
break;
case 59:
#line 144 "parse.y"
{ ADD_OP(OP_AND); SET_BR_OFF(yyvsp[-1].inst, GetPC()); }
break;
case 60:
#line 145 "parse.y"
{ ADD_OP(OP_OR); SET_BR_OFF(yyvsp[-1].inst, GetPC()); }
break;
case 61:
#line 146 "parse.y"
{ ADD_OP(OP_NOT); }
break;
case 62:
#line 147 "parse.y"
{ ADD_OP(OP_PUSH_SYM); ADD_SYM(yyvsp[0].sym); ADD_OP(OP_INCR);
ADD_OP(OP_DUP); ADD_OP(OP_ASSIGN); ADD_SYM(yyvsp[0].sym); }
break;
case 63:
#line 149 "parse.y"
{ ADD_OP(OP_PUSH_SYM); ADD_SYM(yyvsp[-1].sym); ADD_OP(OP_DUP);
ADD_OP(OP_INCR); ADD_OP(OP_ASSIGN); ADD_SYM(yyvsp[-1].sym); }
break;
case 64:
#line 151 "parse.y"
{ ADD_OP(OP_PUSH_SYM); ADD_SYM(yyvsp[0].sym); ADD_OP(OP_DECR);
ADD_OP(OP_DUP); ADD_OP(OP_ASSIGN); ADD_SYM(yyvsp[0].sym); }
break;
case 65:
#line 153 "parse.y"
{ ADD_OP(OP_PUSH_SYM); ADD_SYM(yyvsp[-1].sym); ADD_OP(OP_DUP);
ADD_OP(OP_DECR); ADD_OP(OP_ASSIGN); ADD_SYM(yyvsp[-1].sym); }
break;
case 66:
#line 156 "parse.y"
{ yyval.inst = GetPC(); StartLoopAddrList(); }
break;
case 67:
#line 158 "parse.y"
{ StartLoopAddrList(); }
break;
case 68:
#line 160 "parse.y"
{ ADD_OP(OP_BRANCH); yyval.inst = GetPC(); ADD_BR_OFF(0); }
break;
case 69:
#line 162 "parse.y"
{ ADD_OP(OP_BRANCH_NEVER); yyval.inst = GetPC(); ADD_BR_OFF(0); }
break;
case 70:
#line 163 "parse.y"
{ ADD_OP(OP_BRANCH_FALSE); yyval.inst = GetPC(); ADD_BR_OFF(0); }
break;
case 71:
#line 165 "parse.y"
{ ADD_OP(OP_DUP); ADD_OP(OP_BRANCH_FALSE); yyval.inst = GetPC();
ADD_BR_OFF(0); }
break;
case 72:
#line 168 "parse.y"
{ ADD_OP(OP_DUP); ADD_OP(OP_BRANCH_TRUE); yyval.inst = GetPC();
ADD_BR_OFF(0); }
break;
#line 1205 "y.tab.c"
}
yyssp -= yym;
yystate = *yyssp;
yyvsp -= yym;
yym = yylhs[yyn];
if (yystate == 0 && yym == 0)
{
#if YYDEBUG
if (yydebug)
printf("yydebug: after reduction, shifting from state 0 to\
state %d\n", YYFINAL);
#endif
yystate = YYFINAL;
*++yyssp = YYFINAL;
*++yyvsp = yyval;
if (yychar < 0)
{
if ((yychar = yylex()) < 0) yychar = 0;
#if YYDEBUG
if (yydebug)
{
yys = 0;
if (yychar <= YYMAXTOKEN) yys = yyname[yychar];
if (!yys) yys = "illegal-symbol";
printf("yydebug: state %d, reading %d (%s)\n",
YYFINAL, yychar, yys);
}
#endif
}
if (yychar == 0) goto yyaccept;
goto yyloop;
}
if ((yyn = yygindex[yym]) && (yyn += yystate) >= 0 &&
yyn <= YYTABLESIZE && yycheck[yyn] == yystate)
yystate = yytable[yyn];
else
yystate = yydgoto[yym];
#if YYDEBUG
if (yydebug)
printf("yydebug: after reduction, shifting from state %d \
to state %d\n", *yyssp, yystate);
#endif
if (yyssp >= yyss + yystacksize - 1)
{
goto yyoverflow;
}
*++yyssp = yystate;
*++yyvsp = yyval;
goto yyloop;
yyoverflow:
yyerror("yacc stack overflow");
yyabort:
return (1);
yyaccept:
return (0);
}
|