(linenum→info "unix/slp.c:2238")

glibc/2.7/intl/plural.c

    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 Free Software Foundation, Inc.
   23:    This file is part of the GNU C Library.
   24:    Written by Ulrich Drepper <drepper@cygnus.com>, 2000.
   25: 
   26:    The GNU C Library is free software; you can redistribute it and/or
   27:    modify it under the terms of the GNU Lesser General Public
   28:    License as published by the Free Software Foundation; either
   29:    version 2.1 of the License, or (at your option) any later version.
   30: 
   31:    The GNU C Library is distributed in the hope that it will be useful,
   32:    but WITHOUT ANY WARRANTY; without even the implied warranty of
   33:    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   34:    Lesser General Public License for more details.
   35: 
   36:    You should have received a copy of the GNU Lesser General Public
   37:    License along with the GNU C Library; if not, write to the Free
   38:    Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
   39:    02111-1307 USA.  */
   40: 
   41: /* The bison generated parser uses alloca.  AIX 3 forces us to put this
   42:    declaration at the beginning of the file.  The declaration in bison's
   43:    skeleton file comes too late.  This must come before <config.h>
   44:    because <config.h> may include arbitrary system headers.  */
   45: #if defined _AIX && !defined __GNUC__
   46:  #pragma alloca
   47: #endif
   48: #ifdef HAVE_CONFIG_H
   49: # include <config.h>
   50: #endif
   51: 
   52: #include <stddef.h>
   53: #include <stdlib.h>
   54: #include <string.h>
   55: #include "plural-exp.h"
   56: 
   57: /* The main function generated by the parser is called __gettextparse,
   58:    but we want it to be called PLURAL_PARSE.  */
   59: #ifndef _LIBC
   60: # define __gettextparse PLURAL_PARSE
   61: #endif
   62: 
   63: #define YYLEX_PARAM     &((struct parse_args *) arg)->cp
   64: #define YYPARSE_PARAM   arg
   65: 
   66: #line 49 "plural.y"
   67: #ifndef YYSTYPE
   68: typedef union {
   69:   unsigned long int num;
   70:   enum operator op;
   71:   struct expression *exp;
   72: } yystype;
   73: # define YYSTYPE yystype
   74: # define YYSTYPE_IS_TRIVIAL 1
   75: #endif
   76: #line 55 "plural.y"
   77: 
   78: /* Prototypes for local functions.  */
   79: static struct expression *new_exp PARAMS ((int nargs, enum operator op,
   80:                                            struct expression * const *args));
   81: static inline struct expression *new_exp_0 PARAMS ((enum operator op));
   82: static inline struct expression *new_exp_1 PARAMS ((enum operator op,
   83:                                                    struct expression *right));
   84: static struct expression *new_exp_2 PARAMS ((enum operator op,
   85:                                              struct expression *left,
   86:                                              struct expression *right));
   87: static inline struct expression *new_exp_3 PARAMS ((enum operator op,
   88:                                                    struct expression *bexp,
   89:                                                    struct expression *tbranch,
   90:                                                    struct expression *fbranch));
   91: static int yylex PARAMS ((YYSTYPE *lval, const char **pexp));
   92: static void yyerror PARAMS ((const char *str));
   93: 
   94: /* Allocation of expressions.  */
   95: 
   96: static struct expression *
   97: new_exp (nargs, op, args)
   98:      int nargs;
   99:      enum operator op;
  100:      struct expression * const *args;
  101: {
  102:   int i;
  103:   struct expression *newp;
  104: 
  105:   /* If any of the argument could not be malloc'ed, just return NULL.  */
  106:   for (i = nargs - 1; i >= 0; i--)
  107:     if (args[i] == NULL)
  108:       goto fail;
  109: 
  110:   /* Allocate a new expression.  */
  111:   newp = (struct expression *) malloc (sizeof (*newp));
  112:   if (newp != NULL)
  113:     {
  114:       newp->nargs = nargs;
  115:       newp->operation = op;
  116:       for (i = nargs - 1; i >= 0; i--)
  117:         newp->val.args[i] = args[i];
  118:       return newp;
  119:     }
  120: 
  121:  fail:
  122:   for (i = nargs - 1; i >= 0; i--)
  123:     FREE_EXPRESSION (args[i]);
  124: 
  125:   return NULL;
  126: }
  127: 
  128: static inline struct expression *
  129: new_exp_0 (op)
  130:      enum operator op;
  131: {
  132:   return new_exp (0, op, NULL);
  133: }
  134: 
  135: static inline struct expression *
  136: new_exp_1 (op, right)
  137:      enum operator op;
  138:      struct expression *right;
  139: {
  140:   struct expression *args[1];
  141: 
  142:   args[0] = right;
  143:   return new_exp (1, op, args);
  144: }
  145: 
  146: static struct expression *
  147: new_exp_2 (op, left, right)
  148:      enum operator op;
  149:      struct expression *left;
  150:      struct expression *right;
  151: {
  152:   struct expression *args[2];
  153: 
  154:   args[0] = left;
  155:   args[1] = right;
  156:   return new_exp (2, op, args);
  157: }
  158: 
  159: static inline struct expression *
  160: new_exp_3 (op, bexp, tbranch, fbranch)
  161:      enum operator op;
  162:      struct expression *bexp;
  163:      struct expression *tbranch;
  164:      struct expression *fbranch;
  165: {
  166:   struct expression *args[3];
  167: 
  168:   args[0] = bexp;
  169:   args[1] = tbranch;
  170:   args[2] = fbranch;
  171:   return new_exp (3, op, args);
  172: }
  173: 
  174: #ifndef YYDEBUG
  175: # define YYDEBUG 0
  176: #endif
  177: 
  178: 
  179: 
  180: #define YYFINAL         27
  181: #define YYFLAG          -32768
  182: #define YYNTBASE        16
  183: 
  184: /* YYTRANSLATE(YYLEX) -- Bison token number corresponding to YYLEX. */
  185: #define YYTRANSLATE(x) ((unsigned)(x) <= 261 ? yytranslate[x] : 18)
  186: 
  187: /* YYTRANSLATE[YYLEX] -- Bison token number corresponding to YYLEX. */
  188: static const char yytranslate[] =
  189: {
  190:        0,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  191:        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  192:        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  193:        2,     2,     2,    10,     2,     2,     2,     2,     5,     2,
  194:       14,    15,     2,     2,     2,     2,     2,     2,     2,     2,
  195:        2,     2,     2,     2,     2,     2,     2,     2,    12,     2,
  196:        2,     2,     2,     3,     2,     2,     2,     2,     2,     2,
  197:        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  198:        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  199:        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  200:        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  201:       13,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  202:        2,     2,     2,     2,     4,     2,     2,     2,     2,     2,
  203:        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  204:        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  205:        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  206:        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  207:        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  208:        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  209:        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  210:        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  211:        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  212:        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  213:        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  214:        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  215:        2,     2,     2,     2,     2,     2,     1,     6,     7,     8,
  216:        9,    11
  217: };
  218: 
  219: #if YYDEBUG
  220: static const short yyprhs[] =
  221: {
  222:        0,     0,     2,     8,    12,    16,    20,    24,    28,    32,
  223:       35,    37,    39
  224: };
  225: static const short yyrhs[] =
  226: {
  227:       17,     0,    17,     3,    17,    12,    17,     0,    17,     4,
  228:       17,     0,    17,     5,    17,     0,    17,     6,    17,     0,
  229:       17,     7,    17,     0,    17,     8,    17,     0,    17,     9,
  230:       17,     0,    10,    17,     0,    13,     0,    11,     0,    14,
  231:       17,    15,     0
  232: };
  233: 
  234: #endif
  235: 
  236: #if YYDEBUG
  237: /* YYRLINE[YYN] -- source line where rule number YYN was defined. */
  238: static const short yyrline[] =
  239: {
  240:        0,   174,   182,   186,   190,   194,   198,   202,   206,   210,
  241:      214,   218,   223
  242: };
  243: #endif
  244: 
  245: 
  246: #if (YYDEBUG) || defined YYERROR_VERBOSE
  247: 
  248: /* YYTNAME[TOKEN_NUM] -- String name of the token TOKEN_NUM. */
  249: static const char *const yytname[] =
  250: {
  251:   "$", "error", "$undefined.", "'?'", "'|'", "'&'", "EQUOP2", "CMPOP2", 
  252:   "ADDOP2", "MULOP2", "'!'", "NUMBER", "':'", "'n'", "'('", "')'", 
  253:   "start", "exp", 0
  254: };
  255: #endif
  256: 
  257: /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */
  258: static const short yyr1[] =
  259: {
  260:        0,    16,    17,    17,    17,    17,    17,    17,    17,    17,
  261:       17,    17,    17
  262: };
  263: 
  264: /* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */
  265: static const short yyr2[] =
  266: {
  267:        0,     1,     5,     3,     3,     3,     3,     3,     3,     2,
  268:        1,     1,     3
  269: };
  270: 
  271: /* YYDEFACT[S] -- default rule to reduce with in state S when YYTABLE
  272:    doesn't specify something else to do.  Zero means the default is an
  273:    error. */
  274: static const short yydefact[] =
  275: {
  276:        0,     0,    11,    10,     0,     1,     9,     0,     0,     0,
  277:        0,     0,     0,     0,     0,    12,     0,     3,     4,     5,
  278:        6,     7,     8,     0,     2,     0,     0,     0
  279: };
  280: 
  281: static const short yydefgoto[] =
  282: {
  283:       25,     5
  284: };
  285: 
  286: static const short yypact[] =
  287: {
  288:       -9,    -9,-32768,-32768,    -9,    34,-32768,    11,    -9,    -9,
  289:       -9,    -9,    -9,    -9,    -9,-32768,    24,    39,    43,    16,
  290:       26,    -3,-32768,    -9,    34,    21,    53,-32768
  291: };
  292: 
  293: static const short yypgoto[] =
  294: {
  295:   -32768,    -1
  296: };
  297: 
  298: 
  299: #define YYLAST          53
  300: 
  301: 
  302: static const short yytable[] =
  303: {
  304:        6,     1,     2,     7,     3,     4,    14,    16,    17,    18,
  305:       19,    20,    21,    22,     8,     9,    10,    11,    12,    13,
  306:       14,    26,    24,    12,    13,    14,    15,     8,     9,    10,
  307:       11,    12,    13,    14,    13,    14,    23,     8,     9,    10,
  308:       11,    12,    13,    14,    10,    11,    12,    13,    14,    11,
  309:       12,    13,    14,    27
  310: };
  311: 
  312: static const short yycheck[] =
  313: {
  314:        1,    10,    11,     4,    13,    14,     9,     8,     9,    10,
  315:       11,    12,    13,    14,     3,     4,     5,     6,     7,     8,
  316:        9,     0,    23,     7,     8,     9,    15,     3,     4,     5,
  317:        6,     7,     8,     9,     8,     9,    12,     3,     4,     5,
  318:        6,     7,     8,     9,     5,     6,     7,     8,     9,     6,
  319:        7,     8,     9,     0
  320: };
  321: #define YYPURE 1
  322: 
  323: /* -*-C-*-  Note some compilers choke on comments on `#line' lines.  */
  324: #line 3 "/castro/street/H-alpha-linux/share/bison/bison.simple"
  325: 
  326: /* Skeleton output parser for bison,
  327: 
  328:    Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002 Free Software
  329:    Foundation, Inc.
  330: 
  331:    This program is free software; you can redistribute it and/or modify
  332:    it under the terms of the GNU General Public License as published by
  333:    the Free Software Foundation; either version 2, or (at your option)
  334:    any later version.
  335: 
  336:    This program is distributed in the hope that it will be useful,
  337:    but WITHOUT ANY WARRANTY; without even the implied warranty of
  338:    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  339:    GNU General Public License for more details.
  340: 
  341:    You should have received a copy of the GNU General Public License
  342:    along with this program; if not, write to the Free Software
  343:    Foundation, Inc., 59 Temple Place - Suite 330,
  344:    Boston, MA 02111-1307, USA.  */
  345: 
  346: /* As a special exception, when this file is copied by Bison into a
  347:    Bison output file, you may use that output file without restriction.
  348:    This special exception was added by the Free Software Foundation
  349:    in version 1.24 of Bison.  */
  350: 
  351: /* This is the parser code that is written into each bison parser when
  352:    the %semantic_parser declaration is not specified in the grammar.
  353:    It was written by Richard Stallman by simplifying the hairy parser
  354:    used when %semantic_parser is specified.  */
  355: 
  356: /* All symbols defined below should begin with yy or YY, to avoid
  357:    infringing on user name space.  This should be done even for local
  358:    variables, as they might otherwise be expanded by user macros.
  359:    There are some unavoidable exceptions within include files to
  360:    define necessary library symbols; they are noted "INFRINGES ON
  361:    USER NAME SPACE" below.  */
  362: 
  363: #if ! defined (yyoverflow) || defined (YYERROR_VERBOSE)
  364: 
  365: /* The parser invokes alloca or malloc; define the necessary symbols.  */
  366: 
  367: # if YYSTACK_USE_ALLOCA
  368: #  define YYSTACK_ALLOC alloca
  369: # else
  370: #  ifndef YYSTACK_USE_ALLOCA
  371: #   if defined (alloca) || defined (_ALLOCA_H)
  372: #    define YYSTACK_ALLOC alloca
  373: #   else
  374: #    ifdef __GNUC__
  375: #     define YYSTACK_ALLOC __builtin_alloca
  376: #    endif
  377: #   endif
  378: #  endif
  379: # endif
  380: 
  381: # ifdef YYSTACK_ALLOC
  382:    /* Pacify GCC's `empty if-body' warning. */
  383: #  define YYSTACK_FREE(Ptr) do { /* empty */; } while (0)
  384: # else
  385: #  if defined (__STDC__) || defined (__cplusplus)
  386: #   include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
  387: #   define YYSIZE_T size_t
  388: #  endif
  389: #  define YYSTACK_ALLOC malloc
  390: #  define YYSTACK_FREE free
  391: # endif
  392: #endif /* ! defined (yyoverflow) || defined (YYERROR_VERBOSE) */
  393: 
  394: 
  395: #if (! defined (yyoverflow) \
  396:      && (! defined (__cplusplus) \
  397:          || (YYLTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL)))
  398: 
  399: /* A type that is properly aligned for any stack member.  */
  400: union yyalloc
  401: {
  402:   short yyss;
  403:   YYSTYPE yyvs;
  404: # if YYLSP_NEEDED
  405:   YYLTYPE yyls;
  406: # endif
  407: };
  408: 
  409: /* The size of the maximum gap between one aligned stack and the next.  */
  410: # define YYSTACK_GAP_MAX (sizeof (union yyalloc) - 1)
  411: 
  412: /* The size of an array large to enough to hold all stacks, each with
  413:    N elements.  */
  414: # if YYLSP_NEEDED
  415: #  define YYSTACK_BYTES(N) \
  416:      ((N) * (sizeof (short) + sizeof (YYSTYPE) + sizeof (YYLTYPE))      \
  417:       + 2 * YYSTACK_GAP_MAX)
  418: # else
  419: #  define YYSTACK_BYTES(N) \
  420:      ((N) * (sizeof (short) + sizeof (YYSTYPE))                         \
  421:       + YYSTACK_GAP_MAX)
  422: # endif
  423: 
  424: /* Copy COUNT objects from FROM to TO.  The source and destination do
  425:    not overlap.  */
  426: # ifndef YYCOPY
  427: #  if 1 < __GNUC__
  428: #   define YYCOPY(To, From, Count) \
  429:       __builtin_memcpy (To, From, (Count) * sizeof (*(From)))
  430: #  else
  431: #   define YYCOPY(To, From, Count)              \
  432:       do                                        \
  433:         {                                      \
  434:           register YYSIZE_T yyi;               \
  435:           for (yyi = 0; yyi < (Count); yyi++)  \
  436:             (To)[yyi] = (From)[yyi];           \
  437:         }                                      \
  438:       while (0)
  439: #  endif
  440: # endif
  441: 
  442: /* Relocate STACK from its old location to the new one.  The
  443:    local variables YYSIZE and YYSTACKSIZE give the old and new number of
  444:    elements in the stack, and YYPTR gives the new location of the
  445:    stack.  Advance YYPTR to a properly aligned location for the next
  446:    stack.  */
  447: # define YYSTACK_RELOCATE(Stack)                                        \
  448:     do                                                                  \
  449:       {                                                                 \
  450:         YYSIZE_T yynewbytes;                                           \
  451:         YYCOPY (&yyptr->Stack, Stack, yysize);                         \
  452:         Stack = &yyptr->Stack;                                         \
  453:         yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAX;  \
  454:         yyptr += yynewbytes / sizeof (*yyptr);                         \
  455:       }                                                                 \
  456:     while (0)
  457: 
  458: #endif
  459: 
  460: 
  461: #if ! defined (YYSIZE_T) && defined (__SIZE_TYPE__)
  462: # define YYSIZE_T __SIZE_TYPE__
  463: #endif
  464: #if ! defined (YYSIZE_T) && defined (size_t)
  465: # define YYSIZE_T size_t
  466: #endif
  467: #if ! defined (YYSIZE_T)
  468: # if defined (__STDC__) || defined (__cplusplus)
  469: #  include <stddef.h> /* INFRINGES ON USER NAME SPACE */
  470: #  define YYSIZE_T size_t
  471: # endif
  472: #endif
  473: #if ! defined (YYSIZE_T)
  474: # define YYSIZE_T unsigned int
  475: #endif
  476: 
  477: #define yyerrok         (yyerrstatus = 0)
  478: #define yyclearin       (yychar = YYEMPTY)
  479: #define YYEMPTY         -2
  480: #define YYEOF           0
  481: #define YYACCEPT        goto yyacceptlab
  482: #define YYABORT         goto yyabortlab
  483: #define YYERROR         goto yyerrlab1
  484: /* Like YYERROR except do call yyerror.  This remains here temporarily
  485:    to ease the transition to the new meaning of YYERROR, for GCC.
  486:    Once GCC version 2 has supplanted version 1, this can go.  */
  487: #define YYFAIL          goto yyerrlab
  488: #define YYRECOVERING()  (!!yyerrstatus)
  489: #define YYBACKUP(Token, Value)                                  \
  490: do                                                              \
  491:   if (yychar == YYEMPTY && yylen == 1)                          \
  492:     {                                                           \
  493:       yychar = (Token);                                         \
  494:       yylval = (Value);                                         \
  495:       yychar1 = YYTRANSLATE (yychar);                           \
  496:       YYPOPSTACK;                                               \
  497:       goto yybackup;                                            \
  498:     }                                                           \
  499:   else                                                          \
  500:     {                                                           \
  501:       yyerror ("syntax error: cannot back up");                 \
  502:       YYERROR;                                                  \
  503: <