1/* A Bison parser, made from plural.y 2 by GNU bison 1.35. */ 3 4#define YYBISON 1 /* Identify Bison output. */ 5 6#define yyparse __gettextparse 7#define yylex __gettextlex 8#define yyerror __gettexterror 9#define yylval __gettextlval 10#define yychar __gettextchar 11#define yydebug __gettextdebug 12#define yynerrs __gettextnerrs 13# define EQUOP2 257 14# define CMPOP2 258 15# define ADDOP2 259 16# define MULOP2 260 17# define NUMBER 261 18 19#line 1 "plural.y" 20 21/* Expression parsing for plural form selection. 22 Copyright (C) 2000-2001, 2003 Free Software Foundation, Inc. 23 Written by Ulrich Drepper <drepper@cygnus.com>, 2000. 24 25 This program is free software; you can redistribute it and/or modify it 26 under the terms of the GNU Library General Public License as published 27 by the Free Software Foundation; either version 2, or (at your option) 28 any later version. 29 30 This program is distributed in the hope that it will be useful, 31 but WITHOUT ANY WARRANTY; without even the implied warranty of 32 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 33 Library General Public License for more details. 34 35 You should have received a copy of the GNU Library General Public 36 License along with this program; if not, write to the Free Software 37 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, 38 USA. */ 39 40/* The bison generated parser uses alloca. AIX 3 forces us to put this 41 declaration at the beginning of the file. The declaration in bison's 42 skeleton file comes too late. This must come before <config.h> 43 because <config.h> may include arbitrary system headers. */ 44#if defined _AIX && !defined __GNUC__ 45 #pragma alloca 46#endif 47 48#ifdef HAVE_CONFIG_H 49# include <config.h> 50#endif 51 52#include <stddef.h> 53#include <stdlib.h> 54#include "plural-exp.h" 55 56/* The main function generated by the parser is called __gettextparse, 57 but we want it to be called PLURAL_PARSE. */ 58#ifndef _LIBC 59# define __gettextparse PLURAL_PARSE 60#endif 61 62#define YYLEX_PARAM &((struct parse_args *) arg)->cp 63#define YYPARSE_PARAM arg 64 65#line 49 "plural.y" 66#ifndef YYSTYPE 67typedef union { 68 unsigned long int num; 69 enum operator op; 70 struct expression *exp; 71} yystype; 72# define YYSTYPE yystype 73# define YYSTYPE_IS_TRIVIAL 1 74#endif 75#line 55 "plural.y" 76 77/* Prototypes for local functions. */ 78static int yylex (YYSTYPE *lval, const char **pexp); 79static void yyerror (const char *str); 80 81/* Allocation of expressions. */ 82 83static struct expression * 84new_exp (int nargs, enum operator op, struct expression * const *args) 85{ 86 int i; 87 struct expression *newp; 88 89 /* If any of the argument could not be malloc'ed, just return NULL. */ 90 for (i = nargs - 1; i >= 0; i--) 91 if (args[i] == NULL) 92 goto fail; 93 94 /* Allocate a new expression. */ 95 newp = (struct expression *) malloc (sizeof (*newp)); 96 if (newp != NULL) 97 { 98 newp->nargs = nargs; 99 newp->operation = op; 100 for (i = nargs - 1; i >= 0; i--) 101 newp->val.args[i] = args[i]; 102 return newp; 103 } 104 105 fail: 106 for (i = nargs - 1; i >= 0; i--) 107 FREE_EXPRESSION (args[i]); 108 109 return NULL; 110} 111 112static inline struct expression * 113new_exp_0 (enum operator op) 114{ 115 return new_exp (0, op, NULL); 116} 117 118static inline struct expression * 119new_exp_1 (enum operator op, struct expression *right) 120{ 121 struct expression *args[1]; 122 123 args[0] = right; 124 return new_exp (1, op, args); 125} 126 127static struct expression * 128new_exp_2 (enum operator op, struct expression *left, struct expression *right) 129{ 130 struct expression *args[2]; 131 132 args[0] = left; 133 args[1] = right; 134 return new_exp (2, op, args); 135} 136 137static inline struct expression * 138new_exp_3 (enum operator op, struct expression *bexp, 139 struct expression *tbranch, struct expression *fbranch) 140{ 141 struct expression *args[3]; 142 143 args[0] = bexp; 144 args[1] = tbranch; 145 args[2] = fbranch; 146 return new_exp (3, op, args); 147} 148 149#ifndef YYDEBUG 150# define YYDEBUG 0 151#endif 152 153 154 155#define YYFINAL 27 156#define YYFLAG -32768 157#define YYNTBASE 16 158 159/* YYTRANSLATE(YYLEX) -- Bison token number corresponding to YYLEX. */ 160#define YYTRANSLATE(x) ((unsigned)(x) <= 261 ? yytranslate[x] : 18) 161 162/* YYTRANSLATE[YYLEX] -- Bison token number corresponding to YYLEX. */ 163static const char yytranslate[] = 164{ 165 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 166 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 167 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 168 2, 2, 2, 10, 2, 2, 2, 2, 5, 2, 169 14, 15, 2, 2, 2, 2, 2, 2, 2, 2, 170 2, 2, 2, 2, 2, 2, 2, 2, 12, 2, 171 2, 2, 2, 3, 2, 2, 2, 2, 2, 2, 172 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 173 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 174 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 175 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 176 13, 2, 2, 2, 2, 2, 2, 2, 2, 2, 177 2, 2, 2, 2, 4, 2, 2, 2, 2, 2, 178 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 179 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 180 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 181 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 182 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 183 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 184 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 185 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 186 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 187 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 188 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 189 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 190 2, 2, 2, 2, 2, 2, 1, 6, 7, 8, 191 9, 11 192}; 193 194#if YYDEBUG 195static const short yyprhs[] = 196{ 197 0, 0, 2, 8, 12, 16, 20, 24, 28, 32, 198 35, 37, 39 199}; 200static const short yyrhs[] = 201{ 202 17, 0, 17, 3, 17, 12, 17, 0, 17, 4, 203 17, 0, 17, 5, 17, 0, 17, 6, 17, 0, 204 17, 7, 17, 0, 17, 8, 17, 0, 17, 9, 205 17, 0, 10, 17, 0, 13, 0, 11, 0, 14, 206 17, 15, 0 207}; 208 209#endif 210 211#if YYDEBUG 212/* YYRLINE[YYN] -- source line where rule number YYN was defined. */ 213static const short yyrline[] = 214{ 215 0, 150, 158, 162, 166, 170, 174, 178, 182, 186, 216 190, 194, 199 217}; 218#endif 219 220 221#if (YYDEBUG) || defined YYERROR_VERBOSE 222 223/* YYTNAME[TOKEN_NUM] -- String name of the token TOKEN_NUM. */ 224static const char *const yytname[] = 225{ 226 "$", "error", "$undefined.", "'?'", "'|'", "'&'", "EQUOP2", "CMPOP2", 227 "ADDOP2", "MULOP2", "'!'", "NUMBER", "':'", "'n'", "'('", "')'", 228 "start", "exp", 0 229}; 230#endif 231 232/* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */ 233static const short yyr1[] = 234{ 235 0, 16, 17, 17, 17, 17, 17, 17, 17, 17, 236 17, 17, 17 237}; 238 239/* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */ 240static const short yyr2[] = 241{ 242 0, 1, 5, 3, 3, 3, 3, 3, 3, 2, 243 1, 1, 3 244}; 245 246/* YYDEFACT[S] -- default rule to reduce with in state S when YYTABLE 247 doesn't specify something else to do. Zero means the default is an 248 error. */ 249static const short yydefact[] = 250{ 251 0, 0, 11, 10, 0, 1, 9, 0, 0, 0, 252 0, 0, 0, 0, 0, 12, 0, 3, 4, 5, 253 6, 7, 8, 0, 2, 0, 0, 0 254}; 255 256static const short yydefgoto[] = 257{ 258 25, 5 259}; 260 261static const short yypact[] = 262{ 263 -9, -9,-32768,-32768, -9, 34,-32768, 11, -9, -9, 264 -9, -9, -9, -9, -9,-32768, 24, 39, 43, 16, 265 26, -3,-32768, -9, 34, 21, 53,-32768 266}; 267 268static const short yypgoto[] = 269{ 270 -32768, -1 271}; 272 273 274#define YYLAST 53 275 276 277static const short yytable[] = 278{ 279 6, 1, 2, 7, 3, 4, 14, 16, 17, 18, 280 19, 20, 21, 22, 8, 9, 10, 11, 12, 13, 281 14, 26, 24, 12, 13, 14, 15, 8, 9, 10, 282 11, 12, 13, 14, 13, 14, 23, 8, 9, 10, 283 11, 12, 13, 14, 10, 11, 12, 13, 14, 11, 284 12, 13, 14, 27 285}; 286 287static const short yycheck[] = 288{ 289 1, 10, 11, 4, 13, 14, 9, 8, 9, 10, 290 11, 12, 13, 14, 3, 4, 5, 6, 7, 8, 291 9, 0, 23, 7, 8, 9, 15, 3, 4, 5, 292 6, 7, 8, 9, 8, 9, 12, 3, 4, 5, 293 6, 7, 8, 9, 5, 6, 7, 8, 9, 6, 294 7, 8, 9, 0 295}; 296#define YYPURE 1 297 298/* -*-C-*- Note some compilers choke on comments on `#line' lines. */ 299#line 3 "/usr/local/share/bison/bison.simple" 300 301/* Skeleton output parser for bison, 302 303 Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002 Free Software 304 Foundation, Inc. 305 306 This program is free software; you can redistribute it and/or modify 307 it under the terms of the GNU General Public License as published by 308 the Free Software Foundation; either version 2, or (at your option) 309 any later version. 310 311 This program is distributed in the hope that it will be useful, 312 but WITHOUT ANY WARRANTY; without even the implied warranty of 313 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 314 GNU General Public License for more details. 315 316 You should have received a copy of the GNU General Public License 317 along with this program; if not, write to the Free Software 318 Foundation, Inc., 59 Temple Place - Suite 330, 319 Boston, MA 02111-1307, USA. */ 320 321/* As a special exception, when this file is copied by Bison into a 322 Bison output file, you may use that output file without restriction. 323 This special exception was added by the Free Software Foundation 324 in version 1.24 of Bison. */ 325 326/* This is the parser code that is written into each bison parser when 327 the %semantic_parser declaration is not specified in the grammar. 328 It was written by Richard Stallman by simplifying the hairy parser 329 used when %semantic_parser is specified. */ 330 331/* All symbols defined below should begin with yy or YY, to avoid 332 infringing on user name space. This should be done even for local 333 variables, as they might otherwise be expanded by user macros. 334 There are some unavoidable exceptions within include files to 335 define necessary library symbols; they are noted "INFRINGES ON 336 USER NAME SPACE" below. */ 337 338#if ! defined (yyoverflow) || defined (YYERROR_VERBOSE) 339 340/* The parser invokes alloca or malloc; define the necessary symbols. */ 341 342# if YYSTACK_USE_ALLOCA 343# define YYSTACK_ALLOC alloca 344# else 345# ifndef YYSTACK_USE_ALLOCA 346# if defined (alloca) || defined (_ALLOCA_H) 347# define YYSTACK_ALLOC alloca 348# else 349# ifdef __GNUC__ 350# define YYSTACK_ALLOC __builtin_alloca 351# endif 352# endif 353# endif 354# endif 355 356# ifdef YYSTACK_ALLOC 357 /* Pacify GCC's `empty if-body' warning. */ 358# define YYSTACK_FREE(Ptr) do { /* empty */; } while (0) 359# else 360# if defined (__STDC__) || defined (__cplusplus) 361# include <stdlib.h> /* INFRINGES ON USER NAME SPACE */ 362# define YYSIZE_T size_t 363# endif 364# define YYSTACK_ALLOC malloc 365# define YYSTACK_FREE free 366# endif 367#endif /* ! defined (yyoverflow) || defined (YYERROR_VERBOSE) */ 368 369 370#if (! defined (yyoverflow) \ 371 && (! defined (__cplusplus) \ 372 || (YYLTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL))) 373 374/* A type that is properly aligned for any stack member. */ 375union yyalloc 376{ 377 short yyss; 378 YYSTYPE yyvs; 379# if YYLSP_NEEDED 380 YYLTYPE yyls; 381# endif 382}; 383 384/* The size of the maximum gap between one aligned stack and the next. */ 385# define YYSTACK_GAP_MAX (sizeof (union yyalloc) - 1) 386 387/* The size of an array large to enough to hold all stacks, each with 388 N elements. */ 389# if YYLSP_NEEDED 390# define YYSTACK_BYTES(N) \ 391 ((N) * (sizeof (short) + sizeof (YYSTYPE) + sizeof (YYLTYPE)) \ 392 + 2 * YYSTACK_GAP_MAX) 393# else 394# define YYSTACK_BYTES(N) \ 395 ((N) * (sizeof (short) + sizeof (YYSTYPE)) \ 396 + YYSTACK_GAP_MAX) 397# endif 398 399/* Copy COUNT objects from FROM to TO. The source and destination do 400 not overlap. */ 401# ifndef YYCOPY 402# if 1 < __GNUC__ 403# define YYCOPY(To, From, Count) \ 404 __builtin_memcpy (To, From, (Count) * sizeof (*(From))) 405# else 406# define YYCOPY(To, From, Count) \ 407 do \ 408 { \ 409 register YYSIZE_T yyi; \ 410 for (yyi = 0; yyi < (Count); yyi++) \ 411 (To)[yyi] = (From)[yyi]; \ 412 } \ 413 while (0) 414# endif 415# endif 416 417/* Relocate STACK from its old location to the new one. The 418 local variables YYSIZE and YYSTACKSIZE give the old and new number of 419 elements in the stack, and YYPTR gives the new location of the 420 stack. Advance YYPTR to a properly aligned location for the next 421 stack. */ 422# define YYSTACK_RELOCATE(Stack) \ 423 do \ 424 { \ 425 YYSIZE_T yynewbytes; \ 426 YYCOPY (&yyptr->Stack, Stack, yysize); \ 427 Stack = &yyptr->Stack; \ 428 yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAX; \ 429 yyptr += yynewbytes / sizeof (*yyptr); \ 430 } \ 431 while (0) 432 433#endif 434 435 436#if ! defined (YYSIZE_T) && defined (__SIZE_TYPE__) 437# define YYSIZE_T __SIZE_TYPE__ 438#endif 439#if ! defined (YYSIZE_T) && defined (size_t) 440# define YYSIZE_T size_t 441#endif 442#if ! defined (YYSIZE_T) 443# if defined (__STDC__) || defined (__cplusplus) 444# include <stddef.h> /* INFRINGES ON USER NAME SPACE */ 445# define YYSIZE_T size_t 446# endif 447#endif 448#if ! defined (YYSIZE_T) 449# define YYSIZE_T unsigned int 450#endif 451 452#define yyerrok (yyerrstatus = 0) 453#define yyclearin (yychar = YYEMPTY) 454#define YYEMPTY -2 455#define YYEOF 0 456#define YYACCEPT goto yyacceptlab 457#define YYABORT goto yyabortlab 458#define YYERROR goto yyerrlab1 459/* Like YYERROR except do call yyerror. This remains here temporarily 460 to ease the transition to the new meaning of YYERROR, for GCC. 461 Once GCC version 2 has supplanted version 1, this can go. */ 462#define YYFAIL goto yyerrlab 463#define YYRECOVERING() (!!yyerrstatus) 464#define YYBACKUP(Token, Value) \ 465do \ 466 if (yychar == YYEMPTY && yylen == 1) \ 467 { \ 468 yychar = (Token); \ 469 yylval = (Value); \ 470 yychar1 = YYTRANSLATE (yychar); \ 471 YYPOPSTACK; \ 472 goto yybackup; \ 473 } \ 474 else \ 475 { \ 476 yyerror ("syntax error: cannot back up"); \ 477 YYERROR; \ 478 } \ 479while (0) 480 481#define YYTERROR 1 482#define YYERRCODE 256 483 484 485/* YYLLOC_DEFAULT -- Compute the default location (before the actions 486 are run). 487 488 When YYLLOC_DEFAULT is run, CURRENT is set the location of the 489 first token. By default, to implement support for ranges, extend 490 its range to the last symbol. */ 491 492#ifndef YYLLOC_DEFAULT 493# define YYLLOC_DEFAULT(Current, Rhs, N) \ 494 Current.last_line = Rhs[N].last_line; \ 495 Current.last_column = Rhs[N].last_column; 496#endif 497 498 499/* YYLEX -- calling `yylex' with the right arguments. */ 500 501#if YYPURE 502# if YYLSP_NEEDED 503# ifdef YYLEX_PARAM 504# define YYLEX yylex (&yylval, &yylloc, YYLEX_PARAM) 505# else 506# define YYLEX yylex (&yylval, &yylloc) 507# endif 508# else /* !YYLSP_NEEDED */ 509# ifdef YYLEX_PARAM 510# define YYLEX yylex (&yylval, YYLEX_PARAM) 511# else 512# define YYLEX yylex (&yylval) 513# endif 514# endif /* !YYLSP_NEEDED */ 515#else /* !YYPURE */ 516# define YYLEX yylex () 517#endif /* !YYPURE */ 518 519 520/* Enable debugging if requested. */ 521#if YYDEBUG 522 523# ifndef YYFPRINTF 524# include <stdio.h> /* INFRINGES ON USER NAME SPACE */ 525# define YYFPRINTF fprintf 526# endif 527 528# define YYDPRINTF(Args) \ 529do { \ 530 if (yydebug) \ 531 YYFPRINTF Args; \ 532} while (0) 533/* Nonzero means print parse trace. It is left uninitialized so that 534 multiple parsers can coexist. */ 535int yydebug; 536#else /* !YYDEBUG */ 537# define YYDPRINTF(Args) 538#endif /* !YYDEBUG */ 539 540/* YYINITDEPTH -- initial size of the parser's stacks. */ 541#ifndef YYINITDEPTH 542# define YYINITDEPTH 200 543#endif 544 545/* YYMAXDEPTH -- maximum size the stacks can grow to (effective only 546 if the built-in stack extension method is used). 547 548 Do not make this value too large; the results are undefined if 549 SIZE_MAX < YYSTACK_BYTES (YYMAXDEPTH) 550 evaluated with infinite-precision integer arithmetic. */ 551 552#if YYMAXDEPTH == 0 553# undef YYMAXDEPTH 554#endif 555 556#ifndef YYMAXDEPTH 557# define YYMAXDEPTH 10000 558#endif 559 560#ifdef YYERROR_VERBOSE 561 562# ifndef yystrlen 563# if defined (__GLIBC__) && defined (_STRING_H) 564# define yystrlen strlen 565# else 566/* Return the length of YYSTR. */ 567static YYSIZE_T 568# if defined (__STDC__) || defined (__cplusplus) 569yystrlen (const char *yystr) 570# else 571yystrlen (yystr) 572 const char *yystr; 573# endif 574{ 575 register const char *yys = yystr; 576 577 while (*yys++ != '\0') 578 continue; 579 580 return yys - yystr - 1; 581} 582# endif 583# endif 584 585# ifndef yystpcpy 586# if defined (__GLIBC__) && defined (_STRING_H) && defined (_GNU_SOURCE) 587# define yystpcpy stpcpy 588# else 589/* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in 590 YYDEST. */ 591static char * 592# if defined (__STDC__) || defined (__cplusplus) 593yystpcpy (char *yydest, const char *yysrc) 594# else 595yystpcpy (yydest, yysrc) 596 char *yydest; 597 const char *yysrc; 598# endif 599{ 600 register char *yyd = yydest; 601 register const char *yys = yysrc; 602 603 while ((*yyd++ = *yys++) != '\0') 604 continue; 605 606 return yyd - 1; 607} 608# endif 609# endif 610#endif 611 612#line 315 "/usr/local/share/bison/bison.simple" 613 614 615/* The user can define YYPARSE_PARAM as the name of an argument to be passed 616 into yyparse. The argument should have type void *. 617 It should actually point to an object. 618 Grammar actions can access the variable by casting it 619 to the proper pointer type. */ 620 621#ifdef YYPARSE_PARAM 622# if defined (__STDC__) || defined (__cplusplus) 623# define YYPARSE_PARAM_ARG void *YYPARSE_PARAM 624# define YYPARSE_PARAM_DECL 625# else 626# define YYPARSE_PARAM_ARG YYPARSE_PARAM 627# define YYPARSE_PARAM_DECL void *YYPARSE_PARAM; 628# endif 629#else /* !YYPARSE_PARAM */ 630# define YYPARSE_PARAM_ARG 631# define YYPARSE_PARAM_DECL 632#endif /* !YYPARSE_PARAM */ 633 634/* Prevent warning if -Wstrict-prototypes. */ 635#ifdef __GNUC__ 636# ifdef YYPARSE_PARAM 637int yyparse (void *); 638# else 639int yyparse (void); 640# endif 641#endif 642 643/* YY_DECL_VARIABLES -- depending whether we use a pure parser, 644 variables are global, or local to YYPARSE. */ 645 646#define YY_DECL_NON_LSP_VARIABLES \ 647/* The lookahead symbol. */ \ 648int yychar; \ 649 \ 650/* The semantic value of the lookahead symbol. */ \ 651YYSTYPE yylval; \ 652 \ 653/* Number of parse errors so far. */ \ 654int yynerrs; 655 656#if YYLSP_NEEDED 657# define YY_DECL_VARIABLES \ 658YY_DECL_NON_LSP_VARIABLES \ 659 \ 660/* Location data for the lookahead symbol. */ \ 661YYLTYPE yylloc; 662#else 663# define YY_DECL_VARIABLES \ 664YY_DECL_NON_LSP_VARIABLES 665#endif 666 667 668/* If nonreentrant, generate the variables here. */ 669 670#if !YYPURE 671YY_DECL_VARIABLES 672#endif /* !YYPURE */ 673 674int 675yyparse (YYPARSE_PARAM_ARG) 676 YYPARSE_PARAM_DECL 677{ 678 /* If reentrant, generate the variables here. */ 679#if YYPURE 680 YY_DECL_VARIABLES 681#endif /* !YYPURE */ 682 683 register int yystate; 684 register int yyn; 685 int yyresult; 686 /* Number of tokens to shift before error messages enabled. */ 687 int yyerrstatus; 688 /* Lookahead token as an internal (translated) token number. */ 689 int yychar1 = 0; 690 691 /* Three stacks and their tools: 692 `yyss': related to states, 693 `yyvs': related to semantic values, 694 `yyls': related to locations. 695 696 Refer to the stacks thru separate pointers, to allow yyoverflow 697 to reallocate them elsewhere. */ 698 699 /* The state stack. */ 700 short yyssa[YYINITDEPTH]; 701 short *yyss = yyssa; 702 register short *yyssp; 703 704 /* The semantic value stack. */ 705 YYSTYPE yyvsa[YYINITDEPTH]; 706 YYSTYPE *yyvs = yyvsa; 707 register YYSTYPE *yyvsp; 708 709#if YYLSP_NEEDED 710 /* The location stack. */ 711 YYLTYPE yylsa[YYINITDEPTH]; 712 YYLTYPE *yyls = yylsa; 713 YYLTYPE *yylsp; 714#endif 715 716#if YYLSP_NEEDED 717# define YYPOPSTACK (yyvsp--, yyssp--, yylsp--) 718#else 719# define YYPOPSTACK (yyvsp--, yyssp--) 720#endif 721 722 YYSIZE_T yystacksize = YYINITDEPTH; 723 724 725 /* The variables used to return semantic value and location from the 726 action routines. */ 727 YYSTYPE yyval; 728#if YYLSP_NEEDED 729 YYLTYPE yyloc; 730#endif 731 732 /* When reducing, the number of symbols on the RHS of the reduced 733 rule. */ 734 int yylen; 735 736 YYDPRINTF ((stderr, "Starting parse\n")); 737 738 yystate = 0; 739 yyerrstatus = 0; 740 yynerrs = 0; 741 yychar = YYEMPTY; /* Cause a token to be read. */ 742 743 /* Initialize stack pointers. 744 Waste one element of value and location stack 745 so that they stay on the same level as the state stack. 746 The wasted elements are never initialized. */ 747 748 yyssp = yyss; 749 yyvsp = yyvs; 750#if YYLSP_NEEDED 751 yylsp = yyls; 752#endif 753 goto yysetstate; 754 755/*------------------------------------------------------------. 756| yynewstate -- Push a new state, which is found in yystate. | 757`------------------------------------------------------------*/ 758 yynewstate: 759 /* In all cases, when you get here, the value and location stacks 760 have just been pushed. so pushing a state here evens the stacks. 761 */ 762 yyssp++; 763 764 yysetstate: 765 *yyssp = yystate; 766 767 if (yyssp >= yyss + yystacksize - 1) 768 { 769 /* Get the current used size of the three stacks, in elements. */ 770 YYSIZE_T yysize = yyssp - yyss + 1; 771 772#ifdef yyoverflow 773 { 774 /* Give user a chance to reallocate the stack. Use copies of 775 these so that the &'s don't force the real ones into 776 memory. */ 777 YYSTYPE *yyvs1 = yyvs; 778 short *yyss1 = yyss; 779 780 /* Each stack pointer address is followed by the size of the 781 data in use in that stack, in bytes. */ 782# if YYLSP_NEEDED 783 YYLTYPE *yyls1 = yyls; 784 /* This used to be a conditional around just the two extra args, 785 but that might be undefined if yyoverflow is a macro. */ 786 yyoverflow ("parser stack overflow", 787 &yyss1, yysize * sizeof (*yyssp), 788 &yyvs1, yysize * sizeof (*yyvsp), 789 &yyls1, yysize * sizeof (*yylsp), 790 &yystacksize); 791 yyls = yyls1; 792# else 793 yyoverflow ("parser stack overflow", 794 &yyss1, yysize * sizeof (*yyssp), 795 &yyvs1, yysize * sizeof (*yyvsp), 796 &yystacksize); 797# endif 798 yyss = yyss1; 799 yyvs = yyvs1; 800 } 801#else /* no yyoverflow */ 802# ifndef YYSTACK_RELOCATE 803 goto yyoverflowlab; 804# else 805 /* Extend the stack our own way. */ 806 if (yystacksize >= YYMAXDEPTH) 807 goto yyoverflowlab; 808 yystacksize *= 2; 809 if (yystacksize > YYMAXDEPTH) 810 yystacksize = YYMAXDEPTH; 811 812 { 813 short *yyss1 = yyss; 814 union yyalloc *yyptr = 815 (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize)); 816 if (! yyptr) 817 goto yyoverflowlab; 818 YYSTACK_RELOCATE (yyss); 819 YYSTACK_RELOCATE (yyvs); 820# if YYLSP_NEEDED 821 YYSTACK_RELOCATE (yyls); 822# endif 823# undef YYSTACK_RELOCATE 824 if (yyss1 != yyssa) 825 YYSTACK_FREE (yyss1); 826 } 827# endif 828#endif /* no yyoverflow */ 829 830 yyssp = yyss + yysize - 1; 831 yyvsp = yyvs + yysize - 1; 832#if YYLSP_NEEDED 833 yylsp = yyls + yysize - 1; 834#endif 835 836 YYDPRINTF ((stderr, "Stack size increased to %lu\n", 837 (unsigned long int) yystacksize)); 838 839 if (yyssp >= yyss + yystacksize - 1) 840 YYABORT; 841 } 842 843 YYDPRINTF ((stderr, "Entering state %d\n", yystate)); 844 845 goto yybackup; 846 847 848/*-----------. 849| yybackup. | 850`-----------*/ 851yybackup: 852 853/* Do appropriate processing given the current state. */ 854/* Read a lookahead token if we need one and don't already have one. */ 855/* yyresume: */ 856 857 /* First try to decide what to do without reference to lookahead token. */ 858 859 yyn = yypact[yystate]; 860 if (yyn == YYFLAG) 861 goto yydefault; 862 863 /* Not known => get a lookahead token if don't already have one. */ 864 865 /* yychar is either YYEMPTY or YYEOF 866 or a valid token in external form. */ 867 868 if (yychar == YYEMPTY) 869 { 870 YYDPRINTF ((stderr, "Reading a token: ")); 871 yychar = YYLEX; 872 } 873 874 /* Convert token to internal form (in yychar1) for indexing tables with */ 875 876 if (yychar <= 0) /* This means end of input. */ 877 { 878 yychar1 = 0; 879 yychar = YYEOF; /* Don't call YYLEX any more */ 880 881 YYDPRINTF ((stderr, "Now at end of input.\n")); 882 } 883 else 884 { 885 yychar1 = YYTRANSLATE (yychar); 886 887#if YYDEBUG 888 /* We have to keep this `#if YYDEBUG', since we use variables 889 which are defined only if `YYDEBUG' is set. */ 890 if (yydebug) 891 { 892 YYFPRINTF (stderr, "Next token is %d (%s", 893 yychar, yytname[yychar1]); 894 /* Give the individual parser a way to print the precise 895 meaning of a token, for further debugging info. */ 896# ifdef YYPRINT 897 YYPRINT (stderr, yychar, yylval); 898# endif 899 YYFPRINTF (stderr, ")\n"); 900 } 901#endif 902 } 903 904 yyn += yychar1; 905 if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != yychar1) 906 goto yydefault; 907 908 yyn = yytable[yyn]; 909 910 /* yyn is what to do for this token type in this state. 911 Negative => reduce, -yyn is rule number. 912 Positive => shift, yyn is new state. 913 New state is final state => don't bother to shift, 914 just return success. 915 0, or most negative number => error. */ 916 917 if (yyn < 0) 918 { 919 if (yyn == YYFLAG) 920 goto yyerrlab; 921 yyn = -yyn; 922 goto yyreduce; 923 } 924 else if (yyn == 0) 925 goto yyerrlab; 926 927 if (yyn == YYFINAL) 928 YYACCEPT; 929 930 /* Shift the lookahead token. */ 931 YYDPRINTF ((stderr, "Shifting token %d (%s), ", 932 yychar, yytname[yychar1])); 933 934 /* Discard the token being shifted unless it is eof. */ 935 if (yychar != YYEOF) 936 yychar = YYEMPTY; 937 938 *++yyvsp = yylval; 939#if YYLSP_NEEDED 940 *++yylsp = yylloc; 941#endif 942 943 /* Count tokens shifted since error; after three, turn off error 944 status. */ 945 if (yyerrstatus) 946 yyerrstatus--; 947 948 yystate = yyn; 949 goto yynewstate; 950 951 952/*-----------------------------------------------------------. 953| yydefault -- do the default action for the current state. | 954`-----------------------------------------------------------*/ 955yydefault: 956 yyn = yydefact[yystate]; 957 if (yyn == 0) 958 goto yyerrlab; 959 goto yyreduce; 960 961 962/*-----------------------------. 963| yyreduce -- Do a reduction. | 964`-----------------------------*/ 965yyreduce: 966 /* yyn is the number of a rule to reduce with. */ 967 yylen = yyr2[yyn]; 968 969 /* If YYLEN is nonzero, implement the default value of the action: 970 `$$ = $1'. 971 972 Otherwise, the following line sets YYVAL to the semantic value of 973 the lookahead token. This behavior is undocumented and Bison 974 users should not rely upon it. Assigning to YYVAL 975 unconditionally makes the parser a bit smaller, and it avoids a 976 GCC warning that YYVAL may be used uninitialized. */ 977 yyval = yyvsp[1-yylen]; 978 979#if YYLSP_NEEDED 980 /* Similarly for the default location. Let the user run additional 981 commands if for instance locations are ranges. */ 982 yyloc = yylsp[1-yylen]; 983 YYLLOC_DEFAULT (yyloc, (yylsp - yylen), yylen); 984#endif 985 986#if YYDEBUG 987 /* We have to keep this `#if YYDEBUG', since we use variables which 988 are defined only if `YYDEBUG' is set. */ 989 if (yydebug) 990 { 991 int yyi; 992 993 YYFPRINTF (stderr, "Reducing via rule %d (line %d), ", 994 yyn, yyrline[yyn]); 995 996 /* Print the symbols being reduced, and their result. */ 997 for (yyi = yyprhs[yyn]; yyrhs[yyi] > 0; yyi++) 998 YYFPRINTF (stderr, "%s ", yytname[yyrhs[yyi]]); 999 YYFPRINTF (stderr, " -> %s\n", yytname[yyr1[yyn]]); 1000 } 1001#endif 1002 1003 switch (yyn) { 1004 1005case 1: 1006#line 151 "plural.y" 1007{ 1008 if (yyvsp[0].exp == NULL) 1009 YYABORT; 1010 ((struct parse_args *) arg)->res = yyvsp[0].exp; 1011 } 1012 break; 1013case 2: 1014#line 159 "plural.y" 1015{ 1016 yyval.exp = new_exp_3 (qmop, yyvsp[-4].exp, yyvsp[-2].exp, yyvsp[0].exp); 1017 } 1018 break; 1019case 3: 1020#line 163 "plural.y" 1021{ 1022 yyval.exp = new_exp_2 (lor, yyvsp[-2].exp, yyvsp[0].exp); 1023 } 1024 break; 1025case 4: 1026#line 167 "plural.y" 1027{ 1028 yyval.exp = new_exp_2 (land, yyvsp[-2].exp, yyvsp[0].exp); 1029 } 1030 break; 1031case 5: 1032#line 171 "plural.y" 1033{ 1034 yyval.exp = new_exp_2 (yyvsp[-1].op, yyvsp[-2].exp, yyvsp[0].exp); 1035 } 1036 break; 1037case 6: 1038#line 175 "plural.y" 1039{ 1040 yyval.exp = new_exp_2 (yyvsp[-1].op, yyvsp[-2].exp, yyvsp[0].exp); 1041 } 1042 break; 1043case 7: 1044#line 179 "plural.y" 1045{ 1046 yyval.exp = new_exp_2 (yyvsp[-1].op, yyvsp[-2].exp, yyvsp[0].exp); 1047 } 1048 break; 1049case 8: 1050#line 183 "plural.y" 1051{ 1052 yyval.exp = new_exp_2 (yyvsp[-1].op, yyvsp[-2].exp, yyvsp[0].exp); 1053 } 1054 break; 1055case 9: 1056#line 187 "plural.y" 1057{ 1058 yyval.exp = new_exp_1 (lnot, yyvsp[0].exp); 1059 } 1060 break; 1061case 10: 1062#line 191 "plural.y" 1063{ 1064 yyval.exp = new_exp_0 (var); 1065 } 1066 break; 1067case 11: 1068#line 195 "plural.y" 1069{ 1070 if ((yyval.exp = new_exp_0 (num)) != NULL) 1071 yyval.exp->val.num = yyvsp[0].num; 1072 } 1073 break; 1074case 12: 1075#line 200 "plural.y" 1076{ 1077 yyval.exp = yyvsp[-1].exp; 1078 } 1079 break; 1080} 1081 1082#line 705 "/usr/local/share/bison/bison.simple" 1083 1084 1085 yyvsp -= yylen; 1086 yyssp -= yylen; 1087#if YYLSP_NEEDED 1088 yylsp -= yylen; 1089#endif 1090 1091#if YYDEBUG 1092 if (yydebug) 1093 { 1094 short *yyssp1 = yyss - 1; 1095 YYFPRINTF (stderr, "state stack now"); 1096 while (yyssp1 != yyssp) 1097 YYFPRINTF (stderr, " %d", *++yyssp1); 1098 YYFPRINTF (stderr, "\n"); 1099 } 1100#endif 1101 1102 *++yyvsp = yyval; 1103#if YYLSP_NEEDED 1104 *++yylsp = yyloc; 1105#endif 1106 1107 /* Now `shift' the result of the reduction. Determine what state 1108 that goes to, based on the state we popped back to and the rule 1109 number reduced by. */ 1110 1111 yyn = yyr1[yyn]; 1112 1113 yystate = yypgoto[yyn - YYNTBASE] + *yyssp; 1114 if (yystate >= 0 && yystate <= YYLAST && yycheck[yystate] == *yyssp) 1115 yystate = yytable[yystate]; 1116 else 1117 yystate = yydefgoto[yyn - YYNTBASE]; 1118 1119 goto yynewstate; 1120 1121 1122/*------------------------------------. 1123| yyerrlab -- here on detecting error | 1124`------------------------------------*/ 1125yyerrlab: 1126 /* If not already recovering from an error, report this error. */ 1127 if (!yyerrstatus) 1128 { 1129 ++yynerrs; 1130 1131#ifdef YYERROR_VERBOSE 1132 yyn = yypact[yystate]; 1133 1134 if (yyn > YYFLAG && yyn < YYLAST) 1135 { 1136 YYSIZE_T yysize = 0; 1137 char *yymsg; 1138 int yyx, yycount; 1139 1140 yycount = 0; 1141 /* Start YYX at -YYN if negative to avoid negative indexes in 1142 YYCHECK. */ 1143 for (yyx = yyn < 0 ? -yyn : 0; 1144 yyx < (int) (sizeof (yytname) / sizeof (char *)); yyx++) 1145 if (yycheck[yyx + yyn] == yyx) 1146 yysize += yystrlen (yytname[yyx]) + 15, yycount++; 1147 yysize += yystrlen ("parse error, unexpected ") + 1; 1148 yysize += yystrlen (yytname[YYTRANSLATE (yychar)]); 1149 yymsg = (char *) YYSTACK_ALLOC (yysize); 1150 if (yymsg != 0) 1151 { 1152 char *yyp = yystpcpy (yymsg, "parse error, unexpected "); 1153 yyp = yystpcpy (yyp, yytname[YYTRANSLATE (yychar)]); 1154 1155 if (yycount < 5) 1156 { 1157 yycount = 0; 1158 for (yyx = yyn < 0 ? -yyn : 0; 1159 yyx < (int) (sizeof (yytname) / sizeof (char *)); 1160 yyx++) 1161 if (yycheck[yyx + yyn] == yyx) 1162 { 1163 const char *yyq = ! yycount ? ", expecting " : " or "; 1164 yyp = yystpcpy (yyp, yyq); 1165 yyp = yystpcpy (yyp, yytname[yyx]); 1166 yycount++; 1167 } 1168 } 1169 yyerror (yymsg); 1170 YYSTACK_FREE (yymsg); 1171 } 1172 else 1173 yyerror ("parse error; also virtual memory exhausted"); 1174 } 1175 else 1176#endif /* defined (YYERROR_VERBOSE) */ 1177 yyerror ("parse error"); 1178 } 1179 goto yyerrlab1; 1180 1181 1182/*--------------------------------------------------. 1183| yyerrlab1 -- error raised explicitly by an action | 1184`--------------------------------------------------*/ 1185yyerrlab1: 1186 if (yyerrstatus == 3) 1187 { 1188 /* If just tried and failed to reuse lookahead token after an 1189 error, discard it. */ 1190 1191 /* return failure if at end of input */ 1192 if (yychar == YYEOF) 1193 YYABORT; 1194 YYDPRINTF ((stderr, "Discarding token %d (%s).\n", 1195 yychar, yytname[yychar1])); 1196 yychar = YYEMPTY; 1197 } 1198 1199 /* Else will try to reuse lookahead token after shifting the error 1200 token. */ 1201 1202 yyerrstatus = 3; /* Each real token shifted decrements this */ 1203 1204 goto yyerrhandle; 1205 1206 1207/*-------------------------------------------------------------------. 1208| yyerrdefault -- current state does not do anything special for the | 1209| error token. | 1210`-------------------------------------------------------------------*/ 1211yyerrdefault: 1212#if 0 1213 /* This is wrong; only states that explicitly want error tokens 1214 should shift them. */ 1215 1216 /* If its default is to accept any token, ok. Otherwise pop it. */ 1217 yyn = yydefact[yystate]; 1218 if (yyn) 1219 goto yydefault; 1220#endif 1221 1222 1223/*---------------------------------------------------------------. 1224| yyerrpop -- pop the current state because it cannot handle the | 1225| error token | 1226`---------------------------------------------------------------*/ 1227yyerrpop: 1228 if (yyssp == yyss) 1229 YYABORT; 1230 yyvsp--; 1231 yystate = *--yyssp; 1232#if YYLSP_NEEDED 1233 yylsp--; 1234#endif 1235 1236#if YYDEBUG 1237 if (yydebug) 1238 { 1239 short *yyssp1 = yyss - 1; 1240 YYFPRINTF (stderr, "Error: state stack now"); 1241 while (yyssp1 != yyssp) 1242 YYFPRINTF (stderr, " %d", *++yyssp1); 1243 YYFPRINTF (stderr, "\n"); 1244 } 1245#endif 1246 1247/*--------------. 1248| yyerrhandle. | 1249`--------------*/ 1250yyerrhandle: 1251 yyn = yypact[yystate]; 1252 if (yyn == YYFLAG) 1253 goto yyerrdefault; 1254 1255 yyn += YYTERROR; 1256 if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != YYTERROR) 1257 goto yyerrdefault; 1258 1259 yyn = yytable[yyn]; 1260 if (yyn < 0) 1261 { 1262 if (yyn == YYFLAG) 1263 goto yyerrpop; 1264 yyn = -yyn; 1265 goto yyreduce; 1266 } 1267 else if (yyn == 0) 1268 goto yyerrpop; 1269 1270 if (yyn == YYFINAL) 1271 YYACCEPT; 1272 1273 YYDPRINTF ((stderr, "Shifting error token, ")); 1274 1275 *++yyvsp = yylval; 1276#if YYLSP_NEEDED 1277 *++yylsp = yylloc; 1278#endif 1279 1280 yystate = yyn; 1281 goto yynewstate; 1282 1283 1284/*-------------------------------------. 1285| yyacceptlab -- YYACCEPT comes here. | 1286`-------------------------------------*/ 1287yyacceptlab: 1288 yyresult = 0; 1289 goto yyreturn; 1290 1291/*-----------------------------------. 1292| yyabortlab -- YYABORT comes here. | 1293`-----------------------------------*/ 1294yyabortlab: 1295 yyresult = 1; 1296 goto yyreturn; 1297 1298/*---------------------------------------------. 1299| yyoverflowab -- parser overflow comes here. | 1300`---------------------------------------------*/ 1301yyoverflowlab: 1302 yyerror ("parser stack overflow"); 1303 yyresult = 2; 1304 /* Fall through. */ 1305 1306yyreturn: 1307#ifndef yyoverflow 1308 if (yyss != yyssa) 1309 YYSTACK_FREE (yyss); 1310#endif 1311 return yyresult; 1312} 1313#line 205 "plural.y" 1314 1315 1316void 1317internal_function 1318FREE_EXPRESSION (struct expression *exp) 1319{ 1320 if (exp == NULL) 1321 return; 1322 1323 /* Handle the recursive case. */ 1324 switch (exp->nargs) 1325 { 1326 case 3: 1327 FREE_EXPRESSION (exp->val.args[2]); 1328 /* FALLTHROUGH */ 1329 case 2: 1330 FREE_EXPRESSION (exp->val.args[1]); 1331 /* FALLTHROUGH */ 1332 case 1: 1333 FREE_EXPRESSION (exp->val.args[0]); 1334 /* FALLTHROUGH */ 1335 default: 1336 break; 1337 } 1338 1339 free (exp); 1340} 1341 1342 1343static int 1344yylex (YYSTYPE *lval, const char **pexp) 1345{ 1346 const char *exp = *pexp; 1347 int result; 1348 1349 while (1) 1350 { 1351 if (exp[0] == '\0') 1352 { 1353 *pexp = exp; 1354 return YYEOF; 1355 } 1356 1357 if (exp[0] != ' ' && exp[0] != '\t') 1358 break; 1359 1360 ++exp; 1361 } 1362 1363 result = *exp++; 1364 switch (result) 1365 { 1366 case '0': case '1': case '2': case '3': case '4': 1367 case '5': case '6': case '7': case '8': case '9': 1368 { 1369 unsigned long int n = result - '0'; 1370 while (exp[0] >= '0' && exp[0] <= '9') 1371 { 1372 n *= 10; 1373 n += exp[0] - '0'; 1374 ++exp; 1375 } 1376 lval->num = n; 1377 result = NUMBER; 1378 } 1379 break; 1380 1381 case '=': 1382 if (exp[0] == '=') 1383 { 1384 ++exp; 1385 lval->op = equal; 1386 result = EQUOP2; 1387 } 1388 else 1389 result = YYERRCODE; 1390 break; 1391 1392 case '!': 1393 if (exp[0] == '=') 1394 { 1395 ++exp; 1396 lval->op = not_equal; 1397 result = EQUOP2; 1398 } 1399 break; 1400 1401 case '&': 1402 case '|': 1403 if (exp[0] == result) 1404 ++exp; 1405 else 1406 result = YYERRCODE; 1407 break; 1408 1409 case '<': 1410 if (exp[0] == '=') 1411 { 1412 ++exp; 1413 lval->op = less_or_equal; 1414 } 1415 else 1416 lval->op = less_than; 1417 result = CMPOP2; 1418 break; 1419 1420 case '>': 1421 if (exp[0] == '=') 1422 { 1423 ++exp; 1424 lval->op = greater_or_equal; 1425 } 1426 else 1427 lval->op = greater_than; 1428 result = CMPOP2; 1429 break; 1430 1431 case '*': 1432 lval->op = mult; 1433 result = MULOP2; 1434 break; 1435 1436 case '/': 1437 lval->op = divide; 1438 result = MULOP2; 1439 break; 1440 1441 case '%': 1442 lval->op = module; 1443 result = MULOP2; 1444 break; 1445 1446 case '+': 1447 lval->op = plus; 1448 result = ADDOP2; 1449 break; 1450 1451 case '-': 1452 lval->op = minus; 1453 result = ADDOP2; 1454 break; 1455 1456 case 'n': 1457 case '?': 1458 case ':': 1459 case '(': 1460 case ')': 1461 /* Nothing, just return the character. */ 1462 break; 1463 1464 case ';': 1465 case '\n': 1466 case '\0': 1467 /* Be safe and let the user call this function again. */ 1468 --exp; 1469 result = YYEOF; 1470 break; 1471 1472 default: 1473 result = YYERRCODE; 1474#if YYDEBUG != 0 1475 --exp; 1476#endif 1477 break; 1478 } 1479 1480 *pexp = exp; 1481 1482 return result; 1483} 1484 1485 1486static void 1487yyerror (const char *str) 1488{ 1489 /* Do nothing. We don't print error messages here. */ 1490} 1491