[9] | 1 | #ifndef lint
|
---|
| 2 | static char yysccsid[] = "@(#)yaccpar 1.9 (Berkeley) 02/21/93";
|
---|
| 3 | #endif
|
---|
| 4 | #define YYBYACC 1
|
---|
| 5 | #define YYMAJOR 1
|
---|
| 6 | #define YYMINOR 9
|
---|
| 7 | #define yyclearin (yychar=(-1))
|
---|
| 8 | #define yyerrok (yyerrflag=0)
|
---|
| 9 | #define YYRECOVERING (yyerrflag!=0)
|
---|
| 10 | #define YYPREFIX "yy"
|
---|
| 11 | #line 2 "bc.y"
|
---|
| 12 | /* bc.y: The grammar for a POSIX compatable bc processor with some
|
---|
| 13 | extensions to the language. */
|
---|
| 14 |
|
---|
| 15 | /* This file is part of bc written for MINIX.
|
---|
| 16 | Copyright (C) 1991, 1992 Free Software Foundation, Inc.
|
---|
| 17 |
|
---|
| 18 | This program is free software; you can redistribute it and/or modify
|
---|
| 19 | it under the terms of the GNU General Public License as published by
|
---|
| 20 | the Free Software Foundation; either version 2 of the License , or
|
---|
| 21 | (at your option) any later version.
|
---|
| 22 |
|
---|
| 23 | This program is distributed in the hope that it will be useful,
|
---|
| 24 | but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
| 25 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
| 26 | GNU General Public License for more details.
|
---|
| 27 |
|
---|
| 28 | You should have received a copy of the GNU General Public License
|
---|
| 29 | along with this program; see the file COPYING. If not, write to
|
---|
| 30 | the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
|
---|
| 31 |
|
---|
| 32 | You may contact the author by:
|
---|
| 33 | e-mail: phil@cs.wwu.edu
|
---|
| 34 | us-mail: Philip A. Nelson
|
---|
| 35 | Computer Science Department, 9062
|
---|
| 36 | Western Washington University
|
---|
| 37 | Bellingham, WA 98226-9062
|
---|
| 38 |
|
---|
| 39 | *************************************************************************/
|
---|
| 40 |
|
---|
| 41 | #include "bcdefs.h"
|
---|
| 42 | #include "global.h"
|
---|
| 43 | #include "proto.h"
|
---|
| 44 | #line 38 "bc.y"
|
---|
| 45 | typedef union {
|
---|
| 46 | char *s_value;
|
---|
| 47 | char c_value;
|
---|
| 48 | int i_value;
|
---|
| 49 | arg_list *a_value;
|
---|
| 50 | } YYSTYPE;
|
---|
| 51 | #line 52 "y.tab.c"
|
---|
| 52 | #define NEWLINE 257
|
---|
| 53 | #define AND 258
|
---|
| 54 | #define OR 259
|
---|
| 55 | #define NOT 260
|
---|
| 56 | #define STRING 261
|
---|
| 57 | #define NAME 262
|
---|
| 58 | #define NUMBER 263
|
---|
| 59 | #define MUL_OP 264
|
---|
| 60 | #define ASSIGN_OP 265
|
---|
| 61 | #define REL_OP 266
|
---|
| 62 | #define INCR_DECR 267
|
---|
| 63 | #define Define 268
|
---|
| 64 | #define Break 269
|
---|
| 65 | #define Quit 270
|
---|
| 66 | #define Length 271
|
---|
| 67 | #define Return 272
|
---|
| 68 | #define For 273
|
---|
| 69 | #define If 274
|
---|
| 70 | #define While 275
|
---|
| 71 | #define Sqrt 276
|
---|
| 72 | #define Else 277
|
---|
| 73 | #define Scale 278
|
---|
| 74 | #define Ibase 279
|
---|
| 75 | #define Obase 280
|
---|
| 76 | #define Auto 281
|
---|
| 77 | #define Read 282
|
---|
| 78 | #define Warranty 283
|
---|
| 79 | #define Halt 284
|
---|
| 80 | #define Last 285
|
---|
| 81 | #define Continue 286
|
---|
| 82 | #define Print 287
|
---|
| 83 | #define Limits 288
|
---|
| 84 | #define UNARY_MINUS 289
|
---|
| 85 | #define YYERRCODE 256
|
---|
| 86 | short yylhs[] = { -1,
|
---|
| 87 | 0, 0, 10, 10, 10, 11, 11, 11, 11, 12,
|
---|
| 88 | 12, 12, 12, 12, 12, 15, 15, 13, 13, 13,
|
---|
| 89 | 13, 13, 13, 13, 13, 13, 13, 16, 17, 18,
|
---|
| 90 | 19, 13, 20, 13, 22, 23, 13, 13, 25, 13,
|
---|
| 91 | 24, 24, 26, 26, 21, 27, 21, 28, 14, 5,
|
---|
| 92 | 5, 6, 6, 6, 7, 7, 7, 7, 8, 8,
|
---|
| 93 | 9, 9, 9, 9, 4, 4, 2, 2, 29, 1,
|
---|
| 94 | 30, 1, 31, 1, 1, 1, 1, 1, 1, 1,
|
---|
| 95 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
|
---|
| 96 | 1, 3, 3, 3, 3, 3, 3,
|
---|
| 97 | };
|
---|
| 98 | short yylen[] = { 2,
|
---|
| 99 | 0, 2, 2, 1, 2, 0, 1, 3, 2, 0,
|
---|
| 100 | 1, 2, 3, 2, 3, 1, 2, 1, 1, 1,
|
---|
| 101 | 1, 1, 1, 1, 1, 1, 4, 0, 0, 0,
|
---|
| 102 | 0, 13, 0, 7, 0, 0, 7, 3, 0, 3,
|
---|
| 103 | 1, 3, 1, 1, 0, 0, 3, 0, 12, 0,
|
---|
| 104 | 1, 0, 3, 3, 1, 3, 3, 5, 0, 1,
|
---|
| 105 | 1, 3, 3, 5, 0, 1, 0, 1, 0, 4,
|
---|
| 106 | 0, 4, 0, 4, 2, 3, 3, 3, 3, 3,
|
---|
| 107 | 2, 1, 1, 3, 4, 2, 2, 4, 4, 4,
|
---|
| 108 | 3, 1, 4, 1, 1, 1, 1,
|
---|
| 109 | };
|
---|
| 110 | short yydefred[] = { 1,
|
---|
| 111 | 0, 0, 0, 21, 0, 83, 0, 0, 22, 24,
|
---|
| 112 | 0, 0, 28, 0, 35, 0, 0, 94, 95, 0,
|
---|
| 113 | 18, 25, 97, 23, 39, 19, 0, 0, 0, 0,
|
---|
| 114 | 0, 2, 0, 16, 4, 7, 5, 17, 0, 0,
|
---|
| 115 | 0, 0, 96, 86, 0, 0, 0, 0, 0, 0,
|
---|
| 116 | 0, 0, 0, 0, 81, 0, 0, 0, 11, 71,
|
---|
| 117 | 73, 0, 0, 0, 0, 0, 69, 87, 3, 0,
|
---|
| 118 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
---|
| 119 | 0, 0, 0, 0, 91, 43, 0, 40, 0, 84,
|
---|
| 120 | 0, 0, 38, 0, 0, 0, 0, 0, 0, 0,
|
---|
| 121 | 0, 8, 0, 85, 0, 93, 0, 0, 0, 88,
|
---|
| 122 | 27, 0, 0, 33, 0, 89, 90, 0, 13, 15,
|
---|
| 123 | 0, 0, 0, 62, 0, 0, 0, 0, 0, 29,
|
---|
| 124 | 0, 0, 42, 0, 56, 0, 0, 0, 0, 0,
|
---|
| 125 | 64, 0, 0, 0, 46, 34, 37, 0, 48, 58,
|
---|
| 126 | 30, 0, 0, 0, 0, 47, 53, 54, 0, 0,
|
---|
| 127 | 0, 31, 49, 0, 32,
|
---|
| 128 | };
|
---|
| 129 | short yydgoto[] = { 1,
|
---|
| 130 | 30, 79, 31, 113, 108, 149, 109, 73, 74, 32,
|
---|
| 131 | 33, 58, 34, 35, 59, 48, 138, 155, 164, 131,
|
---|
| 132 | 146, 50, 132, 88, 54, 89, 152, 154, 101, 94,
|
---|
| 133 | 95,
|
---|
| 134 | };
|
---|
| 135 | short yysindex[] = { 0,
|
---|
| 136 | -7, 58, 212, 0, -22, 0, -233, -241, 0, 0,
|
---|
| 137 | -8, -5, 0, -4, 0, 2, 4, 0, 0, 9,
|
---|
| 138 | 0, 0, 0, 0, 0, 0, 212, 212, 91, 725,
|
---|
| 139 | -240, 0, -29, 0, 0, 0, 0, 0, 84, 245,
|
---|
| 140 | 212, -57, 0, 0, 10, 212, 212, 14, 212, 16,
|
---|
| 141 | 212, 212, 23, 156, 0, 549, 127, -52, 0, 0,
|
---|
| 142 | 0, 212, 212, 212, 212, 212, 0, 0, 0, 91,
|
---|
| 143 | -17, 725, 24, -3, 578, -205, 562, 725, 27, 212,
|
---|
| 144 | 606, 212, 669, 716, 0, 0, 725, 0, 19, 0,
|
---|
| 145 | 91, 127, 0, 212, 212, -36, -39, -91, -91, -36,
|
---|
| 146 | 212, 0, 166, 0, 277, 0, -21, 36, 40, 0,
|
---|
| 147 | 0, 725, 28, 0, 725, 0, 0, 156, 0, 0,
|
---|
| 148 | 84, 540, -39, 0, -9, 725, -2, -37, -174, 0,
|
---|
| 149 | 127, 48, 0, 346, 0, -167, 3, 212, -185, 127,
|
---|
| 150 | 0, -188, 6, 37, 0, 0, 0, -205, 0, 0,
|
---|
| 151 | 0, 127, -42, 91, 212, 0, 0, 0, -20, 54,
|
---|
| 152 | 26, 0, 0, 127, 0,
|
---|
| 153 | };
|
---|
| 154 | short yyrindex[] = { 0,
|
---|
| 155 | -16, 0, 0, 0, 409, 0, 0, 0, 0, 0,
|
---|
| 156 | 0, -58, 0, 0, 0, 0, 426, 0, 0, 0,
|
---|
| 157 | 0, 0, 0, 0, 0, 0, 0, 0, -50, 46,
|
---|
| 158 | 470, 0, 0, 0, 0, 0, 0, 0, 661, 56,
|
---|
| 159 | 0, 525, 0, 0, 0, 0, 59, 0, 0, 0,
|
---|
| 160 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
---|
| 161 | 0, 0, 0, 0, 0, 0, 0, 0, 0, -6,
|
---|
| 162 | 705, 7, 0, 60, 0, 61, 0, 63, 0, 49,
|
---|
| 163 | 0, 0, 0, 0, 0, 0, 17, 0, 78, 0,
|
---|
| 164 | -47, -45, 0, 0, 0, 537, 440, 620, 637, 594,
|
---|
| 165 | 0, 0, 0, 0, 0, 0, -33, 0, 66, 0,
|
---|
| 166 | 0, -19, 0, 0, 68, 0, 0, 0, 0, 0,
|
---|
| 167 | 667, 680, 508, 0, 705, 18, 0, 0, 0, 0,
|
---|
| 168 | 0, 0, 0, 0, 0, 0, -31, 49, -44, 0,
|
---|
| 169 | 0, -40, 0, 0, 0, 0, 0, 0, 0, 0,
|
---|
| 170 | 0, 0, 0, 1, 69, 0, 0, 0, 0, 0,
|
---|
| 171 | 13, 0, 0, 0, 0,
|
---|
| 172 | };
|
---|
| 173 | short yygindex[] = { 0,
|
---|
| 174 | 958, 0, 104, -118, 0, 0, -35, 0, 0, 0,
|
---|
| 175 | 0, -34, 22, 0, 15, 0, 0, 0, 0, 0,
|
---|
| 176 | 0, 0, 0, -1, 0, 0, 0, 0, 0, 0,
|
---|
| 177 | 0,
|
---|
| 178 | };
|
---|
| 179 | #define YYTABLESIZE 1113
|
---|
| 180 | short yytable[] = { 52,
|
---|
| 181 | 26, 129, 66, 64, 52, 65, 92, 55, 10, 57,
|
---|
| 182 | 55, 12, 57, 14, 45, 36, 158, 40, 52, 144,
|
---|
| 183 | 45, 66, 40, 38, 67, 55, 68, 57, 42, 70,
|
---|
| 184 | 40, 46, 28, 41, 47, 49, 160, 27, 92, 66,
|
---|
| 185 | 105, 51, 6, 52, 43, 18, 19, 61, 53, 76,
|
---|
| 186 | 61, 23, 9, 80, 66, 82, 107, 66, 63, 10,
|
---|
| 187 | 44, 63, 118, 85, 104, 28, 26, 111, 41, 127,
|
---|
| 188 | 27, 12, 93, 103, 10, 44, 128, 12, 38, 14,
|
---|
| 189 | 45, 134, 52, 129, 102, 136, 130, 137, 140, 142,
|
---|
| 190 | 135, 145, 148, 143, 162, 151, 59, 28, 150, 67,
|
---|
| 191 | 60, 50, 27, 68, 20, 119, 51, 65, 36, 65,
|
---|
| 192 | 44, 0, 153, 120, 0, 29, 133, 0, 0, 159,
|
---|
| 193 | 0, 0, 0, 0, 0, 0, 64, 0, 65, 0,
|
---|
| 194 | 28, 0, 0, 0, 0, 27, 41, 0, 0, 0,
|
---|
| 195 | 0, 44, 0, 0, 0, 0, 0, 0, 29, 0,
|
---|
| 196 | 163, 0, 139, 0, 0, 0, 0, 0, 0, 0,
|
---|
| 197 | 0, 147, 0, 0, 0, 0, 28, 0, 0, 0,
|
---|
| 198 | 20, 27, 62, 156, 0, 119, 0, 66, 0, 0,
|
---|
| 199 | 29, 0, 0, 0, 0, 165, 0, 0, 0, 0,
|
---|
| 200 | 0, 0, 0, 0, 0, 28, 0, 0, 26, 0,
|
---|
| 201 | 27, 0, 41, 0, 91, 28, 10, 0, 0, 12,
|
---|
| 202 | 27, 14, 45, 29, 157, 52, 52, 0, 26, 52,
|
---|
| 203 | 52, 52, 52, 55, 62, 57, 52, 69, 52, 52,
|
---|
| 204 | 52, 52, 52, 52, 52, 52, 161, 52, 52, 52,
|
---|
| 205 | 6, 52, 52, 52, 52, 52, 52, 52, 2, 29,
|
---|
| 206 | 9, 28, 3, 4, 5, 6, 27, 10, 124, 7,
|
---|
| 207 | 8, 9, 10, 11, 12, 13, 14, 15, 16, 12,
|
---|
| 208 | 17, 18, 19, 44, 20, 21, 22, 23, 24, 25,
|
---|
| 209 | 26, 57, 0, 0, 28, 3, 4, 5, 6, 27,
|
---|
| 210 | 0, 0, 7, 44, 9, 10, 11, 12, 13, 14,
|
---|
| 211 | 15, 16, 20, 17, 18, 19, 0, 20, 21, 22,
|
---|
| 212 | 23, 24, 25, 26, 37, 0, 28, 3, 4, 5,
|
---|
| 213 | 6, 27, 20, 0, 7, 0, 9, 10, 11, 12,
|
---|
| 214 | 13, 14, 15, 16, 41, 17, 18, 19, 0, 20,
|
---|
| 215 | 21, 22, 23, 24, 25, 26, 57, 62, 0, 63,
|
---|
| 216 | 3, 4, 5, 6, 41, 0, 0, 7, 0, 9,
|
---|
| 217 | 10, 11, 12, 13, 14, 15, 16, 0, 17, 18,
|
---|
| 218 | 19, 0, 20, 21, 22, 23, 24, 25, 26, 0,
|
---|
| 219 | 0, 0, 0, 0, 0, 28, 3, 4, 5, 6,
|
---|
| 220 | 27, 0, 0, 7, 0, 9, 10, 11, 12, 13,
|
---|
| 221 | 14, 15, 16, 0, 17, 18, 19, 0, 20, 21,
|
---|
| 222 | 22, 23, 24, 25, 26, 3, 86, 5, 6, 0,
|
---|
| 223 | 0, 0, 7, 0, 0, 3, 11, 5, 6, 0,
|
---|
| 224 | 0, 16, 7, 17, 18, 19, 11, 20, 141, 0,
|
---|
| 225 | 23, 16, 0, 17, 18, 19, 0, 20, 0, 92,
|
---|
| 226 | 23, 92, 92, 92, 0, 0, 0, 0, 0, 0,
|
---|
| 227 | 0, 0, 0, 0, 0, 0, 96, 92, 96, 96,
|
---|
| 228 | 96, 3, 0, 5, 6, 0, 0, 0, 7, 0,
|
---|
| 229 | 76, 0, 11, 76, 96, 0, 0, 16, 0, 17,
|
---|
| 230 | 18, 19, 0, 20, 0, 0, 23, 0, 76, 0,
|
---|
| 231 | 0, 92, 92, 0, 3, 0, 71, 6, 0, 0,
|
---|
| 232 | 82, 7, 82, 82, 82, 11, 0, 0, 96, 96,
|
---|
| 233 | 16, 0, 17, 18, 19, 0, 20, 0, 82, 23,
|
---|
| 234 | 0, 0, 76, 92, 0, 0, 3, 0, 125, 6,
|
---|
| 235 | 0, 0, 0, 7, 0, 0, 0, 11, 70, 0,
|
---|
| 236 | 96, 70, 16, 0, 17, 18, 19, 0, 20, 0,
|
---|
| 237 | 0, 23, 82, 82, 76, 92, 70, 92, 92, 92,
|
---|
| 238 | 0, 0, 0, 0, 0, 0, 0, 79, 0, 79,
|
---|
| 239 | 79, 79, 64, 92, 65, 0, 0, 0, 0, 90,
|
---|
| 240 | 0, 64, 0, 65, 82, 79, 0, 0, 0, 0,
|
---|
| 241 | 70, 0, 110, 0, 64, 3, 65, 5, 6, 0,
|
---|
| 242 | 0, 0, 7, 0, 0, 0, 11, 92, 92, 0,
|
---|
| 243 | 64, 16, 65, 17, 18, 19, 0, 20, 0, 79,
|
---|
| 244 | 23, 0, 70, 66, 80, 0, 80, 80, 80, 0,
|
---|
| 245 | 0, 0, 66, 0, 0, 0, 114, 0, 64, 92,
|
---|
| 246 | 65, 0, 80, 0, 0, 66, 0, 0, 0, 0,
|
---|
| 247 | 77, 79, 77, 77, 77, 92, 92, 92, 0, 0,
|
---|
| 248 | 106, 66, 92, 92, 92, 92, 0, 78, 77, 78,
|
---|
| 249 | 78, 78, 96, 96, 96, 92, 80, 0, 0, 96,
|
---|
| 250 | 96, 96, 96, 0, 0, 78, 76, 76, 76, 66,
|
---|
| 251 | 0, 75, 96, 0, 75, 76, 0, 72, 0, 116,
|
---|
| 252 | 72, 64, 77, 65, 0, 0, 76, 0, 80, 75,
|
---|
| 253 | 74, 0, 0, 74, 0, 72, 82, 82, 82, 78,
|
---|
| 254 | 0, 0, 0, 82, 0, 82, 0, 0, 74, 0,
|
---|
| 255 | 0, 0, 0, 0, 77, 92, 82, 92, 92, 92,
|
---|
| 256 | 0, 0, 0, 75, 0, 0, 117, 0, 64, 72,
|
---|
| 257 | 65, 78, 66, 0, 70, 70, 70, 64, 0, 65,
|
---|
| 258 | 0, 0, 74, 70, 0, 0, 0, 0, 0, 0,
|
---|
| 259 | 0, 92, 92, 92, 70, 75, 0, 0, 92, 0,
|
---|
| 260 | 92, 72, 0, 79, 79, 79, 0, 60, 92, 0,
|
---|
| 261 | 79, 92, 79, 62, 74, 63, 60, 61, 0, 66,
|
---|
| 262 | 0, 0, 62, 79, 63, 0, 0, 0, 66, 60,
|
---|
| 263 | 61, 0, 0, 0, 0, 62, 0, 63, 0, 0,
|
---|
| 264 | 0, 0, 0, 0, 0, 60, 61, 0, 0, 0,
|
---|
| 265 | 0, 62, 0, 63, 0, 0, 0, 0, 0, 0,
|
---|
| 266 | 80, 80, 80, 0, 0, 0, 0, 80, 0, 80,
|
---|
| 267 | 0, 0, 0, 60, 61, 0, 0, 0, 0, 62,
|
---|
| 268 | 80, 63, 0, 0, 0, 0, 77, 77, 77, 0,
|
---|
| 269 | 0, 0, 0, 0, 0, 77, 0, 0, 0, 0,
|
---|
| 270 | 0, 0, 0, 78, 78, 78, 77, 0, 0, 0,
|
---|
| 271 | 0, 0, 78, 0, 0, 0, 0, 0, 0, 0,
|
---|
| 272 | 0, 0, 0, 78, 0, 0, 0, 75, 75, 75,
|
---|
| 273 | 0, 0, 0, 72, 72, 72, 60, 61, 0, 0,
|
---|
| 274 | 0, 0, 62, 0, 63, 0, 74, 75, 74, 0,
|
---|
| 275 | 0, 0, 0, 72, 0, 0, 0, 0, 0, 0,
|
---|
| 276 | 0, 0, 0, 0, 0, 0, 74, 0, 0, 0,
|
---|
| 277 | 39, 0, 92, 92, 0, 0, 0, 0, 92, 92,
|
---|
| 278 | 92, 92, 0, 60, 61, 0, 0, 0, 0, 62,
|
---|
| 279 | 0, 63, 60, 61, 55, 56, 0, 0, 62, 0,
|
---|
| 280 | 63, 0, 0, 0, 0, 0, 0, 72, 75, 0,
|
---|
| 281 | 0, 0, 0, 77, 78, 0, 81, 0, 83, 84,
|
---|
| 282 | 0, 87, 0, 0, 0, 0, 0, 0, 0, 96,
|
---|
| 283 | 97, 98, 99, 100, 0, 0, 0, 0, 0, 0,
|
---|
| 284 | 0, 0, 0, 0, 0, 0, 0, 112, 0, 115,
|
---|
| 285 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
---|
| 286 | 0, 121, 122, 0, 0, 0, 0, 0, 123, 0,
|
---|
| 287 | 75, 0, 126, 0, 0, 0, 0, 0, 0, 0,
|
---|
| 288 | 0, 0, 0, 0, 0, 87, 0, 0, 0, 0,
|
---|
| 289 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
---|
| 290 | 0, 75, 0, 0, 0, 112, 0, 0, 0, 0,
|
---|
| 291 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
---|
| 292 | 0, 0, 112,
|
---|
| 293 | };
|
---|
| 294 | short yycheck[] = { 40,
|
---|
| 295 | 59, 44, 94, 43, 45, 45, 59, 41, 59, 41,
|
---|
| 296 | 44, 59, 44, 59, 59, 1, 59, 40, 59, 138,
|
---|
| 297 | 262, 41, 40, 2, 265, 59, 267, 59, 262, 59,
|
---|
| 298 | 40, 40, 40, 91, 40, 40, 155, 45, 59, 59,
|
---|
| 299 | 44, 40, 59, 40, 278, 279, 280, 41, 40, 40,
|
---|
| 300 | 44, 285, 59, 40, 94, 40, 262, 94, 41, 59,
|
---|
| 301 | 44, 44, 44, 41, 41, 40, 125, 41, 91, 91,
|
---|
| 302 | 45, 59, 125, 91, 125, 59, 41, 125, 57, 125,
|
---|
| 303 | 125, 91, 123, 44, 70, 123, 59, 262, 41, 257,
|
---|
| 304 | 93, 277, 281, 91, 41, 59, 41, 40, 93, 41,
|
---|
| 305 | 41, 41, 45, 41, 59, 91, 41, 59, 41, 41,
|
---|
| 306 | 7, -1, 148, 92, -1, 123, 118, -1, -1, 154,
|
---|
| 307 | -1, -1, -1, -1, -1, -1, 43, -1, 45, -1,
|
---|
| 308 | 40, -1, -1, -1, -1, 45, 59, -1, -1, -1,
|
---|
| 309 | -1, 125, -1, -1, -1, -1, -1, -1, 123, -1,
|
---|
| 310 | 125, -1, 131, -1, -1, -1, -1, -1, -1, -1,
|
---|
| 311 | -1, 140, -1, -1, -1, -1, 40, -1, -1, -1,
|
---|
| 312 | 125, 45, 264, 152, -1, 161, -1, 94, -1, -1,
|
---|
| 313 | 123, -1, -1, -1, -1, 164, -1, -1, -1, -1,
|
---|
| 314 | -1, -1, -1, -1, -1, 40, -1, -1, 257, -1,
|
---|
| 315 | 45, -1, 125, -1, 257, 40, 257, -1, -1, 257,
|
---|
| 316 | 45, 257, 257, 123, 257, 256, 257, -1, 277, 260,
|
---|
| 317 | 261, 262, 263, 257, 264, 257, 267, 257, 269, 270,
|
---|
| 318 | 271, 272, 273, 274, 275, 276, 257, 278, 279, 280,
|
---|
| 319 | 257, 282, 283, 284, 285, 286, 287, 288, 256, 123,
|
---|
| 320 | 257, 40, 260, 261, 262, 263, 45, 257, 93, 267,
|
---|
| 321 | 268, 269, 270, 271, 272, 273, 274, 275, 276, 257,
|
---|
| 322 | 278, 279, 280, 257, 282, 283, 284, 285, 286, 287,
|
---|
| 323 | 288, 256, -1, -1, 40, 260, 261, 262, 263, 45,
|
---|
| 324 | -1, -1, 267, 277, 269, 270, 271, 272, 273, 274,
|
---|
| 325 | 275, 276, 257, 278, 279, 280, -1, 282, 283, 284,
|
---|
| 326 | 285, 286, 287, 288, 257, -1, 40, 260, 261, 262,
|
---|
| 327 | 263, 45, 277, -1, 267, -1, 269, 270, 271, 272,
|
---|
| 328 | 273, 274, 275, 276, 257, 278, 279, 280, -1, 282,
|
---|
| 329 | 283, 284, 285, 286, 287, 288, 256, 264, -1, 266,
|
---|
| 330 | 260, 261, 262, 263, 277, -1, -1, 267, -1, 269,
|
---|
| 331 | 270, 271, 272, 273, 274, 275, 276, -1, 278, 279,
|
---|
| 332 | 280, -1, 282, 283, 284, 285, 286, 287, 288, -1,
|
---|
| 333 | -1, -1, -1, -1, -1, 40, 260, 261, 262, 263,
|
---|
| 334 | 45, -1, -1, 267, -1, 269, 270, 271, 272, 273,
|
---|
| 335 | 274, 275, 276, -1, 278, 279, 280, -1, 282, 283,
|
---|
| 336 | 284, 285, 286, 287, 288, 260, 261, 262, 263, -1,
|
---|
| 337 | -1, -1, 267, -1, -1, 260, 271, 262, 263, -1,
|
---|
| 338 | -1, 276, 267, 278, 279, 280, 271, 282, 93, -1,
|
---|
| 339 | 285, 276, -1, 278, 279, 280, -1, 282, -1, 41,
|
---|
| 340 | 285, 43, 44, 45, -1, -1, -1, -1, -1, -1,
|
---|
| 341 | -1, -1, -1, -1, -1, -1, 41, 59, 43, 44,
|
---|
| 342 | 45, 260, -1, 262, 263, -1, -1, -1, 267, -1,
|
---|
| 343 | 41, -1, 271, 44, 59, -1, -1, 276, -1, 278,
|
---|
| 344 | 279, 280, -1, 282, -1, -1, 285, -1, 59, -1,
|
---|
| 345 | -1, 93, 94, -1, 260, -1, 262, 263, -1, -1,
|
---|
| 346 | 41, 267, 43, 44, 45, 271, -1, -1, 93, 94,
|
---|
| 347 | 276, -1, 278, 279, 280, -1, 282, -1, 59, 285,
|
---|
| 348 | -1, -1, 93, 125, -1, -1, 260, -1, 262, 263,
|
---|
| 349 | -1, -1, -1, 267, -1, -1, -1, 271, 41, -1,
|
---|
| 350 | 125, 44, 276, -1, 278, 279, 280, -1, 282, -1,
|
---|
| 351 | -1, 285, 93, 94, 125, 41, 59, 43, 44, 45,
|
---|
| 352 | -1, -1, -1, -1, -1, -1, -1, 41, -1, 43,
|
---|
| 353 | 44, 45, 43, 59, 45, -1, -1, -1, -1, 41,
|
---|
| 354 | -1, 43, -1, 45, 125, 59, -1, -1, -1, -1,
|
---|
| 355 | 93, -1, 41, -1, 43, 260, 45, 262, 263, -1,
|
---|
| 356 | -1, -1, 267, -1, -1, -1, 271, 93, 94, -1,
|
---|
| 357 | 43, 276, 45, 278, 279, 280, -1, 282, -1, 93,
|
---|
| 358 | 285, -1, 125, 94, 41, -1, 43, 44, 45, -1,
|
---|
| 359 | -1, -1, 94, -1, -1, -1, 41, -1, 43, 125,
|
---|
| 360 | 45, -1, 59, -1, -1, 94, -1, -1, -1, -1,
|
---|
| 361 | 41, 125, 43, 44, 45, 257, 258, 259, -1, -1,
|
---|
| 362 | 93, 94, 264, 265, 266, 267, -1, 41, 59, 43,
|
---|
| 363 | 44, 45, 257, 258, 259, 277, 93, -1, -1, 264,
|
---|
| 364 | 265, 266, 267, -1, -1, 59, 257, 258, 259, 94,
|
---|
| 365 | -1, 41, 277, -1, 44, 266, -1, 41, -1, 41,
|
---|
| 366 | 44, 43, 93, 45, -1, -1, 277, -1, 125, 59,
|
---|
| 367 | 41, -1, -1, 44, -1, 59, 257, 258, 259, 93,
|
---|
| 368 | -1, -1, -1, 264, -1, 266, -1, -1, 59, -1,
|
---|
| 369 | -1, -1, -1, -1, 125, 41, 277, 43, 44, 45,
|
---|
| 370 | -1, -1, -1, 93, -1, -1, 41, -1, 43, 93,
|
---|
| 371 | 45, 125, 94, -1, 257, 258, 259, 43, -1, 45,
|
---|
| 372 | -1, -1, 93, 266, -1, -1, -1, -1, -1, -1,
|
---|
| 373 | -1, 257, 258, 259, 277, 125, -1, -1, 264, -1,
|
---|
| 374 | 266, 125, -1, 257, 258, 259, -1, 258, 94, -1,
|
---|
| 375 | 264, 277, 266, 264, 125, 266, 258, 259, -1, 94,
|
---|
| 376 | -1, -1, 264, 277, 266, -1, -1, -1, 94, 258,
|
---|
| 377 | 259, -1, -1, -1, -1, 264, -1, 266, -1, -1,
|
---|
| 378 | -1, -1, -1, -1, -1, 258, 259, -1, -1, -1,
|
---|
| 379 | -1, 264, -1, 266, -1, -1, -1, -1, -1, -1,
|
---|
| 380 | 257, 258, 259, -1, -1, -1, -1, 264, -1, 266,
|
---|
| 381 | -1, -1, -1, 258, 259, -1, -1, -1, -1, 264,
|
---|
| 382 | 277, 266, -1, -1, -1, -1, 257, 258, 259, -1,
|
---|
| 383 | -1, -1, -1, -1, -1, 266, -1, -1, -1, -1,
|
---|
| 384 | -1, -1, -1, 257, 258, 259, 277, -1, -1, -1,
|
---|
| 385 | -1, -1, 266, -1, -1, -1, -1, -1, -1, -1,
|
---|
| 386 | -1, -1, -1, 277, -1, -1, -1, 257, 258, 259,
|
---|
| 387 | -1, -1, -1, 257, 258, 259, 258, 259, -1, -1,
|
---|
| 388 | -1, -1, 264, -1, 266, -1, 257, 277, 259, -1,
|
---|
| 389 | -1, -1, -1, 277, -1, -1, -1, -1, -1, -1,
|
---|
| 390 | -1, -1, -1, -1, -1, -1, 277, -1, -1, -1,
|
---|
| 391 | 3, -1, 258, 259, -1, -1, -1, -1, 264, 265,
|
---|
| 392 | 266, 267, -1, 258, 259, -1, -1, -1, -1, 264,
|
---|
| 393 | -1, 266, 258, 259, 27, 28, -1, -1, 264, -1,
|
---|
| 394 | 266, -1, -1, -1, -1, -1, -1, 40, 41, -1,
|
---|
| 395 | -1, -1, -1, 46, 47, -1, 49, -1, 51, 52,
|
---|
| 396 | -1, 54, -1, -1, -1, -1, -1, -1, -1, 62,
|
---|
| 397 | 63, 64, 65, 66, -1, -1, -1, -1, -1, -1,
|
---|
| 398 | -1, -1, -1, -1, -1, -1, -1, 80, -1, 82,
|
---|
| 399 | -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
|
---|
| 400 | -1, 94, 95, -1, -1, -1, -1, -1, 101, -1,
|
---|
| 401 | 103, -1, 105, -1, -1, -1, -1, -1, -1, -1,
|
---|
| 402 | -1, -1, -1, -1, -1, 118, -1, -1, -1, -1,
|
---|
| 403 | -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
|
---|
| 404 | -1, 134, -1, -1, -1, 138, -1, -1, -1, -1,
|
---|
| 405 | -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
|
---|
| 406 | -1, -1, 155,
|
---|
| 407 | };
|
---|
| 408 | #define YYFINAL 1
|
---|
| 409 | #ifndef YYDEBUG
|
---|
| 410 | #define YYDEBUG 0
|
---|
| 411 | #endif
|
---|
| 412 | #define YYMAXTOKEN 289
|
---|
| 413 | #if YYDEBUG
|
---|
| 414 | char *yyname[] = {
|
---|
| 415 | "end-of-file",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,
|
---|
| 416 | 0,0,0,0,0,0,"'('","')'",0,"'+'","','","'-'",0,0,0,0,0,0,0,0,0,0,0,0,0,"';'",0,0,
|
---|
| 417 | 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,
|
---|
| 418 | 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,
|
---|
| 419 | 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,
|
---|
| 420 | 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,
|
---|
| 421 | 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,
|
---|
| 422 | 0,0,0,0,0,"NEWLINE","AND","OR","NOT","STRING","NAME","NUMBER","MUL_OP",
|
---|
| 423 | "ASSIGN_OP","REL_OP","INCR_DECR","Define","Break","Quit","Length","Return",
|
---|
| 424 | "For","If","While","Sqrt","Else","Scale","Ibase","Obase","Auto","Read",
|
---|
| 425 | "Warranty","Halt","Last","Continue","Print","Limits","UNARY_MINUS",
|
---|
| 426 | };
|
---|
| 427 | char *yyrule[] = {
|
---|
| 428 | "$accept : program",
|
---|
| 429 | "program :",
|
---|
| 430 | "program : program input_item",
|
---|
| 431 | "input_item : semicolon_list NEWLINE",
|
---|
| 432 | "input_item : function",
|
---|
| 433 | "input_item : error NEWLINE",
|
---|
| 434 | "semicolon_list :",
|
---|
| 435 | "semicolon_list : statement_or_error",
|
---|
| 436 | "semicolon_list : semicolon_list ';' statement_or_error",
|
---|
| 437 | "semicolon_list : semicolon_list ';'",
|
---|
| 438 | "statement_list :",
|
---|
| 439 | "statement_list : statement_or_error",
|
---|
| 440 | "statement_list : statement_list NEWLINE",
|
---|
| 441 | "statement_list : statement_list NEWLINE statement_or_error",
|
---|
| 442 | "statement_list : statement_list ';'",
|
---|
| 443 | "statement_list : statement_list ';' statement",
|
---|
| 444 | "statement_or_error : statement",
|
---|
| 445 | "statement_or_error : error statement",
|
---|
| 446 | "statement : Warranty",
|
---|
| 447 | "statement : Limits",
|
---|
| 448 | "statement : expression",
|
---|
| 449 | "statement : STRING",
|
---|
| 450 | "statement : Break",
|
---|
| 451 | "statement : Continue",
|
---|
| 452 | "statement : Quit",
|
---|
| 453 | "statement : Halt",
|
---|
| 454 | "statement : Return",
|
---|
| 455 | "statement : Return '(' return_expression ')'",
|
---|
| 456 | "$$1 :",
|
---|
| 457 | "$$2 :",
|
---|
| 458 | "$$3 :",
|
---|
| 459 | "$$4 :",
|
---|
| 460 | "statement : For $$1 '(' opt_expression ';' $$2 opt_expression ';' $$3 opt_expression ')' $$4 statement",
|
---|
| 461 | "$$5 :",
|
---|
| 462 | "statement : If '(' expression ')' $$5 statement opt_else",
|
---|
| 463 | "$$6 :",
|
---|
| 464 | "$$7 :",
|
---|
| 465 | "statement : While $$6 '(' expression $$7 ')' statement",
|
---|
| 466 | "statement : '{' statement_list '}'",
|
---|
| 467 | "$$8 :",
|
---|
| 468 | "statement : Print $$8 print_list",
|
---|
| 469 | "print_list : print_element",
|
---|
| 470 | "print_list : print_element ',' print_list",
|
---|
| 471 | "print_element : STRING",
|
---|
| 472 | "print_element : expression",
|
---|
| 473 | "opt_else :",
|
---|
| 474 | "$$9 :",
|
---|
| 475 | "opt_else : Else $$9 statement",
|
---|
| 476 | "$$10 :",
|
---|
| 477 | "function : Define NAME '(' opt_parameter_list ')' '{' NEWLINE opt_auto_define_list $$10 statement_list NEWLINE '}'",
|
---|
| 478 | "opt_parameter_list :",
|
---|
| 479 | "opt_parameter_list : define_list",
|
---|
| 480 | "opt_auto_define_list :",
|
---|
| 481 | "opt_auto_define_list : Auto define_list NEWLINE",
|
---|
| 482 | "opt_auto_define_list : Auto define_list ';'",
|
---|
| 483 | "define_list : NAME",
|
---|
| 484 | "define_list : NAME '[' ']'",
|
---|
| 485 | "define_list : define_list ',' NAME",
|
---|
| 486 | "define_list : define_list ',' NAME '[' ']'",
|
---|
| 487 | "opt_argument_list :",
|
---|
| 488 | "opt_argument_list : argument_list",
|
---|
| 489 | "argument_list : expression",
|
---|
| 490 | "argument_list : NAME '[' ']'",
|
---|
| 491 | "argument_list : argument_list ',' expression",
|
---|
| 492 | "argument_list : argument_list ',' NAME '[' ']'",
|
---|
| 493 | "opt_expression :",
|
---|
| 494 | "opt_expression : expression",
|
---|
| 495 | "return_expression :",
|
---|
| 496 | "return_expression : expression",
|
---|
| 497 | "$$11 :",
|
---|
| 498 | "expression : named_expression ASSIGN_OP $$11 expression",
|
---|
| 499 | "$$12 :",
|
---|
| 500 | "expression : expression AND $$12 expression",
|
---|
| 501 | "$$13 :",
|
---|
| 502 | "expression : expression OR $$13 expression",
|
---|
| 503 | "expression : NOT expression",
|
---|
| 504 | "expression : expression REL_OP expression",
|
---|
| 505 | "expression : expression '+' expression",
|
---|
| 506 | "expression : expression '-' expression",
|
---|
| 507 | "expression : expression MUL_OP expression",
|
---|
| 508 | "expression : expression '^' expression",
|
---|
| 509 | "expression : '-' expression",
|
---|
| 510 | "expression : named_expression",
|
---|
| 511 | "expression : NUMBER",
|
---|
| 512 | "expression : '(' expression ')'",
|
---|
| 513 | "expression : NAME '(' opt_argument_list ')'",
|
---|
| 514 | "expression : INCR_DECR named_expression",
|
---|
| 515 | "expression : named_expression INCR_DECR",
|
---|
| 516 | "expression : Length '(' expression ')'",
|
---|
| 517 | "expression : Sqrt '(' expression ')'",
|
---|
| 518 | "expression : Scale '(' expression ')'",
|
---|
| 519 | "expression : Read '(' ')'",
|
---|
| 520 | "named_expression : NAME",
|
---|
| 521 | "named_expression : NAME '[' expression ']'",
|
---|
| 522 | "named_expression : Ibase",
|
---|
| 523 | "named_expression : Obase",
|
---|
| 524 | "named_expression : Scale",
|
---|
| 525 | "named_expression : Last",
|
---|
| 526 | };
|
---|
| 527 | #endif
|
---|
| 528 | #ifdef YYSTACKSIZE
|
---|
| 529 | #undef YYMAXDEPTH
|
---|
| 530 | #define YYMAXDEPTH YYSTACKSIZE
|
---|
| 531 | #else
|
---|
| 532 | #ifdef YYMAXDEPTH
|
---|
| 533 | #define YYSTACKSIZE YYMAXDEPTH
|
---|
| 534 | #else
|
---|
| 535 | #define YYSTACKSIZE 500
|
---|
| 536 | #define YYMAXDEPTH 500
|
---|
| 537 | #endif
|
---|
| 538 | #endif
|
---|
| 539 | int yydebug;
|
---|
| 540 | int yynerrs;
|
---|
| 541 | int yyerrflag;
|
---|
| 542 | int yychar;
|
---|
| 543 | short *yyssp;
|
---|
| 544 | YYSTYPE *yyvsp;
|
---|
| 545 | YYSTYPE yyval;
|
---|
| 546 | YYSTYPE yylval;
|
---|
| 547 | short yyss[YYSTACKSIZE];
|
---|
| 548 | YYSTYPE yyvs[YYSTACKSIZE];
|
---|
| 549 | #define yystacksize YYSTACKSIZE
|
---|
| 550 | #define YYABORT goto yyabort
|
---|
| 551 | #define YYREJECT goto yyabort
|
---|
| 552 | #define YYACCEPT goto yyaccept
|
---|
| 553 | #define YYERROR goto yyerrlab
|
---|
| 554 | int
|
---|
| 555 | yyparse()
|
---|
| 556 | {
|
---|
| 557 | register int yym, yyn, yystate;
|
---|
| 558 | #if YYDEBUG
|
---|
| 559 | register char *yys;
|
---|
| 560 | extern char *getenv();
|
---|
| 561 |
|
---|
| 562 | if (yys = getenv("YYDEBUG"))
|
---|
| 563 | {
|
---|
| 564 | yyn = *yys;
|
---|
| 565 | if (yyn >= '0' && yyn <= '9')
|
---|
| 566 | yydebug = yyn - '0';
|
---|
| 567 | }
|
---|
| 568 | #endif
|
---|
| 569 |
|
---|
| 570 | yynerrs = 0;
|
---|
| 571 | yyerrflag = 0;
|
---|
| 572 | yychar = (-1);
|
---|
| 573 |
|
---|
| 574 | yyssp = yyss;
|
---|
| 575 | yyvsp = yyvs;
|
---|
| 576 | *yyssp = yystate = 0;
|
---|
| 577 |
|
---|
| 578 | yyloop:
|
---|
| 579 | if (yyn = yydefred[yystate]) goto yyreduce;
|
---|
| 580 | if (yychar < 0)
|
---|
| 581 | {
|
---|
| 582 | if ((yychar = yylex()) < 0) yychar = 0;
|
---|
| 583 | #if YYDEBUG
|
---|
| 584 | if (yydebug)
|
---|
| 585 | {
|
---|
| 586 | yys = 0;
|
---|
| 587 | if (yychar <= YYMAXTOKEN) yys = yyname[yychar];
|
---|
| 588 | if (!yys) yys = "illegal-symbol";
|
---|
| 589 | printf("%sdebug: state %d, reading %d (%s)\n",
|
---|
| 590 | YYPREFIX, yystate, yychar, yys);
|
---|
| 591 | }
|
---|
| 592 | #endif
|
---|
| 593 | }
|
---|
| 594 | if ((yyn = yysindex[yystate]) && (yyn += yychar) >= 0 &&
|
---|
| 595 | yyn <= YYTABLESIZE && yycheck[yyn] == yychar)
|
---|
| 596 | {
|
---|
| 597 | #if YYDEBUG
|
---|
| 598 | if (yydebug)
|
---|
| 599 | printf("%sdebug: state %d, shifting to state %d\n",
|
---|
| 600 | YYPREFIX, yystate, yytable[yyn]);
|
---|
| 601 | #endif
|
---|
| 602 | if (yyssp >= yyss + yystacksize - 1)
|
---|
| 603 | {
|
---|
| 604 | goto yyoverflow;
|
---|
| 605 | }
|
---|
| 606 | *++yyssp = yystate = yytable[yyn];
|
---|
| 607 | *++yyvsp = yylval;
|
---|
| 608 | yychar = (-1);
|
---|
| 609 | if (yyerrflag > 0) --yyerrflag;
|
---|
| 610 | goto yyloop;
|
---|
| 611 | }
|
---|
| 612 | if ((yyn = yyrindex[yystate]) && (yyn += yychar) >= 0 &&
|
---|
| 613 | yyn <= YYTABLESIZE && yycheck[yyn] == yychar)
|
---|
| 614 | {
|
---|
| 615 | yyn = yytable[yyn];
|
---|
| 616 | goto yyreduce;
|
---|
| 617 | }
|
---|
| 618 | if (yyerrflag) goto yyinrecovery;
|
---|
| 619 | #ifdef lint
|
---|
| 620 | goto yynewerror;
|
---|
| 621 | #endif
|
---|
| 622 | yynewerror:
|
---|
| 623 | yyerror("syntax error");
|
---|
| 624 | #ifdef lint
|
---|
| 625 | goto yyerrlab;
|
---|
| 626 | #endif
|
---|
| 627 | yyerrlab:
|
---|
| 628 | ++yynerrs;
|
---|
| 629 | yyinrecovery:
|
---|
| 630 | if (yyerrflag < 3)
|
---|
| 631 | {
|
---|
| 632 | yyerrflag = 3;
|
---|
| 633 | for (;;)
|
---|
| 634 | {
|
---|
| 635 | if ((yyn = yysindex[*yyssp]) && (yyn += YYERRCODE) >= 0 &&
|
---|
| 636 | yyn <= YYTABLESIZE && yycheck[yyn] == YYERRCODE)
|
---|
| 637 | {
|
---|
| 638 | #if YYDEBUG
|
---|
| 639 | if (yydebug)
|
---|
| 640 | printf("%sdebug: state %d, error recovery shifting\
|
---|
| 641 | to state %d\n", YYPREFIX, *yyssp, yytable[yyn]);
|
---|
| 642 | #endif
|
---|
| 643 | if (yyssp >= yyss + yystacksize - 1)
|
---|
| 644 | {
|
---|
| 645 | goto yyoverflow;
|
---|
| 646 | }
|
---|
| 647 | *++yyssp = yystate = yytable[yyn];
|
---|
| 648 | *++yyvsp = yylval;
|
---|
| 649 | goto yyloop;
|
---|
| 650 | }
|
---|
| 651 | else
|
---|
| 652 | {
|
---|
| 653 | #if YYDEBUG
|
---|
| 654 | if (yydebug)
|
---|
| 655 | printf("%sdebug: error recovery discarding state %d\n",
|
---|
| 656 | YYPREFIX, *yyssp);
|
---|
| 657 | #endif
|
---|
| 658 | if (yyssp <= yyss) goto yyabort;
|
---|
| 659 | --yyssp;
|
---|
| 660 | --yyvsp;
|
---|
| 661 | }
|
---|
| 662 | }
|
---|
| 663 | }
|
---|
| 664 | else
|
---|
| 665 | {
|
---|
| 666 | if (yychar == 0) goto yyabort;
|
---|
| 667 | #if YYDEBUG
|
---|
| 668 | if (yydebug)
|
---|
| 669 | {
|
---|
| 670 | yys = 0;
|
---|
| 671 | if (yychar <= YYMAXTOKEN) yys = yyname[yychar];
|
---|
| 672 | if (!yys) yys = "illegal-symbol";
|
---|
| 673 | printf("%sdebug: state %d, error recovery discards token %d (%s)\n",
|
---|
| 674 | YYPREFIX, yystate, yychar, yys);
|
---|
| 675 | }
|
---|
| 676 | #endif
|
---|
| 677 | yychar = (-1);
|
---|
| 678 | goto yyloop;
|
---|
| 679 | }
|
---|
| 680 | yyreduce:
|
---|
| 681 | #if YYDEBUG
|
---|
| 682 | if (yydebug)
|
---|
| 683 | printf("%sdebug: state %d, reducing by rule %d (%s)\n",
|
---|
| 684 | YYPREFIX, yystate, yyn, yyrule[yyn]);
|
---|
| 685 | #endif
|
---|
| 686 | yym = yylen[yyn];
|
---|
| 687 | yyval = yyvsp[1-yym];
|
---|
| 688 | switch (yyn)
|
---|
| 689 | {
|
---|
| 690 | case 1:
|
---|
| 691 | #line 106 "bc.y"
|
---|
| 692 | {
|
---|
| 693 | yyval.i_value = 0;
|
---|
| 694 | if (interactive)
|
---|
| 695 | {
|
---|
| 696 | printf ("%s\n", BC_VERSION);
|
---|
| 697 | welcome ();
|
---|
| 698 | }
|
---|
| 699 | }
|
---|
| 700 | break;
|
---|
| 701 | case 3:
|
---|
| 702 | #line 117 "bc.y"
|
---|
| 703 | { run_code (); }
|
---|
| 704 | break;
|
---|
| 705 | case 4:
|
---|
| 706 | #line 119 "bc.y"
|
---|
| 707 | { run_code (); }
|
---|
| 708 | break;
|
---|
| 709 | case 5:
|
---|
| 710 | #line 121 "bc.y"
|
---|
| 711 | {
|
---|
| 712 | yyerrok;
|
---|
| 713 | init_gen ();
|
---|
| 714 | }
|
---|
| 715 | break;
|
---|
| 716 | case 6:
|
---|
| 717 | #line 127 "bc.y"
|
---|
| 718 | { yyval.i_value = 0; }
|
---|
| 719 | break;
|
---|
| 720 | case 10:
|
---|
| 721 | #line 133 "bc.y"
|
---|
| 722 | { yyval.i_value = 0; }
|
---|
| 723 | break;
|
---|
| 724 | case 17:
|
---|
| 725 | #line 142 "bc.y"
|
---|
| 726 | { yyval.i_value = yyvsp[0].i_value; }
|
---|
| 727 | break;
|
---|
| 728 | case 18:
|
---|
| 729 | #line 145 "bc.y"
|
---|
| 730 | { warranty (""); }
|
---|
| 731 | break;
|
---|
| 732 | case 19:
|
---|
| 733 | #line 147 "bc.y"
|
---|
| 734 | { limits (); }
|
---|
| 735 | break;
|
---|
| 736 | case 20:
|
---|
| 737 | #line 149 "bc.y"
|
---|
| 738 | {
|
---|
| 739 | if (yyvsp[0].i_value & 2)
|
---|
| 740 | warn ("comparison in expression");
|
---|
| 741 | if (yyvsp[0].i_value & 1)
|
---|
| 742 | generate ("W");
|
---|
| 743 | else
|
---|
| 744 | generate ("p");
|
---|
| 745 | }
|
---|
| 746 | break;
|
---|
| 747 | case 21:
|
---|
| 748 | #line 158 "bc.y"
|
---|
| 749 | {
|
---|
| 750 | yyval.i_value = 0;
|
---|
| 751 | generate ("w");
|
---|
| 752 | generate (yyvsp[0].s_value);
|
---|
| 753 | free (yyvsp[0].s_value);
|
---|
| 754 | }
|
---|
| 755 | break;
|
---|
| 756 | case 22:
|
---|
| 757 | #line 165 "bc.y"
|
---|
| 758 | {
|
---|
| 759 | if (break_label == 0)
|
---|
| 760 | yyerror ("Break outside a for/while");
|
---|
| 761 | else
|
---|
| 762 | {
|
---|
| 763 | sprintf (genstr, "J%1d:", break_label);
|
---|
| 764 | generate (genstr);
|
---|
| 765 | }
|
---|
| 766 | }
|
---|
| 767 | break;
|
---|
| 768 | case 23:
|
---|
| 769 | #line 175 "bc.y"
|
---|
| 770 | {
|
---|
| 771 | warn ("Continue statement");
|
---|
| 772 | if (continue_label == 0)
|
---|
| 773 | yyerror ("Continue outside a for");
|
---|
| 774 | else
|
---|
| 775 | {
|
---|
| 776 | sprintf (genstr, "J%1d:", continue_label);
|
---|
| 777 | generate (genstr);
|
---|
| 778 | }
|
---|
| 779 | }
|
---|
| 780 | break;
|
---|
| 781 | case 24:
|
---|
| 782 | #line 186 "bc.y"
|
---|
| 783 | { exit (0); }
|
---|
| 784 | break;
|
---|
| 785 | case 25:
|
---|
| 786 | #line 188 "bc.y"
|
---|
| 787 | { generate ("h"); }
|
---|
| 788 | break;
|
---|
| 789 | case 26:
|
---|
| 790 | #line 190 "bc.y"
|
---|
| 791 | { generate ("0R"); }
|
---|
| 792 | break;
|
---|
| 793 | case 27:
|
---|
| 794 | #line 192 "bc.y"
|
---|
| 795 | { generate ("R"); }
|
---|
| 796 | break;
|
---|
| 797 | case 28:
|
---|
| 798 | #line 194 "bc.y"
|
---|
| 799 | {
|
---|
| 800 | yyvsp[0].i_value = break_label;
|
---|
| 801 | break_label = next_label++;
|
---|
| 802 | }
|
---|
| 803 | break;
|
---|
| 804 | case 29:
|
---|
| 805 | #line 199 "bc.y"
|
---|
| 806 | {
|
---|
| 807 | if (yyvsp[-1].i_value > 1)
|
---|
| 808 | warn ("Comparison in first for expression");
|
---|
| 809 | yyvsp[-1].i_value = next_label++;
|
---|
| 810 | if (yyvsp[-1].i_value < 0)
|
---|
| 811 | sprintf (genstr, "N%1d:", yyvsp[-1].i_value);
|
---|
| 812 | else
|
---|
| 813 | sprintf (genstr, "pN%1d:", yyvsp[-1].i_value);
|
---|
| 814 | generate (genstr);
|
---|
| 815 | }
|
---|
| 816 | break;
|
---|
| 817 | case 30:
|
---|
| 818 | #line 210 "bc.y"
|
---|
| 819 | {
|
---|
| 820 | if (yyvsp[-1].i_value < 0) generate ("1");
|
---|
| 821 | yyvsp[-1].i_value = next_label++;
|
---|
| 822 | sprintf (genstr, "B%1d:J%1d:", yyvsp[-1].i_value, break_label);
|
---|
| 823 | generate (genstr);
|
---|
| 824 | yyval.i_value = continue_label;
|
---|
| 825 | continue_label = next_label++;
|
---|
| 826 | sprintf (genstr, "N%1d:", continue_label);
|
---|
| 827 | generate (genstr);
|
---|
| 828 | }
|
---|
| 829 | break;
|
---|
| 830 | case 31:
|
---|
| 831 | #line 221 "bc.y"
|
---|
| 832 | {
|
---|
| 833 | if (yyvsp[-1].i_value > 1)
|
---|
| 834 | warn ("Comparison in third for expression");
|
---|
| 835 | if (yyvsp[-1].i_value < 0)
|
---|
| 836 | sprintf (genstr, "J%1d:N%1d:", yyvsp[-7].i_value, yyvsp[-4].i_value);
|
---|
| 837 | else
|
---|
| 838 | sprintf (genstr, "pJ%1d:N%1d:", yyvsp[-7].i_value, yyvsp[-4].i_value);
|
---|
| 839 | generate (genstr);
|
---|
| 840 | }
|
---|
| 841 | break;
|
---|
| 842 | case 32:
|
---|
| 843 | #line 231 "bc.y"
|
---|
| 844 | {
|
---|
| 845 | sprintf (genstr, "J%1d:N%1d:",
|
---|
| 846 | continue_label, break_label);
|
---|
| 847 | generate (genstr);
|
---|
| 848 | break_label = yyvsp[-12].i_value;
|
---|
| 849 | continue_label = yyvsp[-4].i_value;
|
---|
| 850 | }
|
---|
| 851 | break;
|
---|
| 852 | case 33:
|
---|
| 853 | #line 239 "bc.y"
|
---|
| 854 | {
|
---|
| 855 | yyvsp[-1].i_value = if_label;
|
---|
| 856 | if_label = next_label++;
|
---|
| 857 | sprintf (genstr, "Z%1d:", if_label);
|
---|
| 858 | generate (genstr);
|
---|
| 859 | }
|
---|
| 860 | break;
|
---|
| 861 | case 34:
|
---|
| 862 | #line 246 "bc.y"
|
---|
| 863 | {
|
---|
| 864 | sprintf (genstr, "N%1d:", if_label);
|
---|
| 865 | generate (genstr);
|
---|
| 866 | if_label = yyvsp[-4].i_value;
|
---|
| 867 | }
|
---|
| 868 | break;
|
---|
| 869 | case 35:
|
---|
| 870 | #line 252 "bc.y"
|
---|
| 871 | {
|
---|
| 872 | yyvsp[0].i_value = next_label++;
|
---|
| 873 | sprintf (genstr, "N%1d:", yyvsp[0].i_value);
|
---|
| 874 | generate (genstr);
|
---|
| 875 | }
|
---|
| 876 | break;
|
---|
| 877 | case 36:
|
---|
| 878 | #line 258 "bc.y"
|
---|
| 879 | {
|
---|
| 880 | yyvsp[0].i_value = break_label;
|
---|
| 881 | break_label = next_label++;
|
---|
| 882 | sprintf (genstr, "Z%1d:", break_label);
|
---|
| 883 | generate (genstr);
|
---|
| 884 | }
|
---|
| 885 | break;
|
---|
| 886 | case 37:
|
---|
| 887 | #line 265 "bc.y"
|
---|
| 888 | {
|
---|
| 889 | sprintf (genstr, "J%1d:N%1d:", yyvsp[-6].i_value, break_label);
|
---|
| 890 | generate (genstr);
|
---|
| 891 | break_label = yyvsp[-3].i_value;
|
---|
| 892 | }
|
---|
| 893 | break;
|
---|
| 894 | case 38:
|
---|
| 895 | #line 271 "bc.y"
|
---|
| 896 | { yyval.i_value = 0; }
|
---|
| 897 | break;
|
---|
| 898 | case 39:
|
---|
| 899 | #line 273 "bc.y"
|
---|
| 900 | { warn ("print statement"); }
|
---|
| 901 | break;
|
---|
| 902 | case 43:
|
---|
| 903 | #line 280 "bc.y"
|
---|
| 904 | {
|
---|
| 905 | generate ("O");
|
---|
| 906 | generate (yyvsp[0].s_value);
|
---|
| 907 | free (yyvsp[0].s_value);
|
---|
| 908 | }
|
---|
| 909 | break;
|
---|
| 910 | case 44:
|
---|
| 911 | #line 286 "bc.y"
|
---|
| 912 | { generate ("P"); }
|
---|
| 913 | break;
|
---|
| 914 | case 46:
|
---|
| 915 | #line 290 "bc.y"
|
---|
| 916 | {
|
---|
| 917 | warn ("else clause in if statement");
|
---|
| 918 | yyvsp[0].i_value = next_label++;
|
---|
| 919 | sprintf (genstr, "J%d:N%1d:", yyvsp[0].i_value, if_label);
|
---|
| 920 | generate (genstr);
|
---|
| 921 | if_label = yyvsp[0].i_value;
|
---|
| 922 | }
|
---|
| 923 | break;
|
---|
| 924 | case 48:
|
---|
| 925 | #line 300 "bc.y"
|
---|
| 926 | {
|
---|
| 927 | /* Check auto list against parameter list? */
|
---|
| 928 | check_params (yyvsp[-4].a_value,yyvsp[0].a_value);
|
---|
| 929 | sprintf (genstr, "F%d,%s.%s[", lookup(yyvsp[-6].s_value,FUNCT),
|
---|
| 930 | arg_str (yyvsp[-4].a_value,TRUE), arg_str (yyvsp[0].a_value,TRUE));
|
---|
| 931 | generate (genstr);
|
---|
| 932 | free_args (yyvsp[-4].a_value);
|
---|
| 933 | free_args (yyvsp[0].a_value);
|
---|
| 934 | yyvsp[-7].i_value = next_label;
|
---|
| 935 | next_label = 0;
|
---|
| 936 | }
|
---|
| 937 | break;
|
---|
| 938 | case 49:
|
---|
| 939 | #line 312 "bc.y"
|
---|
| 940 | {
|
---|
| 941 | generate ("0R]");
|
---|
| 942 | next_label = yyvsp[-11].i_value;
|
---|
| 943 | }
|
---|
| 944 | break;
|
---|
| 945 | case 50:
|
---|
| 946 | #line 318 "bc.y"
|
---|
| 947 | { yyval.a_value = NULL; }
|
---|
| 948 | break;
|
---|
| 949 | case 52:
|
---|
| 950 | #line 322 "bc.y"
|
---|
| 951 | { yyval.a_value = NULL; }
|
---|
| 952 | break;
|
---|
| 953 | case 53:
|
---|
| 954 | #line 324 "bc.y"
|
---|
| 955 | { yyval.a_value = yyvsp[-1].a_value; }
|
---|
| 956 | break;
|
---|
| 957 | case 54:
|
---|
| 958 | #line 326 "bc.y"
|
---|
| 959 | { yyval.a_value = yyvsp[-1].a_value; }
|
---|
| 960 | break;
|
---|
| 961 | case 55:
|
---|
| 962 | #line 329 "bc.y"
|
---|
| 963 | { yyval.a_value = nextarg (NULL, lookup (yyvsp[0].s_value,SIMPLE)); }
|
---|
| 964 | break;
|
---|
| 965 | case 56:
|
---|
| 966 | #line 331 "bc.y"
|
---|
| 967 | { yyval.a_value = nextarg (NULL, lookup (yyvsp[-2].s_value,ARRAY)); }
|
---|
| 968 | break;
|
---|
| 969 | case 57:
|
---|
| 970 | #line 333 "bc.y"
|
---|
| 971 | { yyval.a_value = nextarg (yyvsp[-2].a_value, lookup (yyvsp[0].s_value,SIMPLE)); }
|
---|
| 972 | break;
|
---|
| 973 | case 58:
|
---|
| 974 | #line 335 "bc.y"
|
---|
| 975 | { yyval.a_value = nextarg (yyvsp[-4].a_value, lookup (yyvsp[-2].s_value,ARRAY)); }
|
---|
| 976 | break;
|
---|
| 977 | case 59:
|
---|
| 978 | #line 338 "bc.y"
|
---|
| 979 | { yyval.a_value = NULL; }
|
---|
| 980 | break;
|
---|
| 981 | case 61:
|
---|
| 982 | #line 342 "bc.y"
|
---|
| 983 | {
|
---|
| 984 | if (yyvsp[0].i_value > 1) warn ("comparison in argument");
|
---|
| 985 | yyval.a_value = nextarg (NULL,0);
|
---|
| 986 | }
|
---|
| 987 | break;
|
---|
| 988 | case 62:
|
---|
| 989 | #line 347 "bc.y"
|
---|
| 990 | {
|
---|
| 991 | sprintf (genstr, "K%d:", -lookup (yyvsp[-2].s_value,ARRAY));
|
---|
| 992 | generate (genstr);
|
---|
| 993 | yyval.a_value = nextarg (NULL,1);
|
---|
| 994 | }
|
---|
| 995 | break;
|
---|
| 996 | case 63:
|
---|
| 997 | #line 353 "bc.y"
|
---|
| 998 | {
|
---|
| 999 | if (yyvsp[0].i_value > 1) warn ("comparison in argument");
|
---|
| 1000 | yyval.a_value = nextarg (yyvsp[-2].a_value,0);
|
---|
| 1001 | }
|
---|
| 1002 | break;
|
---|
| 1003 | case 64:
|
---|
| 1004 | #line 358 "bc.y"
|
---|
| 1005 | {
|
---|
| 1006 | sprintf (genstr, "K%d:", -lookup (yyvsp[-2].s_value,ARRAY));
|
---|
| 1007 | generate (genstr);
|
---|
| 1008 | yyval.a_value = nextarg (yyvsp[-4].a_value,1);
|
---|
| 1009 | }
|
---|
| 1010 | break;
|
---|
| 1011 | case 65:
|
---|
| 1012 | #line 365 "bc.y"
|
---|
| 1013 | {
|
---|
| 1014 | yyval.i_value = -1;
|
---|
| 1015 | warn ("Missing expression in for statement");
|
---|
| 1016 | }
|
---|
| 1017 | break;
|
---|
| 1018 | case 67:
|
---|
| 1019 | #line 372 "bc.y"
|
---|
| 1020 | {
|
---|
| 1021 | yyval.i_value = 0;
|
---|
| 1022 | generate ("0");
|
---|
| 1023 | }
|
---|
| 1024 | break;
|
---|
| 1025 | case 68:
|
---|
| 1026 | #line 377 "bc.y"
|
---|
| 1027 | {
|
---|
| 1028 | if (yyvsp[0].i_value > 1)
|
---|
| 1029 | warn ("comparison in return expresion");
|
---|
| 1030 | }
|
---|
| 1031 | break;
|
---|
| 1032 | case 69:
|
---|
| 1033 | #line 383 "bc.y"
|
---|
| 1034 | {
|
---|
| 1035 | if (yyvsp[0].c_value != '=')
|
---|
| 1036 | {
|
---|
| 1037 | if (yyvsp[-1].i_value < 0)
|
---|
| 1038 | sprintf (genstr, "DL%d:", -yyvsp[-1].i_value);
|
---|
| 1039 | else
|
---|
| 1040 | sprintf (genstr, "l%d:", yyvsp[-1].i_value);
|
---|
| 1041 | generate (genstr);
|
---|
| 1042 | }
|
---|
| 1043 | }
|
---|
| 1044 | break;
|
---|
| 1045 | case 70:
|
---|
| 1046 | #line 394 "bc.y"
|
---|
| 1047 | {
|
---|
| 1048 | if (yyvsp[0].i_value > 1) warn("comparison in assignment");
|
---|
| 1049 | if (yyvsp[-2].c_value != '=')
|
---|
| 1050 | {
|
---|
| 1051 | sprintf (genstr, "%c", yyvsp[-2].c_value);
|
---|
| 1052 | generate (genstr);
|
---|
| 1053 | }
|
---|
| 1054 | if (yyvsp[-3].i_value < 0)
|
---|
| 1055 | sprintf (genstr, "S%d:", -yyvsp[-3].i_value);
|
---|
| 1056 | else
|
---|
| 1057 | sprintf (genstr, "s%d:", yyvsp[-3].i_value);
|
---|
| 1058 | generate (genstr);
|
---|
| 1059 | yyval.i_value = 0;
|
---|
| 1060 | }
|
---|
| 1061 | break;
|
---|
| 1062 | case 71:
|
---|
| 1063 | #line 410 "bc.y"
|
---|
| 1064 | {
|
---|
| 1065 | warn("&& operator");
|
---|
| 1066 | yyvsp[0].i_value = next_label++;
|
---|
| 1067 | sprintf (genstr, "DZ%d:p", yyvsp[0].i_value);
|
---|
| 1068 | generate (genstr);
|
---|
| 1069 | }
|
---|
| 1070 | break;
|
---|
| 1071 | case 72:
|
---|
| 1072 | #line 417 "bc.y"
|
---|
| 1073 | {
|
---|
| 1074 | sprintf (genstr, "DZ%d:p1N%d:", yyvsp[-2].i_value, yyvsp[-2].i_value);
|
---|
| 1075 | generate (genstr);
|
---|
| 1076 | yyval.i_value = yyvsp[-3].i_value | yyvsp[0].i_value;
|
---|
| 1077 | }
|
---|
| 1078 | break;
|
---|
| 1079 | case 73:
|
---|
| 1080 | #line 423 "bc.y"
|
---|
| 1081 | {
|
---|
| 1082 | warn("|| operator");
|
---|
| 1083 | yyvsp[0].i_value = next_label++;
|
---|
| 1084 | sprintf (genstr, "B%d:", yyvsp[0].i_value);
|
---|
| 1085 | generate (genstr);
|
---|
| 1086 | }
|
---|
| 1087 | break;
|
---|
| 1088 | case 74:
|
---|
| 1089 | #line 430 "bc.y"
|
---|
| 1090 | {
|
---|
| 1091 | int tmplab;
|
---|
| 1092 | tmplab = next_label++;
|
---|
| 1093 | sprintf (genstr, "B%d:0J%d:N%d:1N%d:",
|
---|
| 1094 | yyvsp[-2].i_value, tmplab, yyvsp[-2].i_value, tmplab);
|
---|
| 1095 | generate (genstr);
|
---|
| 1096 | yyval.i_value = yyvsp[-3].i_value | yyvsp[0].i_value;
|
---|
| 1097 | }
|
---|
| 1098 | break;
|
---|
| 1099 | case 75:
|
---|
| 1100 | #line 439 "bc.y"
|
---|
| 1101 | {
|
---|
| 1102 | yyval.i_value = yyvsp[0].i_value;
|
---|
| 1103 | warn("! operator");
|
---|
| 1104 | generate ("!");
|
---|
| 1105 | }
|
---|
| 1106 | break;
|
---|
| 1107 | case 76:
|
---|
| 1108 | #line 445 "bc.y"
|
---|
| 1109 | {
|
---|
| 1110 | yyval.i_value = 3;
|
---|
| 1111 | switch (*(yyvsp[-1].s_value))
|
---|
| 1112 | {
|
---|
| 1113 | case '=':
|
---|
| 1114 | generate ("=");
|
---|
| 1115 | break;
|
---|
| 1116 |
|
---|
| 1117 | case '!':
|
---|
| 1118 | generate ("#");
|
---|
| 1119 | break;
|
---|
| 1120 |
|
---|
| 1121 | case '<':
|
---|
| 1122 | if (yyvsp[-1].s_value[1] == '=')
|
---|
| 1123 | generate ("{");
|
---|
| 1124 | else
|
---|
| 1125 | generate ("<");
|
---|
| 1126 | break;
|
---|
| 1127 |
|
---|
| 1128 | case '>':
|
---|
| 1129 | if (yyvsp[-1].s_value[1] == '=')
|
---|
| 1130 | generate ("}");
|
---|
| 1131 | else
|
---|
| 1132 | generate (">");
|
---|
| 1133 | break;
|
---|
| 1134 | }
|
---|
| 1135 | }
|
---|
| 1136 | break;
|
---|
| 1137 | case 77:
|
---|
| 1138 | #line 473 "bc.y"
|
---|
| 1139 | {
|
---|
| 1140 | generate ("+");
|
---|
| 1141 | yyval.i_value = yyvsp[-2].i_value | yyvsp[0].i_value;
|
---|
| 1142 | }
|
---|
| 1143 | break;
|
---|
| 1144 | case 78:
|
---|
| 1145 | #line 478 "bc.y"
|
---|
| 1146 | {
|
---|
| 1147 | generate ("-");
|
---|
| 1148 | yyval.i_value = yyvsp[-2].i_value | yyvsp[0].i_value;
|
---|
| 1149 | }
|
---|
| 1150 | break;
|
---|
| 1151 | case 79:
|
---|
| 1152 | #line 483 "bc.y"
|
---|
| 1153 | {
|
---|
| 1154 | genstr[0] = yyvsp[-1].c_value;
|
---|
| 1155 | genstr[1] = 0;
|
---|
| 1156 | generate (genstr);
|
---|
| 1157 | yyval.i_value = yyvsp[-2].i_value | yyvsp[0].i_value;
|
---|
| 1158 | }
|
---|
| 1159 | break;
|
---|
| 1160 | case 80:
|
---|
| 1161 | #line 490 "bc.y"
|
---|
| 1162 | {
|
---|
| 1163 | generate ("^");
|
---|
| 1164 | yyval.i_value = yyvsp[-2].i_value | yyvsp[0].i_value;
|
---|
| 1165 | }
|
---|
| 1166 | break;
|
---|
| 1167 | case 81:
|
---|
| 1168 | #line 495 "bc.y"
|
---|
| 1169 | {
|
---|
| 1170 | generate ("n");
|
---|
| 1171 | yyval.i_value = yyvsp[0].i_value;
|
---|
| 1172 | }
|
---|
| 1173 | break;
|
---|
| 1174 | case 82:
|
---|
| 1175 | #line 500 "bc.y"
|
---|
| 1176 | {
|
---|
| 1177 | yyval.i_value = 1;
|
---|
| 1178 | if (yyvsp[0].i_value < 0)
|
---|
| 1179 | sprintf (genstr, "L%d:", -yyvsp[0].i_value);
|
---|
| 1180 | else
|
---|
| 1181 | sprintf (genstr, "l%d:", yyvsp[0].i_value);
|
---|
| 1182 | generate (genstr);
|
---|
| 1183 | }
|
---|
| 1184 | break;
|
---|
| 1185 | case 83:
|
---|
| 1186 | #line 509 "bc.y"
|
---|
| 1187 | {
|
---|
| 1188 | int len = strlen(yyvsp[0].s_value);
|
---|
| 1189 | yyval.i_value = 1;
|
---|
| 1190 | if (len == 1 && *yyvsp[0].s_value == '0')
|
---|
| 1191 | generate ("0");
|
---|
| 1192 | else if (len == 1 && *yyvsp[0].s_value == '1')
|
---|
| 1193 | generate ("1");
|
---|
| 1194 | else
|
---|
| 1195 | {
|
---|
| 1196 | generate ("K");
|
---|
| 1197 | generate (yyvsp[0].s_value);
|
---|
| 1198 | generate (":");
|
---|
| 1199 | }
|
---|
| 1200 | free (yyvsp[0].s_value);
|
---|
| 1201 | }
|
---|
| 1202 | break;
|
---|
| 1203 | case 84:
|
---|
| 1204 | #line 525 "bc.y"
|
---|
| 1205 | { yyval.i_value = yyvsp[-1].i_value | 1; }
|
---|
| 1206 | break;
|
---|
| 1207 | case 85:
|
---|
| 1208 | #line 527 "bc.y"
|
---|
| 1209 | {
|
---|
| 1210 | yyval.i_value = 1;
|
---|
| 1211 | if (yyvsp[-1].a_value != NULL)
|
---|
| 1212 | {
|
---|
| 1213 | sprintf (genstr, "C%d,%s:",
|
---|
| 1214 | lookup (yyvsp[-3].s_value,FUNCT),
|
---|
| 1215 | arg_str (yyvsp[-1].a_value,FALSE));
|
---|
| 1216 | free_args (yyvsp[-1].a_value);
|
---|
| 1217 | }
|
---|
| 1218 | else
|
---|
| 1219 | {
|
---|
| 1220 | sprintf (genstr, "C%d:", lookup (yyvsp[-3].s_value,FUNCT));
|
---|
| 1221 | }
|
---|
| 1222 | generate (genstr);
|
---|
| 1223 | }
|
---|
| 1224 | break;
|
---|
| 1225 | case 86:
|
---|
| 1226 | #line 543 "bc.y"
|
---|
| 1227 | {
|
---|
| 1228 | yyval.i_value = 1;
|
---|
| 1229 | if (yyvsp[0].i_value < 0)
|
---|
| 1230 | {
|
---|
| 1231 | if (yyvsp[-1].c_value == '+')
|
---|
| 1232 | sprintf (genstr, "DA%d:L%d:", -yyvsp[0].i_value, -yyvsp[0].i_value);
|
---|
| 1233 | else
|
---|
| 1234 | sprintf (genstr, "DM%d:L%d:", -yyvsp[0].i_value, -yyvsp[0].i_value);
|
---|
| 1235 | }
|
---|
| 1236 | else
|
---|
| 1237 | {
|
---|
| 1238 | if (yyvsp[-1].c_value == '+')
|
---|
| 1239 | sprintf (genstr, "i%d:l%d:", yyvsp[0].i_value, yyvsp[0].i_value);
|
---|
| 1240 | else
|
---|
| 1241 | sprintf (genstr, "d%d:l%d:", yyvsp[0].i_value, yyvsp[0].i_value);
|
---|
| 1242 | }
|
---|
| 1243 | generate (genstr);
|
---|
| 1244 | }
|
---|
| 1245 | break;
|
---|
| 1246 | case 87:
|
---|
| 1247 | #line 562 "bc.y"
|
---|
| 1248 | {
|
---|
| 1249 | yyval.i_value = 1;
|
---|
| 1250 | if (yyvsp[-1].i_value < 0)
|
---|
| 1251 | {
|
---|
| 1252 | sprintf (genstr, "DL%d:x", -yyvsp[-1].i_value);
|
---|
| 1253 | generate (genstr);
|
---|
| 1254 | if (yyvsp[0].c_value == '+')
|
---|
| 1255 | sprintf (genstr, "A%d:", -yyvsp[-1].i_value);
|
---|
| 1256 | else
|
---|
| 1257 | sprintf (genstr, "M%d:", -yyvsp[-1].i_value);
|
---|
| 1258 | }
|
---|
| 1259 | else
|
---|
| 1260 | {
|
---|
| 1261 | sprintf (genstr, "l%d:", yyvsp[-1].i_value);
|
---|
| 1262 | generate (genstr);
|
---|
| 1263 | if (yyvsp[0].c_value == '+')
|
---|
| 1264 | sprintf (genstr, "i%d:", yyvsp[-1].i_value);
|
---|
| 1265 | else
|
---|
| 1266 | sprintf (genstr, "d%d:", yyvsp[-1].i_value);
|
---|
| 1267 | }
|
---|
| 1268 | generate (genstr);
|
---|
| 1269 | }
|
---|
| 1270 | break;
|
---|
| 1271 | case 88:
|
---|
| 1272 | #line 585 "bc.y"
|
---|
| 1273 | { generate ("cL"); yyval.i_value = 1;}
|
---|
| 1274 | break;
|
---|
| 1275 | case 89:
|
---|
| 1276 | #line 587 "bc.y"
|
---|
| 1277 | { generate ("cR"); yyval.i_value = 1;}
|
---|
| 1278 | break;
|
---|
| 1279 | case 90:
|
---|
| 1280 | #line 589 "bc.y"
|
---|
| 1281 | { generate ("cS"); yyval.i_value = 1;}
|
---|
| 1282 | break;
|
---|
| 1283 | case 91:
|
---|
| 1284 | #line 591 "bc.y"
|
---|
| 1285 | {
|
---|
| 1286 | warn ("read function");
|
---|
| 1287 | generate ("cI"); yyval.i_value = 1;
|
---|
| 1288 | }
|
---|
| 1289 | break;
|
---|
| 1290 | case 92:
|
---|
| 1291 | #line 597 "bc.y"
|
---|
| 1292 | { yyval.i_value = lookup(yyvsp[0].s_value,SIMPLE); }
|
---|
| 1293 | break;
|
---|
| 1294 | case 93:
|
---|
| 1295 | #line 599 "bc.y"
|
---|
| 1296 | {
|
---|
| 1297 | if (yyvsp[-1].i_value > 1) warn("comparison in subscript");
|
---|
| 1298 | yyval.i_value = lookup(yyvsp[-3].s_value,ARRAY);
|
---|
| 1299 | }
|
---|
| 1300 | break;
|
---|
| 1301 | case 94:
|
---|
| 1302 | #line 604 "bc.y"
|
---|
| 1303 | { yyval.i_value = 0; }
|
---|
| 1304 | break;
|
---|
| 1305 | case 95:
|
---|
| 1306 | #line 606 "bc.y"
|
---|
| 1307 | { yyval.i_value = 1; }
|
---|
| 1308 | break;
|
---|
| 1309 | case 96:
|
---|
| 1310 | #line 608 "bc.y"
|
---|
| 1311 | { yyval.i_value = 2; }
|
---|
| 1312 | break;
|
---|
| 1313 | case 97:
|
---|
| 1314 | #line 610 "bc.y"
|
---|
| 1315 | { yyval.i_value = 3; }
|
---|
| 1316 | break;
|
---|
| 1317 | #line 1318 "y.tab.c"
|
---|
| 1318 | }
|
---|
| 1319 | yyssp -= yym;
|
---|
| 1320 | yystate = *yyssp;
|
---|
| 1321 | yyvsp -= yym;
|
---|
| 1322 | yym = yylhs[yyn];
|
---|
| 1323 | if (yystate == 0 && yym == 0)
|
---|
| 1324 | {
|
---|
| 1325 | #if YYDEBUG
|
---|
| 1326 | if (yydebug)
|
---|
| 1327 | printf("%sdebug: after reduction, shifting from state 0 to\
|
---|
| 1328 | state %d\n", YYPREFIX, YYFINAL);
|
---|
| 1329 | #endif
|
---|
| 1330 | yystate = YYFINAL;
|
---|
| 1331 | *++yyssp = YYFINAL;
|
---|
| 1332 | *++yyvsp = yyval;
|
---|
| 1333 | if (yychar < 0)
|
---|
| 1334 | {
|
---|
| 1335 | if ((yychar = yylex()) < 0) yychar = 0;
|
---|
| 1336 | #if YYDEBUG
|
---|
| 1337 | if (yydebug)
|
---|
| 1338 | {
|
---|
| 1339 | yys = 0;
|
---|
| 1340 | if (yychar <= YYMAXTOKEN) yys = yyname[yychar];
|
---|
| 1341 | if (!yys) yys = "illegal-symbol";
|
---|
| 1342 | printf("%sdebug: state %d, reading %d (%s)\n",
|
---|
| 1343 | YYPREFIX, YYFINAL, yychar, yys);
|
---|
| 1344 | }
|
---|
| 1345 | #endif
|
---|
| 1346 | }
|
---|
| 1347 | if (yychar == 0) goto yyaccept;
|
---|
| 1348 | goto yyloop;
|
---|
| 1349 | }
|
---|
| 1350 | if ((yyn = yygindex[yym]) && (yyn += yystate) >= 0 &&
|
---|
| 1351 | yyn <= YYTABLESIZE && yycheck[yyn] == yystate)
|
---|
| 1352 | yystate = yytable[yyn];
|
---|
| 1353 | else
|
---|
| 1354 | yystate = yydgoto[yym];
|
---|
| 1355 | #if YYDEBUG
|
---|
| 1356 | if (yydebug)
|
---|
| 1357 | printf("%sdebug: after reduction, shifting from state %d \
|
---|
| 1358 | to state %d\n", YYPREFIX, *yyssp, yystate);
|
---|
| 1359 | #endif
|
---|
| 1360 | if (yyssp >= yyss + yystacksize - 1)
|
---|
| 1361 | {
|
---|
| 1362 | goto yyoverflow;
|
---|
| 1363 | }
|
---|
| 1364 | *++yyssp = yystate;
|
---|
| 1365 | *++yyvsp = yyval;
|
---|
| 1366 | goto yyloop;
|
---|
| 1367 | yyoverflow:
|
---|
| 1368 | yyerror("yacc stack overflow");
|
---|
| 1369 | yyabort:
|
---|
| 1370 | return (1);
|
---|
| 1371 | yyaccept:
|
---|
| 1372 | return (0);
|
---|
| 1373 | }
|
---|