OSDN Git Service

Fix no pic
[uclinux-h8/uClinux-dist.git] / user / at / y.tab.c
1
2 /*  A Bison parser, made from parsetime.y with Bison version GNU Bison version 1.22
3   */
4
5 #define YYBISON 1  /* Identify Bison output.  */
6
7 #define INT     258
8 #define NOW     259
9 #define AM      260
10 #define PM      261
11 #define NOON    262
12 #define MIDNIGHT        263
13 #define TEATIME 264
14 #define SUN     265
15 #define MON     266
16 #define TUE     267
17 #define WED     268
18 #define THU     269
19 #define FRI     270
20 #define SAT     271
21 #define TODAY   272
22 #define TOMORROW        273
23 #define NEXT    274
24 #define MINUTE  275
25 #define HOUR    276
26 #define DAY     277
27 #define WEEK    278
28 #define MONTH   279
29 #define YEAR    280
30 #define JAN     281
31 #define FEB     282
32 #define MAR     283
33 #define APR     284
34 #define MAY     285
35 #define JUN     286
36 #define JUL     287
37 #define AUG     288
38 #define SEP     289
39 #define OCT     290
40 #define NOV     291
41 #define DEC     292
42 #define WORD    293
43
44 #line 1 "parsetime.y"
45
46 #include <time.h>
47 #include <stdlib.h>
48 #include <string.h>
49 #include "parsetime.h"
50
51 #define YYDEBUG 1
52
53 time_t currtime;
54 struct tm exectm;
55 static int isgmt;
56 static int time_only;
57
58 int add_date(int number, int period);
59
60 #line 17 "parsetime.y"
61 typedef union {
62         char *          charval;
63         int             intval;
64 } YYSTYPE;
65
66 #ifndef YYLTYPE
67 typedef
68   struct yyltype
69     {
70       int timestamp;
71       int first_line;
72       int first_column;
73       int last_line;
74       int last_column;
75       char *text;
76    }
77   yyltype;
78
79 #define YYLTYPE yyltype
80 #endif
81
82 #include <stdio.h>
83
84 #ifndef __cplusplus
85 #ifndef __STDC__
86 #define const
87 #endif
88 #endif
89
90
91
92 #define YYFINAL         100
93 #define YYFLAG          -32768
94 #define YYNTBASE        47
95
96 #define YYTRANSLATE(x) ((unsigned)(x) <= 293 ? yytranslate[x] : 67)
97
98 static const char yytranslate[] = {     0,
99      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
100      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
101      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
102      2,     2,     2,     2,     2,     2,     2,     2,    45,     2,
103      2,     2,    43,    39,    40,    41,    42,     2,     2,     2,
104      2,     2,     2,     2,     2,     2,     2,    44,     2,     2,
105      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
106      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
107      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
108      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
109      2,     2,     2,    46,     2,     2,     2,     2,     2,     2,
110      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
111      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
112      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
113      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
114      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
115      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
116      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
117      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
118      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
119      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
120      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
121      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
122      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
123      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
124      2,     2,     2,     2,     2,     1,     2,     3,     4,     5,
125      6,     7,     8,     9,    10,    11,    12,    13,    14,    15,
126     16,    17,    18,    19,    20,    21,    22,    23,    24,    25,
127     26,    27,    28,    29,    30,    31,    32,    33,    34,    35,
128     36,    37,    38
129 };
130
131 #if YYDEBUG != 0
132 static const short yyprhs[] = {     0,
133      0,     2,     5,     8,    12,    15,    19,    21,    23,    26,
134     29,    31,    33,    36,    40,    45,    48,    52,    57,    63,
135     65,    67,    69,    72,    77,    79,    81,    83,    89,    95,
136     99,   102,   106,   112,   116,   119,   122,   126,   128,   130,
137    132,   134,   136,   138,   140,   142,   144,   146,   148,   150,
138    152,   154,   156,   158,   160,   162,   164,   166,   168,   170,
139    172,   174,   176,   178,   180,   182,   184,   186,   188,   190,
140    192,   194,   196,   198,   200,   202,   204
141 };
142
143 static const short yyrhs[] = {    50,
144      0,    50,    51,     0,    50,    52,     0,    50,    51,    52,
145      0,    50,    53,     0,    50,    51,    53,     0,    48,     0,
146     49,     0,    49,    52,     0,    49,    53,     0,     4,     0,
147     55,     0,    55,    56,     0,    57,    66,    58,     0,    57,
148     66,    58,    56,     0,    57,    59,     0,    57,    59,    56,
149      0,    57,    66,    58,    59,     0,    57,    66,    58,    59,
150     56,     0,     7,     0,     8,     0,     9,     0,    60,    62,
151      0,    60,    62,    39,    63,     0,    64,     0,    17,     0,
152     18,     0,    63,    40,    61,    40,    62,     0,    62,    41,
153     61,    41,    63,     0,    62,    41,    61,     0,    62,    60,
154      0,    62,    60,    63,     0,    61,    42,    62,    42,    63,
155      0,    43,    65,    54,     0,    19,    54,     0,    19,    64,
156      0,    40,    65,    54,     0,    20,     0,    21,     0,    22,
157      0,    23,     0,    24,     0,    25,     0,     3,     0,    38,
158      0,    55,     0,     3,     0,     5,     0,     6,     0,    26,
159      0,    27,     0,    28,     0,    29,     0,    30,     0,    31,
160      0,    32,     0,    33,     0,    34,     0,    35,     0,    36,
161      0,    37,     0,     3,     0,     3,     0,     3,     0,    10,
162      0,    11,     0,    12,     0,    13,     0,    14,     0,    15,
163      0,    16,     0,     3,     0,    44,     0,    45,     0,    41,
164      0,    46,     0,    39,     0
165 };
166
167 #endif
168
169 #if YYDEBUG != 0
170 static const short yyrline[] = { 0,
171     39,    43,    44,    45,    46,    47,    48,    51,    52,    53,
172     56,    59,    60,    61,    62,    63,    64,    65,    66,    67,
173     72,    78,    85,    86,    87,    91,    92,    96,    97,    98,
174     99,   100,   101,   104,   108,   112,   118,   124,   125,   126,
175    127,   128,   129,   132,   157,   170,   173,   183,   184,   197,
176    198,   199,   200,   201,   202,   203,   204,   205,   206,   207,
177    208,   211,   225,   238,   261,   262,   263,   264,   265,   266,
178    267,   270,   280,   281,   282,   283,   284
179 };
180
181 static const char * const yytname[] = {   "$","error","$illegal.","INT","NOW",
182 "AM","PM","NOON","MIDNIGHT","TEATIME","SUN","MON","TUE","WED","THU","FRI","SAT",
183 "TODAY","TOMORROW","NEXT","MINUTE","HOUR","DAY","WEEK","MONTH","YEAR","JAN",
184 "FEB","MAR","APR","MAY","JUN","JUL","AUG","SEP","OCT","NOV","DEC","WORD","','",
185 "'-'","'.'","'/'","'+'","':'","'\\''","'h'","timespec","nowspec","now","time",
186 "date","increment","decrement","inc_period","hr24clock_hr_min","timezone_name",
187 "hr24clock_hour","minute","am_pm","month_name","month_number","day_number","year_number",
188 "day_of_week","inc_number","time_sep",""
189 };
190 #endif
191
192 static const short yyr1[] = {     0,
193     47,    47,    47,    47,    47,    47,    47,    48,    48,    48,
194     49,    50,    50,    50,    50,    50,    50,    50,    50,    50,
195     50,    50,    51,    51,    51,    51,    51,    51,    51,    51,
196     51,    51,    51,    52,    52,    52,    53,    54,    54,    54,
197     54,    54,    54,    55,    56,    57,    58,    59,    59,    60,
198     60,    60,    60,    60,    60,    60,    60,    60,    60,    60,
199     60,    61,    62,    63,    64,    64,    64,    64,    64,    64,
200     64,    65,    66,    66,    66,    66,    66
201 };
202
203 static const short yyr2[] = {     0,
204      1,     2,     2,     3,     2,     3,     1,     1,     2,     2,
205      1,     1,     2,     3,     4,     2,     3,     4,     5,     1,
206      1,     1,     2,     4,     1,     1,     1,     5,     5,     3,
207      2,     3,     5,     3,     2,     2,     3,     1,     1,     1,
208      1,     1,     1,     1,     1,     1,     1,     1,     1,     1,
209      1,     1,     1,     1,     1,     1,     1,     1,     1,     1,
210      1,     1,     1,     1,     1,     1,     1,     1,     1,     1,
211      1,     1,     1,     1,     1,     1,     1
212 };
213
214 static const short yydefact[] = {     0,
215     44,    11,    20,    21,    22,     7,     8,     1,    12,     0,
216      0,     0,     0,     9,    10,    63,    65,    66,    67,    68,
217     69,    70,    71,    26,    27,    50,    51,    52,    53,    54,
218     55,    56,    57,    58,    59,    60,    61,     2,     3,     5,
219      0,     0,     0,     0,    25,    45,    13,    48,    49,    77,
220     75,    73,    74,    76,    16,     0,    38,    39,    40,    41,
221     42,    43,    35,    36,    72,     0,     0,     4,     6,    63,
222     23,     0,     0,    31,     0,    17,    47,    14,    37,    34,
223      0,     0,    62,    30,    64,    32,     0,    15,    18,    24,
224      0,     0,     0,    19,    33,    29,    28,     0,     0,     0
225 };
226
227 static const short yydefgoto[] = {    98,
228      6,     7,     8,    38,    14,    15,    63,     9,    47,    10,
229     78,    55,    41,    42,    43,    44,    45,    66,    56
230 };
231
232 static const short yypact[] = {     8,
233 -32768,-32768,-32768,-32768,-32768,-32768,   -14,    43,    -4,     4,
234     80,     5,     5,-32768,-32768,   -12,-32768,-32768,-32768,-32768,
235 -32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,
236 -32768,-32768,-32768,-32768,-32768,-32768,-32768,   -14,-32768,-32768,
237     10,    -6,    81,    -8,-32768,-32768,-32768,-32768,-32768,-32768,
238 -32768,-32768,-32768,-32768,     9,    48,-32768,-32768,-32768,-32768,
239 -32768,-32768,-32768,-32768,-32768,    -2,    -2,-32768,-32768,-32768,
240     25,    10,    63,    64,    63,-32768,-32768,     1,-32768,-32768,
241     64,    26,-32768,    41,-32768,-32768,    44,-32768,     9,-32768,
242     64,    64,    10,-32768,-32768,-32768,-32768,    85,    87,-32768
243 };
244
245 static const short yypgoto[] = {-32768,
246 -32768,-32768,-32768,-32768,    -5,     6,   -42,-32768,   -51,-32768,
247 -32768,    11,    54,   -10,   -41,     7,    95,   106,-32768
248 };
249
250
251 #define YYLAST          122
252
253
254 static const short yytable[] = {    71,
255    -46,   -46,    39,    76,    11,    48,    49,    65,    48,    49,
256      1,     2,    70,    40,     3,     4,     5,    57,    58,    59,
257     60,    61,    62,    79,    80,    12,    88,   -64,    13,   -62,
258     82,    75,    68,    46,   -46,    72,   -46,    94,    46,   -46,
259    -46,   -46,    50,    69,    51,    16,    46,    52,    53,    54,
260     77,    97,    17,    18,    19,    20,    21,    22,    23,    24,
261     25,    11,    84,    81,    87,    83,    85,    91,    26,    27,
262     28,    29,    30,    31,    32,    33,    34,    35,    36,    37,
263     86,    92,    12,    93,    99,    13,   100,    90,    89,    17,
264     18,    19,    20,    21,    22,    23,    74,    95,    96,    57,
265     58,    59,    60,    61,    62,    64,    26,    27,    28,    29,
266     30,    31,    32,    33,    34,    35,    36,    37,    67,     0,
267      0,    73
268 };
269
270 static const short yycheck[] = {    41,
271      5,     6,     8,    55,    19,     5,     6,     3,     5,     6,
272      3,     4,     3,     8,     7,     8,     9,    20,    21,    22,
273     23,    24,    25,    66,    67,    40,    78,    40,    43,    42,
274     72,    40,    38,    38,    39,    42,    41,    89,    38,    44,
275     45,    46,    39,    38,    41,     3,    38,    44,    45,    46,
276      3,    93,    10,    11,    12,    13,    14,    15,    16,    17,
277     18,    19,    73,    39,    75,     3,     3,    42,    26,    27,
278     28,    29,    30,    31,    32,    33,    34,    35,    36,    37,
279     74,    41,    40,    40,     0,    43,     0,    81,    78,    10,
280     11,    12,    13,    14,    15,    16,    43,    91,    92,    20,
281     21,    22,    23,    24,    25,    11,    26,    27,    28,    29,
282     30,    31,    32,    33,    34,    35,    36,    37,    13,    -1,
283     -1,    41
284 };
285 /* -*-C-*-  Note some compilers choke on comments on `#line' lines.  */
286 #line 3 "/usr/lib/bison.simple"
287
288 /* Skeleton output parser for bison,
289    Copyright (C) 1984, 1989, 1990 Bob Corbett and Richard Stallman
290
291    This program is free software; you can redistribute it and/or modify
292    it under the terms of the GNU General Public License as published by
293    the Free Software Foundation; either version 1, or (at your option)
294    any later version.
295
296    This program is distributed in the hope that it will be useful,
297    but WITHOUT ANY WARRANTY; without even the implied warranty of
298    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
299    GNU General Public License for more details.
300
301    You should have received a copy of the GNU General Public License
302    along with this program; if not, write to the Free Software
303    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.  */
304
305
306 #ifndef alloca
307 #ifdef __GNUC__
308 #define alloca __builtin_alloca
309 #else /* not GNU C.  */
310 #if (!defined (__STDC__) && defined (sparc)) || defined (__sparc__) || defined (__sparc) || defined (__sgi)
311 #include <alloca.h>
312 #else /* not sparc */
313 #if defined (MSDOS) && !defined (__TURBOC__)
314 #include <malloc.h>
315 #else /* not MSDOS, or __TURBOC__ */
316 #if defined(_AIX)
317 #include <malloc.h>
318  #pragma alloca
319 #else /* not MSDOS, __TURBOC__, or _AIX */
320 #ifdef __hpux
321 #ifdef __cplusplus
322 extern "C" {
323 void *alloca (unsigned int);
324 };
325 #else /* not __cplusplus */
326 void *alloca ();
327 #endif /* not __cplusplus */
328 #endif /* __hpux */
329 #endif /* not _AIX */
330 #endif /* not MSDOS, or __TURBOC__ */
331 #endif /* not sparc.  */
332 #endif /* not GNU C.  */
333 #endif /* alloca not defined.  */
334
335 /* This is the parser code that is written into each bison parser
336   when the %semantic_parser declaration is not specified in the grammar.
337   It was written by Richard Stallman by simplifying the hairy parser
338   used when %semantic_parser is specified.  */
339
340 /* Note: there must be only one dollar sign in this file.
341    It is replaced by the list of actions, each action
342    as one case of the switch.  */
343
344 #define yyerrok         (yyerrstatus = 0)
345 #define yyclearin       (yychar = YYEMPTY)
346 #define YYEMPTY         -2
347 #define YYEOF           0
348 #define YYACCEPT        return(0)
349 #define YYABORT         return(1)
350 #define YYERROR         goto yyerrlab1
351 /* Like YYERROR except do call yyerror.
352    This remains here temporarily to ease the
353    transition to the new meaning of YYERROR, for GCC.
354    Once GCC version 2 has supplanted version 1, this can go.  */
355 #define YYFAIL          goto yyerrlab
356 #define YYRECOVERING()  (!!yyerrstatus)
357 #define YYBACKUP(token, value) \
358 do                                                              \
359   if (yychar == YYEMPTY && yylen == 1)                          \
360     { yychar = (token), yylval = (value);                       \
361       yychar1 = YYTRANSLATE (yychar);                           \
362       YYPOPSTACK;                                               \
363       goto yybackup;                                            \
364     }                                                           \
365   else                                                          \
366     { yyerror ("syntax error: cannot back up"); YYERROR; }      \
367 while (0)
368
369 #define YYTERROR        1
370 #define YYERRCODE       256
371
372 #ifndef YYPURE
373 #define YYLEX           yylex()
374 #endif
375
376 #ifdef YYPURE
377 #ifdef YYLSP_NEEDED
378 #define YYLEX           yylex(&yylval, &yylloc)
379 #else
380 #define YYLEX           yylex(&yylval)
381 #endif
382 #endif
383
384 /* If nonreentrant, generate the variables here */
385
386 #ifndef YYPURE
387
388 int     yychar;                 /*  the lookahead symbol                */
389 YYSTYPE yylval;                 /*  the semantic value of the           */
390                                 /*  lookahead symbol                    */
391
392 #ifdef YYLSP_NEEDED
393 YYLTYPE yylloc;                 /*  location data for the lookahead     */
394                                 /*  symbol                              */
395 #endif
396
397 int yynerrs;                    /*  number of parse errors so far       */
398 #endif  /* not YYPURE */
399
400 #if YYDEBUG != 0
401 int yydebug;                    /*  nonzero means print parse trace     */
402 /* Since this is uninitialized, it does not stop multiple parsers
403    from coexisting.  */
404 #endif
405
406 /*  YYINITDEPTH indicates the initial size of the parser's stacks       */
407
408 #ifndef YYINITDEPTH
409 #define YYINITDEPTH 200
410 #endif
411
412 /*  YYMAXDEPTH is the maximum size the stacks can grow to
413     (effective only if the built-in stack extension method is used).  */
414
415 #if YYMAXDEPTH == 0
416 #undef YYMAXDEPTH
417 #endif
418
419 #ifndef YYMAXDEPTH
420 #define YYMAXDEPTH 10000
421 #endif
422
423 /* Prevent warning if -Wstrict-prototypes.  */
424 #ifdef __GNUC__
425 int yyparse (void);
426 #endif
427 \f
428 #if __GNUC__ > 1                /* GNU C and GNU C++ define this.  */
429 #define __yy_bcopy(FROM,TO,COUNT)       __builtin_memcpy(TO,FROM,COUNT)
430 #else                           /* not GNU C or C++ */
431 #ifndef __cplusplus
432
433 /* This is the most reliable way to avoid incompatibilities
434    in available built-in functions on various systems.  */
435 static void
436 __yy_bcopy (from, to, count)
437      char *from;
438      char *to;
439      int count;
440 {
441   register char *f = from;
442   register char *t = to;
443   register int i = count;
444
445   while (i-- > 0)
446     *t++ = *f++;
447 }
448
449 #else /* __cplusplus */
450
451 /* This is the most reliable way to avoid incompatibilities
452    in available built-in functions on various systems.  */
453 static void
454 __yy_bcopy (char *from, char *to, int count)
455 {
456   register char *f = from;
457   register char *t = to;
458   register int i = count;
459
460   while (i-- > 0)
461     *t++ = *f++;
462 }
463
464 #endif
465 #endif
466 \f
467 #line 184 "/usr/lib/bison.simple"
468 int
469 yyparse()
470 {
471   register int yystate;
472   register int yyn;
473   register short *yyssp;
474   register YYSTYPE *yyvsp;
475   int yyerrstatus;      /*  number of tokens to shift before error messages enabled */
476   int yychar1 = 0;              /*  lookahead token as an internal (translated) token number */
477
478   short yyssa[YYINITDEPTH];     /*  the state stack                     */
479   YYSTYPE yyvsa[YYINITDEPTH];   /*  the semantic value stack            */
480
481   short *yyss = yyssa;          /*  refer to the stacks thru separate pointers */
482   YYSTYPE *yyvs = yyvsa;        /*  to allow yyoverflow to reallocate them elsewhere */
483
484 #ifdef YYLSP_NEEDED
485   YYLTYPE yylsa[YYINITDEPTH];   /*  the location stack                  */
486   YYLTYPE *yyls = yylsa;
487   YYLTYPE *yylsp;
488
489 #define YYPOPSTACK   (yyvsp--, yyssp--, yylsp--)
490 #else
491 #define YYPOPSTACK   (yyvsp--, yyssp--)
492 #endif
493
494   int yystacksize = YYINITDEPTH;
495
496 #ifdef YYPURE
497   int yychar;
498   YYSTYPE yylval;
499   int yynerrs;
500 #ifdef YYLSP_NEEDED
501   YYLTYPE yylloc;
502 #endif
503 #endif
504
505   YYSTYPE yyval;                /*  the variable used to return         */
506                                 /*  semantic values from the action     */
507                                 /*  routines                            */
508
509   int yylen;
510
511 #if YYDEBUG != 0
512   if (yydebug)
513     fprintf(stderr, "Starting parse\n");
514 #endif
515
516   yystate = 0;
517   yyerrstatus = 0;
518   yynerrs = 0;
519   yychar = YYEMPTY;             /* Cause a token to be read.  */
520
521   /* Initialize stack pointers.
522      Waste one element of value and location stack
523      so that they stay on the same level as the state stack.
524      The wasted elements are never initialized.  */
525
526   yyssp = yyss - 1;
527   yyvsp = yyvs;
528 #ifdef YYLSP_NEEDED
529   yylsp = yyls;
530 #endif
531
532 /* Push a new state, which is found in  yystate  .  */
533 /* In all cases, when you get here, the value and location stacks
534    have just been pushed. so pushing a state here evens the stacks.  */
535 yynewstate:
536
537   *++yyssp = yystate;
538
539   if (yyssp >= yyss + yystacksize - 1)
540     {
541       /* Give user a chance to reallocate the stack */
542       /* Use copies of these so that the &'s don't force the real ones into memory. */
543       YYSTYPE *yyvs1 = yyvs;
544       short *yyss1 = yyss;
545 #ifdef YYLSP_NEEDED
546       YYLTYPE *yyls1 = yyls;
547 #endif
548
549       /* Get the current used size of the three stacks, in elements.  */
550       int size = yyssp - yyss + 1;
551
552 #ifdef yyoverflow
553       /* Each stack pointer address is followed by the size of
554          the data in use in that stack, in bytes.  */
555 #ifdef YYLSP_NEEDED
556       /* This used to be a conditional around just the two extra args,
557          but that might be undefined if yyoverflow is a macro.  */
558       yyoverflow("parser stack overflow",
559                  &yyss1, size * sizeof (*yyssp),
560                  &yyvs1, size * sizeof (*yyvsp),
561                  &yyls1, size * sizeof (*yylsp),
562                  &yystacksize);
563 #else
564       yyoverflow("parser stack overflow",
565                  &yyss1, size * sizeof (*yyssp),
566                  &yyvs1, size * sizeof (*yyvsp),
567                  &yystacksize);
568 #endif
569
570       yyss = yyss1; yyvs = yyvs1;
571 #ifdef YYLSP_NEEDED
572       yyls = yyls1;
573 #endif
574 #else /* no yyoverflow */
575       /* Extend the stack our own way.  */
576       if (yystacksize >= YYMAXDEPTH)
577         {
578           yyerror("parser stack overflow");
579           return 2;
580         }
581       yystacksize *= 2;
582       if (yystacksize > YYMAXDEPTH)
583         yystacksize = YYMAXDEPTH;
584       yyss = (short *) alloca (yystacksize * sizeof (*yyssp));
585       __yy_bcopy ((char *)yyss1, (char *)yyss, size * sizeof (*yyssp));
586       yyvs = (YYSTYPE *) alloca (yystacksize * sizeof (*yyvsp));
587       __yy_bcopy ((char *)yyvs1, (char *)yyvs, size * sizeof (*yyvsp));
588 #ifdef YYLSP_NEEDED
589       yyls = (YYLTYPE *) alloca (yystacksize * sizeof (*yylsp));
590       __yy_bcopy ((char *)yyls1, (char *)yyls, size * sizeof (*yylsp));
591 #endif
592 #endif /* no yyoverflow */
593
594       yyssp = yyss + size - 1;
595       yyvsp = yyvs + size - 1;
596 #ifdef YYLSP_NEEDED
597       yylsp = yyls + size - 1;
598 #endif
599
600 #if YYDEBUG != 0
601       if (yydebug)
602         fprintf(stderr, "Stack size increased to %d\n", yystacksize);
603 #endif
604
605       if (yyssp >= yyss + yystacksize - 1)
606         YYABORT;
607     }
608
609 #if YYDEBUG != 0
610   if (yydebug)
611     fprintf(stderr, "Entering state %d\n", yystate);
612 #endif
613
614   goto yybackup;
615  yybackup:
616
617 /* Do appropriate processing given the current state.  */
618 /* Read a lookahead token if we need one and don't already have one.  */
619 /* yyresume: */
620
621   /* First try to decide what to do without reference to lookahead token.  */
622
623   yyn = yypact[yystate];
624   if (yyn == YYFLAG)
625     goto yydefault;
626
627   /* Not known => get a lookahead token if don't already have one.  */
628
629   /* yychar is either YYEMPTY or YYEOF
630      or a valid token in external form.  */
631
632   if (yychar == YYEMPTY)
633     {
634 #if YYDEBUG != 0
635       if (yydebug)
636         fprintf(stderr, "Reading a token: ");
637 #endif
638       yychar = YYLEX;
639     }
640
641   /* Convert token to internal form (in yychar1) for indexing tables with */
642
643   if (yychar <= 0)              /* This means end of input. */
644     {
645       yychar1 = 0;
646       yychar = YYEOF;           /* Don't call YYLEX any more */
647
648 #if YYDEBUG != 0
649       if (yydebug)
650         fprintf(stderr, "Now at end of input.\n");
651 #endif
652     }
653   else
654     {
655       yychar1 = YYTRANSLATE(yychar);
656
657 #if YYDEBUG != 0
658       if (yydebug)
659         {
660           fprintf (stderr, "Next token is %d (%s", yychar, yytname[yychar1]);
661           /* Give the individual parser a way to print the precise meaning
662              of a token, for further debugging info.  */
663 #ifdef YYPRINT
664           YYPRINT (stderr, yychar, yylval);
665 #endif
666           fprintf (stderr, ")\n");
667         }
668 #endif
669     }
670
671   yyn += yychar1;
672   if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != yychar1)
673     goto yydefault;
674
675   yyn = yytable[yyn];
676
677   /* yyn is what to do for this token type in this state.
678      Negative => reduce, -yyn is rule number.
679      Positive => shift, yyn is new state.
680        New state is final state => don't bother to shift,
681        just return success.
682      0, or most negative number => error.  */
683
684   if (yyn < 0)
685     {
686       if (yyn == YYFLAG)
687         goto yyerrlab;
688       yyn = -yyn;
689       goto yyreduce;
690     }
691   else if (yyn == 0)
692     goto yyerrlab;
693
694   if (yyn == YYFINAL)
695     YYACCEPT;
696
697   /* Shift the lookahead token.  */
698
699 #if YYDEBUG != 0
700   if (yydebug)
701     fprintf(stderr, "Shifting token %d (%s), ", yychar, yytname[yychar1]);
702 #endif
703
704   /* Discard the token being shifted unless it is eof.  */
705   if (yychar != YYEOF)
706     yychar = YYEMPTY;
707
708   *++yyvsp = yylval;
709 #ifdef YYLSP_NEEDED
710   *++yylsp = yylloc;
711 #endif
712
713   /* count tokens shifted since error; after three, turn off error status.  */
714   if (yyerrstatus) yyerrstatus--;
715
716   yystate = yyn;
717   goto yynewstate;
718
719 /* Do the default action for the current state.  */
720 yydefault:
721
722   yyn = yydefact[yystate];
723   if (yyn == 0)
724     goto yyerrlab;
725
726 /* Do a reduction.  yyn is the number of a rule to reduce with.  */
727 yyreduce:
728   yylen = yyr2[yyn];
729   if (yylen > 0)
730     yyval = yyvsp[1-yylen]; /* implement default value of the action */
731
732 #if YYDEBUG != 0
733   if (yydebug)
734     {
735       int i;
736
737       fprintf (stderr, "Reducing via rule %d (line %d), ",
738                yyn, yyrline[yyn]);
739
740       /* Print the symbols being reduced, and their result.  */
741       for (i = yyprhs[yyn]; yyrhs[i] > 0; i++)
742         fprintf (stderr, "%s ", yytname[yyrhs[i]]);
743       fprintf (stderr, " -> %s\n", yytname[yyr1[yyn]]);
744     }
745 #endif
746
747
748   switch (yyn) {
749
750 case 1:
751 #line 40 "parsetime.y"
752 {
753                         time_only = 1;
754                     ;
755     break;}
756 case 20:
757 #line 68 "parsetime.y"
758 {
759                         exectm.tm_hour = 12;
760                         exectm.tm_min = 0;
761                     ;
762     break;}
763 case 21:
764 #line 73 "parsetime.y"
765 {
766                         exectm.tm_hour = 0;
767                         exectm.tm_min = 0;
768                         add_date(1, DAY);
769                     ;
770     break;}
771 case 22:
772 #line 79 "parsetime.y"
773 {
774                         exectm.tm_hour = 16;
775                         exectm.tm_min = 0;
776                     ;
777     break;}
778 case 25:
779 #line 88 "parsetime.y"
780 {
781                        add_date ((7 + yyvsp[0].intval - exectm.tm_wday) %7, DAY);
782                    ;
783     break;}
784 case 27:
785 #line 93 "parsetime.y"
786 {
787                         add_date(1, DAY);
788                    ;
789     break;}
790 case 34:
791 #line 105 "parsetime.y"
792 {
793                         add_date(yyvsp[-1].intval, yyvsp[0].intval);
794                     ;
795     break;}
796 case 35:
797 #line 109 "parsetime.y"
798 {
799                         add_date(1, yyvsp[0].intval);
800                     ;
801     break;}
802 case 36:
803 #line 113 "parsetime.y"
804 {
805                         add_date ((7 + yyvsp[0].intval - exectm.tm_wday) %7, DAY);
806                     ;
807     break;}
808 case 37:
809 #line 119 "parsetime.y"
810 {
811                         add_date(-yyvsp[-1].intval, yyvsp[0].intval);
812                     ;
813     break;}
814 case 38:
815 #line 124 "parsetime.y"
816 { yyval.intval = MINUTE ; ;
817     break;}
818 case 39:
819 #line 125 "parsetime.y"
820 { yyval.intval = HOUR ; ;
821     break;}
822 case 40:
823 #line 126 "parsetime.y"
824 { yyval.intval = DAY ; ;
825     break;}
826 case 41:
827 #line 127 "parsetime.y"
828 { yyval.intval = WEEK ; ;
829     break;}
830 case 42:
831 #line 128 "parsetime.y"
832 { yyval.intval = MONTH ; ;
833     break;}
834 case 43:
835 #line 129 "parsetime.y"
836 { yyval.intval = YEAR ; ;
837     break;}
838 case 44:
839 #line 133 "parsetime.y"
840 {
841                         exectm.tm_min = -1;
842                         exectm.tm_hour = -1;
843                         if (strlen(yyvsp[0].charval) == 4) {
844                             sscanf(yyvsp[0].charval, "%2d %2d", &exectm.tm_hour,
845                                 &exectm.tm_min);
846                         }
847                         else {
848                             sscanf(yyvsp[0].charval, "%d", &exectm.tm_hour);
849                             exectm.tm_min = 0;
850                         }
851                         free(yyvsp[0].charval);
852
853                         if (exectm.tm_min > 60 || exectm.tm_min < 0) {
854                             yyerror("Problem in minutes specification");
855                             YYERROR;
856                         }
857                         if (exectm.tm_hour > 24 || exectm.tm_hour < 0) {
858                             yyerror("Problem in minutes specification");
859                             YYERROR;
860                         }
861                     ;
862     break;}
863 case 45:
864 #line 158 "parsetime.y"
865 {
866                         if (strcasecmp(yyvsp[0].charval,"utc") == 0) {
867                             isgmt = 1;
868                         }
869                         else {
870                             yyerror("Only UTC timezone is supported");
871                             YYERROR;
872                         }
873                         free(yyvsp[0].charval);
874                     ;
875     break;}
876 case 47:
877 #line 174 "parsetime.y"
878 {
879                         if (sscanf(yyvsp[0].charval, "%d", &exectm.tm_min) != 1) {
880                             yyerror("Error in minute");
881                             YYERROR;
882                         }
883                         free(yyvsp[0].charval);
884                     ;
885     break;}
886 case 49:
887 #line 185 "parsetime.y"
888 {
889                         if (exectm.tm_hour > 12) {
890                             yyerror("Hour too large for PM");
891                             YYERROR;
892                         }
893                         else if (exectm.tm_hour < 12) {
894                             exectm.tm_hour +=12;
895                         }
896                     ;
897     break;}
898 case 50:
899 #line 197 "parsetime.y"
900 { exectm.tm_mon = 0; ;
901     break;}
902 case 51:
903 #line 198 "parsetime.y"
904 { exectm.tm_mon = 1; ;
905     break;}
906 case 52:
907 #line 199 "parsetime.y"
908 { exectm.tm_mon = 2; ;
909     break;}
910 case 53:
911 #line 200 "parsetime.y"
912 { exectm.tm_mon = 3; ;
913     break;}
914 case 54:
915 #line 201 "parsetime.y"
916 { exectm.tm_mon = 4; ;
917     break;}
918 case 55:
919 #line 202 "parsetime.y"
920 { exectm.tm_mon = 5; ;
921     break;}
922 case 56:
923 #line 203 "parsetime.y"
924 { exectm.tm_mon = 6; ;
925     break;}
926 case 57:
927 #line 204 "parsetime.y"
928 { exectm.tm_mon = 7; ;
929     break;}
930 case 58:
931 #line 205 "parsetime.y"
932 { exectm.tm_mon = 8; ;
933     break;}
934 case 59:
935 #line 206 "parsetime.y"
936 { exectm.tm_mon = 9; ;
937     break;}
938 case 60:
939 #line 207 "parsetime.y"
940 { exectm.tm_mon =10; ;
941     break;}
942 case 61:
943 #line 208 "parsetime.y"
944 { exectm.tm_mon =11; ;
945     break;}
946 case 62:
947 #line 212 "parsetime.y"
948 {
949                         {
950                             int mnum = -1;
951                             sscanf(yyvsp[0].charval, "%d", &mnum);
952
953                             if (mnum < 1 || mnum > 12) {
954                                 yyerror("Error in month number");
955                                 YYERROR;
956                             }
957                             exectm.tm_mon = mnum -1;
958                             free(yyvsp[0].charval);
959                         }
960                     ;
961     break;}
962 case 63:
963 #line 226 "parsetime.y"
964 {
965                         exectm.tm_mday = -1;
966                         sscanf(yyvsp[0].charval, "%d", &exectm.tm_mday);
967                         if (exectm.tm_mday < 0 || exectm.tm_mday > 31)
968                         {
969                             yyerror("Error in day of month");
970                             YYERROR; 
971                         }
972                         free(yyvsp[0].charval);
973                      ;
974     break;}
975 case 64:
976 #line 239 "parsetime.y"
977
978                         {
979                             int ynum;
980
981                             if ( sscanf(yyvsp[0].charval, "%d", &ynum) != 1) {
982                                 yyerror("Error in year");
983                                 YYERROR;
984                             }
985                             if (ynum < 70) {
986                                 ynum += 100;
987                             }
988                             else if (ynum > 1900) {
989                                 ynum -= 1900;
990                             }
991
992                             exectm.tm_year = ynum ;
993                             free(yyvsp[0].charval);
994                         }
995                     ;
996     break;}
997 case 65:
998 #line 261 "parsetime.y"
999 { yyval.intval = 0; ;
1000     break;}
1001 case 66:
1002 #line 262 "parsetime.y"
1003 { yyval.intval = 1; ;
1004     break;}
1005 case 67:
1006 #line 263 "parsetime.y"
1007 { yyval.intval = 2; ;
1008     break;}
1009 case 68:
1010 #line 264 "parsetime.y"
1011 { yyval.intval = 3; ;
1012     break;}
1013 case 69:
1014 #line 265 "parsetime.y"
1015 { yyval.intval = 4; ;
1016     break;}
1017 case 70:
1018 #line 266 "parsetime.y"
1019 { yyval.intval = 5; ;
1020     break;}
1021 case 71:
1022 #line 267 "parsetime.y"
1023 { yyval.intval = 6; ;
1024     break;}
1025 case 72:
1026 #line 271 "parsetime.y"
1027 {
1028                         if (sscanf(yyvsp[0].charval, "%d", &yyval.intval) != 1) {
1029                             yyerror("Unknown increment");
1030                             YYERROR;
1031                         }
1032                         free(yyvsp[0].charval);
1033                     ;
1034     break;}
1035 }
1036    /* the action file gets copied in in place of this dollarsign */
1037 #line 465 "/usr/lib/bison.simple"
1038 \f
1039   yyvsp -= yylen;
1040   yyssp -= yylen;
1041 #ifdef YYLSP_NEEDED
1042   yylsp -= yylen;
1043 #endif
1044
1045 #if YYDEBUG != 0
1046   if (yydebug)
1047     {
1048       short *ssp1 = yyss - 1;
1049       fprintf (stderr, "state stack now");
1050       while (ssp1 != yyssp)
1051         fprintf (stderr, " %d", *++ssp1);
1052       fprintf (stderr, "\n");
1053     }
1054 #endif
1055
1056   *++yyvsp = yyval;
1057
1058 #ifdef YYLSP_NEEDED
1059   yylsp++;
1060   if (yylen == 0)
1061     {
1062       yylsp->first_line = yylloc.first_line;
1063       yylsp->first_column = yylloc.first_column;
1064       yylsp->last_line = (yylsp-1)->last_line;
1065       yylsp->last_column = (yylsp-1)->last_column;
1066       yylsp->text = 0;
1067     }
1068   else
1069     {
1070       yylsp->last_line = (yylsp+yylen-1)->last_line;
1071       yylsp->last_column = (yylsp+yylen-1)->last_column;
1072     }
1073 #endif
1074
1075   /* Now "shift" the result of the reduction.
1076      Determine what state that goes to,
1077      based on the state we popped back to
1078      and the rule number reduced by.  */
1079
1080   yyn = yyr1[yyn];
1081
1082   yystate = yypgoto[yyn - YYNTBASE] + *yyssp;
1083   if (yystate >= 0 && yystate <= YYLAST && yycheck[yystate] == *yyssp)
1084     yystate = yytable[yystate];
1085   else
1086     yystate = yydefgoto[yyn - YYNTBASE];
1087
1088   goto yynewstate;
1089
1090 yyerrlab:   /* here on detecting error */
1091
1092   if (! yyerrstatus)
1093     /* If not already recovering from an error, report this error.  */
1094     {
1095       ++yynerrs;
1096
1097 #ifdef YYERROR_VERBOSE
1098       yyn = yypact[yystate];
1099
1100       if (yyn > YYFLAG && yyn < YYLAST)
1101         {
1102           int size = 0;
1103           char *msg;
1104           int x, count;
1105
1106           count = 0;
1107           /* Start X at -yyn if nec to avoid negative indexes in yycheck.  */
1108           for (x = (yyn < 0 ? -yyn : 0);
1109                x < (sizeof(yytname) / sizeof(char *)); x++)
1110             if (yycheck[x + yyn] == x)
1111               size += strlen(yytname[x]) + 15, count++;
1112           msg = (char *) malloc(size + 15);
1113           if (msg != 0)
1114             {
1115               strcpy(msg, "parse error");
1116
1117               if (count < 5)
1118                 {
1119                   count = 0;
1120                   for (x = (yyn < 0 ? -yyn : 0);
1121                        x < (sizeof(yytname) / sizeof(char *)); x++)
1122                     if (yycheck[x + yyn] == x)
1123                       {
1124                         strcat(msg, count == 0 ? ", expecting `" : " or `");
1125                         strcat(msg, yytname[x]);
1126                         strcat(msg, "'");
1127                         count++;
1128                       }
1129                 }
1130               yyerror(msg);
1131               free(msg);
1132             }
1133           else
1134             yyerror ("parse error; also virtual memory exceeded");
1135         }
1136       else
1137 #endif /* YYERROR_VERBOSE */
1138         yyerror("parse error");
1139     }
1140
1141   goto yyerrlab1;
1142 yyerrlab1:   /* here on error raised explicitly by an action */
1143
1144   if (yyerrstatus == 3)
1145     {
1146       /* if just tried and failed to reuse lookahead token after an error, discard it.  */
1147
1148       /* return failure if at end of input */
1149       if (yychar == YYEOF)
1150         YYABORT;
1151
1152 #if YYDEBUG != 0
1153       if (yydebug)
1154         fprintf(stderr, "Discarding token %d (%s).\n", yychar, yytname[yychar1]);
1155 #endif
1156
1157       yychar = YYEMPTY;
1158     }
1159
1160   /* Else will try to reuse lookahead token
1161      after shifting the error token.  */
1162
1163   yyerrstatus = 3;              /* Each real token shifted decrements this */
1164
1165   goto yyerrhandle;
1166
1167 yyerrdefault:  /* current state does not do anything special for the error token. */
1168
1169 #if 0
1170   /* This is wrong; only states that explicitly want error tokens
1171      should shift them.  */
1172   yyn = yydefact[yystate];  /* If its default is to accept any token, ok.  Otherwise pop it.*/
1173   if (yyn) goto yydefault;
1174 #endif
1175
1176 yyerrpop:   /* pop the current state because it cannot handle the error token */
1177
1178   if (yyssp == yyss) YYABORT;
1179   yyvsp--;
1180   yystate = *--yyssp;
1181 #ifdef YYLSP_NEEDED
1182   yylsp--;
1183 #endif
1184
1185 #if YYDEBUG != 0
1186   if (yydebug)
1187     {
1188       short *ssp1 = yyss - 1;
1189       fprintf (stderr, "Error: state stack now");
1190       while (ssp1 != yyssp)
1191         fprintf (stderr, " %d", *++ssp1);
1192       fprintf (stderr, "\n");
1193     }
1194 #endif
1195
1196 yyerrhandle:
1197
1198   yyn = yypact[yystate];
1199   if (yyn == YYFLAG)
1200     goto yyerrdefault;
1201
1202   yyn += YYTERROR;
1203   if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != YYTERROR)
1204     goto yyerrdefault;
1205
1206   yyn = yytable[yyn];
1207   if (yyn < 0)
1208     {
1209       if (yyn == YYFLAG)
1210         goto yyerrpop;
1211       yyn = -yyn;
1212       goto yyreduce;
1213     }
1214   else if (yyn == 0)
1215     goto yyerrpop;
1216
1217   if (yyn == YYFINAL)
1218     YYACCEPT;
1219
1220 #if YYDEBUG != 0
1221   if (yydebug)
1222     fprintf(stderr, "Shifting error token, ");
1223 #endif
1224
1225   *++yyvsp = yylval;
1226 #ifdef YYLSP_NEEDED
1227   *++yylsp = yylloc;
1228 #endif
1229
1230   yystate = yyn;
1231   goto yynewstate;
1232 }
1233 #line 287 "parsetime.y"
1234
1235
1236
1237 time_t parsetime(int, char **);
1238
1239 time_t
1240 parsetime(int argc, char **argv)
1241 {
1242     time_t exectime;
1243
1244     my_argv = argv;
1245     currtime = time(NULL);
1246     exectm = *localtime(&currtime);
1247     exectm.tm_sec = 0;
1248     exectm.tm_isdst = -1;
1249     time_only = 0;
1250     if (yyparse() == 0) {
1251         exectime = mktime(&exectm);
1252         if (isgmt) {
1253             exectime += timezone;
1254             if (daylight) {
1255                 exectime -= 3600;
1256             }
1257         }
1258         if (time_only && (currtime > exectime)) {
1259             exectime += 24*3600;
1260         }
1261         return exectime;
1262     }
1263     else {
1264         return 0;    
1265     }
1266 }
1267
1268 #ifdef TEST_PARSER
1269 int
1270 main(int argc, char **argv)
1271 {
1272     time_t res;
1273     res = parsetime(argc-1, &argv[1]);
1274     if (res > 0) {
1275         printf("%s",ctime(&res));
1276     }
1277     else {
1278         printf("Ooops...\n");
1279     }
1280     return 0;
1281 }
1282
1283 #endif
1284 int yyerror(char *s)
1285 {
1286     if (last_token == NULL)
1287         last_token = "(empty)";
1288     fprintf(stderr,"%s. Last token seen: %s\n",s, last_token);
1289     return 0;
1290 }
1291
1292 void
1293 add_seconds(struct tm *tm, long numsec)
1294 {
1295     time_t timeval;
1296     timeval = mktime(tm);
1297     timeval += numsec;
1298     *tm = *localtime(&timeval);
1299 }
1300
1301 int
1302 add_date(int number, int period)
1303 {
1304     switch(period) {
1305     case MINUTE:
1306         add_seconds(&exectm , 60l*number);
1307         break;
1308
1309     case HOUR:
1310         add_seconds(&exectm, 3600l * number);
1311         break;
1312
1313     case DAY:
1314         add_seconds(&exectm, 24*3600l * number);
1315         break;
1316
1317     case WEEK:
1318         add_seconds(&exectm, 7*24*3600l*number);
1319         break;
1320
1321     case MONTH:
1322         {
1323             int newmonth = exectm.tm_mon + number;
1324             number = 0;
1325             while (newmonth < 0) {
1326                 newmonth += 12;
1327                 number --;
1328             }
1329             exectm.tm_mon = newmonth % 12;
1330             number += newmonth / 12 ;
1331         }
1332         if (number == 0) {
1333             break;
1334         }
1335         /* fall through */
1336
1337     case YEAR:
1338         exectm.tm_year += number;
1339         break;
1340
1341     default:
1342         yyerror("Internal parser error");
1343         fprintf(stderr,"Unexpected case %d\n", period);
1344         abort();
1345     }
1346     return 0;
1347 }