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