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