Main Page   Alphabetical List   Data Structures   File List   Data Fields   Globals  

plural.c

00001 
00002 /*  A Bison parser, made from plural.y
00003     by GNU Bison version 1.28  */
00004 
00005 #define YYBISON 1  /* Identify Bison output.  */
00006 
00007 #define yyparse __gettextparse
00008 #define yylex __gettextlex
00009 #define yyerror __gettexterror
00010 #define yylval __gettextlval
00011 #define yychar __gettextchar
00012 #define yydebug __gettextdebug
00013 #define yynerrs __gettextnerrs
00014 #define EQUOP2  257
00015 #define CMPOP2  258
00016 #define ADDOP2  259
00017 #define MULOP2  260
00018 #define NUMBER  261
00019 
00020 #line 1 "plural.y"
00021 
00022 /* Expression parsing for plural form selection.
00023    Copyright (C) 2000, 2001 Free Software Foundation, Inc.
00024    Written by Ulrich Drepper <drepper@cygnus.com>, 2000.
00025 
00026    This program is free software; you can redistribute it and/or modify it
00027    under the terms of the GNU Library General Public License as published
00028    by the Free Software Foundation; either version 2, or (at your option)
00029    any later version.
00030 
00031    This program is distributed in the hope that it will be useful,
00032    but WITHOUT ANY WARRANTY; without even the implied warranty of
00033    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00034    Library General Public License for more details.
00035 
00036    You should have received a copy of the GNU Library General Public
00037    License along with this program; if not, write to the Free Software
00038    Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
00039    USA.  */
00040 
00041 /* The bison generated parser uses alloca.  AIX 3 forces us to put this
00042    declaration at the beginning of the file.  The declaration in bison's
00043    skeleton file comes too late.  This must come before <config.h>
00044    because <config.h> may include arbitrary system headers.  */
00045 #if defined _AIX && !defined __GNUC__
00046  #pragma alloca
00047 #endif
00048 
00049 #ifdef HAVE_CONFIG_H
00050 # include <config.h>
00051 #endif
00052 
00053 #include <stddef.h>
00054 #include <stdlib.h>
00055 #include "plural-exp.h"
00056 
00057 /* The main function generated by the parser is called __gettextparse,
00058    but we want it to be called PLURAL_PARSE.  */
00059 #ifndef _LIBC
00060 # define __gettextparse PLURAL_PARSE
00061 #endif
00062 
00063 #define YYLEX_PARAM     &((struct parse_args *) arg)->cp
00064 #define YYPARSE_PARAM   arg
00065 
00066 #line 49 "plural.y"
00067 typedef union {
00068   unsigned long int num;
00069   enum operator op;
00070   struct expression *exp;
00071 } YYSTYPE;
00072 #line 55 "plural.y"
00073 
00074 /* Prototypes for local functions.  */
00075 static struct expression *new_exp PARAMS ((int nargs, enum operator op,
00076                                            struct expression * const *args));
00077 static inline struct expression *new_exp_0 PARAMS ((enum operator op));
00078 static inline struct expression *new_exp_1 PARAMS ((enum operator op,
00079                                                    struct expression *right));
00080 static struct expression *new_exp_2 PARAMS ((enum operator op,
00081                                              struct expression *left,
00082                                              struct expression *right));
00083 static inline struct expression *new_exp_3 PARAMS ((enum operator op,
00084                                                    struct expression *bexp,
00085                                                    struct expression *tbranch,
00086                                                    struct expression *fbranch));
00087 static int yylex PARAMS ((YYSTYPE *lval, const char **pexp));
00088 static void yyerror PARAMS ((const char *str));
00089 
00090 /* Allocation of expressions.  */
00091 
00092 static struct expression *
00093 new_exp (nargs, op, args)
00094      int nargs;
00095      enum operator op;
00096      struct expression * const *args;
00097 {
00098   int i;
00099   struct expression *newp;
00100 
00101   /* If any of the argument could not be malloc'ed, just return NULL.  */
00102   for (i = nargs - 1; i >= 0; i--)
00103     if (args[i] == NULL)
00104       goto fail;
00105 
00106   /* Allocate a new expression.  */
00107   newp = (struct expression *) malloc (sizeof (*newp));
00108   if (newp != NULL)
00109     {
00110       newp->nargs = nargs;
00111       newp->operation = op;
00112       for (i = nargs - 1; i >= 0; i--)
00113         newp->val.args[i] = args[i];
00114       return newp;
00115     }
00116 
00117  fail:
00118   for (i = nargs - 1; i >= 0; i--)
00119     FREE_EXPRESSION (args[i]);
00120 
00121   return NULL;
00122 }
00123 
00124 static inline struct expression *
00125 new_exp_0 (op)
00126      enum operator op;
00127 {
00128   return new_exp (0, op, NULL);
00129 }
00130 
00131 static inline struct expression *
00132 new_exp_1 (op, right)
00133      enum operator op;
00134      struct expression *right;
00135 {
00136   struct expression *args[1];
00137 
00138   args[0] = right;
00139   return new_exp (1, op, args);
00140 }
00141 
00142 static struct expression *
00143 new_exp_2 (op, left, right)
00144      enum operator op;
00145      struct expression *left;
00146      struct expression *right;
00147 {
00148   struct expression *args[2];
00149 
00150   args[0] = left;
00151   args[1] = right;
00152   return new_exp (2, op, args);
00153 }
00154 
00155 static inline struct expression *
00156 new_exp_3 (op, bexp, tbranch, fbranch)
00157      enum operator op;
00158      struct expression *bexp;
00159      struct expression *tbranch;
00160      struct expression *fbranch;
00161 {
00162   struct expression *args[3];
00163 
00164   args[0] = bexp;
00165   args[1] = tbranch;
00166   args[2] = fbranch;
00167   return new_exp (3, op, args);
00168 }
00169 
00170 #include <stdio.h>
00171 
00172 #ifndef __cplusplus
00173 #ifndef __STDC__
00174 #define const
00175 #endif
00176 #endif
00177 
00178 
00179 
00180 #define YYFINAL         27
00181 #define YYFLAG          -32768
00182 #define YYNTBASE        16
00183 
00184 #define YYTRANSLATE(x) ((unsigned)(x) <= 261 ? yytranslate[x] : 18)
00185 
00186 static const char yytranslate[] = {     0,
00187      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
00188      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
00189      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
00190      2,     2,    10,     2,     2,     2,     2,     5,     2,    14,
00191     15,     2,     2,     2,     2,     2,     2,     2,     2,     2,
00192      2,     2,     2,     2,     2,     2,     2,    12,     2,     2,
00193      2,     2,     3,     2,     2,     2,     2,     2,     2,     2,
00194      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
00195      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
00196      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
00197      2,     2,     2,     2,     2,     2,     2,     2,     2,    13,
00198      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
00199      2,     2,     2,     4,     2,     2,     2,     2,     2,     2,
00200      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
00201      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
00202      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
00203      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
00204      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
00205      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
00206      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
00207      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
00208      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
00209      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
00210      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
00211      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
00212      2,     2,     2,     2,     2,     1,     6,     7,     8,     9,
00213     11
00214 };
00215 
00216 #if YYDEBUG != 0
00217 static const short yyprhs[] = {     0,
00218      0,     2,     8,    12,    16,    20,    24,    28,    32,    35,
00219     37,    39
00220 };
00221 
00222 static const short yyrhs[] = {    17,
00223      0,    17,     3,    17,    12,    17,     0,    17,     4,    17,
00224      0,    17,     5,    17,     0,    17,     6,    17,     0,    17,
00225      7,    17,     0,    17,     8,    17,     0,    17,     9,    17,
00226      0,    10,    17,     0,    13,     0,    11,     0,    14,    17,
00227     15,     0
00228 };
00229 
00230 #endif
00231 
00232 #if YYDEBUG != 0
00233 static const short yyrline[] = { 0,
00234    174,   182,   186,   190,   194,   198,   202,   206,   210,   214,
00235    218,   223
00236 };
00237 #endif
00238 
00239 
00240 #if YYDEBUG != 0 || defined (YYERROR_VERBOSE)
00241 
00242 static const char * const yytname[] = {   "$","error","$undefined.","'?'","'|'",
00243 "'&'","EQUOP2","CMPOP2","ADDOP2","MULOP2","'!'","NUMBER","':'","'n'","'('","')'",
00244 "start","exp", NULL
00245 };
00246 #endif
00247 
00248 static const short yyr1[] = {     0,
00249     16,    17,    17,    17,    17,    17,    17,    17,    17,    17,
00250     17,    17
00251 };
00252 
00253 static const short yyr2[] = {     0,
00254      1,     5,     3,     3,     3,     3,     3,     3,     2,     1,
00255      1,     3
00256 };
00257 
00258 static const short yydefact[] = {     0,
00259      0,    11,    10,     0,     1,     9,     0,     0,     0,     0,
00260      0,     0,     0,     0,    12,     0,     3,     4,     5,     6,
00261      7,     8,     0,     2,     0,     0,     0
00262 };
00263 
00264 static const short yydefgoto[] = {    25,
00265      5
00266 };
00267 
00268 static const short yypact[] = {    -9,
00269     -9,-32768,-32768,    -9,    34,-32768,    11,    -9,    -9,    -9,
00270     -9,    -9,    -9,    -9,-32768,    24,    39,    43,    16,    26,
00271     -3,-32768,    -9,    34,    21,    53,-32768
00272 };
00273 
00274 static const short yypgoto[] = {-32768,
00275     -1
00276 };
00277 
00278 
00279 #define YYLAST          53
00280 
00281 
00282 static const short yytable[] = {     6,
00283      1,     2,     7,     3,     4,    14,    16,    17,    18,    19,
00284     20,    21,    22,     8,     9,    10,    11,    12,    13,    14,
00285     26,    24,    12,    13,    14,    15,     8,     9,    10,    11,
00286     12,    13,    14,    13,    14,    23,     8,     9,    10,    11,
00287     12,    13,    14,    10,    11,    12,    13,    14,    11,    12,
00288     13,    14,    27
00289 };
00290 
00291 static const short yycheck[] = {     1,
00292     10,    11,     4,    13,    14,     9,     8,     9,    10,    11,
00293     12,    13,    14,     3,     4,     5,     6,     7,     8,     9,
00294      0,    23,     7,     8,     9,    15,     3,     4,     5,     6,
00295      7,     8,     9,     8,     9,    12,     3,     4,     5,     6,
00296      7,     8,     9,     5,     6,     7,     8,     9,     6,     7,
00297      8,     9,     0
00298 };
00299 #define YYPURE 1
00300 
00301 /* -*-C-*-  Note some compilers choke on comments on `#line' lines.  */
00302 #line 3 "/usr/local/share/bison.simple"
00303 /* This file comes from bison-1.28.  */
00304 
00305 /* Skeleton output parser for bison,
00306    Copyright (C) 1984, 1989, 1990 Free Software Foundation, Inc.
00307 
00308    This program is free software; you can redistribute it and/or modify
00309    it under the terms of the GNU General Public License as published by
00310    the Free Software Foundation; either version 2, or (at your option)
00311    any later version.
00312 
00313    This program is distributed in the hope that it will be useful,
00314    but WITHOUT ANY WARRANTY; without even the implied warranty of
00315    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00316    GNU General Public License for more details.
00317 
00318    You should have received a copy of the GNU General Public License
00319    along with this program; if not, write to the Free Software
00320    Foundation, Inc., 59 Temple Place - Suite 330,
00321    Boston, MA 02111-1307, USA.  */
00322 
00323 /* As a special exception, when this file is copied by Bison into a
00324    Bison output file, you may use that output file without restriction.
00325    This special exception was added by the Free Software Foundation
00326    in version 1.24 of Bison.  */
00327 
00328 /* This is the parser code that is written into each bison parser
00329   when the %semantic_parser declaration is not specified in the grammar.
00330   It was written by Richard Stallman by simplifying the hairy parser
00331   used when %semantic_parser is specified.  */
00332 
00333 #ifndef YYSTACK_USE_ALLOCA
00334 #ifdef alloca
00335 #define YYSTACK_USE_ALLOCA
00336 #else /* alloca not defined */
00337 #ifdef __GNUC__
00338 #define YYSTACK_USE_ALLOCA
00339 #define alloca __builtin_alloca
00340 #else /* not GNU C.  */
00341 #if (!defined (__STDC__) && defined (sparc)) || defined (__sparc__) || defined (__sparc) || defined (__sgi) || (defined (__sun) && defined (__i386))
00342 #define YYSTACK_USE_ALLOCA
00343 #include <alloca.h>
00344 #else /* not sparc */
00345 /* We think this test detects Watcom and Microsoft C.  */
00346 /* This used to test MSDOS, but that is a bad idea
00347    since that symbol is in the user namespace.  */
00348 #if (defined (_MSDOS) || defined (_MSDOS_)) && !defined (__TURBOC__)
00349 #if 0 /* No need for malloc.h, which pollutes the namespace;
00350          instead, just don't use alloca.  */
00351 #include <malloc.h>
00352 #endif
00353 #else /* not MSDOS, or __TURBOC__ */
00354 #if defined(_AIX)
00355 /* I don't know what this was needed for, but it pollutes the namespace.
00356    So I turned it off.   rms, 2 May 1997.  */
00357 /* #include <malloc.h>  */
00358  #pragma alloca
00359 #define YYSTACK_USE_ALLOCA
00360 #else /* not MSDOS, or __TURBOC__, or _AIX */
00361 #if 0
00362 #ifdef __hpux /* haible@ilog.fr says this works for HPUX 9.05 and up,
00363                  and on HPUX 10.  Eventually we can turn this on.  */
00364 #define YYSTACK_USE_ALLOCA
00365 #define alloca __builtin_alloca
00366 #endif /* __hpux */
00367 #endif
00368 #endif /* not _AIX */
00369 #endif /* not MSDOS, or __TURBOC__ */
00370 #endif /* not sparc */
00371 #endif /* not GNU C */
00372 #endif /* alloca not defined */
00373 #endif /* YYSTACK_USE_ALLOCA not defined */
00374 
00375 #ifdef YYSTACK_USE_ALLOCA
00376 #define YYSTACK_ALLOC alloca
00377 #else
00378 #define YYSTACK_ALLOC malloc
00379 #endif
00380 
00381 /* Note: there must be only one dollar sign in this file.
00382    It is replaced by the list of actions, each action
00383    as one case of the switch.  */
00384 
00385 #define yyerrok         (yyerrstatus = 0)
00386 #define yyclearin       (yychar = YYEMPTY)
00387 #define YYEMPTY         -2
00388 #define YYEOF           0
00389 #define YYACCEPT        goto yyacceptlab
00390 #define YYABORT         goto yyabortlab
00391 #define YYERROR         goto yyerrlab1
00392 /* Like YYERROR except do call yyerror.
00393    This remains here temporarily to ease the
00394    transition to the new meaning of YYERROR, for GCC.
00395    Once GCC version 2 has supplanted version 1, this can go.  */
00396 #define YYFAIL          goto yyerrlab
00397 #define YYRECOVERING()  (!!yyerrstatus)
00398 #define YYBACKUP(token, value) \
00399 do                                                              \
00400   if (yychar == YYEMPTY && yylen == 1)                          \
00401     { yychar = (token), yylval = (value);                       \
00402       yychar1 = YYTRANSLATE (yychar);                           \
00403       YYPOPSTACK;                                               \
00404       goto yybackup;                                            \
00405     }                                                           \
00406   else                                                          \
00407     { yyerror ("syntax error: cannot back up"); YYERROR; }      \
00408 while (0)
00409 
00410 #define YYTERROR        1
00411 #define YYERRCODE       256
00412 
00413 #ifndef YYPURE
00414 #define YYLEX           yylex()
00415 #endif
00416 
00417 #ifdef YYPURE
00418 #ifdef YYLSP_NEEDED
00419 #ifdef YYLEX_PARAM
00420 #define YYLEX           yylex(&yylval, &yylloc, YYLEX_PARAM)
00421 #else
00422 #define YYLEX           yylex(&yylval, &yylloc)
00423 #endif
00424 #else /* not YYLSP_NEEDED */
00425 #ifdef YYLEX_PARAM
00426 #define YYLEX           yylex(&yylval, YYLEX_PARAM)
00427 #else
00428 #define YYLEX           yylex(&yylval)
00429 #endif
00430 #endif /* not YYLSP_NEEDED */
00431 #endif
00432 
00433 /* If nonreentrant, generate the variables here */
00434 
00435 #ifndef YYPURE
00436 
00437 int     yychar;                 /*  the lookahead symbol                */
00438 YYSTYPE yylval;                 /*  the semantic value of the           */
00439                                 /*  lookahead symbol                    */
00440 
00441 #ifdef YYLSP_NEEDED
00442 YYLTYPE yylloc;                 /*  location data for the lookahead     */
00443                                 /*  symbol                              */
00444 #endif
00445 
00446 int yynerrs;                    /*  number of parse errors so far       */
00447 #endif  /* not YYPURE */
00448 
00449 #if YYDEBUG != 0
00450 int yydebug;                    /*  nonzero means print parse trace     */
00451 /* Since this is uninitialized, it does not stop multiple parsers
00452    from coexisting.  */
00453 #endif
00454 
00455 /*  YYINITDEPTH indicates the initial size of the parser's stacks       */
00456 
00457 #ifndef YYINITDEPTH
00458 #define YYINITDEPTH 200
00459 #endif
00460 
00461 /*  YYMAXDEPTH is the maximum size the stacks can grow to
00462     (effective only if the built-in stack extension method is used).  */
00463 
00464 #if YYMAXDEPTH == 0
00465 #undef YYMAXDEPTH
00466 #endif
00467 
00468 #ifndef YYMAXDEPTH
00469 #define YYMAXDEPTH 10000
00470 #endif
00471 
00472 /* Define __yy_memcpy.  Note that the size argument
00473    should be passed with type unsigned int, because that is what the non-GCC
00474    definitions require.  With GCC, __builtin_memcpy takes an arg
00475    of type size_t, but it can handle unsigned int.  */
00476 
00477 #if __GNUC__ > 1                /* GNU C and GNU C++ define this.  */
00478 #define __yy_memcpy(TO,FROM,COUNT)      __builtin_memcpy(TO,FROM,COUNT)
00479 #else                           /* not GNU C or C++ */
00480 #ifndef __cplusplus
00481 
00482 /* This is the most reliable way to avoid incompatibilities
00483    in available built-in functions on various systems.  */
00484 static void
00485 __yy_memcpy (to, from, count)
00486      char *to;
00487      char *from;
00488      unsigned int count;
00489 {
00490   register char *f = from;
00491   register char *t = to;
00492   register int i = count;
00493 
00494   while (i-- > 0)
00495     *t++ = *f++;
00496 }
00497 
00498 #else /* __cplusplus */
00499 
00500 /* This is the most reliable way to avoid incompatibilities
00501    in available built-in functions on various systems.  */
00502 static void
00503 __yy_memcpy (char *to, char *from, unsigned int count)
00504 {
00505   register char *t = to;
00506   register char *f = from;
00507   register int i = count;
00508 
00509   while (i-- > 0)
00510     *t++ = *f++;
00511 }
00512 
00513 #endif
00514 #endif
00515 
00516 #line 217 "/usr/local/share/bison.simple"
00517 
00518 /* The user can define YYPARSE_PARAM as the name of an argument to be passed
00519    into yyparse.  The argument should have type void *.
00520    It should actually point to an object.
00521    Grammar actions can access the variable by casting it
00522    to the proper pointer type.  */
00523 
00524 #ifdef YYPARSE_PARAM
00525 #ifdef __cplusplus
00526 #define YYPARSE_PARAM_ARG void *YYPARSE_PARAM
00527 #define YYPARSE_PARAM_DECL
00528 #else /* not __cplusplus */
00529 #define YYPARSE_PARAM_ARG YYPARSE_PARAM
00530 #define YYPARSE_PARAM_DECL void *YYPARSE_PARAM;
00531 #endif /* not __cplusplus */
00532 #else /* not YYPARSE_PARAM */
00533 #define YYPARSE_PARAM_ARG
00534 #define YYPARSE_PARAM_DECL
00535 #endif /* not YYPARSE_PARAM */
00536 
00537 /* Prevent warning if -Wstrict-prototypes.  */
00538 #ifdef __GNUC__
00539 #ifdef YYPARSE_PARAM
00540 int yyparse (void *);
00541 #else
00542 int yyparse (void);
00543 #endif
00544 #endif
00545 
00546 int
00547 yyparse(YYPARSE_PARAM_ARG)
00548      YYPARSE_PARAM_DECL
00549 {
00550   register int yystate;
00551   register int yyn;
00552   register short *yyssp;
00553   register YYSTYPE *yyvsp;
00554   int yyerrstatus;      /*  number of tokens to shift before error messages enabled */
00555   int yychar1 = 0;              /*  lookahead token as an internal (translated) token number */
00556 
00557   short yyssa[YYINITDEPTH];     /*  the state stack                     */
00558   YYSTYPE yyvsa[YYINITDEPTH];   /*  the semantic value stack            */
00559 
00560   short *yyss = yyssa;          /*  refer to the stacks thru separate pointers */
00561   YYSTYPE *yyvs = yyvsa;        /*  to allow yyoverflow to reallocate them elsewhere */
00562 
00563 #ifdef YYLSP_NEEDED
00564   YYLTYPE yylsa[YYINITDEPTH];   /*  the location stack                  */
00565   YYLTYPE *yyls = yylsa;
00566   YYLTYPE *yylsp;
00567 
00568 #define YYPOPSTACK   (yyvsp--, yyssp--, yylsp--)
00569 #else
00570 #define YYPOPSTACK   (yyvsp--, yyssp--)
00571 #endif
00572 
00573   int yystacksize = YYINITDEPTH;
00574   int yyfree_stacks = 0;
00575 
00576 #ifdef YYPURE
00577   int yychar;
00578   YYSTYPE yylval;
00579   int yynerrs;
00580 #ifdef YYLSP_NEEDED
00581   YYLTYPE yylloc;
00582 #endif
00583 #endif
00584 
00585   YYSTYPE yyval;                /*  the variable used to return         */
00586                                 /*  semantic values from the action     */
00587                                 /*  routines                            */
00588 
00589   int yylen;
00590 
00591 #if YYDEBUG != 0
00592   if (yydebug)
00593     fprintf(stderr, "Starting parse\n");
00594 #endif
00595 
00596   yystate = 0;
00597   yyerrstatus = 0;
00598   yynerrs = 0;
00599   yychar = YYEMPTY;             /* Cause a token to be read.  */
00600 
00601   /* Initialize stack pointers.
00602      Waste one element of value and location stack
00603      so that they stay on the same level as the state stack.
00604      The wasted elements are never initialized.  */
00605 
00606   yyssp = yyss - 1;
00607   yyvsp = yyvs;
00608 #ifdef YYLSP_NEEDED
00609   yylsp = yyls;
00610 #endif
00611 
00612 /* Push a new state, which is found in  yystate  .  */
00613 /* In all cases, when you get here, the value and location stacks
00614    have just been pushed. so pushing a state here evens the stacks.  */
00615 yynewstate:
00616 
00617   *++yyssp = yystate;
00618 
00619   if (yyssp >= yyss + yystacksize - 1)
00620     {
00621       /* Give user a chance to reallocate the stack */
00622       /* Use copies of these so that the &'s don't force the real ones into memory. */
00623       YYSTYPE *yyvs1 = yyvs;
00624       short *yyss1 = yyss;
00625 #ifdef YYLSP_NEEDED
00626       YYLTYPE *yyls1 = yyls;
00627 #endif
00628 
00629       /* Get the current used size of the three stacks, in elements.  */
00630       int size = yyssp - yyss + 1;
00631 
00632 #ifdef yyoverflow
00633       /* Each stack pointer address is followed by the size of
00634          the data in use in that stack, in bytes.  */
00635 #ifdef YYLSP_NEEDED
00636       /* This used to be a conditional around just the two extra args,
00637          but that might be undefined if yyoverflow is a macro.  */
00638       yyoverflow("parser stack overflow",
00639                  &yyss1, size * sizeof (*yyssp),
00640                  &yyvs1, size * sizeof (*yyvsp),
00641                  &yyls1, size * sizeof (*yylsp),
00642                  &yystacksize);
00643 #else
00644       yyoverflow("parser stack overflow",
00645                  &yyss1, size * sizeof (*yyssp),
00646                  &yyvs1, size * sizeof (*yyvsp),
00647                  &yystacksize);
00648 #endif
00649 
00650       yyss = yyss1; yyvs = yyvs1;
00651 #ifdef YYLSP_NEEDED
00652       yyls = yyls1;
00653 #endif
00654 #else /* no yyoverflow */
00655       /* Extend the stack our own way.  */
00656       if (yystacksize >= YYMAXDEPTH)
00657         {
00658           yyerror("parser stack overflow");
00659           if (yyfree_stacks)
00660             {
00661               free (yyss);
00662               free (yyvs);
00663 #ifdef YYLSP_NEEDED
00664               free (yyls);
00665 #endif
00666             }
00667           return 2;
00668         }
00669       yystacksize *= 2;
00670       if (yystacksize > YYMAXDEPTH)
00671         yystacksize = YYMAXDEPTH;
00672 #ifndef YYSTACK_USE_ALLOCA
00673       yyfree_stacks = 1;
00674 #endif
00675       yyss = (short *) YYSTACK_ALLOC (yystacksize * sizeof (*yyssp));
00676       __yy_memcpy ((char *)yyss, (char *)yyss1,
00677                    size * (unsigned int) sizeof (*yyssp));
00678       yyvs = (YYSTYPE *) YYSTACK_ALLOC (yystacksize * sizeof (*yyvsp));
00679       __yy_memcpy ((char *)yyvs, (char *)yyvs1,
00680                    size * (unsigned int) sizeof (*yyvsp));
00681 #ifdef YYLSP_NEEDED
00682       yyls = (YYLTYPE *) YYSTACK_ALLOC (yystacksize * sizeof (*yylsp));
00683       __yy_memcpy ((char *)yyls, (char *)yyls1,
00684                    size * (unsigned int) sizeof (*yylsp));
00685 #endif
00686 #endif /* no yyoverflow */
00687 
00688       yyssp = yyss + size - 1;
00689       yyvsp = yyvs + size - 1;
00690 #ifdef YYLSP_NEEDED
00691       yylsp = yyls + size - 1;
00692 #endif
00693 
00694 #if YYDEBUG != 0
00695       if (yydebug)
00696         fprintf(stderr, "Stack size increased to %d\n", yystacksize);
00697 #endif
00698 
00699       if (yyssp >= yyss + yystacksize - 1)
00700         YYABORT;
00701     }
00702 
00703 #if YYDEBUG != 0
00704   if (yydebug)
00705     fprintf(stderr, "Entering state %d\n", yystate);
00706 #endif
00707 
00708   goto yybackup;
00709  yybackup:
00710 
00711 /* Do appropriate processing given the current state.  */
00712 /* Read a lookahead token if we need one and don't already have one.  */
00713 /* yyresume: */
00714 
00715   /* First try to decide what to do without reference to lookahead token.  */
00716 
00717   yyn = yypact[yystate];
00718   if (yyn == YYFLAG)
00719     goto yydefault;
00720 
00721   /* Not known => get a lookahead token if don't already have one.  */
00722 
00723   /* yychar is either YYEMPTY or YYEOF
00724      or a valid token in external form.  */
00725 
00726   if (yychar == YYEMPTY)
00727     {
00728 #if YYDEBUG != 0
00729       if (yydebug)
00730         fprintf(stderr, "Reading a token: ");
00731 #endif
00732       yychar = YYLEX;
00733     }
00734 
00735   /* Convert token to internal form (in yychar1) for indexing tables with */
00736 
00737   if (yychar <= 0)              /* This means end of input. */
00738     {
00739       yychar1 = 0;
00740       yychar = YYEOF;           /* Don't call YYLEX any more */
00741 
00742 #if YYDEBUG != 0
00743       if (yydebug)
00744         fprintf(stderr, "Now at end of input.\n");
00745 #endif
00746     }
00747   else
00748     {
00749       yychar1 = YYTRANSLATE(yychar);
00750 
00751 #if YYDEBUG != 0
00752       if (yydebug)
00753         {
00754           fprintf (stderr, "Next token is %d (%s", yychar, yytname[yychar1]);
00755           /* Give the individual parser a way to print the precise meaning
00756              of a token, for further debugging info.  */
00757 #ifdef YYPRINT
00758           YYPRINT (stderr, yychar, yylval);
00759 #endif
00760           fprintf (stderr, ")\n");
00761         }
00762 #endif
00763     }
00764 
00765   yyn += yychar1;
00766   if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != yychar1)
00767     goto yydefault;
00768 
00769   yyn = yytable[yyn];
00770 
00771   /* yyn is what to do for this token type in this state.
00772      Negative => reduce, -yyn is rule number.
00773      Positive => shift, yyn is new state.
00774        New state is final state => don't bother to shift,
00775        just return success.
00776      0, or most negative number => error.  */
00777 
00778   if (yyn < 0)
00779     {
00780       if (yyn == YYFLAG)
00781         goto yyerrlab;
00782       yyn = -yyn;
00783       goto yyreduce;
00784     }
00785   else if (yyn == 0)
00786     goto yyerrlab;
00787 
00788   if (yyn == YYFINAL)
00789     YYACCEPT;
00790 
00791   /* Shift the lookahead token.  */
00792 
00793 #if YYDEBUG != 0
00794   if (yydebug)
00795     fprintf(stderr, "Shifting token %d (%s), ", yychar, yytname[yychar1]);
00796 #endif
00797 
00798   /* Discard the token being shifted unless it is eof.  */
00799   if (yychar != YYEOF)
00800     yychar = YYEMPTY;
00801 
00802   *++yyvsp = yylval;
00803 #ifdef YYLSP_NEEDED
00804   *++yylsp = yylloc;
00805 #endif
00806 
00807   /* count tokens shifted since error; after three, turn off error status.  */
00808   if (yyerrstatus) yyerrstatus--;
00809 
00810   yystate = yyn;
00811   goto yynewstate;
00812 
00813 /* Do the default action for the current state.  */
00814 yydefault:
00815 
00816   yyn = yydefact[yystate];
00817   if (yyn == 0)
00818     goto yyerrlab;
00819 
00820 /* Do a reduction.  yyn is the number of a rule to reduce with.  */
00821 yyreduce:
00822   yylen = yyr2[yyn];
00823   if (yylen > 0)
00824     yyval = yyvsp[1-yylen]; /* implement default value of the action */
00825 
00826 #if YYDEBUG != 0
00827   if (yydebug)
00828     {
00829       int i;
00830 
00831       fprintf (stderr, "Reducing via rule %d (line %d), ",
00832                yyn, yyrline[yyn]);
00833 
00834       /* Print the symbols being reduced, and their result.  */
00835       for (i = yyprhs[yyn]; yyrhs[i] > 0; i++)
00836         fprintf (stderr, "%s ", yytname[yyrhs[i]]);
00837       fprintf (stderr, " -> %s\n", yytname[yyr1[yyn]]);
00838     }
00839 #endif
00840 
00841 
00842   switch (yyn) {
00843 
00844 case 1:
00845 #line 175 "plural.y"
00846 {
00847             if (yyvsp[0].exp == NULL)
00848               YYABORT;
00849             ((struct parse_args *) arg)->res = yyvsp[0].exp;
00850           ;
00851     break;}
00852 case 2:
00853 #line 183 "plural.y"
00854 {
00855             yyval.exp = new_exp_3 (qmop, yyvsp[-4].exp, yyvsp[-2].exp, yyvsp[0].exp);
00856           ;
00857     break;}
00858 case 3:
00859 #line 187 "plural.y"
00860 {
00861             yyval.exp = new_exp_2 (lor, yyvsp[-2].exp, yyvsp[0].exp);
00862           ;
00863     break;}
00864 case 4:
00865 #line 191 "plural.y"
00866 {
00867             yyval.exp = new_exp_2 (land, yyvsp[-2].exp, yyvsp[0].exp);
00868           ;
00869     break;}
00870 case 5:
00871 #line 195 "plural.y"
00872 {
00873             yyval.exp = new_exp_2 (yyvsp[-1].op, yyvsp[-2].exp, yyvsp[0].exp);
00874           ;
00875     break;}
00876 case 6:
00877 #line 199 "plural.y"
00878 {
00879             yyval.exp = new_exp_2 (yyvsp[-1].op, yyvsp[-2].exp, yyvsp[0].exp);
00880           ;
00881     break;}
00882 case 7:
00883 #line 203 "plural.y"
00884 {
00885             yyval.exp = new_exp_2 (yyvsp[-1].op, yyvsp[-2].exp, yyvsp[0].exp);
00886           ;
00887     break;}
00888 case 8:
00889 #line 207 "plural.y"
00890 {
00891             yyval.exp = new_exp_2 (yyvsp[-1].op, yyvsp[-2].exp, yyvsp[0].exp);
00892           ;
00893     break;}
00894 case 9:
00895 #line 211 "plural.y"
00896 {
00897             yyval.exp = new_exp_1 (lnot, yyvsp[0].exp);
00898           ;
00899     break;}
00900 case 10:
00901 #line 215 "plural.y"
00902 {
00903             yyval.exp = new_exp_0 (var);
00904           ;
00905     break;}
00906 case 11:
00907 #line 219 "plural.y"
00908 {
00909             if ((yyval.exp = new_exp_0 (num)) != NULL)
00910               yyval.exp->val.num = yyvsp[0].num;
00911           ;
00912     break;}
00913 case 12:
00914 #line 224 "plural.y"
00915 {
00916             yyval.exp = yyvsp[-1].exp;
00917           ;
00918     break;}
00919 }
00920    /* the action file gets copied in in place of this dollarsign */
00921 #line 543 "/usr/local/share/bison.simple"
00922 
00923   yyvsp -= yylen;
00924   yyssp -= yylen;
00925 #ifdef YYLSP_NEEDED
00926   yylsp -= yylen;
00927 #endif
00928 
00929 #if YYDEBUG != 0
00930   if (yydebug)
00931     {
00932       short *ssp1 = yyss - 1;
00933       fprintf (stderr, "state stack now");
00934       while (ssp1 != yyssp)
00935         fprintf (stderr, " %d", *++ssp1);
00936       fprintf (stderr, "\n");
00937     }
00938 #endif
00939 
00940   *++yyvsp = yyval;
00941 
00942 #ifdef YYLSP_NEEDED
00943   yylsp++;
00944   if (yylen == 0)
00945     {
00946       yylsp->first_line = yylloc.first_line;
00947       yylsp->first_column = yylloc.first_column;
00948       yylsp->last_line = (yylsp-1)->last_line;
00949       yylsp->last_column = (yylsp-1)->last_column;
00950       yylsp->text = 0;
00951     }
00952   else
00953     {
00954       yylsp->last_line = (yylsp+yylen-1)->last_line;
00955       yylsp->last_column = (yylsp+yylen-1)->last_column;
00956     }
00957 #endif
00958 
00959   /* Now "shift" the result of the reduction.
00960      Determine what state that goes to,
00961      based on the state we popped back to
00962      and the rule number reduced by.  */
00963 
00964   yyn = yyr1[yyn];
00965 
00966   yystate = yypgoto[yyn - YYNTBASE] + *yyssp;
00967   if (yystate >= 0 && yystate <= YYLAST && yycheck[yystate] == *yyssp)
00968     yystate = yytable[yystate];
00969   else
00970     yystate = yydefgoto[yyn - YYNTBASE];
00971 
00972   goto yynewstate;
00973 
00974 yyerrlab:   /* here on detecting error */
00975 
00976   if (! yyerrstatus)
00977     /* If not already recovering from an error, report this error.  */
00978     {
00979       ++yynerrs;
00980 
00981 #ifdef YYERROR_VERBOSE
00982       yyn = yypact[yystate];
00983 
00984       if (yyn > YYFLAG && yyn < YYLAST)
00985         {
00986           int size = 0;
00987           char *msg;
00988           int x, count;
00989 
00990           count = 0;
00991           /* Start X at -yyn if nec to avoid negative indexes in yycheck.  */
00992           for (x = (yyn < 0 ? -yyn : 0);
00993                x < (sizeof(yytname) / sizeof(char *)); x++)
00994             if (yycheck[x + yyn] == x)
00995               size += strlen(yytname[x]) + 15, count++;
00996           msg = (char *) malloc(size + 15);
00997           if (msg != 0)
00998             {
00999               strcpy(msg, "parse error");
01000 
01001               if (count < 5)
01002                 {
01003                   count = 0;
01004                   for (x = (yyn < 0 ? -yyn : 0);
01005                        x < (sizeof(yytname) / sizeof(char *)); x++)
01006                     if (yycheck[x + yyn] == x)
01007                       {
01008                         strcat(msg, count == 0 ? ", expecting `" : " or `");
01009                         strcat(msg, yytname[x]);
01010                         strcat(msg, "'");
01011                         count++;
01012                       }
01013                 }
01014               yyerror(msg);
01015               free(msg);
01016             }
01017           else
01018             yyerror ("parse error; also virtual memory exceeded");
01019         }
01020       else
01021 #endif /* YYERROR_VERBOSE */
01022         yyerror("parse error");
01023     }
01024 
01025   goto yyerrlab1;
01026 yyerrlab1:   /* here on error raised explicitly by an action */
01027 
01028   if (yyerrstatus == 3)
01029     {
01030       /* if just tried and failed to reuse lookahead token after an error, discard it.  */
01031 
01032       /* return failure if at end of input */
01033       if (yychar == YYEOF)
01034         YYABORT;
01035 
01036 #if YYDEBUG != 0
01037       if (yydebug)
01038         fprintf(stderr, "Discarding token %d (%s).\n", yychar, yytname[yychar1]);
01039 #endif
01040 
01041       yychar = YYEMPTY;
01042     }
01043 
01044   /* Else will try to reuse lookahead token
01045      after shifting the error token.  */
01046 
01047   yyerrstatus = 3;              /* Each real token shifted decrements this */
01048 
01049   goto yyerrhandle;
01050 
01051 yyerrdefault:  /* current state does not do anything special for the error token. */
01052 
01053 #if 0
01054   /* This is wrong; only states that explicitly want error tokens
01055      should shift them.  */
01056   yyn = yydefact[yystate];  /* If its default is to accept any token, ok.  Otherwise pop it.*/
01057   if (yyn) goto yydefault;
01058 #endif
01059 
01060 yyerrpop:   /* pop the current state because it cannot handle the error token */
01061 
01062   if (yyssp == yyss) YYABORT;
01063   yyvsp--;
01064   yystate = *--yyssp;
01065 #ifdef YYLSP_NEEDED
01066   yylsp--;
01067 #endif
01068 
01069 #if YYDEBUG != 0
01070   if (yydebug)
01071     {
01072       short *ssp1 = yyss - 1;
01073       fprintf (stderr, "Error: state stack now");
01074       while (ssp1 != yyssp)
01075         fprintf (stderr, " %d", *++ssp1);
01076       fprintf (stderr, "\n");
01077     }
01078 #endif
01079 
01080 yyerrhandle:
01081 
01082   yyn = yypact[yystate];
01083   if (yyn == YYFLAG)
01084     goto yyerrdefault;
01085 
01086   yyn += YYTERROR;
01087   if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != YYTERROR)
01088     goto yyerrdefault;
01089 
01090   yyn = yytable[yyn];
01091   if (yyn < 0)
01092     {
01093       if (yyn == YYFLAG)
01094         goto yyerrpop;
01095       yyn = -yyn;
01096       goto yyreduce;
01097     }
01098   else if (yyn == 0)
01099     goto yyerrpop;
01100 
01101   if (yyn == YYFINAL)
01102     YYACCEPT;
01103 
01104 #if YYDEBUG != 0
01105   if (yydebug)
01106     fprintf(stderr, "Shifting error token, ");
01107 #endif
01108 
01109   *++yyvsp = yylval;
01110 #ifdef YYLSP_NEEDED
01111   *++yylsp = yylloc;
01112 #endif
01113 
01114   yystate = yyn;
01115   goto yynewstate;
01116 
01117  yyacceptlab:
01118   /* YYACCEPT comes here.  */
01119   if (yyfree_stacks)
01120     {
01121       free (yyss);
01122       free (yyvs);
01123 #ifdef YYLSP_NEEDED
01124       free (yyls);
01125 #endif
01126     }
01127   return 0;
01128 
01129  yyabortlab:
01130   /* YYABORT comes here.  */
01131   if (yyfree_stacks)
01132     {
01133       free (yyss);
01134       free (yyvs);
01135 #ifdef YYLSP_NEEDED
01136       free (yyls);
01137 #endif
01138     }
01139   return 1;
01140 }
01141 #line 229 "plural.y"
01142 
01143 
01144 void
01145 internal_function
01146 FREE_EXPRESSION (exp)
01147      struct expression *exp;
01148 {
01149   if (exp == NULL)
01150     return;
01151 
01152   /* Handle the recursive case.  */
01153   switch (exp->nargs)
01154     {
01155     case 3:
01156       FREE_EXPRESSION (exp->val.args[2]);
01157       /* FALLTHROUGH */
01158     case 2:
01159       FREE_EXPRESSION (exp->val.args[1]);
01160       /* FALLTHROUGH */
01161     case 1:
01162       FREE_EXPRESSION (exp->val.args[0]);
01163       /* FALLTHROUGH */
01164     default:
01165       break;
01166     }
01167 
01168   free (exp);
01169 }
01170 
01171 
01172 static int
01173 yylex (lval, pexp)
01174      YYSTYPE *lval;
01175      const char **pexp;
01176 {
01177   const char *exp = *pexp;
01178   int result;
01179 
01180   while (1)
01181     {
01182       if (exp[0] == '\0')
01183         {
01184           *pexp = exp;
01185           return YYEOF;
01186         }
01187 
01188       if (exp[0] != ' ' && exp[0] != '\t')
01189         break;
01190 
01191       ++exp;
01192     }
01193 
01194   result = *exp++;
01195   switch (result)
01196     {
01197     case '0': case '1': case '2': case '3': case '4':
01198     case '5': case '6': case '7': case '8': case '9':
01199       {
01200         unsigned long int n = result - '0';
01201         while (exp[0] >= '0' && exp[0] <= '9')
01202           {
01203             n *= 10;
01204             n += exp[0] - '0';
01205             ++exp;
01206           }
01207         lval->num = n;
01208         result = NUMBER;
01209       }
01210       break;
01211 
01212     case '=':
01213       if (exp[0] == '=')
01214         {
01215           ++exp;
01216           lval->op = equal;
01217           result = EQUOP2;
01218         }
01219       else
01220         result = YYERRCODE;
01221       break;
01222 
01223     case '!':
01224       if (exp[0] == '=')
01225         {
01226           ++exp;
01227           lval->op = not_equal;
01228           result = EQUOP2;
01229         }
01230       break;
01231 
01232     case '&':
01233     case '|':
01234       if (exp[0] == result)
01235         ++exp;
01236       else
01237         result = YYERRCODE;
01238       break;
01239 
01240     case '<':
01241       if (exp[0] == '=')
01242         {
01243           ++exp;
01244           lval->op = less_or_equal;
01245         }
01246       else
01247         lval->op = less_than;
01248       result = CMPOP2;
01249       break;
01250 
01251     case '>':
01252       if (exp[0] == '=')
01253         {
01254           ++exp;
01255           lval->op = greater_or_equal;
01256         }
01257       else
01258         lval->op = greater_than;
01259       result = CMPOP2;
01260       break;
01261 
01262     case '*':
01263       lval->op = mult;
01264       result = MULOP2;
01265       break;
01266 
01267     case '/':
01268       lval->op = divide;
01269       result = MULOP2;
01270       break;
01271 
01272     case '%':
01273       lval->op = module;
01274       result = MULOP2;
01275       break;
01276 
01277     case '+':
01278       lval->op = plus;
01279       result = ADDOP2;
01280       break;
01281 
01282     case '-':
01283       lval->op = minus;
01284       result = ADDOP2;
01285       break;
01286 
01287     case 'n':
01288     case '?':
01289     case ':':
01290     case '(':
01291     case ')':
01292       /* Nothing, just return the character.  */
01293       break;
01294 
01295     case ';':
01296     case '\n':
01297     case '\0':
01298       /* Be safe and let the user call this function again.  */
01299       --exp;
01300       result = YYEOF;
01301       break;
01302 
01303     default:
01304       result = YYERRCODE;
01305 #if YYDEBUG != 0
01306       --exp;
01307 #endif
01308       break;
01309     }
01310 
01311   *pexp = exp;
01312 
01313   return result;
01314 }
01315 
01316 
01317 static void
01318 yyerror (str)
01319      const char *str;
01320 {
01321   /* Do nothing.  We don't print error messages here.  */
01322 }

Generated on Sun Feb 16 23:39:49 2003 for FreeLCD by doxygen1.2.18