Coverage Report

Created: 2026-01-25 07:18

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/gettext-0.26/gettext-runtime/intl/plural.c
Line
Count
Source
1
/* A Bison parser, made by GNU Bison 3.8.2.  */
2
3
/* Bison implementation for Yacc-like parsers in C
4
5
   Copyright (C) 1984, 1989-1990, 2000-2015, 2018-2021 Free Software Foundation,
6
   Inc.
7
8
   This program is free software: you can redistribute it and/or modify
9
   it under the terms of the GNU General Public License as published by
10
   the Free Software Foundation, either version 3 of the License, or
11
   (at your option) any later version.
12
13
   This program is distributed in the hope that it will be useful,
14
   but WITHOUT ANY WARRANTY; without even the implied warranty of
15
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16
   GNU General Public License for more details.
17
18
   You should have received a copy of the GNU General Public License
19
   along with this program.  If not, see <https://www.gnu.org/licenses/>.  */
20
21
/* As a special exception, you may create a larger work that contains
22
   part or all of the Bison parser skeleton and distribute that work
23
   under terms of your choice, so long as that work isn't itself a
24
   parser generator using the skeleton or a modified version thereof
25
   as a parser skeleton.  Alternatively, if you modify or redistribute
26
   the parser skeleton itself, you may (at your option) remove this
27
   special exception, which will cause the skeleton and the resulting
28
   Bison output files to be licensed under the GNU General Public
29
   License without this special exception.
30
31
   This special exception was added by the Free Software Foundation in
32
   version 2.2 of Bison.  */
33
34
/* C LALR(1) parser skeleton written by Richard Stallman, by
35
   simplifying the original so-called "semantic" parser.  */
36
37
/* DO NOT RELY ON FEATURES THAT ARE NOT DOCUMENTED in the manual,
38
   especially those whose name start with YY_ or yy_.  They are
39
   private implementation details that can be changed or removed.  */
40
41
/* All symbols defined below should begin with yy or YY, to avoid
42
   infringing on user name space.  This should be done even for local
43
   variables, as they might otherwise be expanded by user macros.
44
   There are some unavoidable exceptions within include files to
45
   define necessary library symbols; they are noted "INFRINGES ON
46
   USER NAME SPACE" below.  */
47
48
/* Identify Bison output, and Bison version.  */
49
#define YYBISON 30802
50
51
/* Bison version string.  */
52
#define YYBISON_VERSION "3.8.2"
53
54
/* Skeleton name.  */
55
#define YYSKELETON_NAME "yacc.c"
56
57
/* Pure parsers.  */
58
#define YYPURE 2
59
60
/* Push parsers.  */
61
#define YYPUSH 0
62
63
/* Pull parsers.  */
64
#define YYPULL 1
65
66
67
/* Substitute the variable and function names.  */
68
#define yyparse         __gettextparse
69
0
#define yylex           __gettextlex
70
0
#define yyerror         __gettexterror
71
#define yydebug         __gettextdebug
72
0
#define yynerrs         __gettextnerrs
73
74
/* First part of user prologue.  */
75
#line 1 "plural.y"
76
77
/* Expression parsing for plural form selection.
78
   Copyright (C) 2000-2023 Free Software Foundation, Inc.
79
   Written by Ulrich Drepper <drepper@cygnus.com>, 2000.
80
81
   This program is free software: you can redistribute it and/or modify
82
   it under the terms of the GNU Lesser General Public License as published by
83
   the Free Software Foundation; either version 2.1 of the License, or
84
   (at your option) any later version.
85
86
   This program is distributed in the hope that it will be useful,
87
   but WITHOUT ANY WARRANTY; without even the implied warranty of
88
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
89
   GNU Lesser General Public License for more details.
90
91
   You should have received a copy of the GNU Lesser General Public License
92
   along with this program.  If not, see <https://www.gnu.org/licenses/>.  */
93
94
#ifdef HAVE_CONFIG_H
95
# include <config.h>
96
#endif
97
98
#include <stddef.h>
99
#include <stdlib.h>
100
#include <string.h>
101
#include "plural-exp.h"
102
#include "attribute.h"
103
104
/* The main function generated by the parser is called __gettextparse,
105
   but we want it to be called PLURAL_PARSE.  */
106
#ifndef _LIBC
107
# define __gettextparse PLURAL_PARSE
108
#endif
109
110
/* Later we provide those prototypes.  Without these macros, bison may
111
   generate its own prototypes with possible conflicts.  */
112
#define YYLEX_IS_DECLARED
113
#define YYERROR_IS_DECLARED
114
115
116
#line 117 "plural.c"
117
118
# ifndef YY_CAST
119
#  ifdef __cplusplus
120
#   define YY_CAST(Type, Val) static_cast<Type> (Val)
121
#   define YY_REINTERPRET_CAST(Type, Val) reinterpret_cast<Type> (Val)
122
#  else
123
0
#   define YY_CAST(Type, Val) ((Type) (Val))
124
#   define YY_REINTERPRET_CAST(Type, Val) ((Type) (Val))
125
#  endif
126
# endif
127
# ifndef YY_NULLPTR
128
#  if defined __cplusplus
129
#   if 201103L <= __cplusplus
130
#    define YY_NULLPTR nullptr
131
#   else
132
#    define YY_NULLPTR 0
133
#   endif
134
#  else
135
#   define YY_NULLPTR ((void*)0)
136
#  endif
137
# endif
138
139
#include "plural.h"
140
/* Symbol kind.  */
141
enum yysymbol_kind_t
142
{
143
  YYSYMBOL_YYEMPTY = -2,
144
  YYSYMBOL_YYEOF = 0,                      /* "end of file"  */
145
  YYSYMBOL_YYerror = 1,                    /* error  */
146
  YYSYMBOL_YYUNDEF = 2,                    /* "invalid token"  */
147
  YYSYMBOL_3_ = 3,                         /* '?'  */
148
  YYSYMBOL_4_ = 4,                         /* ':'  */
149
  YYSYMBOL_5_ = 5,                         /* '|'  */
150
  YYSYMBOL_6_ = 6,                         /* '&'  */
151
  YYSYMBOL_7_ = 7,                         /* '!'  */
152
  YYSYMBOL_EQUOP2 = 8,                     /* EQUOP2  */
153
  YYSYMBOL_CMPOP2 = 9,                     /* CMPOP2  */
154
  YYSYMBOL_ADDOP2 = 10,                    /* ADDOP2  */
155
  YYSYMBOL_MULOP2 = 11,                    /* MULOP2  */
156
  YYSYMBOL_NUMBER = 12,                    /* NUMBER  */
157
  YYSYMBOL_13_n_ = 13,                     /* 'n'  */
158
  YYSYMBOL_14_ = 14,                       /* '('  */
159
  YYSYMBOL_15_ = 15,                       /* ')'  */
160
  YYSYMBOL_YYACCEPT = 16,                  /* $accept  */
161
  YYSYMBOL_start = 17,                     /* start  */
162
  YYSYMBOL_exp = 18                        /* exp  */
163
};
164
typedef enum yysymbol_kind_t yysymbol_kind_t;
165
166
167
/* Second part of user prologue.  */
168
#line 53 "plural.y"
169
170
/* Prototypes for local functions.  */
171
static int yylex (YYSTYPE *lval, struct parse_args *arg);
172
static void yyerror (struct parse_args *arg, const char *str);
173
174
/* Allocation of expressions.  */
175
176
static struct expression *
177
new_exp (int nargs, enum expression_operator op,
178
   struct expression * const *args)
179
0
{
180
0
  int i;
181
0
  struct expression *newp;
182
183
  /* If any of the argument could not be malloc'ed, just return NULL.  */
184
0
  for (i = nargs - 1; i >= 0; i--)
185
0
    if (args[i] == NULL)
186
0
      goto fail;
187
188
  /* Allocate a new expression.  */
189
0
  newp = (struct expression *) malloc (sizeof (*newp));
190
0
  if (newp != NULL)
191
0
    {
192
0
      newp->nargs = nargs;
193
0
      newp->operation = op;
194
0
      for (i = nargs - 1; i >= 0; i--)
195
0
  newp->val.args[i] = args[i];
196
0
      return newp;
197
0
    }
198
199
0
 fail:
200
0
  for (i = nargs - 1; i >= 0; i--)
201
0
    FREE_EXPRESSION (args[i]);
202
203
0
  return NULL;
204
0
}
205
206
static inline struct expression *
207
new_exp_0 (enum expression_operator op)
208
0
{
209
0
  return new_exp (0, op, NULL);
210
0
}
211
212
static inline struct expression *
213
new_exp_1 (enum expression_operator op, struct expression *right)
214
0
{
215
0
  struct expression *args[1];
216
217
0
  args[0] = right;
218
0
  return new_exp (1, op, args);
219
0
}
220
221
static struct expression *
222
new_exp_2 (enum expression_operator op, struct expression *left,
223
     struct expression *right)
224
0
{
225
0
  struct expression *args[2];
226
227
0
  args[0] = left;
228
0
  args[1] = right;
229
0
  return new_exp (2, op, args);
230
0
}
231
232
static inline struct expression *
233
new_exp_3 (enum expression_operator op, struct expression *bexp,
234
     struct expression *tbranch, struct expression *fbranch)
235
0
{
236
0
  struct expression *args[3];
237
238
0
  args[0] = bexp;
239
0
  args[1] = tbranch;
240
0
  args[2] = fbranch;
241
0
  return new_exp (3, op, args);
242
0
}
243
244
245
#line 246 "plural.c"
246
247
248
#ifdef short
249
# undef short
250
#endif
251
252
/* On compilers that do not define __PTRDIFF_MAX__ etc., make sure
253
   <limits.h> and (if available) <stdint.h> are included
254
   so that the code can choose integer types of a good width.  */
255
256
#ifndef __PTRDIFF_MAX__
257
# include <limits.h> /* INFRINGES ON USER NAME SPACE */
258
# if defined __STDC_VERSION__ && 199901 <= __STDC_VERSION__
259
#  include <stdint.h> /* INFRINGES ON USER NAME SPACE */
260
#  define YY_STDINT_H
261
# endif
262
#endif
263
264
/* Narrow types that promote to a signed type and that can represent a
265
   signed or unsigned integer of at least N bits.  In tables they can
266
   save space and decrease cache pressure.  Promoting to a signed type
267
   helps avoid bugs in integer arithmetic.  */
268
269
#ifdef __INT_LEAST8_MAX__
270
typedef __INT_LEAST8_TYPE__ yytype_int8;
271
#elif defined YY_STDINT_H
272
typedef int_least8_t yytype_int8;
273
#else
274
typedef signed char yytype_int8;
275
#endif
276
277
#ifdef __INT_LEAST16_MAX__
278
typedef __INT_LEAST16_TYPE__ yytype_int16;
279
#elif defined YY_STDINT_H
280
typedef int_least16_t yytype_int16;
281
#else
282
typedef short yytype_int16;
283
#endif
284
285
/* Work around bug in HP-UX 11.23, which defines these macros
286
   incorrectly for preprocessor constants.  This workaround can likely
287
   be removed in 2023, as HPE has promised support for HP-UX 11.23
288
   (aka HP-UX 11i v2) only through the end of 2022; see Table 2 of
289
   <https://h20195.www2.hpe.com/V2/getpdf.aspx/4AA4-7673ENW.pdf>.  */
290
#ifdef __hpux
291
# undef UINT_LEAST8_MAX
292
# undef UINT_LEAST16_MAX
293
# define UINT_LEAST8_MAX 255
294
# define UINT_LEAST16_MAX 65535
295
#endif
296
297
#if defined __UINT_LEAST8_MAX__ && __UINT_LEAST8_MAX__ <= __INT_MAX__
298
typedef __UINT_LEAST8_TYPE__ yytype_uint8;
299
#elif (!defined __UINT_LEAST8_MAX__ && defined YY_STDINT_H \
300
       && UINT_LEAST8_MAX <= INT_MAX)
301
typedef uint_least8_t yytype_uint8;
302
#elif !defined __UINT_LEAST8_MAX__ && UCHAR_MAX <= INT_MAX
303
typedef unsigned char yytype_uint8;
304
#else
305
typedef short yytype_uint8;
306
#endif
307
308
#if defined __UINT_LEAST16_MAX__ && __UINT_LEAST16_MAX__ <= __INT_MAX__
309
typedef __UINT_LEAST16_TYPE__ yytype_uint16;
310
#elif (!defined __UINT_LEAST16_MAX__ && defined YY_STDINT_H \
311
       && UINT_LEAST16_MAX <= INT_MAX)
312
typedef uint_least16_t yytype_uint16;
313
#elif !defined __UINT_LEAST16_MAX__ && USHRT_MAX <= INT_MAX
314
typedef unsigned short yytype_uint16;
315
#else
316
typedef int yytype_uint16;
317
#endif
318
319
#ifndef YYPTRDIFF_T
320
# if defined __PTRDIFF_TYPE__ && defined __PTRDIFF_MAX__
321
0
#  define YYPTRDIFF_T __PTRDIFF_TYPE__
322
#  define YYPTRDIFF_MAXIMUM __PTRDIFF_MAX__
323
# elif defined PTRDIFF_MAX
324
#  ifndef ptrdiff_t
325
#   include <stddef.h> /* INFRINGES ON USER NAME SPACE */
326
#  endif
327
#  define YYPTRDIFF_T ptrdiff_t
328
#  define YYPTRDIFF_MAXIMUM PTRDIFF_MAX
329
# else
330
#  define YYPTRDIFF_T long
331
#  define YYPTRDIFF_MAXIMUM LONG_MAX
332
# endif
333
#endif
334
335
#ifndef YYSIZE_T
336
# ifdef __SIZE_TYPE__
337
#  define YYSIZE_T __SIZE_TYPE__
338
# elif defined size_t
339
#  define YYSIZE_T size_t
340
# elif defined __STDC_VERSION__ && 199901 <= __STDC_VERSION__
341
#  include <stddef.h> /* INFRINGES ON USER NAME SPACE */
342
#  define YYSIZE_T size_t
343
# else
344
#  define YYSIZE_T unsigned
345
# endif
346
#endif
347
348
#define YYSIZE_MAXIMUM                                  \
349
  YY_CAST (YYPTRDIFF_T,                                 \
350
           (YYPTRDIFF_MAXIMUM < YY_CAST (YYSIZE_T, -1)  \
351
            ? YYPTRDIFF_MAXIMUM                         \
352
            : YY_CAST (YYSIZE_T, -1)))
353
354
0
#define YYSIZEOF(X) YY_CAST (YYPTRDIFF_T, sizeof (X))
355
356
357
/* Stored state numbers (used for stacks). */
358
typedef yytype_int8 yy_state_t;
359
360
/* State numbers in computations.  */
361
typedef int yy_state_fast_t;
362
363
#ifndef YY_
364
# if defined YYENABLE_NLS && YYENABLE_NLS
365
#  if ENABLE_NLS
366
#   include <libintl.h> /* INFRINGES ON USER NAME SPACE */
367
0
#   define YY_(Msgid) dgettext ("bison-runtime", Msgid)
368
#  endif
369
# endif
370
# ifndef YY_
371
#  define YY_(Msgid) Msgid
372
# endif
373
#endif
374
375
376
#ifndef YY_ATTRIBUTE_PURE
377
# if defined __GNUC__ && 2 < __GNUC__ + (96 <= __GNUC_MINOR__)
378
#  define YY_ATTRIBUTE_PURE __attribute__ ((__pure__))
379
# else
380
#  define YY_ATTRIBUTE_PURE
381
# endif
382
#endif
383
384
#ifndef YY_ATTRIBUTE_UNUSED
385
# if defined __GNUC__ && 2 < __GNUC__ + (7 <= __GNUC_MINOR__)
386
#  define YY_ATTRIBUTE_UNUSED __attribute__ ((__unused__))
387
# else
388
#  define YY_ATTRIBUTE_UNUSED
389
# endif
390
#endif
391
392
/* Suppress unused-variable warnings by "using" E.  */
393
#if ! defined lint || defined __GNUC__
394
0
# define YY_USE(E) ((void) (E))
395
#else
396
# define YY_USE(E) /* empty */
397
#endif
398
399
/* Suppress an incorrect diagnostic about yylval being uninitialized.  */
400
#if defined __GNUC__ && ! defined __ICC && 406 <= __GNUC__ * 100 + __GNUC_MINOR__
401
# if __GNUC__ * 100 + __GNUC_MINOR__ < 407
402
#  define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN                           \
403
    _Pragma ("GCC diagnostic push")                                     \
404
    _Pragma ("GCC diagnostic ignored \"-Wuninitialized\"")
405
# else
406
#  define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN                           \
407
    _Pragma ("GCC diagnostic push")                                     \
408
    _Pragma ("GCC diagnostic ignored \"-Wuninitialized\"")              \
409
    _Pragma ("GCC diagnostic ignored \"-Wmaybe-uninitialized\"")
410
# endif
411
# define YY_IGNORE_MAYBE_UNINITIALIZED_END      \
412
    _Pragma ("GCC diagnostic pop")
413
#else
414
0
# define YY_INITIAL_VALUE(Value) Value
415
#endif
416
#ifndef YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
417
# define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
418
# define YY_IGNORE_MAYBE_UNINITIALIZED_END
419
#endif
420
#ifndef YY_INITIAL_VALUE
421
# define YY_INITIAL_VALUE(Value) /* Nothing. */
422
#endif
423
424
#if defined __cplusplus && defined __GNUC__ && ! defined __ICC && 6 <= __GNUC__
425
# define YY_IGNORE_USELESS_CAST_BEGIN                          \
426
    _Pragma ("GCC diagnostic push")                            \
427
    _Pragma ("GCC diagnostic ignored \"-Wuseless-cast\"")
428
# define YY_IGNORE_USELESS_CAST_END            \
429
    _Pragma ("GCC diagnostic pop")
430
#endif
431
#ifndef YY_IGNORE_USELESS_CAST_BEGIN
432
# define YY_IGNORE_USELESS_CAST_BEGIN
433
# define YY_IGNORE_USELESS_CAST_END
434
#endif
435
436
437
0
#define YY_ASSERT(E) ((void) (0 && (E)))
438
439
#if !defined yyoverflow
440
441
/* The parser invokes alloca or malloc; define the necessary symbols.  */
442
443
# ifdef YYSTACK_USE_ALLOCA
444
#  if YYSTACK_USE_ALLOCA
445
#   ifdef __GNUC__
446
#    define YYSTACK_ALLOC __builtin_alloca
447
#   elif defined __BUILTIN_VA_ARG_INCR
448
#    include <alloca.h> /* INFRINGES ON USER NAME SPACE */
449
#   elif defined _AIX
450
#    define YYSTACK_ALLOC __alloca
451
#   elif defined _MSC_VER
452
#    include <malloc.h> /* INFRINGES ON USER NAME SPACE */
453
#    define alloca _alloca
454
#   else
455
#    define YYSTACK_ALLOC alloca
456
#    if ! defined _ALLOCA_H && ! defined EXIT_SUCCESS
457
#     include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
458
      /* Use EXIT_SUCCESS as a witness for stdlib.h.  */
459
#     ifndef EXIT_SUCCESS
460
#      define EXIT_SUCCESS 0
461
#     endif
462
#    endif
463
#   endif
464
#  endif
465
# endif
466
467
# ifdef YYSTACK_ALLOC
468
   /* Pacify GCC's 'empty if-body' warning.  */
469
#  define YYSTACK_FREE(Ptr) do { /* empty */; } while (0)
470
#  ifndef YYSTACK_ALLOC_MAXIMUM
471
    /* The OS might guarantee only one guard page at the bottom of the stack,
472
       and a page size can be as small as 4096 bytes.  So we cannot safely
473
       invoke alloca (N) if N exceeds 4096.  Use a slightly smaller number
474
       to allow for a few compiler-allocated temporary stack slots.  */
475
#   define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2006 */
476
#  endif
477
# else
478
#  define YYSTACK_ALLOC YYMALLOC
479
0
#  define YYSTACK_FREE YYFREE
480
#  ifndef YYSTACK_ALLOC_MAXIMUM
481
#   define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM
482
#  endif
483
#  if (defined __cplusplus && ! defined EXIT_SUCCESS \
484
       && ! ((defined YYMALLOC || defined malloc) \
485
             && (defined YYFREE || defined free)))
486
#   include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
487
#   ifndef EXIT_SUCCESS
488
#    define EXIT_SUCCESS 0
489
#   endif
490
#  endif
491
#  ifndef YYMALLOC
492
#   define YYMALLOC malloc
493
#   if ! defined malloc && ! defined EXIT_SUCCESS
494
void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */
495
#   endif
496
#  endif
497
#  ifndef YYFREE
498
0
#   define YYFREE free
499
#   if ! defined free && ! defined EXIT_SUCCESS
500
void free (void *); /* INFRINGES ON USER NAME SPACE */
501
#   endif
502
#  endif
503
# endif
504
#endif /* !defined yyoverflow */
505
506
#if (! defined yyoverflow \
507
     && (! defined __cplusplus \
508
         || (defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL)))
509
510
/* A type that is properly aligned for any stack member.  */
511
union yyalloc
512
{
513
  yy_state_t yyss_alloc;
514
  YYSTYPE yyvs_alloc;
515
};
516
517
/* The size of the maximum gap between one aligned stack and the next.  */
518
0
# define YYSTACK_GAP_MAXIMUM (YYSIZEOF (union yyalloc) - 1)
519
520
/* The size of an array large to enough to hold all stacks, each with
521
   N elements.  */
522
# define YYSTACK_BYTES(N) \
523
     ((N) * (YYSIZEOF (yy_state_t) + YYSIZEOF (YYSTYPE)) \
524
      + YYSTACK_GAP_MAXIMUM)
525
526
# define YYCOPY_NEEDED 1
527
528
/* Relocate STACK from its old location to the new one.  The
529
   local variables YYSIZE and YYSTACKSIZE give the old and new number of
530
   elements in the stack, and YYPTR gives the new location of the
531
   stack.  Advance YYPTR to a properly aligned location for the next
532
   stack.  */
533
# define YYSTACK_RELOCATE(Stack_alloc, Stack)                           \
534
0
    do                                                                  \
535
0
      {                                                                 \
536
0
        YYPTRDIFF_T yynewbytes;                                         \
537
0
        YYCOPY (&yyptr->Stack_alloc, Stack, yysize);                    \
538
0
        Stack = &yyptr->Stack_alloc;                                    \
539
0
        yynewbytes = yystacksize * YYSIZEOF (*Stack) + YYSTACK_GAP_MAXIMUM; \
540
0
        yyptr += yynewbytes / YYSIZEOF (*yyptr);                        \
541
0
      }                                                                 \
542
0
    while (0)
543
544
#endif
545
546
#if defined YYCOPY_NEEDED && YYCOPY_NEEDED
547
/* Copy COUNT objects from SRC to DST.  The source and destination do
548
   not overlap.  */
549
# ifndef YYCOPY
550
#  if defined __GNUC__ && 1 < __GNUC__
551
#   define YYCOPY(Dst, Src, Count) \
552
0
      __builtin_memcpy (Dst, Src, YY_CAST (YYSIZE_T, (Count)) * sizeof (*(Src)))
553
#  else
554
#   define YYCOPY(Dst, Src, Count)              \
555
      do                                        \
556
        {                                       \
557
          YYPTRDIFF_T yyi;                      \
558
          for (yyi = 0; yyi < (Count); yyi++)   \
559
            (Dst)[yyi] = (Src)[yyi];            \
560
        }                                       \
561
      while (0)
562
#  endif
563
# endif
564
#endif /* !YYCOPY_NEEDED */
565
566
/* YYFINAL -- State number of the termination state.  */
567
0
#define YYFINAL  9
568
/* YYLAST -- Last index in YYTABLE.  */
569
0
#define YYLAST   58
570
571
/* YYNTOKENS -- Number of terminals.  */
572
0
#define YYNTOKENS  16
573
/* YYNNTS -- Number of nonterminals.  */
574
#define YYNNTS  3
575
/* YYNRULES -- Number of rules.  */
576
#define YYNRULES  13
577
/* YYNSTATES -- Number of states.  */
578
#define YYNSTATES  27
579
580
/* YYMAXUTOK -- Last valid token kind.  */
581
0
#define YYMAXUTOK   262
582
583
584
/* YYTRANSLATE(TOKEN-NUM) -- Symbol number corresponding to TOKEN-NUM
585
   as returned by yylex, with out-of-bounds checking.  */
586
#define YYTRANSLATE(YYX)                                \
587
0
  (0 <= (YYX) && (YYX) <= YYMAXUTOK                     \
588
0
   ? YY_CAST (yysymbol_kind_t, yytranslate[YYX])        \
589
0
   : YYSYMBOL_YYUNDEF)
590
591
/* YYTRANSLATE[TOKEN-NUM] -- Symbol number corresponding to TOKEN-NUM
592
   as returned by yylex.  */
593
static const yytype_int8 yytranslate[] =
594
{
595
       0,     2,     2,     2,     2,     2,     2,     2,     2,     2,
596
       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
597
       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
598
       2,     2,     2,     7,     2,     2,     2,     2,     6,     2,
599
      14,    15,     2,     2,     2,     2,     2,     2,     2,     2,
600
       2,     2,     2,     2,     2,     2,     2,     2,     4,     2,
601
       2,     2,     2,     3,     2,     2,     2,     2,     2,     2,
602
       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
603
       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
604
       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
605
       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
606
      13,     2,     2,     2,     2,     2,     2,     2,     2,     2,
607
       2,     2,     2,     2,     5,     2,     2,     2,     2,     2,
608
       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
609
       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
610
       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
611
       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
612
       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
613
       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
614
       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
615
       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
616
       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
617
       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
618
       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
619
       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
620
       2,     2,     2,     2,     2,     2,     1,     2,     8,     9,
621
      10,    11,    12
622
};
623
624
#if YYDEBUG
625
/* YYRLINE[YYN] -- Source line where rule number YYN was defined.  */
626
static const yytype_uint8 yyrline[] =
627
{
628
       0,   150,   150,   158,   162,   166,   170,   174,   178,   182,
629
     186,   190,   194,   199
630
};
631
#endif
632
633
/** Accessing symbol of state STATE.  */
634
0
#define YY_ACCESSING_SYMBOL(State) YY_CAST (yysymbol_kind_t, yystos[State])
635
636
#if YYDEBUG || 0
637
/* The user-facing name of the symbol whose (internal) number is
638
   YYSYMBOL.  No bounds checking.  */
639
static const char *yysymbol_name (yysymbol_kind_t yysymbol) YY_ATTRIBUTE_UNUSED;
640
641
/* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
642
   First, the terminals, then, starting at YYNTOKENS, nonterminals.  */
643
static const char *const yytname[] =
644
{
645
  "\"end of file\"", "error", "\"invalid token\"", "'?'", "':'", "'|'",
646
  "'&'", "'!'", "EQUOP2", "CMPOP2", "ADDOP2", "MULOP2", "NUMBER", "'n'",
647
  "'('", "')'", "$accept", "start", "exp", YY_NULLPTR
648
};
649
650
static const char *
651
yysymbol_name (yysymbol_kind_t yysymbol)
652
{
653
  return yytname[yysymbol];
654
}
655
#endif
656
657
0
#define YYPACT_NINF (-8)
658
659
#define yypact_value_is_default(Yyn) \
660
0
  ((Yyn) == YYPACT_NINF)
661
662
#define YYTABLE_NINF (-1)
663
664
#define yytable_value_is_error(Yyn) \
665
0
  0
666
667
/* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
668
   STATE-NUM.  */
669
static const yytype_int8 yypact[] =
670
{
671
      -6,    -6,    -8,    -8,    -6,     2,    39,    -8,    17,    -8,
672
      -6,    -6,    -6,    -6,    -6,    -6,    -6,    -8,    30,    45,
673
       8,    20,    47,    -7,    -8,    -6,    39
674
};
675
676
/* YYDEFACT[STATE-NUM] -- Default reduction number in state STATE-NUM.
677
   Performed when YYTABLE does not specify something else to do.  Zero
678
   means the default is an error.  */
679
static const yytype_int8 yydefact[] =
680
{
681
       0,     0,    12,    11,     0,     0,     2,    10,     0,     1,
682
       0,     0,     0,     0,     0,     0,     0,    13,     0,     4,
683
       5,     6,     7,     8,     9,     0,     3
684
};
685
686
/* YYPGOTO[NTERM-NUM].  */
687
static const yytype_int8 yypgoto[] =
688
{
689
      -8,    -8,    -1
690
};
691
692
/* YYDEFGOTO[NTERM-NUM].  */
693
static const yytype_int8 yydefgoto[] =
694
{
695
       0,     5,     6
696
};
697
698
/* YYTABLE[YYPACT[STATE-NUM]] -- What to do in state STATE-NUM.  If
699
   positive, shift that token.  If negative, reduce the rule whose
700
   number is the opposite.  If YYTABLE_NINF, syntax error.  */
701
static const yytype_int8 yytable[] =
702
{
703
       7,     1,     9,     8,    16,     0,     2,     3,     4,    18,
704
      19,    20,    21,    22,    23,    24,    13,    14,    15,    16,
705
      10,     0,    11,    12,    26,    13,    14,    15,    16,    14,
706
      15,    16,    17,    10,    25,    11,    12,     0,    13,    14,
707
      15,    16,    10,     0,    11,    12,     0,    13,    14,    15,
708
      16,    12,     0,    13,    14,    15,    16,    15,    16
709
};
710
711
static const yytype_int8 yycheck[] =
712
{
713
       1,     7,     0,     4,    11,    -1,    12,    13,    14,    10,
714
      11,    12,    13,    14,    15,    16,     8,     9,    10,    11,
715
       3,    -1,     5,     6,    25,     8,     9,    10,    11,     9,
716
      10,    11,    15,     3,     4,     5,     6,    -1,     8,     9,
717
      10,    11,     3,    -1,     5,     6,    -1,     8,     9,    10,
718
      11,     6,    -1,     8,     9,    10,    11,    10,    11
719
};
720
721
/* YYSTOS[STATE-NUM] -- The symbol kind of the accessing symbol of
722
   state STATE-NUM.  */
723
static const yytype_int8 yystos[] =
724
{
725
       0,     7,    12,    13,    14,    17,    18,    18,    18,     0,
726
       3,     5,     6,     8,     9,    10,    11,    15,    18,    18,
727
      18,    18,    18,    18,    18,     4,    18
728
};
729
730
/* YYR1[RULE-NUM] -- Symbol kind of the left-hand side of rule RULE-NUM.  */
731
static const yytype_int8 yyr1[] =
732
{
733
       0,    16,    17,    18,    18,    18,    18,    18,    18,    18,
734
      18,    18,    18,    18
735
};
736
737
/* YYR2[RULE-NUM] -- Number of symbols on the right-hand side of rule RULE-NUM.  */
738
static const yytype_int8 yyr2[] =
739
{
740
       0,     2,     1,     5,     3,     3,     3,     3,     3,     3,
741
       2,     1,     1,     3
742
};
743
744
745
enum { YYENOMEM = -2 };
746
747
#define yyerrok         (yyerrstatus = 0)
748
#define yyclearin       (yychar = YYEMPTY)
749
750
0
#define YYACCEPT        goto yyacceptlab
751
0
#define YYABORT         goto yyabortlab
752
0
#define YYERROR         goto yyerrorlab
753
0
#define YYNOMEM         goto yyexhaustedlab
754
755
756
#define YYRECOVERING()  (!!yyerrstatus)
757
758
#define YYBACKUP(Token, Value)                                    \
759
  do                                                              \
760
    if (yychar == YYEMPTY)                                        \
761
      {                                                           \
762
        yychar = (Token);                                         \
763
        yylval = (Value);                                         \
764
        YYPOPSTACK (yylen);                                       \
765
        yystate = *yyssp;                                         \
766
        goto yybackup;                                            \
767
      }                                                           \
768
    else                                                          \
769
      {                                                           \
770
        yyerror (arg, YY_("syntax error: cannot back up")); \
771
        YYERROR;                                                  \
772
      }                                                           \
773
  while (0)
774
775
/* Backward compatibility with an undocumented macro.
776
   Use YYerror or YYUNDEF. */
777
0
#define YYERRCODE YYUNDEF
778
779
780
/* Enable debugging if requested.  */
781
#if YYDEBUG
782
783
# ifndef YYFPRINTF
784
#  include <stdio.h> /* INFRINGES ON USER NAME SPACE */
785
#  define YYFPRINTF fprintf
786
# endif
787
788
# define YYDPRINTF(Args)                        \
789
do {                                            \
790
  if (yydebug)                                  \
791
    YYFPRINTF Args;                             \
792
} while (0)
793
794
795
796
797
# define YY_SYMBOL_PRINT(Title, Kind, Value, Location)                    \
798
do {                                                                      \
799
  if (yydebug)                                                            \
800
    {                                                                     \
801
      YYFPRINTF (stderr, "%s ", Title);                                   \
802
      yy_symbol_print (stderr,                                            \
803
                  Kind, Value, arg); \
804
      YYFPRINTF (stderr, "\n");                                           \
805
    }                                                                     \
806
} while (0)
807
808
809
/*-----------------------------------.
810
| Print this symbol's value on YYO.  |
811
`-----------------------------------*/
812
813
static void
814
yy_symbol_value_print (FILE *yyo,
815
                       yysymbol_kind_t yykind, YYSTYPE const * const yyvaluep, struct parse_args *arg)
816
{
817
  FILE *yyoutput = yyo;
818
  YY_USE (yyoutput);
819
  YY_USE (arg);
820
  if (!yyvaluep)
821
    return;
822
  YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
823
  YY_USE (yykind);
824
  YY_IGNORE_MAYBE_UNINITIALIZED_END
825
}
826
827
828
/*---------------------------.
829
| Print this symbol on YYO.  |
830
`---------------------------*/
831
832
static void
833
yy_symbol_print (FILE *yyo,
834
                 yysymbol_kind_t yykind, YYSTYPE const * const yyvaluep, struct parse_args *arg)
835
{
836
  YYFPRINTF (yyo, "%s %s (",
837
             yykind < YYNTOKENS ? "token" : "nterm", yysymbol_name (yykind));
838
839
  yy_symbol_value_print (yyo, yykind, yyvaluep, arg);
840
  YYFPRINTF (yyo, ")");
841
}
842
843
/*------------------------------------------------------------------.
844
| yy_stack_print -- Print the state stack from its BOTTOM up to its |
845
| TOP (included).                                                   |
846
`------------------------------------------------------------------*/
847
848
static void
849
yy_stack_print (yy_state_t *yybottom, yy_state_t *yytop)
850
{
851
  YYFPRINTF (stderr, "Stack now");
852
  for (; yybottom <= yytop; yybottom++)
853
    {
854
      int yybot = *yybottom;
855
      YYFPRINTF (stderr, " %d", yybot);
856
    }
857
  YYFPRINTF (stderr, "\n");
858
}
859
860
# define YY_STACK_PRINT(Bottom, Top)                            \
861
do {                                                            \
862
  if (yydebug)                                                  \
863
    yy_stack_print ((Bottom), (Top));                           \
864
} while (0)
865
866
867
/*------------------------------------------------.
868
| Report that the YYRULE is going to be reduced.  |
869
`------------------------------------------------*/
870
871
static void
872
yy_reduce_print (yy_state_t *yyssp, YYSTYPE *yyvsp,
873
                 int yyrule, struct parse_args *arg)
874
{
875
  int yylno = yyrline[yyrule];
876
  int yynrhs = yyr2[yyrule];
877
  int yyi;
878
  YYFPRINTF (stderr, "Reducing stack by rule %d (line %d):\n",
879
             yyrule - 1, yylno);
880
  /* The symbols being reduced.  */
881
  for (yyi = 0; yyi < yynrhs; yyi++)
882
    {
883
      YYFPRINTF (stderr, "   $%d = ", yyi + 1);
884
      yy_symbol_print (stderr,
885
                       YY_ACCESSING_SYMBOL (+yyssp[yyi + 1 - yynrhs]),
886
                       &yyvsp[(yyi + 1) - (yynrhs)], arg);
887
      YYFPRINTF (stderr, "\n");
888
    }
889
}
890
891
# define YY_REDUCE_PRINT(Rule)          \
892
do {                                    \
893
  if (yydebug)                          \
894
    yy_reduce_print (yyssp, yyvsp, Rule, arg); \
895
} while (0)
896
897
/* Nonzero means print parse trace.  It is left uninitialized so that
898
   multiple parsers can coexist.  */
899
int yydebug;
900
#else /* !YYDEBUG */
901
0
# define YYDPRINTF(Args) ((void) 0)
902
# define YY_SYMBOL_PRINT(Title, Kind, Value, Location)
903
# define YY_STACK_PRINT(Bottom, Top)
904
# define YY_REDUCE_PRINT(Rule)
905
#endif /* !YYDEBUG */
906
907
908
/* YYINITDEPTH -- initial size of the parser's stacks.  */
909
#ifndef YYINITDEPTH
910
0
# define YYINITDEPTH 200
911
#endif
912
913
/* YYMAXDEPTH -- maximum size the stacks can grow to (effective only
914
   if the built-in stack extension method is used).
915
916
   Do not make this value too large; the results are undefined if
917
   YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH)
918
   evaluated with infinite-precision integer arithmetic.  */
919
920
#ifndef YYMAXDEPTH
921
0
# define YYMAXDEPTH 10000
922
#endif
923
924
925
926
927
928
929
/*-----------------------------------------------.
930
| Release the memory associated to this symbol.  |
931
`-----------------------------------------------*/
932
933
static void
934
yydestruct (const char *yymsg,
935
            yysymbol_kind_t yykind, YYSTYPE *yyvaluep, struct parse_args *arg)
936
0
{
937
0
  YY_USE (yyvaluep);
938
0
  YY_USE (arg);
939
0
  if (!yymsg)
940
0
    yymsg = "Deleting";
941
0
  YY_SYMBOL_PRINT (yymsg, yykind, yyvaluep, yylocationp);
942
943
0
  YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
944
0
  YY_USE (yykind);
945
0
  YY_IGNORE_MAYBE_UNINITIALIZED_END
946
0
}
947
948
949
950
951
952
953
/*----------.
954
| yyparse.  |
955
`----------*/
956
957
int
958
yyparse (struct parse_args *arg)
959
0
{
960
/* Lookahead token kind.  */
961
0
int yychar;
962
963
964
/* The semantic value of the lookahead symbol.  */
965
/* Default value used for initialization, for pacifying older GCCs
966
   or non-GCC compilers.  */
967
0
YY_INITIAL_VALUE (static YYSTYPE yyval_default;)
968
0
YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default);
969
970
    /* Number of syntax errors so far.  */
971
0
    int yynerrs = 0;
972
973
0
    yy_state_fast_t yystate = 0;
974
    /* Number of tokens to shift before error messages enabled.  */
975
0
    int yyerrstatus = 0;
976
977
    /* Refer to the stacks through separate pointers, to allow yyoverflow
978
       to reallocate them elsewhere.  */
979
980
    /* Their size.  */
981
0
    YYPTRDIFF_T yystacksize = YYINITDEPTH;
982
983
    /* The state stack: array, bottom, top.  */
984
0
    yy_state_t yyssa[YYINITDEPTH];
985
0
    yy_state_t *yyss = yyssa;
986
0
    yy_state_t *yyssp = yyss;
987
988
    /* The semantic value stack: array, bottom, top.  */
989
0
    YYSTYPE yyvsa[YYINITDEPTH];
990
0
    YYSTYPE *yyvs = yyvsa;
991
0
    YYSTYPE *yyvsp = yyvs;
992
993
0
  int yyn;
994
  /* The return value of yyparse.  */
995
0
  int yyresult;
996
  /* Lookahead symbol kind.  */
997
0
  yysymbol_kind_t yytoken = YYSYMBOL_YYEMPTY;
998
  /* The variables used to return semantic value and location from the
999
     action routines.  */
1000
0
  YYSTYPE yyval;
1001
1002
1003
1004
0
#define YYPOPSTACK(N)   (yyvsp -= (N), yyssp -= (N))
1005
1006
  /* The number of symbols on the RHS of the reduced rule.
1007
     Keep to zero when no symbol should be popped.  */
1008
0
  int yylen = 0;
1009
1010
0
  YYDPRINTF ((stderr, "Starting parse\n"));
1011
1012
0
  yychar = YYEMPTY; /* Cause a token to be read.  */
1013
1014
0
  goto yysetstate;
1015
1016
1017
/*------------------------------------------------------------.
1018
| yynewstate -- push a new state, which is found in yystate.  |
1019
`------------------------------------------------------------*/
1020
0
yynewstate:
1021
  /* In all cases, when you get here, the value and location stacks
1022
     have just been pushed.  So pushing a state here evens the stacks.  */
1023
0
  yyssp++;
1024
1025
1026
/*--------------------------------------------------------------------.
1027
| yysetstate -- set current state (the top of the stack) to yystate.  |
1028
`--------------------------------------------------------------------*/
1029
0
yysetstate:
1030
0
  YYDPRINTF ((stderr, "Entering state %d\n", yystate));
1031
0
  YY_ASSERT (0 <= yystate && yystate < YYNSTATES);
1032
0
  YY_IGNORE_USELESS_CAST_BEGIN
1033
0
  *yyssp = YY_CAST (yy_state_t, yystate);
1034
0
  YY_IGNORE_USELESS_CAST_END
1035
0
  YY_STACK_PRINT (yyss, yyssp);
1036
1037
0
  if (yyss + yystacksize - 1 <= yyssp)
1038
#if !defined yyoverflow && !defined YYSTACK_RELOCATE
1039
    YYNOMEM;
1040
#else
1041
0
    {
1042
      /* Get the current used size of the three stacks, in elements.  */
1043
0
      YYPTRDIFF_T yysize = yyssp - yyss + 1;
1044
1045
# if defined yyoverflow
1046
      {
1047
        /* Give user a chance to reallocate the stack.  Use copies of
1048
           these so that the &'s don't force the real ones into
1049
           memory.  */
1050
        yy_state_t *yyss1 = yyss;
1051
        YYSTYPE *yyvs1 = yyvs;
1052
1053
        /* Each stack pointer address is followed by the size of the
1054
           data in use in that stack, in bytes.  This used to be a
1055
           conditional around just the two extra args, but that might
1056
           be undefined if yyoverflow is a macro.  */
1057
        yyoverflow (YY_("memory exhausted"),
1058
                    &yyss1, yysize * YYSIZEOF (*yyssp),
1059
                    &yyvs1, yysize * YYSIZEOF (*yyvsp),
1060
                    &yystacksize);
1061
        yyss = yyss1;
1062
        yyvs = yyvs1;
1063
      }
1064
# else /* defined YYSTACK_RELOCATE */
1065
      /* Extend the stack our own way.  */
1066
0
      if (YYMAXDEPTH <= yystacksize)
1067
0
        YYNOMEM;
1068
0
      yystacksize *= 2;
1069
0
      if (YYMAXDEPTH < yystacksize)
1070
0
        yystacksize = YYMAXDEPTH;
1071
1072
0
      {
1073
0
        yy_state_t *yyss1 = yyss;
1074
0
        union yyalloc *yyptr =
1075
0
          YY_CAST (union yyalloc *,
1076
0
                   YYSTACK_ALLOC (YY_CAST (YYSIZE_T, YYSTACK_BYTES (yystacksize))));
1077
0
        if (! yyptr)
1078
0
          YYNOMEM;
1079
0
        YYSTACK_RELOCATE (yyss_alloc, yyss);
1080
0
        YYSTACK_RELOCATE (yyvs_alloc, yyvs);
1081
0
#  undef YYSTACK_RELOCATE
1082
0
        if (yyss1 != yyssa)
1083
0
          YYSTACK_FREE (yyss1);
1084
0
      }
1085
0
# endif
1086
1087
0
      yyssp = yyss + yysize - 1;
1088
0
      yyvsp = yyvs + yysize - 1;
1089
1090
0
      YY_IGNORE_USELESS_CAST_BEGIN
1091
0
      YYDPRINTF ((stderr, "Stack size increased to %ld\n",
1092
0
                  YY_CAST (long, yystacksize)));
1093
0
      YY_IGNORE_USELESS_CAST_END
1094
1095
0
      if (yyss + yystacksize - 1 <= yyssp)
1096
0
        YYABORT;
1097
0
    }
1098
0
#endif /* !defined yyoverflow && !defined YYSTACK_RELOCATE */
1099
1100
1101
0
  if (yystate == YYFINAL)
1102
0
    YYACCEPT;
1103
1104
0
  goto yybackup;
1105
1106
1107
/*-----------.
1108
| yybackup.  |
1109
`-----------*/
1110
0
yybackup:
1111
  /* Do appropriate processing given the current state.  Read a
1112
     lookahead token if we need one and don't already have one.  */
1113
1114
  /* First try to decide what to do without reference to lookahead token.  */
1115
0
  yyn = yypact[yystate];
1116
0
  if (yypact_value_is_default (yyn))
1117
0
    goto yydefault;
1118
1119
  /* Not known => get a lookahead token if don't already have one.  */
1120
1121
  /* YYCHAR is either empty, or end-of-input, or a valid lookahead.  */
1122
0
  if (yychar == YYEMPTY)
1123
0
    {
1124
0
      YYDPRINTF ((stderr, "Reading a token\n"));
1125
0
      yychar = yylex (&yylval, arg);
1126
0
    }
1127
1128
0
  if (yychar <= YYEOF)
1129
0
    {
1130
0
      yychar = YYEOF;
1131
0
      yytoken = YYSYMBOL_YYEOF;
1132
0
      YYDPRINTF ((stderr, "Now at end of input.\n"));
1133
0
    }
1134
0
  else if (yychar == YYerror)
1135
0
    {
1136
      /* The scanner already issued an error message, process directly
1137
         to error recovery.  But do not keep the error token as
1138
         lookahead, it is too special and may lead us to an endless
1139
         loop in error recovery. */
1140
0
      yychar = YYUNDEF;
1141
0
      yytoken = YYSYMBOL_YYerror;
1142
0
      goto yyerrlab1;
1143
0
    }
1144
0
  else
1145
0
    {
1146
0
      yytoken = YYTRANSLATE (yychar);
1147
0
      YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc);
1148
0
    }
1149
1150
  /* If the proper action on seeing token YYTOKEN is to reduce or to
1151
     detect an error, take that action.  */
1152
0
  yyn += yytoken;
1153
0
  if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken)
1154
0
    goto yydefault;
1155
0
  yyn = yytable[yyn];
1156
0
  if (yyn <= 0)
1157
0
    {
1158
0
      if (yytable_value_is_error (yyn))
1159
0
        goto yyerrlab;
1160
0
      yyn = -yyn;
1161
0
      goto yyreduce;
1162
0
    }
1163
1164
  /* Count tokens shifted since error; after three, turn off error
1165
     status.  */
1166
0
  if (yyerrstatus)
1167
0
    yyerrstatus--;
1168
1169
  /* Shift the lookahead token.  */
1170
0
  YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc);
1171
0
  yystate = yyn;
1172
0
  YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
1173
0
  *++yyvsp = yylval;
1174
0
  YY_IGNORE_MAYBE_UNINITIALIZED_END
1175
1176
  /* Discard the shifted token.  */
1177
0
  yychar = YYEMPTY;
1178
0
  goto yynewstate;
1179
1180
1181
/*-----------------------------------------------------------.
1182
| yydefault -- do the default action for the current state.  |
1183
`-----------------------------------------------------------*/
1184
0
yydefault:
1185
0
  yyn = yydefact[yystate];
1186
0
  if (yyn == 0)
1187
0
    goto yyerrlab;
1188
0
  goto yyreduce;
1189
1190
1191
/*-----------------------------.
1192
| yyreduce -- do a reduction.  |
1193
`-----------------------------*/
1194
0
yyreduce:
1195
  /* yyn is the number of a rule to reduce with.  */
1196
0
  yylen = yyr2[yyn];
1197
1198
  /* If YYLEN is nonzero, implement the default value of the action:
1199
     '$$ = $1'.
1200
1201
     Otherwise, the following line sets YYVAL to garbage.
1202
     This behavior is undocumented and Bison
1203
     users should not rely upon it.  Assigning to YYVAL
1204
     unconditionally makes the parser a bit smaller, and it avoids a
1205
     GCC warning that YYVAL may be used uninitialized.  */
1206
0
  yyval = yyvsp[1-yylen];
1207
1208
1209
0
  YY_REDUCE_PRINT (yyn);
1210
0
  switch (yyn)
1211
0
    {
1212
0
  case 2: /* start: exp  */
1213
0
#line 151 "plural.y"
1214
0
          {
1215
0
      if ((yyvsp[0].exp) == NULL)
1216
0
        YYABORT;
1217
0
      arg->res = (yyvsp[0].exp);
1218
0
    }
1219
0
#line 1220 "plural.c"
1220
0
    break;
1221
1222
0
  case 3: /* exp: exp '?' exp ':' exp  */
1223
0
#line 159 "plural.y"
1224
0
          {
1225
0
      (yyval.exp) = new_exp_3 (qmop, (yyvsp[-4].exp), (yyvsp[-2].exp), (yyvsp[0].exp));
1226
0
    }
1227
0
#line 1228 "plural.c"
1228
0
    break;
1229
1230
0
  case 4: /* exp: exp '|' exp  */
1231
0
#line 163 "plural.y"
1232
0
          {
1233
0
      (yyval.exp) = new_exp_2 (lor, (yyvsp[-2].exp), (yyvsp[0].exp));
1234
0
    }
1235
0
#line 1236 "plural.c"
1236
0
    break;
1237
1238
0
  case 5: /* exp: exp '&' exp  */
1239
0
#line 167 "plural.y"
1240
0
          {
1241
0
      (yyval.exp) = new_exp_2 (land, (yyvsp[-2].exp), (yyvsp[0].exp));
1242
0
    }
1243
0
#line 1244 "plural.c"
1244
0
    break;
1245
1246
0
  case 6: /* exp: exp EQUOP2 exp  */
1247
0
#line 171 "plural.y"
1248
0
          {
1249
0
      (yyval.exp) = new_exp_2 ((yyvsp[-1].op), (yyvsp[-2].exp), (yyvsp[0].exp));
1250
0
    }
1251
0
#line 1252 "plural.c"
1252
0
    break;
1253
1254
0
  case 7: /* exp: exp CMPOP2 exp  */
1255
0
#line 175 "plural.y"
1256
0
          {
1257
0
      (yyval.exp) = new_exp_2 ((yyvsp[-1].op), (yyvsp[-2].exp), (yyvsp[0].exp));
1258
0
    }
1259
0
#line 1260 "plural.c"
1260
0
    break;
1261
1262
0
  case 8: /* exp: exp ADDOP2 exp  */
1263
0
#line 179 "plural.y"
1264
0
          {
1265
0
      (yyval.exp) = new_exp_2 ((yyvsp[-1].op), (yyvsp[-2].exp), (yyvsp[0].exp));
1266
0
    }
1267
0
#line 1268 "plural.c"
1268
0
    break;
1269
1270
0
  case 9: /* exp: exp MULOP2 exp  */
1271
0
#line 183 "plural.y"
1272
0
          {
1273
0
      (yyval.exp) = new_exp_2 ((yyvsp[-1].op), (yyvsp[-2].exp), (yyvsp[0].exp));
1274
0
    }
1275
0
#line 1276 "plural.c"
1276
0
    break;
1277
1278
0
  case 10: /* exp: '!' exp  */
1279
0
#line 187 "plural.y"
1280
0
          {
1281
0
      (yyval.exp) = new_exp_1 (lnot, (yyvsp[0].exp));
1282
0
    }
1283
0
#line 1284 "plural.c"
1284
0
    break;
1285
1286
0
  case 11: /* exp: 'n'  */
1287
0
#line 191 "plural.y"
1288
0
          {
1289
0
      (yyval.exp) = new_exp_0 (var);
1290
0
    }
1291
0
#line 1292 "plural.c"
1292
0
    break;
1293
1294
0
  case 12: /* exp: NUMBER  */
1295
0
#line 195 "plural.y"
1296
0
          {
1297
0
      if (((yyval.exp) = new_exp_0 (num)) != NULL)
1298
0
        (yyval.exp)->val.num = (yyvsp[0].num);
1299
0
    }
1300
0
#line 1301 "plural.c"
1301
0
    break;
1302
1303
0
  case 13: /* exp: '(' exp ')'  */
1304
0
#line 200 "plural.y"
1305
0
          {
1306
0
      (yyval.exp) = (yyvsp[-1].exp);
1307
0
    }
1308
0
#line 1309 "plural.c"
1309
0
    break;
1310
1311
1312
0
#line 1313 "plural.c"
1313
1314
0
      default: break;
1315
0
    }
1316
  /* User semantic actions sometimes alter yychar, and that requires
1317
     that yytoken be updated with the new translation.  We take the
1318
     approach of translating immediately before every use of yytoken.
1319
     One alternative is translating here after every semantic action,
1320
     but that translation would be missed if the semantic action invokes
1321
     YYABORT, YYACCEPT, or YYERROR immediately after altering yychar or
1322
     if it invokes YYBACKUP.  In the case of YYABORT or YYACCEPT, an
1323
     incorrect destructor might then be invoked immediately.  In the
1324
     case of YYERROR or YYBACKUP, subsequent parser actions might lead
1325
     to an incorrect destructor call or verbose syntax error message
1326
     before the lookahead is translated.  */
1327
0
  YY_SYMBOL_PRINT ("-> $$ =", YY_CAST (yysymbol_kind_t, yyr1[yyn]), &yyval, &yyloc);
1328
1329
0
  YYPOPSTACK (yylen);
1330
0
  yylen = 0;
1331
1332
0
  *++yyvsp = yyval;
1333
1334
  /* Now 'shift' the result of the reduction.  Determine what state
1335
     that goes to, based on the state we popped back to and the rule
1336
     number reduced by.  */
1337
0
  {
1338
0
    const int yylhs = yyr1[yyn] - YYNTOKENS;
1339
0
    const int yyi = yypgoto[yylhs] + *yyssp;
1340
0
    yystate = (0 <= yyi && yyi <= YYLAST && yycheck[yyi] == *yyssp
1341
0
               ? yytable[yyi]
1342
0
               : yydefgoto[yylhs]);
1343
0
  }
1344
1345
0
  goto yynewstate;
1346
1347
1348
/*--------------------------------------.
1349
| yyerrlab -- here on detecting error.  |
1350
`--------------------------------------*/
1351
0
yyerrlab:
1352
  /* Make sure we have latest lookahead translation.  See comments at
1353
     user semantic actions for why this is necessary.  */
1354
0
  yytoken = yychar == YYEMPTY ? YYSYMBOL_YYEMPTY : YYTRANSLATE (yychar);
1355
  /* If not already recovering from an error, report this error.  */
1356
0
  if (!yyerrstatus)
1357
0
    {
1358
0
      ++yynerrs;
1359
0
      yyerror (arg, YY_("syntax error"));
1360
0
    }
1361
1362
0
  if (yyerrstatus == 3)
1363
0
    {
1364
      /* If just tried and failed to reuse lookahead token after an
1365
         error, discard it.  */
1366
1367
0
      if (yychar <= YYEOF)
1368
0
        {
1369
          /* Return failure if at end of input.  */
1370
0
          if (yychar == YYEOF)
1371
0
            YYABORT;
1372
0
        }
1373
0
      else
1374
0
        {
1375
0
          yydestruct ("Error: discarding",
1376
0
                      yytoken, &yylval, arg);
1377
0
          yychar = YYEMPTY;
1378
0
        }
1379
0
    }
1380
1381
  /* Else will try to reuse lookahead token after shifting the error
1382
     token.  */
1383
0
  goto yyerrlab1;
1384
1385
1386
/*---------------------------------------------------.
1387
| yyerrorlab -- error raised explicitly by YYERROR.  |
1388
`---------------------------------------------------*/
1389
0
yyerrorlab:
1390
  /* Pacify compilers when the user code never invokes YYERROR and the
1391
     label yyerrorlab therefore never appears in user code.  */
1392
0
  if (0)
1393
0
    YYERROR;
1394
0
  ++yynerrs;
1395
1396
  /* Do not reclaim the symbols of the rule whose action triggered
1397
     this YYERROR.  */
1398
0
  YYPOPSTACK (yylen);
1399
0
  yylen = 0;
1400
0
  YY_STACK_PRINT (yyss, yyssp);
1401
0
  yystate = *yyssp;
1402
0
  goto yyerrlab1;
1403
1404
1405
/*-------------------------------------------------------------.
1406
| yyerrlab1 -- common code for both syntax error and YYERROR.  |
1407
`-------------------------------------------------------------*/
1408
0
yyerrlab1:
1409
0
  yyerrstatus = 3;      /* Each real token shifted decrements this.  */
1410
1411
  /* Pop stack until we find a state that shifts the error token.  */
1412
0
  for (;;)
1413
0
    {
1414
0
      yyn = yypact[yystate];
1415
0
      if (!yypact_value_is_default (yyn))
1416
0
        {
1417
0
          yyn += YYSYMBOL_YYerror;
1418
0
          if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYSYMBOL_YYerror)
1419
0
            {
1420
0
              yyn = yytable[yyn];
1421
0
              if (0 < yyn)
1422
0
                break;
1423
0
            }
1424
0
        }
1425
1426
      /* Pop the current state because it cannot handle the error token.  */
1427
0
      if (yyssp == yyss)
1428
0
        YYABORT;
1429
1430
1431
0
      yydestruct ("Error: popping",
1432
0
                  YY_ACCESSING_SYMBOL (yystate), yyvsp, arg);
1433
0
      YYPOPSTACK (1);
1434
0
      yystate = *yyssp;
1435
0
      YY_STACK_PRINT (yyss, yyssp);
1436
0
    }
1437
1438
0
  YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
1439
0
  *++yyvsp = yylval;
1440
0
  YY_IGNORE_MAYBE_UNINITIALIZED_END
1441
1442
1443
  /* Shift the error token.  */
1444
0
  YY_SYMBOL_PRINT ("Shifting", YY_ACCESSING_SYMBOL (yyn), yyvsp, yylsp);
1445
1446
0
  yystate = yyn;
1447
0
  goto yynewstate;
1448
1449
1450
/*-------------------------------------.
1451
| yyacceptlab -- YYACCEPT comes here.  |
1452
`-------------------------------------*/
1453
0
yyacceptlab:
1454
0
  yyresult = 0;
1455
0
  goto yyreturnlab;
1456
1457
1458
/*-----------------------------------.
1459
| yyabortlab -- YYABORT comes here.  |
1460
`-----------------------------------*/
1461
0
yyabortlab:
1462
0
  yyresult = 1;
1463
0
  goto yyreturnlab;
1464
1465
1466
/*-----------------------------------------------------------.
1467
| yyexhaustedlab -- YYNOMEM (memory exhaustion) comes here.  |
1468
`-----------------------------------------------------------*/
1469
0
yyexhaustedlab:
1470
0
  yyerror (arg, YY_("memory exhausted"));
1471
0
  yyresult = 2;
1472
0
  goto yyreturnlab;
1473
1474
1475
/*----------------------------------------------------------.
1476
| yyreturnlab -- parsing is finished, clean up and return.  |
1477
`----------------------------------------------------------*/
1478
0
yyreturnlab:
1479
0
  if (yychar != YYEMPTY)
1480
0
    {
1481
      /* Make sure we have latest lookahead translation.  See comments at
1482
         user semantic actions for why this is necessary.  */
1483
0
      yytoken = YYTRANSLATE (yychar);
1484
0
      yydestruct ("Cleanup: discarding lookahead",
1485
0
                  yytoken, &yylval, arg);
1486
0
    }
1487
  /* Do not reclaim the symbols of the rule whose action triggered
1488
     this YYABORT or YYACCEPT.  */
1489
0
  YYPOPSTACK (yylen);
1490
0
  YY_STACK_PRINT (yyss, yyssp);
1491
0
  while (yyssp != yyss)
1492
0
    {
1493
0
      yydestruct ("Cleanup: popping",
1494
0
                  YY_ACCESSING_SYMBOL (+*yyssp), yyvsp, arg);
1495
0
      YYPOPSTACK (1);
1496
0
    }
1497
0
#ifndef yyoverflow
1498
0
  if (yyss != yyssa)
1499
0
    YYSTACK_FREE (yyss);
1500
0
#endif
1501
1502
0
  return yyresult;
1503
0
}
1504
1505
#line 205 "plural.y"
1506
1507
1508
void
1509
FREE_EXPRESSION (struct expression *exp)
1510
0
{
1511
0
  if (exp == NULL)
1512
0
    return;
1513
1514
  /* Handle the recursive case.  */
1515
0
  switch (exp->nargs)
1516
0
    {
1517
0
    case 3:
1518
0
      FREE_EXPRESSION (exp->val.args[2]);
1519
0
      FALLTHROUGH;
1520
0
    case 2:
1521
0
      FREE_EXPRESSION (exp->val.args[1]);
1522
0
      FALLTHROUGH;
1523
0
    case 1:
1524
0
      FREE_EXPRESSION (exp->val.args[0]);
1525
0
      FALLTHROUGH;
1526
0
    default:
1527
0
      break;
1528
0
    }
1529
1530
0
  free (exp);
1531
0
}
1532
1533
1534
static int
1535
yylex (YYSTYPE *lval, struct parse_args *arg)
1536
0
{
1537
0
  const char *exp = arg->cp;
1538
0
  int result;
1539
1540
0
  while (1)
1541
0
    {
1542
0
      if (exp[0] == '\0')
1543
0
  {
1544
0
    arg->cp = exp;
1545
0
    return YYEOF;
1546
0
  }
1547
1548
0
      if (exp[0] != ' ' && exp[0] != '\t')
1549
0
  break;
1550
1551
0
      ++exp;
1552
0
    }
1553
1554
0
  result = *exp++;
1555
0
  switch (result)
1556
0
    {
1557
0
    case '0': case '1': case '2': case '3': case '4':
1558
0
    case '5': case '6': case '7': case '8': case '9':
1559
0
      {
1560
0
  unsigned long int n = result - '0';
1561
0
  while (exp[0] >= '0' && exp[0] <= '9')
1562
0
    {
1563
0
      n *= 10;
1564
0
      n += exp[0] - '0';
1565
0
      ++exp;
1566
0
    }
1567
0
  lval->num = n;
1568
0
  result = NUMBER;
1569
0
      }
1570
0
      break;
1571
1572
0
    case '=':
1573
0
      if (exp[0] == '=')
1574
0
  {
1575
0
    ++exp;
1576
0
    lval->op = equal;
1577
0
    result = EQUOP2;
1578
0
  }
1579
0
      else
1580
0
  result = YYERRCODE;
1581
0
      break;
1582
1583
0
    case '!':
1584
0
      if (exp[0] == '=')
1585
0
  {
1586
0
    ++exp;
1587
0
    lval->op = not_equal;
1588
0
    result = EQUOP2;
1589
0
  }
1590
0
      break;
1591
1592
0
    case '&':
1593
0
    case '|':
1594
0
      if (exp[0] == result)
1595
0
  ++exp;
1596
0
      else
1597
0
  result = YYERRCODE;
1598
0
      break;
1599
1600
0
    case '<':
1601
0
      if (exp[0] == '=')
1602
0
  {
1603
0
    ++exp;
1604
0
    lval->op = less_or_equal;
1605
0
  }
1606
0
      else
1607
0
  lval->op = less_than;
1608
0
      result = CMPOP2;
1609
0
      break;
1610
1611
0
    case '>':
1612
0
      if (exp[0] == '=')
1613
0
  {
1614
0
    ++exp;
1615
0
    lval->op = greater_or_equal;
1616
0
  }
1617
0
      else
1618
0
  lval->op = greater_than;
1619
0
      result = CMPOP2;
1620
0
      break;
1621
1622
0
    case '*':
1623
0
      lval->op = mult;
1624
0
      result = MULOP2;
1625
0
      break;
1626
1627
0
    case '/':
1628
0
      lval->op = divide;
1629
0
      result = MULOP2;
1630
0
      break;
1631
1632
0
    case '%':
1633
0
      lval->op = module;
1634
0
      result = MULOP2;
1635
0
      break;
1636
1637
0
    case '+':
1638
0
      lval->op = plus;
1639
0
      result = ADDOP2;
1640
0
      break;
1641
1642
0
    case '-':
1643
0
      lval->op = minus;
1644
0
      result = ADDOP2;
1645
0
      break;
1646
1647
0
    case 'n':
1648
0
    case '?':
1649
0
    case ':':
1650
0
    case '(':
1651
0
    case ')':
1652
      /* Nothing, just return the character.  */
1653
0
      break;
1654
1655
0
    case ';':
1656
0
    case '\n':
1657
0
    case '\0':
1658
      /* Be safe and let the user call this function again.  */
1659
0
      --exp;
1660
0
      result = YYEOF;
1661
0
      break;
1662
1663
0
    default:
1664
0
      result = YYERRCODE;
1665
#if YYDEBUG != 0
1666
      --exp;
1667
#endif
1668
0
      break;
1669
0
    }
1670
1671
0
  arg->cp = exp;
1672
1673
0
  return result;
1674
0
}
1675
1676
1677
static void
1678
yyerror (struct parse_args *arg, const char *str)
1679
0
{
1680
  /* Do nothing.  We don't print error messages here.  */
1681
0
}