1 2 /* A Bison parser, made from bc.y 3 by GNU Bison version 1.25 4 */ 5 6 #define YYBISON 1 /* Identify Bison output. */ 7 8 #define NEWLINE 258 9 #define AND 259 10 #define OR 260 11 #define NOT 261 12 #define STRING 262 13 #define NAME 263 14 #define NUMBER 264 15 #define ASSIGN_OP 265 16 #define REL_OP 266 17 #define INCR_DECR 267 18 #define Define 268 19 #define Break 269 20 #define Quit 270 21 #define Length 271 22 #define Return 272 23 #define For 273 24 #define If 274 25 #define While 275 26 #define Sqrt 276 27 #define Else 277 28 #define Scale 278 29 #define Ibase 279 30 #define Obase 280 31 #define Auto 281 32 #define Read 282 33 #define Warranty 283 34 #define Halt 284 35 #define Last 285 36 #define Continue 286 37 #define Print 287 38 #define Limits 288 39 #define UNARY_MINUS 289 40 #define History 290 41 42 #line 1 "bc.y" 43 44 /* bc.y: The grammar for a POSIX compatable bc processor with some 45 extensions to the language. */ 46 47 /* This file is part of GNU bc. 48 Copyright (C) 1991, 1992, 1993, 1994, 1997 Free Software Foundation, Inc. 49 50 This program is free software; you can redistribute it and/or modify 51 it under the terms of the GNU General Public License as published by 52 the Free Software Foundation; either version 2 of the License , or 53 (at your option) any later version. 54 55 This program is distributed in the hope that it will be useful, 56 but WITHOUT ANY WARRANTY; without even the implied warranty of 57 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 58 GNU General Public License for more details. 59 60 You should have received a copy of the GNU General Public License 61 along with this program; see the file COPYING. If not, write to 62 the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. 63 64 You may contact the author by: 65 e-mail: phil@cs.wwu.edu 66 us-mail: Philip A. Nelson 67 Computer Science Department, 9062 68 Western Washington University 69 Bellingham, WA 98226-9062 70 71 *************************************************************************/ 72 73 #include "bcdefs.h" 74 #include "global.h" 75 #include "proto.h" 76 77 #line 38 "bc.y" 78 typedef union { 79 char *s_value; 80 char c_value; 81 int i_value; 82 arg_list *a_value; 83 } YYSTYPE; 84 #include <stdio.h> 85 86 #ifndef __cplusplus 87 #ifndef __STDC__ 88 #define const 89 #endif 90 #endif 91 92 93 94 #define YYFINAL 185 95 #define YYFLAG -32768 96 #define YYNTBASE 50 97 98 #define YYTRANSLATE(x) ((unsigned)(x) <= 290 ? yytranslate[x] : 83) 99 100 static const char yytranslate[] = { 0, 101 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 102 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 103 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 104 2, 2, 2, 2, 2, 2, 40, 2, 2, 43, 105 44, 38, 36, 47, 37, 2, 39, 2, 2, 2, 106 2, 2, 2, 2, 2, 2, 2, 2, 42, 2, 107 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 108 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 109 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 110 48, 2, 49, 41, 2, 2, 2, 2, 2, 2, 111 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 112 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 113 2, 2, 45, 2, 46, 2, 2, 2, 2, 2, 114 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 115 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 116 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 117 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 118 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 119 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 120 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 121 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 122 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 123 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 124 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 125 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 126 2, 2, 2, 2, 2, 1, 2, 3, 4, 5, 127 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 128 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 129 26, 27, 28, 29, 30, 31, 32, 33, 34, 35 130 }; 131 132 #if YYDEBUG != 0 133 static const short yyprhs[] = { 0, 134 0, 1, 4, 7, 9, 12, 13, 15, 16, 18, 135 22, 25, 26, 28, 31, 35, 38, 42, 44, 47, 136 49, 51, 53, 55, 57, 59, 61, 63, 65, 70, 137 71, 72, 73, 74, 89, 90, 99, 100, 101, 110, 138 114, 115, 119, 121, 125, 127, 129, 130, 131, 136, 139 137, 150, 151, 153, 154, 158, 162, 164, 168, 173, 140 177, 183, 190, 191, 193, 195, 199, 203, 209, 210, 141 212, 213, 215, 216, 221, 222, 227, 228, 233, 236, 142 240, 244, 248, 252, 256, 260, 264, 267, 269, 271, 143 275, 280, 283, 286, 291, 296, 301, 305, 307, 312, 144 314, 316, 318, 320 145 }; 146 147 static const short yyrhs[] = { -1, 148 50, 51, 0, 53, 3, 0, 69, 0, 1, 3, 149 0, 0, 3, 0, 0, 55, 0, 53, 42, 55, 150 0, 53, 42, 0, 0, 55, 0, 54, 3, 0, 151 54, 3, 55, 0, 54, 42, 0, 54, 42, 56, 152 0, 56, 0, 1, 56, 0, 28, 0, 33, 0, 153 78, 0, 7, 0, 14, 0, 31, 0, 15, 0, 154 29, 0, 17, 0, 17, 43, 77, 44, 0, 0, 155 0, 0, 0, 18, 57, 43, 76, 42, 58, 76, 156 42, 59, 76, 44, 60, 52, 56, 0, 0, 19, 157 43, 78, 44, 61, 52, 56, 67, 0, 0, 0, 158 20, 62, 43, 78, 63, 44, 52, 56, 0, 45, 159 54, 46, 0, 0, 32, 64, 65, 0, 66, 0, 160 66, 47, 65, 0, 7, 0, 78, 0, 0, 0, 161 22, 68, 52, 56, 0, 0, 13, 8, 43, 71, 162 44, 52, 45, 3, 72, 70, 54, 46, 0, 0, 163 73, 0, 0, 26, 73, 3, 0, 26, 73, 42, 164 0, 8, 0, 8, 48, 49, 0, 38, 8, 48, 165 49, 0, 73, 47, 8, 0, 73, 47, 8, 48, 166 49, 0, 73, 47, 38, 8, 48, 49, 0, 0, 167 75, 0, 78, 0, 8, 48, 49, 0, 75, 47, 168 78, 0, 75, 47, 8, 48, 49, 0, 0, 78, 169 0, 0, 78, 0, 0, 82, 10, 79, 78, 0, 170 0, 78, 4, 80, 78, 0, 0, 78, 5, 81, 171 78, 0, 6, 78, 0, 78, 11, 78, 0, 78, 172 36, 78, 0, 78, 37, 78, 0, 78, 38, 78, 173 0, 78, 39, 78, 0, 78, 40, 78, 0, 78, 174 41, 78, 0, 37, 78, 0, 82, 0, 9, 0, 175 43, 78, 44, 0, 8, 43, 74, 44, 0, 12, 176 82, 0, 82, 12, 0, 16, 43, 78, 44, 0, 177 21, 43, 78, 44, 0, 23, 43, 78, 44, 0, 178 27, 43, 44, 0, 8, 0, 8, 48, 78, 49, 179 0, 24, 0, 25, 0, 23, 0, 35, 0, 30, 180 0 181 }; 182 183 #endif 184 185 #if YYDEBUG != 0 186 static const short yyrline[] = { 0, 187 105, 114, 116, 118, 120, 126, 127, 130, 132, 133, 188 134, 136, 138, 139, 140, 141, 142, 144, 145, 148, 189 150, 152, 161, 168, 178, 189, 191, 193, 195, 197, 190 202, 213, 224, 234, 242, 249, 255, 261, 268, 274, 191 276, 279, 280, 281, 283, 289, 292, 293, 301, 302, 192 316, 322, 324, 326, 328, 330, 333, 335, 337, 339, 193 341, 343, 346, 348, 350, 355, 361, 366, 373, 378, 194 380, 385, 391, 403, 418, 426, 431, 439, 447, 453, 195 481, 486, 491, 496, 501, 506, 511, 516, 525, 541, 196 543, 559, 578, 601, 603, 605, 607, 613, 615, 620, 197 622, 624, 626, 630 198 }; 199 #endif 200 201 202 #if YYDEBUG != 0 || defined (YYERROR_VERBOSE) 203 204 static const char * const yytname[] = { "$","error","$undefined.","NEWLINE", 205 "AND","OR","NOT","STRING","NAME","NUMBER","ASSIGN_OP","REL_OP","INCR_DECR","Define", 206 "Break","Quit","Length","Return","For","If","While","Sqrt","Else","Scale","Ibase", 207 "Obase","Auto","Read","Warranty","Halt","Last","Continue","Print","Limits","UNARY_MINUS", 208 "History","'+'","'-'","'*'","'/'","'%'","'^'","';'","'('","')'","'{'","'}'", 209 "','","'['","']'","program","input_item","opt_newline","semicolon_list","statement_list", 210 "statement_or_error","statement","@1","@2","@3","@4","@5","@6","@7","@8","print_list", 211 "print_element","opt_else","@9","function","@10","opt_parameter_list","opt_auto_define_list", 212 "define_list","opt_argument_list","argument_list","opt_expression","return_expression", 213 "expression","@11","@12","@13","named_expression", NULL 214 }; 215 #endif 216 217 static const short yyr1[] = { 0, 218 50, 50, 51, 51, 51, 52, 52, 53, 53, 53, 219 53, 54, 54, 54, 54, 54, 54, 55, 55, 56, 220 56, 56, 56, 56, 56, 56, 56, 56, 56, 57, 221 58, 59, 60, 56, 61, 56, 62, 63, 56, 56, 222 64, 56, 65, 65, 66, 66, 67, 68, 67, 70, 223 69, 71, 71, 72, 72, 72, 73, 73, 73, 73, 224 73, 73, 74, 74, 75, 75, 75, 75, 76, 76, 225 77, 77, 79, 78, 80, 78, 81, 78, 78, 78, 226 78, 78, 78, 78, 78, 78, 78, 78, 78, 78, 227 78, 78, 78, 78, 78, 78, 78, 82, 82, 82, 228 82, 82, 82, 82 229 }; 230 231 static const short yyr2[] = { 0, 232 0, 2, 2, 1, 2, 0, 1, 0, 1, 3, 233 2, 0, 1, 2, 3, 2, 3, 1, 2, 1, 234 1, 1, 1, 1, 1, 1, 1, 1, 4, 0, 235 0, 0, 0, 14, 0, 8, 0, 0, 8, 3, 236 0, 3, 1, 3, 1, 1, 0, 0, 4, 0, 237 12, 0, 1, 0, 3, 3, 1, 3, 4, 3, 238 5, 6, 0, 1, 1, 3, 3, 5, 0, 1, 239 0, 1, 0, 4, 0, 4, 0, 4, 2, 3, 240 3, 3, 3, 3, 3, 3, 2, 1, 1, 3, 241 4, 2, 2, 4, 4, 4, 3, 1, 4, 1, 242 1, 1, 1, 1 243 }; 244 245 static const short yydefact[] = { 1, 246 0, 0, 0, 23, 98, 89, 0, 0, 24, 26, 247 0, 28, 30, 0, 37, 0, 102, 100, 101, 0, 248 20, 27, 104, 25, 41, 21, 103, 0, 0, 0, 249 2, 0, 9, 18, 4, 22, 88, 5, 19, 79, 250 63, 0, 98, 102, 92, 0, 0, 71, 0, 0, 251 0, 0, 0, 0, 0, 87, 0, 0, 0, 13, 252 3, 0, 75, 77, 0, 0, 0, 0, 0, 0, 253 0, 73, 93, 98, 0, 64, 65, 0, 52, 0, 254 0, 72, 69, 0, 0, 0, 0, 97, 45, 42, 255 43, 46, 90, 0, 16, 40, 10, 0, 0, 80, 256 81, 82, 83, 84, 85, 86, 0, 0, 91, 0, 257 99, 57, 0, 0, 53, 94, 29, 0, 70, 35, 258 38, 95, 96, 0, 15, 17, 76, 78, 74, 66, 259 98, 67, 0, 0, 6, 0, 31, 6, 0, 44, 260 0, 58, 0, 7, 0, 60, 0, 69, 0, 6, 261 68, 59, 0, 0, 0, 0, 47, 0, 54, 61, 262 0, 32, 48, 36, 39, 0, 50, 62, 69, 6, 263 0, 0, 0, 0, 55, 56, 0, 33, 49, 51, 264 6, 0, 34, 0, 0 265 }; 266 267 static const short yydefgoto[] = { 1, 268 31, 145, 32, 59, 60, 34, 49, 148, 169, 181, 269 138, 51, 139, 55, 90, 91, 164, 170, 35, 172, 270 114, 167, 115, 75, 76, 118, 81, 36, 107, 98, 271 99, 37 272 }; 273 274 static const short yypact[] = {-32768, 275 170, 375, 567,-32768, -37,-32768, 120, 15,-32768,-32768, 276 -38, -34,-32768, -28,-32768, -19, -16,-32768,-32768, -13, 277 -32768,-32768,-32768,-32768,-32768,-32768,-32768, 567, 567, 213, 278 -32768, 17,-32768,-32768,-32768, 642, 6,-32768,-32768, 442, 279 597, 567, -9,-32768,-32768, -11, 567, 567, 39, 567, 280 41, 567, 567, -4, 537,-32768, 122, 505, 16,-32768, 281 -32768, 305,-32768,-32768, 567, 567, 567, 567, 567, 567, 282 567,-32768,-32768, -36, 42, 43, 642, 40, 5, 410, 283 44, 642, 567, 419, 567, 428, 466,-32768,-32768,-32768, 284 45, 642,-32768, 259, 505,-32768,-32768, 567, 567, 404, 285 34, 34, 46, 46, 46, 46, 567, 88,-32768, 627, 286 -32768, 53, 83, 58, 56,-32768,-32768, 63, 642,-32768, 287 642,-32768,-32768, 537,-32768,-32768, 442, -3, 404,-32768, 288 -26, 642, 57, 66, 113, 23,-32768, 113, 73,-32768, 289 337,-32768, 70,-32768, 75, 74, 121, 567, 505, 113, 290 -32768,-32768, 118, 81, 84, 92, 114, 505, 109,-32768, 291 89,-32768,-32768,-32768,-32768, 5,-32768,-32768, 567, 113, 292 7, 213, 95, 505,-32768,-32768, 18,-32768,-32768,-32768, 293 113, 505,-32768, 140,-32768 294 }; 295 296 static const short yypgoto[] = {-32768, 297 -32768, -124,-32768, -30, 1, -2,-32768,-32768,-32768,-32768, 298 -32768,-32768,-32768,-32768, 22,-32768,-32768,-32768,-32768,-32768, 299 -32768,-32768, -17,-32768,-32768, -144,-32768, 0,-32768,-32768, 300 -32768, 144 301 }; 302 303 304 #define YYLAST 683 305 306 307 static const short yytable[] = { 39, 308 63, 33, 40, 156, 47, 41, 41, 65, 48, 175, 309 42, 108, 112, 149, 50, 72, 41, 73, 94, 61, 310 94, 141, 46, 52, 173, 158, 53, 56, 57, 54, 311 146, 79, 66, 67, 68, 69, 70, 71, 42, 88, 312 77, 78, 113, 63, 64, 174, 80, 82, 176, 84, 313 65, 86, 87, 136, 92, 39, 182, 95, 62, 95, 314 147, 96, 97, 180, 100, 101, 102, 103, 104, 105, 315 106, 68, 69, 70, 71, 66, 67, 68, 69, 70, 316 71, 83, 119, 85, 121, 109, 71, 117, 111, 110, 317 134, 124, 126, 3, 125, 5, 6, 127, 128, 7, 318 133, 135, 136, 11, 137, 142, 129, 78, 16, 132, 319 17, 18, 19, 143, 20, 144, 150, 23, 152, 153, 320 159, 154, 27, 92, 28, 63, 64, 43, 155, 160, 321 29, 161, 65, 162, 166, 163, 130, 168, 178, 185, 322 78, 177, 44, 18, 19, 140, 157, 119, 171, 23, 323 45, 0, 0, 0, 27, 165, 0, 66, 67, 68, 324 69, 70, 71, 0, 0, 93, 0, 0, 119, 184, 325 2, 179, -8, 0, 0, 3, 4, 5, 6, 183, 326 0, 7, 8, 9, 10, 11, 12, 13, 14, 15, 327 16, 0, 17, 18, 19, 0, 20, 21, 22, 23, 328 24, 25, 26, 0, 27, 0, 28, 0, 0, 0, 329 0, -8, 29, 58, 30, -12, 0, 0, 3, 4, 330 5, 6, 0, 0, 7, 0, 9, 10, 11, 12, 331 13, 14, 15, 16, 0, 17, 18, 19, 0, 20, 332 21, 22, 23, 24, 25, 26, 0, 27, 0, 28, 333 0, 0, 0, 0, -12, 29, 0, 30, -12, 58, 334 0, -14, 0, 0, 3, 4, 5, 6, 0, 0, 335 7, 0, 9, 10, 11, 12, 13, 14, 15, 16, 336 0, 17, 18, 19, 0, 20, 21, 22, 23, 24, 337 25, 26, 0, 27, 0, 28, 0, 0, 0, 0, 338 -14, 29, 0, 30, -14, 58, 0, -11, 0, 0, 339 3, 4, 5, 6, 0, 0, 7, 0, 9, 10, 340 11, 12, 13, 14, 15, 16, 0, 17, 18, 19, 341 0, 20, 21, 22, 23, 24, 25, 26, 0, 27, 342 0, 28, 3, 0, 5, 6, -11, 29, 7, 30, 343 0, 0, 11, 0, 0, 0, 0, 16, 0, 17, 344 18, 19, 0, 20, 0, 0, 23, 0, 0, 0, 345 0, 27, 0, 28, 0, 0, 0, 38, 0, 29, 346 3, 4, 5, 6, 0, 151, 7, 0, 9, 10, 347 11, 12, 13, 14, 15, 16, 0, 17, 18, 19, 348 0, 20, 21, 22, 23, 24, 25, 26, 0, 27, 349 0, 28, 0, 63, 64, 0, 0, 29, 0, 30, 350 65, 0, 63, 64, 0, 0, 0, 0, 0, 65, 351 0, 63, 64, 0, 0, 0, 0, 0, 65, 66, 352 67, 68, 69, 70, 71, 66, 67, 68, 69, 70, 353 71, 0, 65, 116, 66, 67, 68, 69, 70, 71, 354 0, 0, 120, 66, 67, 68, 69, 70, 71, 63, 355 64, 122, 0, 0, 0, 0, 65, 66, 67, 68, 356 69, 70, 71, 0, 0, 0, 0, 0, 0, 0, 357 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 358 0, 66, 67, 68, 69, 70, 71, 0, 0, 123, 359 3, 4, 5, 6, 0, 0, 7, 0, 9, 10, 360 11, 12, 13, 14, 15, 16, 0, 17, 18, 19, 361 0, 20, 21, 22, 23, 24, 25, 26, 0, 27, 362 0, 28, 3, 89, 5, 6, 0, 29, 7, 30, 363 0, 0, 11, 0, 0, 0, 0, 16, 0, 17, 364 18, 19, 0, 20, 0, 0, 23, 0, 0, 0, 365 0, 27, 3, 28, 5, 6, 0, 0, 7, 29, 366 0, 0, 11, 0, 0, 0, 0, 16, 0, 17, 367 18, 19, 0, 20, 0, 0, 23, 0, 0, 0, 368 0, 27, 3, 28, 74, 6, 0, 0, 7, 29, 369 0, 0, 11, 0, 0, 0, 0, 16, 0, 17, 370 18, 19, 0, 20, 0, 0, 23, 0, 0, 0, 371 0, 27, 3, 28, 131, 6, 0, 0, 7, 29, 372 0, 0, 11, 0, 0, 63, 64, 16, 0, 17, 373 18, 19, 65, 20, 0, 0, 23, 0, 0, 0, 374 0, 27, 0, 28, 0, 0, 0, 0, 0, 29, 375 0, 0, 0, 0, 0, 0, 0, 66, 67, 68, 376 69, 70, 71 377 }; 378 379 static const short yycheck[] = { 2, 380 4, 1, 3, 148, 43, 43, 43, 11, 43, 3, 381 48, 48, 8, 138, 43, 10, 43, 12, 3, 3, 382 3, 48, 8, 43, 169, 150, 43, 28, 29, 43, 383 8, 43, 36, 37, 38, 39, 40, 41, 48, 44, 384 41, 42, 38, 4, 5, 170, 47, 48, 42, 50, 385 11, 52, 53, 47, 55, 58, 181, 42, 42, 42, 386 38, 46, 62, 46, 65, 66, 67, 68, 69, 70, 387 71, 38, 39, 40, 41, 36, 37, 38, 39, 40, 388 41, 43, 83, 43, 85, 44, 41, 44, 49, 47, 389 8, 47, 95, 6, 94, 8, 9, 98, 99, 12, 390 48, 44, 47, 16, 42, 49, 107, 108, 21, 110, 391 23, 24, 25, 48, 27, 3, 44, 30, 49, 45, 392 3, 48, 35, 124, 37, 4, 5, 8, 8, 49, 393 43, 48, 11, 42, 26, 22, 49, 49, 44, 0, 394 141, 172, 23, 24, 25, 124, 149, 148, 166, 30, 395 7, -1, -1, -1, 35, 158, -1, 36, 37, 38, 396 39, 40, 41, -1, -1, 44, -1, -1, 169, 0, 397 1, 174, 3, -1, -1, 6, 7, 8, 9, 182, 398 -1, 12, 13, 14, 15, 16, 17, 18, 19, 20, 399 21, -1, 23, 24, 25, -1, 27, 28, 29, 30, 400 31, 32, 33, -1, 35, -1, 37, -1, -1, -1, 401 -1, 42, 43, 1, 45, 3, -1, -1, 6, 7, 402 8, 9, -1, -1, 12, -1, 14, 15, 16, 17, 403 18, 19, 20, 21, -1, 23, 24, 25, -1, 27, 404 28, 29, 30, 31, 32, 33, -1, 35, -1, 37, 405 -1, -1, -1, -1, 42, 43, -1, 45, 46, 1, 406 -1, 3, -1, -1, 6, 7, 8, 9, -1, -1, 407 12, -1, 14, 15, 16, 17, 18, 19, 20, 21, 408 -1, 23, 24, 25, -1, 27, 28, 29, 30, 31, 409 32, 33, -1, 35, -1, 37, -1, -1, -1, -1, 410 42, 43, -1, 45, 46, 1, -1, 3, -1, -1, 411 6, 7, 8, 9, -1, -1, 12, -1, 14, 15, 412 16, 17, 18, 19, 20, 21, -1, 23, 24, 25, 413 -1, 27, 28, 29, 30, 31, 32, 33, -1, 35, 414 -1, 37, 6, -1, 8, 9, 42, 43, 12, 45, 415 -1, -1, 16, -1, -1, -1, -1, 21, -1, 23, 416 24, 25, -1, 27, -1, -1, 30, -1, -1, -1, 417 -1, 35, -1, 37, -1, -1, -1, 3, -1, 43, 418 6, 7, 8, 9, -1, 49, 12, -1, 14, 15, 419 16, 17, 18, 19, 20, 21, -1, 23, 24, 25, 420 -1, 27, 28, 29, 30, 31, 32, 33, -1, 35, 421 -1, 37, -1, 4, 5, -1, -1, 43, -1, 45, 422 11, -1, 4, 5, -1, -1, -1, -1, -1, 11, 423 -1, 4, 5, -1, -1, -1, -1, -1, 11, 36, 424 37, 38, 39, 40, 41, 36, 37, 38, 39, 40, 425 41, -1, 11, 44, 36, 37, 38, 39, 40, 41, 426 -1, -1, 44, 36, 37, 38, 39, 40, 41, 4, 427 5, 44, -1, -1, -1, -1, 11, 36, 37, 38, 428 39, 40, 41, -1, -1, -1, -1, -1, -1, -1, 429 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 430 -1, 36, 37, 38, 39, 40, 41, -1, -1, 44, 431 6, 7, 8, 9, -1, -1, 12, -1, 14, 15, 432 16, 17, 18, 19, 20, 21, -1, 23, 24, 25, 433 -1, 27, 28, 29, 30, 31, 32, 33, -1, 35, 434 -1, 37, 6, 7, 8, 9, -1, 43, 12, 45, 435 -1, -1, 16, -1, -1, -1, -1, 21, -1, 23, 436 24, 25, -1, 27, -1, -1, 30, -1, -1, -1, 437 -1, 35, 6, 37, 8, 9, -1, -1, 12, 43, 438 -1, -1, 16, -1, -1, -1, -1, 21, -1, 23, 439 24, 25, -1, 27, -1, -1, 30, -1, -1, -1, 440 -1, 35, 6, 37, 8, 9, -1, -1, 12, 43, 441 -1, -1, 16, -1, -1, -1, -1, 21, -1, 23, 442 24, 25, -1, 27, -1, -1, 30, -1, -1, -1, 443 -1, 35, 6, 37, 8, 9, -1, -1, 12, 43, 444 -1, -1, 16, -1, -1, 4, 5, 21, -1, 23, 445 24, 25, 11, 27, -1, -1, 30, -1, -1, -1, 446 -1, 35, -1, 37, -1, -1, -1, -1, -1, 43, 447 -1, -1, -1, -1, -1, -1, -1, 36, 37, 38, 448 39, 40, 41 449 }; 450 /* -*-C-*- Note some compilers choke on comments on `#line' lines. */ 451 #line 3 "/usr/gnu/share/bison.simple" 452 453 /* Skeleton output parser for bison, 454 Copyright (C) 1984, 1989, 1990 Free Software Foundation, Inc. 455 456 This program is free software; you can redistribute it and/or modify 457 it under the terms of the GNU General Public License as published by 458 the Free Software Foundation; either version 2, or (at your option) 459 any later version. 460 461 This program is distributed in the hope that it will be useful, 462 but WITHOUT ANY WARRANTY; without even the implied warranty of 463 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 464 GNU General Public License for more details. 465 466 You should have received a copy of the GNU General Public License 467 along with this program; if not, write to the Free Software 468 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ 469 470 /* As a special exception, when this file is copied by Bison into a 471 Bison output file, you may use that output file without restriction. 472 This special exception was added by the Free Software Foundation 473 in version 1.24 of Bison. */ 474 475 #ifndef alloca 476 #ifdef __GNUC__ 477 #define alloca __builtin_alloca 478 #else /* not GNU C. */ 479 #if (!defined (__STDC__) && defined (sparc)) || defined (__sparc__) || defined (__sparc) || defined (__sgi) 480 #include <alloca.h> 481 #else /* not sparc */ 482 #if defined (MSDOS) && !defined (__TURBOC__) 483 #include <malloc.h> 484 #else /* not MSDOS, or __TURBOC__ */ 485 #if defined(_AIX) 486 #include <malloc.h> 487 #pragma alloca 488 #else /* not MSDOS, __TURBOC__, or _AIX */ 489 #ifdef __hpux 490 #ifdef __cplusplus 491 extern "C" { 492 void *alloca (unsigned int); 493 }; 494 #else /* not __cplusplus */ 495 void *alloca (); 496 #endif /* not __cplusplus */ 497 #endif /* __hpux */ 498 #endif /* not _AIX */ 499 #endif /* not MSDOS, or __TURBOC__ */ 500 #endif /* not sparc. */ 501 #endif /* not GNU C. */ 502 #endif /* alloca not defined. */ 503 504 /* This is the parser code that is written into each bison parser 505 when the %semantic_parser declaration is not specified in the grammar. 506 It was written by Richard Stallman by simplifying the hairy parser 507 used when %semantic_parser is specified. */ 508 509 /* Note: there must be only one dollar sign in this file. 510 It is replaced by the list of actions, each action 511 as one case of the switch. */ 512 513 #define yyerrok (yyerrstatus = 0) 514 #define yyclearin (yychar = YYEMPTY) 515 #define YYEMPTY -2 516 #define YYEOF 0 517 #define YYACCEPT return(0) 518 #define YYABORT return(1) 519 #define YYERROR goto yyerrlab1 520 /* Like YYERROR except do call yyerror. 521 This remains here temporarily to ease the 522 transition to the new meaning of YYERROR, for GCC. 523 Once GCC version 2 has supplanted version 1, this can go. */ 524 #define YYFAIL goto yyerrlab 525 #define YYRECOVERING() (!!yyerrstatus) 526 #define YYBACKUP(token, value) \ 527 do \ 528 if (yychar == YYEMPTY && yylen == 1) \ 529 { yychar = (token), yylval = (value); \ 530 yychar1 = YYTRANSLATE (yychar); \ 531 YYPOPSTACK; \ 532 goto yybackup; \ 533 } \ 534 else \ 535 { yyerror ("syntax error: cannot back up"); YYERROR; } \ 536 while (0) 537 538 #define YYTERROR 1 539 #define YYERRCODE 256 540 541 #ifndef YYPURE 542 #define YYLEX yylex() 543 #endif 544 545 #ifdef YYPURE 546 #ifdef YYLSP_NEEDED 547 #ifdef YYLEX_PARAM 548 #define YYLEX yylex(&yylval, &yylloc, YYLEX_PARAM) 549 #else 550 #define YYLEX yylex(&yylval, &yylloc) 551 #endif 552 #else /* not YYLSP_NEEDED */ 553 #ifdef YYLEX_PARAM 554 #define YYLEX yylex(&yylval, YYLEX_PARAM) 555 #else 556 #define YYLEX yylex(&yylval) 557 #endif 558 #endif /* not YYLSP_NEEDED */ 559 #endif 560 561 /* If nonreentrant, generate the variables here */ 562 563 #ifndef YYPURE 564 565 int yychar; /* the lookahead symbol */ 566 YYSTYPE yylval; /* the semantic value of the */ 567 /* lookahead symbol */ 568 569 #ifdef YYLSP_NEEDED 570 YYLTYPE yylloc; /* location data for the lookahead */ 571 /* symbol */ 572 #endif 573 574 int yynerrs; /* number of parse errors so far */ 575 #endif /* not YYPURE */ 576 577 #if YYDEBUG != 0 578 int yydebug; /* nonzero means print parse trace */ 579 /* Since this is uninitialized, it does not stop multiple parsers 580 from coexisting. */ 581 #endif 582 583 /* YYINITDEPTH indicates the initial size of the parser's stacks */ 584 585 #ifndef YYINITDEPTH 586 #define YYINITDEPTH 200 587 #endif 588 589 /* YYMAXDEPTH is the maximum size the stacks can grow to 590 (effective only if the built-in stack extension method is used). */ 591 592 #if YYMAXDEPTH == 0 593 #undef YYMAXDEPTH 594 #endif 595 596 #ifndef YYMAXDEPTH 597 #define YYMAXDEPTH 10000 598 #endif 599 600 /* Prevent warning if -Wstrict-prototypes. */ 601 #ifdef __GNUC__ 602 int yyparse (void); 603 #endif 604 605 #if __GNUC__ > 1 /* GNU C and GNU C++ define this. */ 606 #define __yy_memcpy(TO,FROM,COUNT) __builtin_memcpy(TO,FROM,COUNT) 607 #else /* not GNU C or C++ */ 608 #ifndef __cplusplus 609 610 /* This is the most reliable way to avoid incompatibilities 611 in available built-in functions on various systems. */ 612 static void 613 __yy_memcpy (to, from, count) 614 char *to; 615 char *from; 616 int count; 617 { 618 register char *f = from; 619 register char *t = to; 620 register int i = count; 621 622 while (i-- > 0) 623 *t++ = *f++; 624 } 625 626 #else /* __cplusplus */ 627 628 /* This is the most reliable way to avoid incompatibilities 629 in available built-in functions on various systems. */ 630 static void 631 __yy_memcpy (char *to, char *from, int count) 632 { 633 register char *f = from; 634 register char *t = to; 635 register int i = count; 636 637 while (i-- > 0) 638 *t++ = *f++; 639 } 640 641 #endif 642 #endif 643 644 #line 196 "/usr/gnu/share/bison.simple" 645 646 /* The user can define YYPARSE_PARAM as the name of an argument to be passed 647 into yyparse. The argument should have type void *. 648 It should actually point to an object. 649 Grammar actions can access the variable by casting it 650 to the proper pointer type. */ 651 652 #ifdef YYPARSE_PARAM 653 #ifdef __cplusplus 654 #define YYPARSE_PARAM_ARG void *YYPARSE_PARAM 655 #define YYPARSE_PARAM_DECL 656 #else /* not __cplusplus */ 657 #define YYPARSE_PARAM_ARG YYPARSE_PARAM 658 #define YYPARSE_PARAM_DECL void *YYPARSE_PARAM; 659 #endif /* not __cplusplus */ 660 #else /* not YYPARSE_PARAM */ 661 #define YYPARSE_PARAM_ARG 662 #define YYPARSE_PARAM_DECL 663 #endif /* not YYPARSE_PARAM */ 664 665 int 666 yyparse(YYPARSE_PARAM_ARG) 667 YYPARSE_PARAM_DECL 668 { 669 register int yystate; 670 register int yyn; 671 register short *yyssp; 672 register YYSTYPE *yyvsp; 673 int yyerrstatus; /* number of tokens to shift before error messages enabled */ 674 int yychar1 = 0; /* lookahead token as an internal (translated) token number */ 675 676 short yyssa[YYINITDEPTH]; /* the state stack */ 677 YYSTYPE yyvsa[YYINITDEPTH]; /* the semantic value stack */ 678 679 short *yyss = yyssa; /* refer to the stacks thru separate pointers */ 680 YYSTYPE *yyvs = yyvsa; /* to allow yyoverflow to reallocate them elsewhere */ 681 682 #ifdef YYLSP_NEEDED 683 YYLTYPE yylsa[YYINITDEPTH]; /* the location stack */ 684 YYLTYPE *yyls = yylsa; 685 YYLTYPE *yylsp; 686 687 #define YYPOPSTACK (yyvsp--, yyssp--, yylsp--) 688 #else 689 #define YYPOPSTACK (yyvsp--, yyssp--) 690 #endif 691 692 int yystacksize = YYINITDEPTH; 693 694 #ifdef YYPURE 695 int yychar; 696 YYSTYPE yylval; 697 int yynerrs; 698 #ifdef YYLSP_NEEDED 699 YYLTYPE yylloc; 700 #endif 701 #endif 702 703 YYSTYPE yyval; /* the variable used to return */ 704 /* semantic values from the action */ 705 /* routines */ 706 707 int yylen; 708 709 #if YYDEBUG != 0 710 if (yydebug) 711 fprintf(stderr, "Starting parse\n"); 712 #endif 713 714 yystate = 0; 715 yyerrstatus = 0; 716 yynerrs = 0; 717 yychar = YYEMPTY; /* Cause a token to be read. */ 718 719 /* Initialize stack pointers. 720 Waste one element of value and location stack 721 so that they stay on the same level as the state stack. 722 The wasted elements are never initialized. */ 723 724 yyssp = yyss - 1; 725 yyvsp = yyvs; 726 #ifdef YYLSP_NEEDED 727 yylsp = yyls; 728 #endif 729 730 /* Push a new state, which is found in yystate . */ 731 /* In all cases, when you get here, the value and location stacks 732 have just been pushed. so pushing a state here evens the stacks. */ 733 yynewstate: 734 735 *++yyssp = yystate; 736 737 if (yyssp >= yyss + yystacksize - 1) 738 { 739 /* Give user a chance to reallocate the stack */ 740 /* Use copies of these so that the &'s don't force the real ones into memory. */ 741 YYSTYPE *yyvs1 = yyvs; 742 short *yyss1 = yyss; 743 #ifdef YYLSP_NEEDED 744 YYLTYPE *yyls1 = yyls; 745 #endif 746 747 /* Get the current used size of the three stacks, in elements. */ 748 int size = yyssp - yyss + 1; 749 750 #ifdef yyoverflow 751 /* Each stack pointer address is followed by the size of 752 the data in use in that stack, in bytes. */ 753 #ifdef YYLSP_NEEDED 754 /* This used to be a conditional around just the two extra args, 755 but that might be undefined if yyoverflow is a macro. */ 756 yyoverflow("parser stack overflow", 757 &yyss1, size * sizeof (*yyssp), 758 &yyvs1, size * sizeof (*yyvsp), 759 &yyls1, size * sizeof (*yylsp), 760 &yystacksize); 761 #else 762 yyoverflow("parser stack overflow", 763 &yyss1, size * sizeof (*yyssp), 764 &yyvs1, size * sizeof (*yyvsp), 765 &yystacksize); 766 #endif 767 768 yyss = yyss1; yyvs = yyvs1; 769 #ifdef YYLSP_NEEDED 770 yyls = yyls1; 771 #endif 772 #else /* no yyoverflow */ 773 /* Extend the stack our own way. */ 774 if (yystacksize >= YYMAXDEPTH) 775 { 776 yyerror("parser stack overflow"); 777 return 2; 778 } 779 yystacksize *= 2; 780 if (yystacksize > YYMAXDEPTH) 781 yystacksize = YYMAXDEPTH; 782 yyss = (short *) alloca (yystacksize * sizeof (*yyssp)); 783 __yy_memcpy ((char *)yyss, (char *)yyss1, size * sizeof (*yyssp)); 784 yyvs = (YYSTYPE *) alloca (yystacksize * sizeof (*yyvsp)); 785 __yy_memcpy ((char *)yyvs, (char *)yyvs1, size * sizeof (*yyvsp)); 786 #ifdef YYLSP_NEEDED 787 yyls = (YYLTYPE *) alloca (yystacksize * sizeof (*yylsp)); 788 __yy_memcpy ((char *)yyls, (char *)yyls1, size * sizeof (*yylsp)); 789 #endif 790 #endif /* no yyoverflow */ 791 792 yyssp = yyss + size - 1; 793 yyvsp = yyvs + size - 1; 794 #ifdef YYLSP_NEEDED 795 yylsp = yyls + size - 1; 796 #endif 797 798 #if YYDEBUG != 0 799 if (yydebug) 800 fprintf(stderr, "Stack size increased to %d\n", yystacksize); 801 #endif 802 803 if (yyssp >= yyss + yystacksize - 1) 804 YYABORT; 805 } 806 807 #if YYDEBUG != 0 808 if (yydebug) 809 fprintf(stderr, "Entering state %d\n", yystate); 810 #endif 811 812 goto yybackup; 813 yybackup: 814 815 /* Do appropriate processing given the current state. */ 816 /* Read a lookahead token if we need one and don't already have one. */ 817 /* yyresume: */ 818 819 /* First try to decide what to do without reference to lookahead token. */ 820 821 yyn = yypact[yystate]; 822 if (yyn == YYFLAG) 823 goto yydefault; 824 825 /* Not known => get a lookahead token if don't already have one. */ 826 827 /* yychar is either YYEMPTY or YYEOF 828 or a valid token in external form. */ 829 830 if (yychar == YYEMPTY) 831 { 832 #if YYDEBUG != 0 833 if (yydebug) 834 fprintf(stderr, "Reading a token: "); 835 #endif 836 yychar = YYLEX; 837 } 838 839 /* Convert token to internal form (in yychar1) for indexing tables with */ 840 841 if (yychar <= 0) /* This means end of input. */ 842 { 843 yychar1 = 0; 844 yychar = YYEOF; /* Don't call YYLEX any more */ 845 846 #if YYDEBUG != 0 847 if (yydebug) 848 fprintf(stderr, "Now at end of input.\n"); 849 #endif 850 } 851 else 852 { 853 yychar1 = YYTRANSLATE(yychar); 854 855 #if YYDEBUG != 0 856 if (yydebug) 857 { 858 fprintf (stderr, "Next token is %d (%s", yychar, yytname[yychar1]); 859 /* Give the individual parser a way to print the precise meaning 860 of a token, for further debugging info. */ 861 #ifdef YYPRINT 862 YYPRINT (stderr, yychar, yylval); 863 #endif 864 fprintf (stderr, ")\n"); 865 } 866 #endif 867 } 868 869 yyn += yychar1; 870 if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != yychar1) 871 goto yydefault; 872 873 yyn = yytable[yyn]; 874 875 /* yyn is what to do for this token type in this state. 876 Negative => reduce, -yyn is rule number. 877 Positive => shift, yyn is new state. 878 New state is final state => don't bother to shift, 879 just return success. 880 0, or most negative number => error. */ 881 882 if (yyn < 0) 883 { 884 if (yyn == YYFLAG) 885 goto yyerrlab; 886 yyn = -yyn; 887 goto yyreduce; 888 } 889 else if (yyn == 0) 890 goto yyerrlab; 891 892 if (yyn == YYFINAL) 893 YYACCEPT; 894 895 /* Shift the lookahead token. */ 896 897 #if YYDEBUG != 0 898 if (yydebug) 899 fprintf(stderr, "Shifting token %d (%s), ", yychar, yytname[yychar1]); 900 #endif 901 902 /* Discard the token being shifted unless it is eof. */ 903 if (yychar != YYEOF) 904 yychar = YYEMPTY; 905 906 *++yyvsp = yylval; 907 #ifdef YYLSP_NEEDED 908 *++yylsp = yylloc; 909 #endif 910 911 /* count tokens shifted since error; after three, turn off error status. */ 912 if (yyerrstatus) yyerrstatus--; 913 914 yystate = yyn; 915 goto yynewstate; 916 917 /* Do the default action for the current state. */ 918 yydefault: 919 920 yyn = yydefact[yystate]; 921 if (yyn == 0) 922 goto yyerrlab; 923 924 /* Do a reduction. yyn is the number of a rule to reduce with. */ 925 yyreduce: 926 yylen = yyr2[yyn]; 927 if (yylen > 0) 928 yyval = yyvsp[1-yylen]; /* implement default value of the action */ 929 930 #if YYDEBUG != 0 931 if (yydebug) 932 { 933 int i; 934 935 fprintf (stderr, "Reducing via rule %d (line %d), ", 936 yyn, yyrline[yyn]); 937 938 /* Print the symbols being reduced, and their result. */ 939 for (i = yyprhs[yyn]; yyrhs[i] > 0; i++) 940 fprintf (stderr, "%s ", yytname[yyrhs[i]]); 941 fprintf (stderr, " -> %s\n", yytname[yyr1[yyn]]); 942 } 943 #endif 944 945 946 switch (yyn) { 947 948 case 1: 949 #line 106 "bc.y" 950 { 951 yyval.i_value = 0; 952 if (interactive && !quiet) 953 { 954 printf ("%s\n", BC_VERSION); 955 welcome (); 956 } 957 ; 958 break;} 959 case 3: 960 #line 117 "bc.y" 961 { run_code (); ; 962 break;} 963 case 4: 964 #line 119 "bc.y" 965 { run_code (); ; 966 break;} 967 case 5: 968 #line 121 "bc.y" 969 { 970 yyerrok; 971 init_gen (); 972 ; 973 break;} 974 case 7: 975 #line 128 "bc.y" 976 { warn ("newline not allowed"); ; 977 break;} 978 case 8: 979 #line 131 "bc.y" 980 { yyval.i_value = 0; ; 981 break;} 982 case 12: 983 #line 137 "bc.y" 984 { yyval.i_value = 0; ; 985 break;} 986 case 19: 987 #line 146 "bc.y" 988 { yyval.i_value = yyvsp[0].i_value; ; 989 break;} 990 case 20: 991 #line 149 "bc.y" 992 { warranty (""); ; 993 break;} 994 case 21: 995 #line 151 "bc.y" 996 { limits (); ; 997 break;} 998 case 22: 999 #line 153 "bc.y" 1000 { 1001 if (yyvsp[0].i_value & 2) 1002 warn ("comparison in expression"); 1003 if (yyvsp[0].i_value & 1) 1004 generate ("W"); 1005 else 1006 generate ("p"); 1007 ; 1008 break;} 1009 case 23: 1010 #line 162 "bc.y" 1011 { 1012 yyval.i_value = 0; 1013 generate ("w"); 1014 generate (yyvsp[0].s_value); 1015 free (yyvsp[0].s_value); 1016 ; 1017 break;} 1018 case 24: 1019 #line 169 "bc.y" 1020 { 1021 if (break_label == 0) 1022 yyerror ("Break outside a for/while"); 1023 else 1024 { 1025 sprintf (genstr, "J%1d:", break_label); 1026 generate (genstr); 1027 } 1028 ; 1029 break;} 1030 case 25: 1031 #line 179 "bc.y" 1032 { 1033 warn ("Continue statement"); 1034 if (continue_label == 0) 1035 yyerror ("Continue outside a for"); 1036 else 1037 { 1038 sprintf (genstr, "J%1d:", continue_label); 1039 generate (genstr); 1040 } 1041 ; 1042 break;} 1043 case 26: 1044 #line 190 "bc.y" 1045 { exit (0); ; 1046 break;} 1047 case 27: 1048 #line 192 "bc.y" 1049 { generate ("h"); ; 1050 break;} 1051 case 28: 1052 #line 194 "bc.y" 1053 { generate ("0R"); ; 1054 break;} 1055 case 29: 1056 #line 196 "bc.y" 1057 { generate ("R"); ; 1058 break;} 1059 case 30: 1060 #line 198 "bc.y" 1061 { 1062 yyvsp[0].i_value = break_label; 1063 break_label = next_label++; 1064 ; 1065 break;} 1066 case 31: 1067 #line 203 "bc.y" 1068 { 1069 if (yyvsp[-1].i_value > 1) 1070 warn ("Comparison in first for expression"); 1071 yyvsp[-1].i_value = next_label++; 1072 if (yyvsp[-1].i_value < 0) 1073 sprintf (genstr, "N%1d:", yyvsp[-1].i_value); 1074 else 1075 sprintf (genstr, "pN%1d:", yyvsp[-1].i_value); 1076 generate (genstr); 1077 ; 1078 break;} 1079 case 32: 1080 #line 214 "bc.y" 1081 { 1082 if (yyvsp[-1].i_value < 0) generate ("1"); 1083 yyvsp[-1].i_value = next_label++; 1084 sprintf (genstr, "B%1d:J%1d:", yyvsp[-1].i_value, break_label); 1085 generate (genstr); 1086 yyval.i_value = continue_label; 1087 continue_label = next_label++; 1088 sprintf (genstr, "N%1d:", continue_label); 1089 generate (genstr); 1090 ; 1091 break;} 1092 case 33: 1093 #line 225 "bc.y" 1094 { 1095 if (yyvsp[-1].i_value > 1) 1096 warn ("Comparison in third for expression"); 1097 if (yyvsp[-1].i_value < 0) 1098 sprintf (genstr, "J%1d:N%1d:", yyvsp[-7].i_value, yyvsp[-4].i_value); 1099 else 1100 sprintf (genstr, "pJ%1d:N%1d:", yyvsp[-7].i_value, yyvsp[-4].i_value); 1101 generate (genstr); 1102 ; 1103 break;} 1104 case 34: 1105 #line 235 "bc.y" 1106 { 1107 sprintf (genstr, "J%1d:N%1d:", 1108 continue_label, break_label); 1109 generate (genstr); 1110 break_label = yyvsp[-13].i_value; 1111 continue_label = yyvsp[-5].i_value; 1112 ; 1113 break;} 1114 case 35: 1115 #line 243 "bc.y" 1116 { 1117 yyvsp[-1].i_value = if_label; 1118 if_label = next_label++; 1119 sprintf (genstr, "Z%1d:", if_label); 1120 generate (genstr); 1121 ; 1122 break;} 1123 case 36: 1124 #line 250 "bc.y" 1125 { 1126 sprintf (genstr, "N%1d:", if_label); 1127 generate (genstr); 1128 if_label = yyvsp[-5].i_value; 1129 ; 1130 break;} 1131 case 37: 1132 #line 256 "bc.y" 1133 { 1134 yyvsp[0].i_value = next_label++; 1135 sprintf (genstr, "N%1d:", yyvsp[0].i_value); 1136 generate (genstr); 1137 ; 1138 break;} 1139 case 38: 1140 #line 262 "bc.y" 1141 { 1142 yyvsp[0].i_value = break_label; 1143 break_label = next_label++; 1144 sprintf (genstr, "Z%1d:", break_label); 1145 generate (genstr); 1146 ; 1147 break;} 1148 case 39: 1149 #line 269 "bc.y" 1150 { 1151 sprintf (genstr, "J%1d:N%1d:", yyvsp[-7].i_value, break_label); 1152 generate (genstr); 1153 break_label = yyvsp[-4].i_value; 1154 ; 1155 break;} 1156 case 40: 1157 #line 275 "bc.y" 1158 { yyval.i_value = 0; ; 1159 break;} 1160 case 41: 1161 #line 277 "bc.y" 1162 { warn ("print statement"); ; 1163 break;} 1164 case 45: 1165 #line 284 "bc.y" 1166 { 1167 generate ("O"); 1168 generate (yyvsp[0].s_value); 1169 free (yyvsp[0].s_value); 1170 ; 1171 break;} 1172 case 46: 1173 #line 290 "bc.y" 1174 { generate ("P"); ; 1175 break;} 1176 case 48: 1177 #line 294 "bc.y" 1178 { 1179 warn ("else clause in if statement"); 1180 yyvsp[0].i_value = next_label++; 1181 sprintf (genstr, "J%d:N%1d:", yyvsp[0].i_value, if_label); 1182 generate (genstr); 1183 if_label = yyvsp[0].i_value; 1184 ; 1185 break;} 1186 case 50: 1187 #line 304 "bc.y" 1188 { 1189 /* Check auto list against parameter list? */ 1190 check_params (yyvsp[-5].a_value,yyvsp[0].a_value); 1191 sprintf (genstr, "F%d,%s.%s[", 1192 lookup(yyvsp[-7].s_value,FUNCTDEF), 1193 arg_str (yyvsp[-5].a_value), arg_str (yyvsp[0].a_value)); 1194 generate (genstr); 1195 free_args (yyvsp[-5].a_value); 1196 free_args (yyvsp[0].a_value); 1197 yyvsp[-8].i_value = next_label; 1198 next_label = 1; 1199 ; 1200 break;} 1201 case 51: 1202 #line 317 "bc.y" 1203 { 1204 generate ("0R]"); 1205 next_label = yyvsp[-11].i_value; 1206 ; 1207 break;} 1208 case 52: 1209 #line 323 "bc.y" 1210 { yyval.a_value = NULL; ; 1211 break;} 1212 case 54: 1213 #line 327 "bc.y" 1214 { yyval.a_value = NULL; ; 1215 break;} 1216 case 55: 1217 #line 329 "bc.y" 1218 { yyval.a_value = yyvsp[-1].a_value; ; 1219 break;} 1220 case 56: 1221 #line 331 "bc.y" 1222 { yyval.a_value = yyvsp[-1].a_value; ; 1223 break;} 1224 case 57: 1225 #line 334 "bc.y" 1226 { yyval.a_value = nextarg (NULL, lookup (yyvsp[0].s_value,SIMPLE), FALSE);; 1227 break;} 1228 case 58: 1229 #line 336 "bc.y" 1230 { yyval.a_value = nextarg (NULL, lookup (yyvsp[-2].s_value,ARRAY), FALSE); ; 1231 break;} 1232 case 59: 1233 #line 338 "bc.y" 1234 { yyval.a_value = nextarg (NULL, lookup (yyvsp[-2].s_value,ARRAY), TRUE); ; 1235 break;} 1236 case 60: 1237 #line 340 "bc.y" 1238 { yyval.a_value = nextarg (yyvsp[-2].a_value, lookup (yyvsp[0].s_value,SIMPLE), FALSE); ; 1239 break;} 1240 case 61: 1241 #line 342 "bc.y" 1242 { yyval.a_value = nextarg (yyvsp[-4].a_value, lookup (yyvsp[-2].s_value,ARRAY), FALSE); ; 1243 break;} 1244 case 62: 1245 #line 344 "bc.y" 1246 { yyval.a_value = nextarg (yyvsp[-5].a_value, lookup (yyvsp[-2].s_value,ARRAY), TRUE); ; 1247 break;} 1248 case 63: 1249 #line 347 "bc.y" 1250 { yyval.a_value = NULL; ; 1251 break;} 1252 case 65: 1253 #line 351 "bc.y" 1254 { 1255 if (yyvsp[0].i_value > 1) warn ("comparison in argument"); 1256 yyval.a_value = nextarg (NULL,0,FALSE); 1257 ; 1258 break;} 1259 case 66: 1260 #line 356 "bc.y" 1261 { 1262 sprintf (genstr, "K%d:", -lookup (yyvsp[-2].s_value,ARRAY)); 1263 generate (genstr); 1264 yyval.a_value = nextarg (NULL,1,FALSE); 1265 ; 1266 break;} 1267 case 67: 1268 #line 362 "bc.y" 1269 { 1270 if (yyvsp[0].i_value > 1) warn ("comparison in argument"); 1271 yyval.a_value = nextarg (yyvsp[-2].a_value,0,FALSE); 1272 ; 1273 break;} 1274 case 68: 1275 #line 367 "bc.y" 1276 { 1277 sprintf (genstr, "K%d:", -lookup (yyvsp[-2].s_value,ARRAY)); 1278 generate (genstr); 1279 yyval.a_value = nextarg (yyvsp[-4].a_value,1,FALSE); 1280 ; 1281 break;} 1282 case 69: 1283 #line 374 "bc.y" 1284 { 1285 yyval.i_value = -1; 1286 warn ("Missing expression in for statement"); 1287 ; 1288 break;} 1289 case 71: 1290 #line 381 "bc.y" 1291 { 1292 yyval.i_value = 0; 1293 generate ("0"); 1294 ; 1295 break;} 1296 case 72: 1297 #line 386 "bc.y" 1298 { 1299 if (yyvsp[0].i_value > 1) 1300 warn ("comparison in return expresion"); 1301 ; 1302 break;} 1303 case 73: 1304 #line 392 "bc.y" 1305 { 1306 if (yyvsp[0].c_value != '=') 1307 { 1308 if (yyvsp[-1].i_value < 0) 1309 sprintf (genstr, "DL%d:", -yyvsp[-1].i_value); 1310 else 1311 sprintf (genstr, "l%d:", yyvsp[-1].i_value); 1312 generate (genstr); 1313 } 1314 ; 1315 break;} 1316 case 74: 1317 #line 403 "bc.y" 1318 { 1319 if (yyvsp[0].i_value > 1) warn("comparison in assignment"); 1320 if (yyvsp[-2].c_value != '=') 1321 { 1322 sprintf (genstr, "%c", yyvsp[-2].c_value); 1323 generate (genstr); 1324 } 1325 if (yyvsp[-3].i_value < 0) 1326 sprintf (genstr, "S%d:", -yyvsp[-3].i_value); 1327 else 1328 sprintf (genstr, "s%d:", yyvsp[-3].i_value); 1329 generate (genstr); 1330 yyval.i_value = 0; 1331 ; 1332 break;} 1333 case 75: 1334 #line 419 "bc.y" 1335 { 1336 warn("&& operator"); 1337 yyvsp[0].i_value = next_label++; 1338 sprintf (genstr, "DZ%d:p", yyvsp[0].i_value); 1339 generate (genstr); 1340 ; 1341 break;} 1342 case 76: 1343 #line 426 "bc.y" 1344 { 1345 sprintf (genstr, "DZ%d:p1N%d:", yyvsp[-2].i_value, yyvsp[-2].i_value); 1346 generate (genstr); 1347 yyval.i_value = yyvsp[-3].i_value | yyvsp[0].i_value; 1348 ; 1349 break;} 1350 case 77: 1351 #line 432 "bc.y" 1352 { 1353 warn("|| operator"); 1354 yyvsp[0].i_value = next_label++; 1355 sprintf (genstr, "B%d:", yyvsp[0].i_value); 1356 generate (genstr); 1357 ; 1358 break;} 1359 case 78: 1360 #line 439 "bc.y" 1361 { 1362 int tmplab; 1363 tmplab = next_label++; 1364 sprintf (genstr, "B%d:0J%d:N%d:1N%d:", 1365 yyvsp[-2].i_value, tmplab, yyvsp[-2].i_value, tmplab); 1366 generate (genstr); 1367 yyval.i_value = yyvsp[-3].i_value | yyvsp[0].i_value; 1368 ; 1369 break;} 1370 case 79: 1371 #line 448 "bc.y" 1372 { 1373 yyval.i_value = yyvsp[0].i_value; 1374 warn("! operator"); 1375 generate ("!"); 1376 ; 1377 break;} 1378 case 80: 1379 #line 454 "bc.y" 1380 { 1381 yyval.i_value = 3; 1382 switch (*(yyvsp[-1].s_value)) 1383 { 1384 case '=': 1385 generate ("="); 1386 break; 1387 1388 case '!': 1389 generate ("#"); 1390 break; 1391 1392 case '<': 1393 if (yyvsp[-1].s_value[1] == '=') 1394 generate ("{"); 1395 else 1396 generate ("<"); 1397 break; 1398 1399 case '>': 1400 if (yyvsp[-1].s_value[1] == '=') 1401 generate ("}"); 1402 else 1403 generate (">"); 1404 break; 1405 } 1406 ; 1407 break;} 1408 case 81: 1409 #line 482 "bc.y" 1410 { 1411 generate ("+"); 1412 yyval.i_value = yyvsp[-2].i_value | yyvsp[0].i_value; 1413 ; 1414 break;} 1415 case 82: 1416 #line 487 "bc.y" 1417 { 1418 generate ("-"); 1419 yyval.i_value = yyvsp[-2].i_value | yyvsp[0].i_value; 1420 ; 1421 break;} 1422 case 83: 1423 #line 492 "bc.y" 1424 { 1425 generate ("*"); 1426 yyval.i_value = yyvsp[-2].i_value | yyvsp[0].i_value; 1427 ; 1428 break;} 1429 case 84: 1430 #line 497 "bc.y" 1431 { 1432 generate ("/"); 1433 yyval.i_value = yyvsp[-2].i_value | yyvsp[0].i_value; 1434 ; 1435 break;} 1436 case 85: 1437 #line 502 "bc.y" 1438 { 1439 generate ("%"); 1440 yyval.i_value = yyvsp[-2].i_value | yyvsp[0].i_value; 1441 ; 1442 break;} 1443 case 86: 1444 #line 507 "bc.y" 1445 { 1446 generate ("^"); 1447 yyval.i_value = yyvsp[-2].i_value | yyvsp[0].i_value; 1448 ; 1449 break;} 1450 case 87: 1451 #line 512 "bc.y" 1452 { 1453 generate ("n"); 1454 yyval.i_value = yyvsp[0].i_value; 1455 ; 1456 break;} 1457 case 88: 1458 #line 517 "bc.y" 1459 { 1460 yyval.i_value = 1; 1461 if (yyvsp[0].i_value < 0) 1462 sprintf (genstr, "L%d:", -yyvsp[0].i_value); 1463 else 1464 sprintf (genstr, "l%d:", yyvsp[0].i_value); 1465 generate (genstr); 1466 ; 1467 break;} 1468 case 89: 1469 #line 526 "bc.y" 1470 { 1471 int len = strlen(yyvsp[0].s_value); 1472 yyval.i_value = 1; 1473 if (len == 1 && *yyvsp[0].s_value == '0') 1474 generate ("0"); 1475 else if (len == 1 && *yyvsp[0].s_value == '1') 1476 generate ("1"); 1477 else 1478 { 1479 generate ("K"); 1480 generate (yyvsp[0].s_value); 1481 generate (":"); 1482 } 1483 free (yyvsp[0].s_value); 1484 ; 1485 break;} 1486 case 90: 1487 #line 542 "bc.y" 1488 { yyval.i_value = yyvsp[-1].i_value | 1; ; 1489 break;} 1490 case 91: 1491 #line 544 "bc.y" 1492 { 1493 yyval.i_value = 1; 1494 if (yyvsp[-1].a_value != NULL) 1495 { 1496 sprintf (genstr, "C%d,%s:", 1497 lookup (yyvsp[-3].s_value,FUNCT), 1498 call_str (yyvsp[-1].a_value)); 1499 free_args (yyvsp[-1].a_value); 1500 } 1501 else 1502 { 1503 sprintf (genstr, "C%d:", lookup (yyvsp[-3].s_value,FUNCT)); 1504 } 1505 generate (genstr); 1506 ; 1507 break;} 1508 case 92: 1509 #line 560 "bc.y" 1510 { 1511 yyval.i_value = 1; 1512 if (yyvsp[0].i_value < 0) 1513 { 1514 if (yyvsp[-1].c_value == '+') 1515 sprintf (genstr, "DA%d:L%d:", -yyvsp[0].i_value, -yyvsp[0].i_value); 1516 else 1517 sprintf (genstr, "DM%d:L%d:", -yyvsp[0].i_value, -yyvsp[0].i_value); 1518 } 1519 else 1520 { 1521 if (yyvsp[-1].c_value == '+') 1522 sprintf (genstr, "i%d:l%d:", yyvsp[0].i_value, yyvsp[0].i_value); 1523 else 1524 sprintf (genstr, "d%d:l%d:", yyvsp[0].i_value, yyvsp[0].i_value); 1525 } 1526 generate (genstr); 1527 ; 1528 break;} 1529 case 93: 1530 #line 579 "bc.y" 1531 { 1532 yyval.i_value = 1; 1533 if (yyvsp[-1].i_value < 0) 1534 { 1535 sprintf (genstr, "DL%d:x", -yyvsp[-1].i_value); 1536 generate (genstr); 1537 if (yyvsp[0].c_value == '+') 1538 sprintf (genstr, "A%d:", -yyvsp[-1].i_value); 1539 else 1540 sprintf (genstr, "M%d:", -yyvsp[-1].i_value); 1541 } 1542 else 1543 { 1544 sprintf (genstr, "l%d:", yyvsp[-1].i_value); 1545 generate (genstr); 1546 if (yyvsp[0].c_value == '+') 1547 sprintf (genstr, "i%d:", yyvsp[-1].i_value); 1548 else 1549 sprintf (genstr, "d%d:", yyvsp[-1].i_value); 1550 } 1551 generate (genstr); 1552 ; 1553 break;} 1554 case 94: 1555 #line 602 "bc.y" 1556 { generate ("cL"); yyval.i_value = 1;; 1557 break;} 1558 case 95: 1559 #line 604 "bc.y" 1560 { generate ("cR"); yyval.i_value = 1;; 1561 break;} 1562 case 96: 1563 #line 606 "bc.y" 1564 { generate ("cS"); yyval.i_value = 1;; 1565 break;} 1566 case 97: 1567 #line 608 "bc.y" 1568 { 1569 warn ("read function"); 1570 generate ("cI"); yyval.i_value = 1; 1571 ; 1572 break;} 1573 case 98: 1574 #line 614 "bc.y" 1575 { yyval.i_value = lookup(yyvsp[0].s_value,SIMPLE); ; 1576 break;} 1577 case 99: 1578 #line 616 "bc.y" 1579 { 1580 if (yyvsp[-1].i_value > 1) warn("comparison in subscript"); 1581 yyval.i_value = lookup(yyvsp[-3].s_value,ARRAY); 1582 ; 1583 break;} 1584 case 100: 1585 #line 621 "bc.y" 1586 { yyval.i_value = 0; ; 1587 break;} 1588 case 101: 1589 #line 623 "bc.y" 1590 { yyval.i_value = 1; ; 1591 break;} 1592 case 102: 1593 #line 625 "bc.y" 1594 { yyval.i_value = 2; ; 1595 break;} 1596 case 103: 1597 #line 627 "bc.y" 1598 { yyval.i_value = 3; 1599 warn ("History variable"); 1600 ; 1601 break;} 1602 case 104: 1603 #line 631 "bc.y" 1604 { yyval.i_value = 4; 1605 warn ("Last variable"); 1606 ; 1607 break;} 1608 } 1609 /* the action file gets copied in in place of this dollarsign */ 1610 #line 498 "/usr/gnu/share/bison.simple" 1611 1612 yyvsp -= yylen; 1613 yyssp -= yylen; 1614 #ifdef YYLSP_NEEDED 1615 yylsp -= yylen; 1616 #endif 1617 1618 #if YYDEBUG != 0 1619 if (yydebug) 1620 { 1621 short *ssp1 = yyss - 1; 1622 fprintf (stderr, "state stack now"); 1623 while (ssp1 != yyssp) 1624 fprintf (stderr, " %d", *++ssp1); 1625 fprintf (stderr, "\n"); 1626 } 1627 #endif 1628 1629 *++yyvsp = yyval; 1630 1631 #ifdef YYLSP_NEEDED 1632 yylsp++; 1633 if (yylen == 0) 1634 { 1635 yylsp->first_line = yylloc.first_line; 1636 yylsp->first_column = yylloc.first_column; 1637 yylsp->last_line = (yylsp-1)->last_line; 1638 yylsp->last_column = (yylsp-1)->last_column; 1639 yylsp->text = 0; 1640 } 1641 else 1642 { 1643 yylsp->last_line = (yylsp+yylen-1)->last_line; 1644 yylsp->last_column = (yylsp+yylen-1)->last_column; 1645 } 1646 #endif 1647 1648 /* Now "shift" the result of the reduction. 1649 Determine what state that goes to, 1650 based on the state we popped back to 1651 and the rule number reduced by. */ 1652 1653 yyn = yyr1[yyn]; 1654 1655 yystate = yypgoto[yyn - YYNTBASE] + *yyssp; 1656 if (yystate >= 0 && yystate <= YYLAST && yycheck[yystate] == *yyssp) 1657 yystate = yytable[yystate]; 1658 else 1659 yystate = yydefgoto[yyn - YYNTBASE]; 1660 1661 goto yynewstate; 1662 1663 yyerrlab: /* here on detecting error */ 1664 1665 if (! yyerrstatus) 1666 /* If not already recovering from an error, report this error. */ 1667 { 1668 ++yynerrs; 1669 1670 #ifdef YYERROR_VERBOSE 1671 yyn = yypact[yystate]; 1672 1673 if (yyn > YYFLAG && yyn < YYLAST) 1674 { 1675 int size = 0; 1676 char *msg; 1677 int x, count; 1678 1679 count = 0; 1680 /* Start X at -yyn if nec to avoid negative indexes in yycheck. */ 1681 for (x = (yyn < 0 ? -yyn : 0); 1682 x < (sizeof(yytname) / sizeof(char *)); x++) 1683 if (yycheck[x + yyn] == x) 1684 size += strlen(yytname[x]) + 15, count++; 1685 msg = (char *) malloc(size + 15); 1686 if (msg != 0) 1687 { 1688 strcpy(msg, "parse error"); 1689 1690 if (count < 5) 1691 { 1692 count = 0; 1693 for (x = (yyn < 0 ? -yyn : 0); 1694 x < (sizeof(yytname) / sizeof(char *)); x++) 1695 if (yycheck[x + yyn] == x) 1696 { 1697 strcat(msg, count == 0 ? ", expecting `" : " or `"); 1698 strcat(msg, yytname[x]); 1699 strcat(msg, "'"); 1700 count++; 1701 } 1702 } 1703 yyerror(msg); 1704 free(msg); 1705 } 1706 else 1707 yyerror ("parse error; also virtual memory exceeded"); 1708 } 1709 else 1710 #endif /* YYERROR_VERBOSE */ 1711 yyerror("parse error"); 1712 } 1713 1714 goto yyerrlab1; 1715 yyerrlab1: /* here on error raised explicitly by an action */ 1716 1717 if (yyerrstatus == 3) 1718 { 1719 /* if just tried and failed to reuse lookahead token after an error, discard it. */ 1720 1721 /* return failure if at end of input */ 1722 if (yychar == YYEOF) 1723 YYABORT; 1724 1725 #if YYDEBUG != 0 1726 if (yydebug) 1727 fprintf(stderr, "Discarding token %d (%s).\n", yychar, yytname[yychar1]); 1728 #endif 1729 1730 yychar = YYEMPTY; 1731 } 1732 1733 /* Else will try to reuse lookahead token 1734 after shifting the error token. */ 1735 1736 yyerrstatus = 3; /* Each real token shifted decrements this */ 1737 1738 goto yyerrhandle; 1739 1740 yyerrdefault: /* current state does not do anything special for the error token. */ 1741 1742 #if 0 1743 /* This is wrong; only states that explicitly want error tokens 1744 should shift them. */ 1745 yyn = yydefact[yystate]; /* If its default is to accept any token, ok. Otherwise pop it.*/ 1746 if (yyn) goto yydefault; 1747 #endif 1748 1749 yyerrpop: /* pop the current state because it cannot handle the error token */ 1750 1751 if (yyssp == yyss) YYABORT; 1752 yyvsp--; 1753 yystate = *--yyssp; 1754 #ifdef YYLSP_NEEDED 1755 yylsp--; 1756 #endif 1757 1758 #if YYDEBUG != 0 1759 if (yydebug) 1760 { 1761 short *ssp1 = yyss - 1; 1762 fprintf (stderr, "Error: state stack now"); 1763 while (ssp1 != yyssp) 1764 fprintf (stderr, " %d", *++ssp1); 1765 fprintf (stderr, "\n"); 1766 } 1767 #endif 1768 1769 yyerrhandle: 1770 1771 yyn = yypact[yystate]; 1772 if (yyn == YYFLAG) 1773 goto yyerrdefault; 1774 1775 yyn += YYTERROR; 1776 if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != YYTERROR) 1777 goto yyerrdefault; 1778 1779 yyn = yytable[yyn]; 1780 if (yyn < 0) 1781 { 1782 if (yyn == YYFLAG) 1783 goto yyerrpop; 1784 yyn = -yyn; 1785 goto yyreduce; 1786 } 1787 else if (yyn == 0) 1788 goto yyerrpop; 1789 1790 if (yyn == YYFINAL) 1791 YYACCEPT; 1792 1793 #if YYDEBUG != 0 1794 if (yydebug) 1795 fprintf(stderr, "Shifting error token, "); 1796 #endif 1797 1798 *++yyvsp = yylval; 1799 #ifdef YYLSP_NEEDED 1800 *++yylsp = yylloc; 1801 #endif 1802 1803 yystate = yyn; 1804 goto yynewstate; 1805 } 1806 #line 636 "bc.y" |