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