Statistics
| Branch: | Tag: | Revision:

dvbd / y.tab.c @ bfdb7446

History | View | Annotate | Download (46.6 KB)

1
/* A Bison parser, made from parsetime.y
2
   by GNU bison 1.31.  */
3

    
4
#define YYBISON 1  /* Identify Bison output.  */
5

    
6
# define        INT        257
7
# define        NOW        258
8
# define        AM        259
9
# define        PM        260
10
# define        NOON        261
11
# define        MIDNIGHT        262
12
# define        TEATIME        263
13
# define        SUN        264
14
# define        MON        265
15
# define        TUE        266
16
# define        WED        267
17
# define        THU        268
18
# define        FRI        269
19
# define        SAT        270
20
# define        TODAY        271
21
# define        TOMORROW        272
22
# define        NEXT        273
23
# define        MINUTE        274
24
# define        HOUR        275
25
# define        DAY        276
26
# define        WEEK        277
27
# define        MONTH        278
28
# define        YEAR        279
29
# define        JAN        280
30
# define        FEB        281
31
# define        MAR        282
32
# define        APR        283
33
# define        MAY        284
34
# define        JUN        285
35
# define        JUL        286
36
# define        AUG        287
37
# define        SEP        288
38
# define        OCT        289
39
# define        NOV        290
40
# define        DEC        291
41
# define        WORD        292
42

    
43
#line 1 "parsetime.y"
44

    
45
#include <time.h>
46
#include <stdlib.h>
47
#include <string.h>
48
#include "parsetime.h"
49

    
50
#define YYDEBUG 1
51

    
52
time_t currtime;
53
struct tm exectm;
54
static int isgmt;
55
static int time_only;
56

    
57
extern int yyerror(char *s);
58
extern int yylex();
59

    
60
int add_date(int number, int period);
61

    
62
#line 20 "parsetime.y"
63
#ifndef YYSTYPE
64
typedef union {
65
        char *                  charval;
66
        int                intval;
67
} yystype;
68
# define YYSTYPE yystype
69
#endif
70
#ifndef YYDEBUG
71
# define YYDEBUG 0
72
#endif
73

    
74

    
75

    
76
#define        YYFINAL                104
77
#define        YYFLAG                -32768
78
#define        YYNTBASE        47
79

    
80
/* YYTRANSLATE(YYLEX) -- Bison token number corresponding to YYLEX. */
81
#define YYTRANSLATE(x) ((unsigned)(x) <= 292 ? yytranslate[x] : 69)
82

    
83
/* YYTRANSLATE[YYLEX] -- Bison token number corresponding to YYLEX. */
84
static const char yytranslate[] =
85
{
86
       0,     2,     2,     2,     2,     2,     2,     2,     2,     2,
87
       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
88
       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
89
       2,     2,     2,     2,     2,     2,     2,     2,     2,    45,
90
       2,     2,     2,    43,    39,    40,    41,    42,     2,     2,
91
       2,     2,     2,     2,     2,     2,     2,     2,    44,     2,
92
       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
93
       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
94
       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
95
       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
96
       2,     2,     2,     2,    46,     2,     2,     2,     2,     2,
97
       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
98
       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
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,     2,     2,
103
       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
104
       2,     2,     2,     2,     2,     2,     2,     2,     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,     2,     2,     2,     2,     2,     2,     2,
110
       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
111
       2,     2,     2,     2,     2,     2,     1,     3,     4,     5,
112
       6,     7,     8,     9,    10,    11,    12,    13,    14,    15,
113
      16,    17,    18,    19,    20,    21,    22,    23,    24,    25,
114
      26,    27,    28,    29,    30,    31,    32,    33,    34,    35,
115
      36,    37,    38
116
};
117

    
118
#if YYDEBUG
119
static const short yyprhs[] =
120
{
121
       0,     0,     2,     4,     7,    10,    14,    16,    18,    21,
122
      23,    25,    27,    28,    30,    33,    37,    42,    45,    49,
123
      54,    60,    62,    64,    66,    69,    73,    78,    80,    82,
124
      84,    90,    96,   100,   103,   107,   113,   115,   117,   121,
125
     124,   127,   131,   133,   135,   137,   139,   141,   143,   145,
126
     147,   149,   151,   153,   155,   157,   159,   161,   163,   165,
127
     167,   169,   171,   173,   175,   177,   179,   181,   183,   185,
128
     187,   189,   191,   193,   195,   197,   199,   201,   203,   205,
129
     207,   209
130
};
131
static const short yyrhs[] =
132
{
133
      52,     0,    51,     0,    51,    52,     0,    50,    53,     0,
134
      50,    52,    53,     0,    48,     0,    49,     0,    49,    53,
135
       0,     4,     0,    18,     0,    51,     0,     0,    57,     0,
136
      57,    58,     0,    59,    68,    60,     0,    59,    68,    60,
137
      58,     0,    59,    61,     0,    59,    61,    58,     0,    59,
138
      68,    60,    61,     0,    59,    68,    60,    61,    58,     0,
139
       7,     0,     8,     0,     9,     0,    62,    64,     0,    62,
140
      64,    65,     0,    62,    64,    39,    65,     0,    66,     0,
141
      17,     0,    18,     0,    65,    40,    63,    40,    64,     0,
142
      64,    41,    63,    41,    65,     0,    64,    41,    63,     0,
143
      64,    62,     0,    64,    62,    65,     0,    63,    42,    64,
144
      42,    65,     0,    54,     0,    55,     0,    43,    67,    56,
145
       0,    19,    56,     0,    19,    66,     0,    40,    67,    56,
146
       0,    20,     0,    21,     0,    22,     0,    23,     0,    24,
147
       0,    25,     0,     3,     0,    38,     0,    57,     0,     3,
148
       0,     5,     0,     6,     0,    26,     0,    27,     0,    28,
149
       0,    29,     0,    30,     0,    31,     0,    32,     0,    33,
150
       0,    34,     0,    35,     0,    36,     0,    37,     0,     3,
151
       0,     3,     0,     3,     0,    10,     0,    11,     0,    12,
152
       0,    13,     0,    14,     0,    15,     0,    16,     0,     3,
153
       0,    44,     0,    45,     0,    41,     0,    46,     0,    39,
154
       0
155
};
156

    
157
#endif
158

    
159
#if YYDEBUG
160
/* YYRLINE[YYN] -- source line where rule number YYN was defined. */
161
static const short yyrline[] =
162
{
163
       0,    42,    43,    47,    48,    49,    50,    53,    54,    57,
164
      58,    64,    65,    67,    68,    69,    70,    71,    72,    73,
165
      74,    75,    80,    86,    93,    94,    95,    96,   100,   101,
166
     105,   106,   107,   108,   109,   110,   113,   114,   116,   120,
167
     124,   130,   136,   137,   138,   139,   140,   141,   144,   213,
168
     226,   229,   239,   249,   262,   263,   264,   265,   266,   267,
169
     268,   269,   270,   271,   272,   273,   276,   290,   303,   326,
170
     327,   328,   329,   330,   331,   332,   335,   345,   346,   347,
171
     348,   349
172
};
173
#endif
174

    
175

    
176
#if (YYDEBUG) || defined YYERROR_VERBOSE
177

    
178
/* YYTNAME[TOKEN_NUM] -- String name of the token TOKEN_NUM. */
179
static const char *const yytname[] =
180
{
181
  "$", "error", "$undefined.", "INT", "NOW", "AM", "PM", "NOON", "MIDNIGHT", 
182
  "TEATIME", "SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT", "TODAY", 
183
  "TOMORROW", "NEXT", "MINUTE", "HOUR", "DAY", "WEEK", "MONTH", "YEAR", 
184
  "JAN", "FEB", "MAR", "APR", "MAY", "JUN", "JUL", "AUG", "SEP", "OCT", 
185
  "NOV", "DEC", "WORD", "','", "'-'", "'.'", "'/'", "'+'", "':'", "'\\''", 
186
  "'h'", "timespec", "nowspec", "now", "time_or_not", "time", "date", 
187
  "inc_or_dec", "increment", "decrement", "inc_period", 
188
  "hr24clock_hr_min", "timezone_name", "hr24clock_hour", "minute", 
189
  "am_pm", "month_name", "month_number", "day_number", "year_number", 
190
  "day_of_week", "inc_number", "time_sep", NULL
191
};
192
#endif
193

    
194
/* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */
195
static const short yyr1[] =
196
{
197
       0,    47,    47,    47,    47,    47,    47,    48,    48,    49,
198
      49,    50,    50,    51,    51,    51,    51,    51,    51,    51,
199
      51,    51,    51,    51,    52,    52,    52,    52,    52,    52,
200
      52,    52,    52,    52,    52,    52,    53,    53,    54,    54,
201
      54,    55,    56,    56,    56,    56,    56,    56,    57,    58,
202
      59,    60,    61,    61,    62,    62,    62,    62,    62,    62,
203
      62,    62,    62,    62,    62,    62,    63,    64,    65,    66,
204
      66,    66,    66,    66,    66,    66,    67,    68,    68,    68,
205
      68,    68
206
};
207

    
208
/* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */
209
static const short yyr2[] =
210
{
211
       0,     1,     1,     2,     2,     3,     1,     1,     2,     1,
212
       1,     1,     0,     1,     2,     3,     4,     2,     3,     4,
213
       5,     1,     1,     1,     2,     3,     4,     1,     1,     1,
214
       5,     5,     3,     2,     3,     5,     1,     1,     3,     2,
215
       2,     3,     1,     1,     1,     1,     1,     1,     1,     1,
216
       1,     1,     1,     1,     1,     1,     1,     1,     1,     1,
217
       1,     1,     1,     1,     1,     1,     1,     1,     1,     1,
218
       1,     1,     1,     1,     1,     1,     1,     1,     1,     1,
219
       1,     1
220
};
221

    
222
/* YYDEFACT[S] -- default rule to reduce with in state S when YYTABLE
223
   doesn't specify something else to do.  Zero means the default is an
224
   error. */
225
static const short yydefact[] =
226
{
227
      12,    48,     9,    21,    22,    23,    69,    70,    71,    72,
228
      73,    74,    75,    28,    10,    54,    55,    56,    57,    58,
229
      59,    60,    61,    62,    63,    64,    65,     6,     7,     0,
230
      11,     1,    13,     0,     0,     0,     0,     0,    27,     0,
231
       0,     0,     8,    36,    37,    67,    29,     0,     4,     3,
232
      49,    14,    52,    53,    81,    79,    77,    78,    80,    17,
233
       0,    67,    24,     0,     0,    33,     0,    42,    43,    44,
234
      45,    46,    47,    39,    40,    76,     0,     0,     5,    18,
235
      51,    15,    68,     0,    25,     0,    66,    32,    34,     0,
236
      41,    38,    16,    19,    26,     0,     0,     0,    20,    35,
237
      31,    30,     0,     0,     0
238
};
239

    
240
static const short yydefgoto[] =
241
{
242
     102,    27,    28,    29,    30,    31,    42,    43,    44,    73,
243
      32,    51,    33,    81,    59,    34,    35,    36,    37,    38,
244
      76,    60
245
};
246

    
247
static const short yypact[] =
248
{
249
     114,   -21,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,
250
  -32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,
251
  -32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,   -13,    41,
252
      79,-32768,    -4,     4,    22,   -14,   142,    -8,-32768,   174,
253
      33,    33,-32768,-32768,-32768,   -18,-32768,   -13,-32768,-32768,
254
  -32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,     9,
255
      58,-32768,     0,    22,    59,    61,    59,-32768,-32768,-32768,
256
  -32768,-32768,-32768,-32768,-32768,-32768,    -5,    -5,-32768,-32768,
257
  -32768,     8,-32768,    61,-32768,    23,-32768,    25,-32768,    40,
258
  -32768,-32768,-32768,     9,-32768,    61,    61,    22,-32768,-32768,
259
  -32768,-32768,    83,    85,-32768
260
};
261

    
262
static const short yypgoto[] =
263
{
264
  -32768,-32768,-32768,-32768,-32768,   -22,   -24,-32768,-32768,   -65,
265
  -32768,   -55,-32768,-32768,     5,    51,   -33,   -34,    71,    49,
266
      57,-32768
267
};
268

    
269

    
270
#define        YYLAST                199
271

    
272

    
273
static const short yytable[] =
274
{
275
      62,   -50,   -50,    82,    79,    48,    39,    47,    49,    52,
276
      53,    90,    91,    52,    53,    67,    68,    69,    70,    71,
277
      72,   -66,   -68,    78,   -66,    61,    92,    40,    63,    85,
278
      41,    87,    66,    89,    50,   -50,    75,   -50,    98,    83,
279
     -50,   -50,   -50,    54,    45,    55,    50,    50,    56,    57,
280
      58,     6,     7,     8,     9,    10,    11,    12,    13,    46,
281
      39,    80,    86,   101,    82,    95,    96,    15,    16,    17,
282
      18,    19,    20,    21,    22,    23,    24,    25,    26,    -2,
283
      97,    40,    45,   103,    41,   104,    93,    65,    74,     6,
284
       7,     8,     9,    10,    11,    12,    13,    46,    77,     0,
285
       0,     0,     0,     0,     0,    15,    16,    17,    18,    19,
286
      20,    21,    22,    23,    24,    25,    26,     1,     2,     0,
287
       0,     3,     4,     5,     6,     7,     8,     9,    10,    11,
288
      12,    13,    14,    84,     0,     0,    88,     0,     0,     0,
289
      15,    16,    17,    18,    19,    20,    21,    22,    23,    24,
290
      25,    26,     0,     0,    94,     0,     0,     0,     0,     0,
291
       0,     0,     0,     0,     0,     0,    99,   100,    15,    16,
292
      17,    18,    19,    20,    21,    22,    23,    24,    25,    26,
293
       0,     0,     0,    64,     6,     7,     8,     9,    10,    11,
294
      12,     0,     0,     0,    67,    68,    69,    70,    71,    72
295
};
296

    
297
static const short yycheck[] =
298
{
299
      34,     5,     6,     3,    59,    29,    19,    29,    30,     5,
300
       6,    76,    77,     5,     6,    20,    21,    22,    23,    24,
301
      25,    42,    40,    47,    42,     3,    81,    40,    42,    63,
302
      43,    64,    40,    66,    38,    39,     3,    41,    93,    39,
303
      44,    45,    46,    39,     3,    41,    38,    38,    44,    45,
304
      46,    10,    11,    12,    13,    14,    15,    16,    17,    18,
305
      19,     3,     3,    97,     3,    42,    41,    26,    27,    28,
306
      29,    30,    31,    32,    33,    34,    35,    36,    37,     0,
307
      40,    40,     3,     0,    43,     0,    81,    36,    39,    10,
308
      11,    12,    13,    14,    15,    16,    17,    18,    41,    -1,
309
      -1,    -1,    -1,    -1,    -1,    26,    27,    28,    29,    30,
310
      31,    32,    33,    34,    35,    36,    37,     3,     4,    -1,
311
      -1,     7,     8,     9,    10,    11,    12,    13,    14,    15,
312
      16,    17,    18,    62,    -1,    -1,    65,    -1,    -1,    -1,
313
      26,    27,    28,    29,    30,    31,    32,    33,    34,    35,
314
      36,    37,    -1,    -1,    83,    -1,    -1,    -1,    -1,    -1,
315
      -1,    -1,    -1,    -1,    -1,    -1,    95,    96,    26,    27,
316
      28,    29,    30,    31,    32,    33,    34,    35,    36,    37,
317
      -1,    -1,    -1,    41,    10,    11,    12,    13,    14,    15,
318
      16,    -1,    -1,    -1,    20,    21,    22,    23,    24,    25
319
};
320
/* -*-C-*-  Note some compilers choke on comments on `#line' lines.  */
321
#line 3 "/usr/share/bison/bison.simple"
322

    
323
/* Skeleton output parser for bison,
324
   Copyright (C) 1984, 1989, 1990, 2000, 2001 Free Software Foundation, Inc.
325

326
   This program is free software; you can redistribute it and/or modify
327
   it under the terms of the GNU General Public License as published by
328
   the Free Software Foundation; either version 2, or (at your option)
329
   any later version.
330

331
   This program is distributed in the hope that it will be useful,
332
   but WITHOUT ANY WARRANTY; without even the implied warranty of
333
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
334
   GNU General Public License for more details.
335

336
   You should have received a copy of the GNU General Public License
337
   along with this program; if not, write to the Free Software
338
   Foundation, Inc., 59 Temple Place - Suite 330,
339
   Boston, MA 02111-1307, USA.  */
340

    
341
/* As a special exception, when this file is copied by Bison into a
342
   Bison output file, you may use that output file without restriction.
343
   This special exception was added by the Free Software Foundation
344
   in version 1.24 of Bison.  */
345

    
346
/* This is the parser code that is written into each bison parser when
347
   the %semantic_parser declaration is not specified in the grammar.
348
   It was written by Richard Stallman by simplifying the hairy parser
349
   used when %semantic_parser is specified.  */
350

    
351
/* All symbols defined below should begin with yy or YY, to avoid
352
   infringing on user name space.  This should be done even for local
353
   variables, as they might otherwise be expanded by user macros.
354
   There are some unavoidable exceptions within include files to
355
   define necessary library symbols; they are noted "INFRINGES ON
356
   USER NAME SPACE" below.  */
357

    
358
#ifdef __cplusplus
359
# define YYSTD(x) std::x
360
#else
361
# define YYSTD(x) x
362
#endif
363

    
364
#if ! defined (yyoverflow) || defined (YYERROR_VERBOSE)
365

    
366
/* The parser invokes alloca or malloc; define the necessary symbols.  */
367

    
368
# if YYSTACK_USE_ALLOCA
369
#  define YYSTACK_ALLOC alloca
370
#  define YYSIZE_T YYSTD (size_t)
371
# else
372
#  ifndef YYSTACK_USE_ALLOCA
373
#   if defined (alloca) || defined (_ALLOCA_H)
374
#    define YYSTACK_ALLOC alloca
375
#    define YYSIZE_T YYSTD (size_t)
376
#   else
377
#    ifdef __GNUC__
378
#     define YYSTACK_ALLOC __builtin_alloca
379
#    endif
380
#   endif
381
#  endif
382
# endif
383

    
384
# ifdef YYSTACK_ALLOC
385
   /* Pacify GCC's `empty if-body' warning. */
386
#  define YYSTACK_FREE(Ptr) do { /* empty */; } while (0)
387
# else
388
#  ifdef __cplusplus
389
#   include <cstdlib> /* INFRINGES ON USER NAME SPACE */
390
#   define YYSIZE_T std::size_t
391
#  else
392
#   ifdef __STDC__
393
#    include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
394
#    define YYSIZE_T size_t
395
#   endif
396
#  endif
397
#  define YYSTACK_ALLOC YYSTD (malloc)
398
#  define YYSTACK_FREE YYSTD (free)
399
# endif
400

    
401
/* A type that is properly aligned for any stack member.  */
402
union yyalloc
403
{
404
  short yyss;
405
  YYSTYPE yyvs;
406
# if YYLSP_NEEDED
407
  YYLTYPE yyls;
408
# endif
409
};
410

    
411
/* The size of the maximum gap between one aligned stack and the next.  */
412
# define YYSTACK_GAP_MAX (sizeof (union yyalloc) - 1)
413

    
414
/* The size of an array large to enough to hold all stacks, each with
415
   N elements.  */
416
# if YYLSP_NEEDED
417
#  define YYSTACK_BYTES(N) \
418
     ((N) * (sizeof (short) + sizeof (YYSTYPE) + sizeof (YYLTYPE))        \
419
      + 2 * YYSTACK_GAP_MAX)
420
# else
421
#  define YYSTACK_BYTES(N) \
422
     ((N) * (sizeof (short) + sizeof (YYSTYPE))                                \
423
      + YYSTACK_GAP_MAX)
424
# endif
425

    
426
/* Relocate the TYPE STACK from its old location to the new one.  The
427
   local variables YYSIZE and YYSTACKSIZE give the old and new number of
428
   elements in the stack, and YYPTR gives the new location of the
429
   stack.  Advance YYPTR to a properly aligned location for the next
430
   stack.  */
431
# define YYSTACK_RELOCATE(Type, Stack)                                        \
432
    do                                                                        \
433
      {                                                                        \
434
        YYSIZE_T yynewbytes;                                                \
435
        yymemcpy ((char *) yyptr, (char *) (Stack),                        \
436
                  yysize * (YYSIZE_T) sizeof (Type));                        \
437
        Stack = &yyptr->Stack;                                                \
438
        yynewbytes = yystacksize * sizeof (Type) + YYSTACK_GAP_MAX;        \
439
        yyptr += yynewbytes / sizeof (*yyptr);                                \
440
      }                                                                        \
441
    while (0)
442

    
443
#endif /* ! defined (yyoverflow) || defined (YYERROR_VERBOSE) */
444

    
445

    
446
#if ! defined (YYSIZE_T) && defined (__SIZE_TYPE__)
447
# define YYSIZE_T __SIZE_TYPE__
448
#endif
449
#if ! defined (YYSIZE_T) && defined (size_t)
450
# define YYSIZE_T size_t
451
#endif
452
#if ! defined (YYSIZE_T)
453
# ifdef __cplusplus
454
#  include <cstddef> /* INFRINGES ON USER NAME SPACE */
455
#  define YYSIZE_T std::size_t
456
# else
457
#  ifdef __STDC__
458
#   include <stddef.h> /* INFRINGES ON USER NAME SPACE */
459
#   define YYSIZE_T size_t
460
#  endif
461
# endif
462
#endif
463
#if ! defined (YYSIZE_T)
464
# define YYSIZE_T unsigned int
465
#endif
466

    
467
#define yyerrok                (yyerrstatus = 0)
468
#define yyclearin        (yychar = YYEMPTY)
469
#define YYEMPTY                -2
470
#define YYEOF                0
471
#define YYACCEPT        goto yyacceptlab
472
#define YYABORT         goto yyabortlab
473
#define YYERROR                goto yyerrlab1
474
/* Like YYERROR except do call yyerror.  This remains here temporarily
475
   to ease the transition to the new meaning of YYERROR, for GCC.
476
   Once GCC version 2 has supplanted version 1, this can go.  */
477
#define YYFAIL                goto yyerrlab
478
#define YYRECOVERING()  (!!yyerrstatus)
479
#define YYBACKUP(Token, Value)                                        \
480
do                                                                \
481
  if (yychar == YYEMPTY && yylen == 1)                                \
482
    {                                                                \
483
      yychar = (Token);                                                \
484
      yylval = (Value);                                                \
485
      yychar1 = YYTRANSLATE (yychar);                                \
486
      YYPOPSTACK;                                                \
487
      goto yybackup;                                                \
488
    }                                                                \
489
  else                                                                \
490
    {                                                                 \
491
      yyerror ("syntax error: cannot back up");                        \
492
      YYERROR;                                                        \
493
    }                                                                \
494
while (0)
495

    
496
#define YYTERROR        1
497
#define YYERRCODE        256
498

    
499

    
500
/* YYLLOC_DEFAULT -- Compute the default location (before the actions
501
   are run).
502

503
   When YYLLOC_DEFAULT is run, CURRENT is set the location of the
504
   first token.  By default, to implement support for ranges, extend
505
   its range to the last symbol.  */
506

    
507
#ifndef YYLLOC_DEFAULT
508
# define YYLLOC_DEFAULT(Current, Rhs, N)               \
509
   Current.last_line   = Rhs[N].last_line;        \
510
   Current.last_column = Rhs[N].last_column;
511
#endif
512

    
513

    
514
/* YYLEX -- calling `yylex' with the right arguments.  */
515

    
516
#if YYPURE
517
# if YYLSP_NEEDED
518
#  ifdef YYLEX_PARAM
519
#   define YYLEX                yylex (&yylval, &yylloc, YYLEX_PARAM)
520
#  else
521
#   define YYLEX                yylex (&yylval, &yylloc)
522
#  endif
523
# else /* !YYLSP_NEEDED */
524
#  ifdef YYLEX_PARAM
525
#   define YYLEX                yylex (&yylval, YYLEX_PARAM)
526
#  else
527
#   define YYLEX                yylex (&yylval)
528
#  endif
529
# endif /* !YYLSP_NEEDED */
530
#else /* !YYPURE */
531
# define YYLEX                        yylex ()
532
#endif /* !YYPURE */
533

    
534

    
535
/* Enable debugging if requested.  */
536
#if YYDEBUG
537

    
538
# ifndef YYFPRINTF
539
#  ifdef __cplusplus
540
#   include <cstdio>  /* INFRINGES ON USER NAME SPACE */
541
#  else
542
#   include <stdio.h> /* INFRINGES ON USER NAME SPACE */
543
#  endif
544
#  define YYFPRINTF YYSTD (fprintf)
545
# endif
546

    
547
# define YYDPRINTF(Args)                        \
548
do {                                                \
549
  if (yydebug)                                        \
550
    YYFPRINTF Args;                                \
551
} while (0)
552
/* Nonzero means print parse trace. [The following comment makes no
553
   sense to me.  Could someone clarify it?  --akim] Since this is
554
   uninitialized, it does not stop multiple parsers from coexisting.
555
   */
556
int yydebug;
557
#else /* !YYDEBUG */
558
# define YYDPRINTF(Args)
559
#endif /* !YYDEBUG */
560

    
561
/* YYINITDEPTH -- initial size of the parser's stacks.  */
562
#ifndef        YYINITDEPTH
563
# define YYINITDEPTH 200
564
#endif
565

    
566
/* YYMAXDEPTH -- maximum size the stacks can grow to (effective only
567
   if the built-in stack extension method is used).
568

569
   Do not make this value too large; the results are undefined if
570
   SIZE_MAX < YYSTACK_BYTES (YYMAXDEPTH)
571
   evaluated with infinite-precision integer arithmetic.  */
572

    
573
#if YYMAXDEPTH == 0
574
# undef YYMAXDEPTH
575
#endif
576

    
577
#ifndef YYMAXDEPTH
578
# define YYMAXDEPTH 10000
579
#endif
580
 
581
#if ! defined (yyoverflow) && ! defined (yymemcpy)
582
# if __GNUC__ > 1                /* GNU C and GNU C++ define this.  */
583
#  define yymemcpy __builtin_memcpy
584
# else                                /* not GNU C or C++ */
585

    
586
/* This is the most reliable way to avoid incompatibilities
587
   in available built-in functions on various systems.  */
588
static void
589
#  if defined (__STDC__) || defined (__cplusplus)
590
yymemcpy (char *yyto, const char *yyfrom, YYSIZE_T yycount)
591
#  else
592
yymemcpy (yyto, yyfrom, yycount)
593
     char *yyto;
594
     const char *yyfrom;
595
     YYSIZE_T yycount;
596
#  endif
597
{
598
  register const char *yyf = yyfrom;
599
  register char *yyt = yyto;
600
  register YYSIZE_T yyi = yycount;
601

    
602
  while (yyi-- != 0)
603
    *yyt++ = *yyf++;
604
}
605
# endif
606
#endif
607

    
608
#ifdef YYERROR_VERBOSE
609

    
610
# ifndef yystrlen
611
#  if defined (__GLIBC__) && defined (_STRING_H)
612
#   define yystrlen strlen
613
#  else
614
/* Return the length of YYSTR.  */
615
static YYSIZE_T
616
#   if defined (__STDC__) || defined (__cplusplus)
617
yystrlen (const char *yystr)
618
#   else
619
yystrlen (yystr)
620
     const char *yystr;
621
#   endif
622
{
623
  register const char *yys = yystr;
624

    
625
  while (*yys++ != '\0')
626
    continue;
627

    
628
  return yys - yystr - 1;
629
}
630
#  endif
631
# endif
632

    
633
# ifndef yystpcpy
634
#  if defined (__GLIBC__) && defined (_STRING_H) && defined (_GNU_SOURCE)
635
#   define yystpcpy stpcpy
636
#  else
637
/* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in
638
   YYDEST.  */
639
static char *
640
#   if defined (__STDC__) || defined (__cplusplus)
641
yystpcpy (char *yydest, const char *yysrc)
642
#   else
643
yystpcpy (yydest, yysrc)
644
     char *yydest;
645
     const char *yysrc;
646
#   endif
647
{
648
  register char *yyd = yydest;
649
  register const char *yys = yysrc;
650

    
651
  while ((*yyd++ = *yys++) != '\0')
652
    continue;
653

    
654
  return yyd - 1;
655
}
656
#  endif
657
# endif
658
#endif
659
 
660
#line 341 "/usr/share/bison/bison.simple"
661

    
662

    
663
/* The user can define YYPARSE_PARAM as the name of an argument to be passed
664
   into yyparse.  The argument should have type void *.
665
   It should actually point to an object.
666
   Grammar actions can access the variable by casting it
667
   to the proper pointer type.  */
668

    
669
#ifdef YYPARSE_PARAM
670
# ifdef __cplusplus
671
#  define YYPARSE_PARAM_ARG void *YYPARSE_PARAM
672
#  define YYPARSE_PARAM_DECL
673
# else /* !__cplusplus */
674
#  define YYPARSE_PARAM_ARG YYPARSE_PARAM
675
#  define YYPARSE_PARAM_DECL void *YYPARSE_PARAM;
676
# endif /* !__cplusplus */
677
#else /* !YYPARSE_PARAM */
678
# define YYPARSE_PARAM_ARG
679
# define YYPARSE_PARAM_DECL
680
#endif /* !YYPARSE_PARAM */
681

    
682
/* Prevent warning if -Wstrict-prototypes.  */
683
#ifdef __GNUC__
684
# ifdef YYPARSE_PARAM
685
int yyparse (void *);
686
# else
687
int yyparse (void);
688
# endif
689
#endif
690

    
691
/* YY_DECL_VARIABLES -- depending whether we use a pure parser,
692
   variables are global, or local to YYPARSE.  */
693

    
694
#define YY_DECL_NON_LSP_VARIABLES                        \
695
/* The lookahead symbol.  */                                \
696
int yychar;                                                \
697
                                                        \
698
/* The semantic value of the lookahead symbol. */        \
699
YYSTYPE yylval;                                                \
700
                                                        \
701
/* Number of parse errors so far.  */                        \
702
int yynerrs;
703

    
704
#if YYLSP_NEEDED
705
# define YY_DECL_VARIABLES                        \
706
YY_DECL_NON_LSP_VARIABLES                        \
707
                                                \
708
/* Location data for the lookahead symbol.  */        \
709
YYLTYPE yylloc;
710
#else
711
# define YY_DECL_VARIABLES                        \
712
YY_DECL_NON_LSP_VARIABLES
713
#endif
714

    
715

    
716
/* If nonreentrant, generate the variables here. */
717

    
718
#if !YYPURE
719
YY_DECL_VARIABLES
720
#endif  /* !YYPURE */
721

    
722
int
723
yyparse (YYPARSE_PARAM_ARG)
724
     YYPARSE_PARAM_DECL
725
{
726
  /* If reentrant, generate the variables here. */
727
#if YYPURE
728
  YY_DECL_VARIABLES
729
#endif  /* !YYPURE */
730

    
731
  register int yystate;
732
  register int yyn;
733
  int yyresult;
734
  /* Number of tokens to shift before error messages enabled.  */
735
  int yyerrstatus;
736
  /* Lookahead token as an internal (translated) token number.  */
737
  int yychar1 = 0;
738

    
739
  /* Three stacks and their tools:
740
     `yyss': related to states,
741
     `yyvs': related to semantic values,
742
     `yyls': related to locations.
743

744
     Refer to the stacks thru separate pointers, to allow yyoverflow
745
     to reallocate them elsewhere.  */
746

    
747
  /* The state stack. */
748
  short        yyssa[YYINITDEPTH];
749
  short *yyss = yyssa;
750
  register short *yyssp;
751

    
752
  /* The semantic value stack.  */
753
  YYSTYPE yyvsa[YYINITDEPTH];
754
  YYSTYPE *yyvs = yyvsa;
755
  register YYSTYPE *yyvsp;
756

    
757
#if YYLSP_NEEDED
758
  /* The location stack.  */
759
  YYLTYPE yylsa[YYINITDEPTH];
760
  YYLTYPE *yyls = yylsa;
761
  YYLTYPE *yylsp;
762
#endif
763

    
764
#if YYLSP_NEEDED
765
# define YYPOPSTACK   (yyvsp--, yyssp--, yylsp--)
766
#else
767
# define YYPOPSTACK   (yyvsp--, yyssp--)
768
#endif
769

    
770
  YYSIZE_T yystacksize = YYINITDEPTH;
771

    
772

    
773
  /* The variables used to return semantic value and location from the
774
     action routines.  */
775
  YYSTYPE yyval;
776
#if YYLSP_NEEDED
777
  YYLTYPE yyloc;
778
#endif
779

    
780
  /* When reducing, the number of symbols on the RHS of the reduced
781
     rule. */
782
  int yylen;
783

    
784
  YYDPRINTF ((stderr, "Starting parse\n"));
785

    
786
  yystate = 0;
787
  yyerrstatus = 0;
788
  yynerrs = 0;
789
  yychar = YYEMPTY;                /* Cause a token to be read.  */
790

    
791
  /* Initialize stack pointers.
792
     Waste one element of value and location stack
793
     so that they stay on the same level as the state stack.
794
     The wasted elements are never initialized.  */
795

    
796
  yyssp = yyss;
797
  yyvsp = yyvs;
798
#if YYLSP_NEEDED
799
  yylsp = yyls;
800
#endif
801
  goto yysetstate;
802

    
803
/*------------------------------------------------------------.
804
| yynewstate -- Push a new state, which is found in yystate.  |
805
`------------------------------------------------------------*/
806
 yynewstate:
807
  /* In all cases, when you get here, the value and location stacks
808
     have just been pushed. so pushing a state here evens the stacks.
809
     */
810
  yyssp++;
811

    
812
 yysetstate:
813
  *yyssp = yystate;
814

    
815
  if (yyssp >= yyss + yystacksize - 1)
816
    {
817
      /* Get the current used size of the three stacks, in elements.  */
818
      YYSIZE_T yysize = yyssp - yyss + 1;
819

    
820
#ifdef yyoverflow
821
      {
822
        /* Give user a chance to reallocate the stack. Use copies of
823
           these so that the &'s don't force the real ones into
824
           memory.  */
825
        YYSTYPE *yyvs1 = yyvs;
826
        short *yyss1 = yyss;
827

    
828
        /* Each stack pointer address is followed by the size of the
829
           data in use in that stack, in bytes.  */
830
# if YYLSP_NEEDED
831
        YYLTYPE *yyls1 = yyls;
832
        /* This used to be a conditional around just the two extra args,
833
           but that might be undefined if yyoverflow is a macro.  */
834
        yyoverflow ("parser stack overflow",
835
                    &yyss1, yysize * sizeof (*yyssp),
836
                    &yyvs1, yysize * sizeof (*yyvsp),
837
                    &yyls1, yysize * sizeof (*yylsp),
838
                    &yystacksize);
839
        yyls = yyls1;
840
# else
841
        yyoverflow ("parser stack overflow",
842
                    &yyss1, yysize * sizeof (*yyssp),
843
                    &yyvs1, yysize * sizeof (*yyvsp),
844
                    &yystacksize);
845
# endif
846
        yyss = yyss1;
847
        yyvs = yyvs1;
848
      }
849
#else /* no yyoverflow */
850
      /* Extend the stack our own way.  */
851
      if (yystacksize >= YYMAXDEPTH)
852
        goto yyoverflowlab;
853
      yystacksize *= 2;
854
      if (yystacksize > YYMAXDEPTH)
855
        yystacksize = YYMAXDEPTH;
856

    
857
      {
858
        short *yyss1 = yyss;
859
        union yyalloc *yyptr =
860
          (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize));
861
        if (! yyptr)
862
          goto yyoverflowlab;
863
        YYSTACK_RELOCATE (short, yyss);
864
        YYSTACK_RELOCATE (YYSTYPE, yyvs);
865
# if YYLSP_NEEDED
866
        YYSTACK_RELOCATE (YYLTYPE, yyls);
867
# endif
868
# undef YYSTACK_RELOCATE
869
        if (yyss1 != yyssa)
870
          YYSTACK_FREE (yyss1);
871
      }
872
#endif /* no yyoverflow */
873

    
874
      yyssp = yyss + yysize - 1;
875
      yyvsp = yyvs + yysize - 1;
876
#if YYLSP_NEEDED
877
      yylsp = yyls + yysize - 1;
878
#endif
879

    
880
      YYDPRINTF ((stderr, "Stack size increased to %lu\n",
881
                  (unsigned long int) yystacksize));
882

    
883
      if (yyssp >= yyss + yystacksize - 1)
884
        YYABORT;
885
    }
886

    
887
  YYDPRINTF ((stderr, "Entering state %d\n", yystate));
888

    
889
  goto yybackup;
890

    
891

    
892
/*-----------.
893
| yybackup.  |
894
`-----------*/
895
yybackup:
896

    
897
/* Do appropriate processing given the current state.  */
898
/* Read a lookahead token if we need one and don't already have one.  */
899
/* yyresume: */
900

    
901
  /* First try to decide what to do without reference to lookahead token.  */
902

    
903
  yyn = yypact[yystate];
904
  if (yyn == YYFLAG)
905
    goto yydefault;
906

    
907
  /* Not known => get a lookahead token if don't already have one.  */
908

    
909
  /* yychar is either YYEMPTY or YYEOF
910
     or a valid token in external form.  */
911

    
912
  if (yychar == YYEMPTY)
913
    {
914
      YYDPRINTF ((stderr, "Reading a token: "));
915
      yychar = YYLEX;
916
    }
917

    
918
  /* Convert token to internal form (in yychar1) for indexing tables with */
919

    
920
  if (yychar <= 0)                /* This means end of input. */
921
    {
922
      yychar1 = 0;
923
      yychar = YYEOF;                /* Don't call YYLEX any more */
924

    
925
      YYDPRINTF ((stderr, "Now at end of input.\n"));
926
    }
927
  else
928
    {
929
      yychar1 = YYTRANSLATE (yychar);
930

    
931
#if YYDEBUG
932
     /* We have to keep this `#if YYDEBUG', since we use variables
933
        which are defined only if `YYDEBUG' is set.  */
934
      if (yydebug)
935
        {
936
          YYFPRINTF (stderr, "Next token is %d (%s",
937
                     yychar, yytname[yychar1]);
938
          /* Give the individual parser a way to print the precise
939
             meaning of a token, for further debugging info.  */
940
# ifdef YYPRINT
941
          YYPRINT (stderr, yychar, yylval);
942
# endif
943
          YYFPRINTF (stderr, ")\n");
944
        }
945
#endif
946
    }
947

    
948
  yyn += yychar1;
949
  if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != yychar1)
950
    goto yydefault;
951

    
952
  yyn = yytable[yyn];
953

    
954
  /* yyn is what to do for this token type in this state.
955
     Negative => reduce, -yyn is rule number.
956
     Positive => shift, yyn is new state.
957
       New state is final state => don't bother to shift,
958
       just return success.
959
     0, or most negative number => error.  */
960

    
961
  if (yyn < 0)
962
    {
963
      if (yyn == YYFLAG)
964
        goto yyerrlab;
965
      yyn = -yyn;
966
      goto yyreduce;
967
    }
968
  else if (yyn == 0)
969
    goto yyerrlab;
970

    
971
  if (yyn == YYFINAL)
972
    YYACCEPT;
973

    
974
  /* Shift the lookahead token.  */
975
  YYDPRINTF ((stderr, "Shifting token %d (%s), ",
976
              yychar, yytname[yychar1]));
977

    
978
  /* Discard the token being shifted unless it is eof.  */
979
  if (yychar != YYEOF)
980
    yychar = YYEMPTY;
981

    
982
  *++yyvsp = yylval;
983
#if YYLSP_NEEDED
984
  *++yylsp = yylloc;
985
#endif
986

    
987
  /* Count tokens shifted since error; after three, turn off error
988
     status.  */
989
  if (yyerrstatus)
990
    yyerrstatus--;
991

    
992
  yystate = yyn;
993
  goto yynewstate;
994

    
995

    
996
/*-----------------------------------------------------------.
997
| yydefault -- do the default action for the current state.  |
998
`-----------------------------------------------------------*/
999
yydefault:
1000
  yyn = yydefact[yystate];
1001
  if (yyn == 0)
1002
    goto yyerrlab;
1003
  goto yyreduce;
1004

    
1005

    
1006
/*-----------------------------.
1007
| yyreduce -- Do a reduction.  |
1008
`-----------------------------*/
1009
yyreduce:
1010
  /* yyn is the number of a rule to reduce with.  */
1011
  yylen = yyr2[yyn];
1012

    
1013
  /* If YYLEN is nonzero, implement the default value of the action:
1014
     `$$ = $1'.
1015

1016
     Otherwise, the following line sets YYVAL to the semantic value of
1017
     the lookahead token.  This behavior is undocumented and Bison
1018
     users should not rely upon it.  Assigning to YYVAL
1019
     unconditionally makes the parser a bit smaller, and it avoids a
1020
     GCC warning that YYVAL may be used uninitialized.  */
1021
  yyval = yyvsp[1-yylen];
1022

    
1023
#if YYLSP_NEEDED
1024
  /* Similarly for the default location.  Let the user run additional
1025
     commands if for instance locations are ranges.  */
1026
  yyloc = yylsp[1-yylen];
1027
  YYLLOC_DEFAULT (yyloc, (yylsp - yylen), yylen);
1028
#endif
1029

    
1030
#if YYDEBUG
1031
  /* We have to keep this `#if YYDEBUG', since we use variables which
1032
     are defined only if `YYDEBUG' is set.  */
1033
  if (yydebug)
1034
    {
1035
      int yyi;
1036

    
1037
      YYFPRINTF (stderr, "Reducing via rule %d (line %d), ",
1038
                 yyn, yyrline[yyn]);
1039

    
1040
      /* Print the symbols being reduced, and their result.  */
1041
      for (yyi = yyprhs[yyn]; yyrhs[yyi] > 0; yyi++)
1042
        YYFPRINTF (stderr, "%s ", yytname[yyrhs[yyi]]);
1043
      YYFPRINTF (stderr, " -> %s\n", yytname[yyr1[yyn]]);
1044
    }
1045
#endif
1046

    
1047
  switch (yyn) {
1048

    
1049
case 2:
1050
#line 44 "parsetime.y"
1051
{
1052
                        time_only = 1;
1053
                    }
1054
    break;
1055
case 10:
1056
#line 59 "parsetime.y"
1057
{
1058
                        add_date(1, DAY);
1059
                   }
1060
    break;
1061
case 21:
1062
#line 76 "parsetime.y"
1063
{
1064
                        exectm.tm_hour = 12;
1065
                        exectm.tm_min = 0;
1066
                    }
1067
    break;
1068
case 22:
1069
#line 81 "parsetime.y"
1070
{
1071
                        exectm.tm_hour = 0;
1072
                        exectm.tm_min = 0;
1073
                        add_date(1, DAY);
1074
                    }
1075
    break;
1076
case 23:
1077
#line 87 "parsetime.y"
1078
{
1079
                        exectm.tm_hour = 16;
1080
                        exectm.tm_min = 0;
1081
                    }
1082
    break;
1083
case 27:
1084
#line 97 "parsetime.y"
1085
{
1086
                       add_date ((6 + yyvsp[0].intval - exectm.tm_wday) %7 + 1, DAY);
1087
                   }
1088
    break;
1089
case 29:
1090
#line 102 "parsetime.y"
1091
{
1092
                        add_date(1, DAY);
1093
                   }
1094
    break;
1095
case 38:
1096
#line 117 "parsetime.y"
1097
{
1098
                        add_date(yyvsp[-1].intval, yyvsp[0].intval);
1099
                    }
1100
    break;
1101
case 39:
1102
#line 121 "parsetime.y"
1103
{
1104
                        add_date(1, yyvsp[0].intval);
1105
                    }
1106
    break;
1107
case 40:
1108
#line 125 "parsetime.y"
1109
{
1110
                        add_date ((6 + yyvsp[0].intval - exectm.tm_wday) %7 +1, DAY);
1111
                    }
1112
    break;
1113
case 41:
1114
#line 131 "parsetime.y"
1115
{
1116
                        add_date(-yyvsp[-1].intval, yyvsp[0].intval);
1117
                    }
1118
    break;
1119
case 42:
1120
#line 136 "parsetime.y"
1121
{ yyval.intval = MINUTE ; }
1122
    break;
1123
case 43:
1124
#line 137 "parsetime.y"
1125
{ yyval.intval = HOUR ; }
1126
    break;
1127
case 44:
1128
#line 138 "parsetime.y"
1129
{ yyval.intval = DAY ; }
1130
    break;
1131
case 45:
1132
#line 139 "parsetime.y"
1133
{ yyval.intval = WEEK ; }
1134
    break;
1135
case 46:
1136
#line 140 "parsetime.y"
1137
{ yyval.intval = MONTH ; }
1138
    break;
1139
case 47:
1140
#line 141 "parsetime.y"
1141
{ yyval.intval = YEAR ; }
1142
    break;
1143
case 48:
1144
#line 145 "parsetime.y"
1145
{
1146
                        if (strlen(yyvsp[0].charval) == 4) {
1147
                            exectm.tm_min = -1;
1148
                            exectm.tm_hour = -1;
1149
                            sscanf(yyvsp[0].charval, "%2d %2d", &exectm.tm_hour,
1150
                                &exectm.tm_min);
1151
                        } else if (strlen(yyvsp[0].charval) >= 5 && strlen(yyvsp[0].charval) <= 8) {
1152
                                /* Ok, this is a kluge.  I hate design errors...  -Joey */
1153
                                char shallot[5];
1154
                                char *onion;
1155

    
1156
                                onion=yyvsp[0].charval;
1157
                                memset (shallot, 0, sizeof (shallot));
1158
                                if (strlen(yyvsp[0].charval) == 5 || strlen(yyvsp[0].charval) == 7) {
1159
                                    strncpy (shallot,onion,1);
1160
                                    onion++;
1161
                                } else {
1162
                                    strncpy (shallot,onion,2);
1163
                                    onion+=2;
1164
                                }
1165
                                sscanf(shallot, "%d", &exectm.tm_mon);
1166

    
1167
                                if (exectm.tm_mon < 1 || exectm.tm_mon > 12) {
1168
                                    yyerror("Error in month number");
1169
                                    YYERROR;
1170
                                }
1171
                                exectm.tm_mon--;
1172

    
1173
                                memset (shallot, 0, sizeof (shallot));
1174
                                strncpy (shallot,onion,2);
1175
                                    sscanf(shallot, "%d", &exectm.tm_mday);
1176
                                if (exectm.tm_mday < 0 || exectm.tm_mday > 31)
1177
                                {
1178
                                    yyerror("Error in day of month");
1179
                                    YYERROR;
1180
                                }
1181

    
1182
                                onion+=2;
1183
                                memset (shallot, 0, sizeof (shallot));
1184
                                strncpy (shallot,onion,4);
1185
                                if ( sscanf(shallot, "%d", &exectm.tm_year) != 1) {
1186
                                    yyerror("Error in year");
1187
                                    YYERROR;
1188
                                }
1189
                                if (exectm.tm_year < 70) {
1190
                                    exectm.tm_year += 100;
1191
                                }
1192
                                else if (exectm.tm_year > 1900) {
1193
                                    exectm.tm_year -= 1900;
1194
                                }
1195
                        }
1196
                        else {
1197
                            sscanf(yyvsp[0].charval, "%d", &exectm.tm_hour);
1198
                            exectm.tm_min = 0;
1199
                        }
1200
                        free(yyvsp[0].charval);
1201

    
1202
                        if (exectm.tm_min > 60 || exectm.tm_min < 0) {
1203
                            yyerror("Problem in minutes specification");
1204
                            YYERROR;
1205
                        }
1206
                        if (exectm.tm_hour > 24 || exectm.tm_hour < 0) {
1207
                            yyerror("Problem in hours specification");
1208
                            YYERROR;
1209
                        }
1210
                    }
1211
    break;
1212
case 49:
1213
#line 214 "parsetime.y"
1214
{
1215
                        if (strcasecmp(yyvsp[0].charval,"utc") == 0) {
1216
                            isgmt = 1;
1217
                        }
1218
                        else {
1219
                            yyerror("Only UTC timezone is supported");
1220
                            YYERROR;
1221
                        }
1222
                        free(yyvsp[0].charval);
1223
                    }
1224
    break;
1225
case 51:
1226
#line 230 "parsetime.y"
1227
{
1228
                        if (sscanf(yyvsp[0].charval, "%d", &exectm.tm_min) != 1) {
1229
                            yyerror("Error in minute");
1230
                            YYERROR;
1231
                        }
1232
                        free(yyvsp[0].charval);
1233
                    }
1234
    break;
1235
case 52:
1236
#line 240 "parsetime.y"
1237
{
1238
                        if (exectm.tm_hour > 12) {
1239
                            yyerror("Hour too large for AM");
1240
                            YYERROR;
1241
                        }
1242
                        else if (exectm.tm_hour == 12) {
1243
                            exectm.tm_hour = 0;
1244
                        }
1245
                    }
1246
    break;
1247
case 53:
1248
#line 250 "parsetime.y"
1249
{
1250
                        if (exectm.tm_hour > 12) {
1251
                            yyerror("Hour too large for PM");
1252
                            YYERROR;
1253
                        }
1254
                        else if (exectm.tm_hour < 12) {
1255
                            exectm.tm_hour +=12;
1256
                        }
1257
                    }
1258
    break;
1259
case 54:
1260
#line 262 "parsetime.y"
1261
{ exectm.tm_mon = 0; }
1262
    break;
1263
case 55:
1264
#line 263 "parsetime.y"
1265
{ exectm.tm_mon = 1; }
1266
    break;
1267
case 56:
1268
#line 264 "parsetime.y"
1269
{ exectm.tm_mon = 2; }
1270
    break;
1271
case 57:
1272
#line 265 "parsetime.y"
1273
{ exectm.tm_mon = 3; }
1274
    break;
1275
case 58:
1276
#line 266 "parsetime.y"
1277
{ exectm.tm_mon = 4; }
1278
    break;
1279
case 59:
1280
#line 267 "parsetime.y"
1281
{ exectm.tm_mon = 5; }
1282
    break;
1283
case 60:
1284
#line 268 "parsetime.y"
1285
{ exectm.tm_mon = 6; }
1286
    break;
1287
case 61:
1288
#line 269 "parsetime.y"
1289
{ exectm.tm_mon = 7; }
1290
    break;
1291
case 62:
1292
#line 270 "parsetime.y"
1293
{ exectm.tm_mon = 8; }
1294
    break;
1295
case 63:
1296
#line 271 "parsetime.y"
1297
{ exectm.tm_mon = 9; }
1298
    break;
1299
case 64:
1300
#line 272 "parsetime.y"
1301
{ exectm.tm_mon =10; }
1302
    break;
1303
case 65:
1304
#line 273 "parsetime.y"
1305
{ exectm.tm_mon =11; }
1306
    break;
1307
case 66:
1308
#line 277 "parsetime.y"
1309
{
1310
                        {
1311
                            int mnum = -1;
1312
                            sscanf(yyvsp[0].charval, "%d", &mnum);
1313

    
1314
                            if (mnum < 1 || mnum > 12) {
1315
                                yyerror("Error in month number");
1316
                                YYERROR;
1317
                            }
1318
                            exectm.tm_mon = mnum -1;
1319
                            free(yyvsp[0].charval);
1320
                        }
1321
                    }
1322
    break;
1323
case 67:
1324
#line 291 "parsetime.y"
1325
{
1326
                        exectm.tm_mday = -1;
1327
                        sscanf(yyvsp[0].charval, "%d", &exectm.tm_mday);
1328
                        if (exectm.tm_mday < 0 || exectm.tm_mday > 31)
1329
                        {
1330
                            yyerror("Error in day of month");
1331
                            YYERROR; 
1332
                        }
1333
                        free(yyvsp[0].charval);
1334
                     }
1335
    break;
1336
case 68:
1337
#line 304 "parsetime.y"
1338
{ 
1339
                        {
1340
                            int ynum;
1341

    
1342
                            if ( sscanf(yyvsp[0].charval, "%d", &ynum) != 1) {
1343
                                yyerror("Error in year");
1344
                                YYERROR;
1345
                            }
1346
                            if (ynum < 70) {
1347
                                ynum += 100;
1348
                            }
1349
                            else if (ynum > 1900) {
1350
                                ynum -= 1900;
1351
                            }
1352

    
1353
                            exectm.tm_year = ynum ;
1354
                            free(yyvsp[0].charval);
1355
                        }
1356
                    }
1357
    break;
1358
case 69:
1359
#line 326 "parsetime.y"
1360
{ yyval.intval = 0; }
1361
    break;
1362
case 70:
1363
#line 327 "parsetime.y"
1364
{ yyval.intval = 1; }
1365
    break;
1366
case 71:
1367
#line 328 "parsetime.y"
1368
{ yyval.intval = 2; }
1369
    break;
1370
case 72:
1371
#line 329 "parsetime.y"
1372
{ yyval.intval = 3; }
1373
    break;
1374
case 73:
1375
#line 330 "parsetime.y"
1376
{ yyval.intval = 4; }
1377
    break;
1378
case 74:
1379
#line 331 "parsetime.y"
1380
{ yyval.intval = 5; }
1381
    break;
1382
case 75:
1383
#line 332 "parsetime.y"
1384
{ yyval.intval = 6; }
1385
    break;
1386
case 76:
1387
#line 336 "parsetime.y"
1388
{
1389
                        if (sscanf(yyvsp[0].charval, "%d", &yyval.intval) != 1) {
1390
                            yyerror("Unknown increment");
1391
                            YYERROR;
1392
                        }
1393
                        free(yyvsp[0].charval);
1394
                    }
1395
    break;
1396
}
1397

    
1398
#line 727 "/usr/share/bison/bison.simple"
1399

    
1400
 
1401
  yyvsp -= yylen;
1402
  yyssp -= yylen;
1403
#if YYLSP_NEEDED
1404
  yylsp -= yylen;
1405
#endif
1406

    
1407
#if YYDEBUG
1408
  if (yydebug)
1409
    {
1410
      short *yyssp1 = yyss - 1;
1411
      YYFPRINTF (stderr, "state stack now");
1412
      while (yyssp1 != yyssp)
1413
        YYFPRINTF (stderr, " %d", *++yyssp1);
1414
      YYFPRINTF (stderr, "\n");
1415
    }
1416
#endif
1417

    
1418
  *++yyvsp = yyval;
1419
#if YYLSP_NEEDED
1420
  *++yylsp = yyloc;
1421
#endif
1422

    
1423
  /* Now `shift' the result of the reduction.  Determine what state
1424
     that goes to, based on the state we popped back to and the rule
1425
     number reduced by.  */
1426

    
1427
  yyn = yyr1[yyn];
1428

    
1429
  yystate = yypgoto[yyn - YYNTBASE] + *yyssp;
1430
  if (yystate >= 0 && yystate <= YYLAST && yycheck[yystate] == *yyssp)
1431
    yystate = yytable[yystate];
1432
  else
1433
    yystate = yydefgoto[yyn - YYNTBASE];
1434

    
1435
  goto yynewstate;
1436

    
1437

    
1438
/*------------------------------------.
1439
| yyerrlab -- here on detecting error |
1440
`------------------------------------*/
1441
yyerrlab:
1442
  /* If not already recovering from an error, report this error.  */
1443
  if (!yyerrstatus)
1444
    {
1445
      ++yynerrs;
1446

    
1447
#ifdef YYERROR_VERBOSE
1448
      yyn = yypact[yystate];
1449

    
1450
      if (yyn > YYFLAG && yyn < YYLAST)
1451
        {
1452
          YYSIZE_T yysize = 0;
1453
          char *yymsg;
1454
          int yyx, yycount;
1455

    
1456
          yycount = 0;
1457
          /* Start YYX at -YYN if negative to avoid negative indexes in
1458
             YYCHECK.  */
1459
          for (yyx = yyn < 0 ? -yyn : 0;
1460
               yyx < (int) (sizeof (yytname) / sizeof (char *)); yyx++)
1461
            if (yycheck[yyx + yyn] == yyx)
1462
              yysize += yystrlen (yytname[yyx]) + 15, yycount++;
1463
          yysize += yystrlen ("parse error, unexpected ") + 1;
1464
          yysize += yystrlen (yytname[YYTRANSLATE (yychar)]);
1465
          yymsg = (char *) YYSTACK_ALLOC (yysize);
1466
          if (yymsg != 0)
1467
            {
1468
              char *yyp = yystpcpy (yymsg, "parse error, unexpected ");
1469
              yyp = yystpcpy (yyp, yytname[YYTRANSLATE (yychar)]);
1470

    
1471
              if (yycount < 5)
1472
                {
1473
                  yycount = 0;
1474
                  for (yyx = yyn < 0 ? -yyn : 0;
1475
                       yyx < (int) (sizeof (yytname) / sizeof (char *));
1476
                       yyx++)
1477
                    if (yycheck[yyx + yyn] == yyx)
1478
                      {
1479
                        const char *yyq = ! yycount ? ", expecting " : " or ";
1480
                        yyp = yystpcpy (yyp, yyq);
1481
                        yyp = yystpcpy (yyp, yytname[yyx]);
1482
                        yycount++;
1483
                      }
1484
                }
1485
              yyerror (yymsg);
1486
              YYSTACK_FREE (yymsg);
1487
            }
1488
          else
1489
            yyerror ("parse error; also virtual memory exhausted");
1490
        }
1491
      else
1492
#endif /* defined (YYERROR_VERBOSE) */
1493
        yyerror ("parse error");
1494
    }
1495
  goto yyerrlab1;
1496

    
1497

    
1498
/*--------------------------------------------------.
1499
| yyerrlab1 -- error raised explicitly by an action |
1500
`--------------------------------------------------*/
1501
yyerrlab1:
1502
  if (yyerrstatus == 3)
1503
    {
1504
      /* If just tried and failed to reuse lookahead token after an
1505
         error, discard it.  */
1506

    
1507
      /* return failure if at end of input */
1508
      if (yychar == YYEOF)
1509
        YYABORT;
1510
      YYDPRINTF ((stderr, "Discarding token %d (%s).\n",
1511
                  yychar, yytname[yychar1]));
1512
      yychar = YYEMPTY;
1513
    }
1514

    
1515
  /* Else will try to reuse lookahead token after shifting the error
1516
     token.  */
1517

    
1518
  yyerrstatus = 3;                /* Each real token shifted decrements this */
1519

    
1520
  goto yyerrhandle;
1521

    
1522

    
1523
/*-------------------------------------------------------------------.
1524
| yyerrdefault -- current state does not do anything special for the |
1525
| error token.                                                       |
1526
`-------------------------------------------------------------------*/
1527
yyerrdefault:
1528
#if 0
1529
  /* This is wrong; only states that explicitly want error tokens
1530
     should shift them.  */
1531

1532
  /* If its default is to accept any token, ok.  Otherwise pop it.  */
1533
  yyn = yydefact[yystate];
1534
  if (yyn)
1535
    goto yydefault;
1536
#endif
1537

    
1538

    
1539
/*---------------------------------------------------------------.
1540
| yyerrpop -- pop the current state because it cannot handle the |
1541
| error token                                                    |
1542
`---------------------------------------------------------------*/
1543
yyerrpop:
1544
  if (yyssp == yyss)
1545
    YYABORT;
1546
  yyvsp--;
1547
  yystate = *--yyssp;
1548
#if YYLSP_NEEDED
1549
  yylsp--;
1550
#endif
1551

    
1552
#if YYDEBUG
1553
  if (yydebug)
1554
    {
1555
      short *yyssp1 = yyss - 1;
1556
      YYFPRINTF (stderr, "Error: state stack now");
1557
      while (yyssp1 != yyssp)
1558
        YYFPRINTF (stderr, " %d", *++yyssp1);
1559
      YYFPRINTF (stderr, "\n");
1560
    }
1561
#endif
1562

    
1563
/*--------------.
1564
| yyerrhandle.  |
1565
`--------------*/
1566
yyerrhandle:
1567
  yyn = yypact[yystate];
1568
  if (yyn == YYFLAG)
1569
    goto yyerrdefault;
1570

    
1571
  yyn += YYTERROR;
1572
  if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != YYTERROR)
1573
    goto yyerrdefault;
1574

    
1575
  yyn = yytable[yyn];
1576
  if (yyn < 0)
1577
    {
1578
      if (yyn == YYFLAG)
1579
        goto yyerrpop;
1580
      yyn = -yyn;
1581
      goto yyreduce;
1582
    }
1583
  else if (yyn == 0)
1584
    goto yyerrpop;
1585

    
1586
  if (yyn == YYFINAL)
1587
    YYACCEPT;
1588

    
1589
  YYDPRINTF ((stderr, "Shifting error token, "));
1590

    
1591
  *++yyvsp = yylval;
1592
#if YYLSP_NEEDED
1593
  *++yylsp = yylloc;
1594
#endif
1595

    
1596
  yystate = yyn;
1597
  goto yynewstate;
1598

    
1599

    
1600
/*-------------------------------------.
1601
| yyacceptlab -- YYACCEPT comes here.  |
1602
`-------------------------------------*/
1603
yyacceptlab:
1604
  yyresult = 0;
1605
  goto yyreturn;
1606

    
1607
/*-----------------------------------.
1608
| yyabortlab -- YYABORT comes here.  |
1609
`-----------------------------------*/
1610
yyabortlab:
1611
  yyresult = 1;
1612
  goto yyreturn;
1613

    
1614
/*---------------------------------------------.
1615
| yyoverflowab -- parser overflow comes here.  |
1616
`---------------------------------------------*/
1617
yyoverflowlab:
1618
  yyerror ("parser stack overflow");
1619
  yyresult = 2;
1620
  /* Fall through.  */
1621

    
1622
yyreturn:
1623
#ifndef yyoverflow
1624
  if (yyss != yyssa)
1625
    YYSTACK_FREE (yyss);
1626
#endif
1627
  return yyresult;
1628
}
1629
#line 352 "parsetime.y"
1630

    
1631

    
1632

    
1633
time_t parsetime(int, char **);
1634

    
1635
time_t
1636
parsetime(int argc, char **argv)
1637
{
1638
    time_t exectime;
1639

    
1640
    my_argv = argv;
1641
    currtime = time(NULL);
1642
    exectm = *localtime(&currtime);
1643
    exectm.tm_sec = 0;
1644
    exectm.tm_isdst = -1;
1645
    time_only = 0;
1646
    if (yyparse() == 0) {
1647
        exectime = mktime(&exectm);
1648
        if (exectime == (time_t)-1)
1649
            return 0;
1650
        if (isgmt) {
1651
            exectime += timezone;
1652
            if (daylight) {
1653
                exectime -= 3600;
1654
            }
1655
        }
1656
        if (time_only && (currtime > exectime)) {
1657
            exectime += 24*3600;
1658
        }
1659
        return exectime;
1660
    }
1661
    else {
1662
        return 0;    
1663
    }
1664
}
1665

    
1666
#ifdef TEST_PARSER
1667
/*
1668

1669
Here are some lines to test:
1670

1671
./parsetest 7AM Mar 24 2000
1672
./parsetest 7AM Mar 24 00
1673
./parsetest 7AM 032400
1674
./parsetest 7AM 03/24/00
1675
./parsetest 7AM 24.03.00
1676
./parsetest 7AM Mar 24
1677

1678
./parsetest 03242000
1679
./parsetest noon 03242000
1680
./parsetest 5:30
1681
./parsetest 4pm + 3 days
1682
./parsetest 10am Jul 31
1683

1684
 */
1685
int
1686
main(int argc, char **argv)
1687
{
1688
    time_t res;
1689
    res = parsetime(argc-1, &argv[1]);
1690
    if (res > 0) {
1691
        printf("%s",ctime(&res));
1692
    }
1693
    else {
1694
        printf("Ooops...\n");
1695
    }
1696
    return 0;
1697
}
1698

    
1699
#endif
1700
int yyerror(char *s)
1701
{
1702
    if (last_token == NULL)
1703
        last_token = "(empty)";
1704
    fprintf(stderr,"%s. Last token seen: %s\n",s, last_token);
1705
    return 0;
1706
}
1707

    
1708
void
1709
add_seconds(struct tm *tm, long numsec)
1710
{
1711
    time_t timeval;
1712
    timeval = mktime(tm);
1713
    if (timeval == (time_t)-1)
1714
        timeval = (time_t)0;
1715
    timeval += numsec;
1716
    *tm = *localtime(&timeval);
1717
}
1718

    
1719
int
1720
add_date(int number, int period)
1721
{
1722
    switch(period) {
1723
    case MINUTE:
1724
        add_seconds(&exectm , 60l*number);
1725
        break;
1726

    
1727
    case HOUR:
1728
        add_seconds(&exectm, 3600l * number);
1729
        break;
1730

    
1731
    case DAY:
1732
        add_seconds(&exectm, 24*3600l * number);
1733
        break;
1734

    
1735
    case WEEK:
1736
        add_seconds(&exectm, 7*24*3600l*number);
1737
        break;
1738

    
1739
    case MONTH:
1740
        {
1741
            int newmonth = exectm.tm_mon + number;
1742
            number = 0;
1743
            while (newmonth < 0) {
1744
                newmonth += 12;
1745
                number --;
1746
            }
1747
            exectm.tm_mon = newmonth % 12;
1748
            number += newmonth / 12 ;
1749
        }
1750
        if (number == 0) {
1751
            break;
1752
        }
1753
        /* fall through */
1754

    
1755
    case YEAR:
1756
        exectm.tm_year += number;
1757
        break;
1758

    
1759
    default:
1760
        yyerror("Internal parser error");
1761
        fprintf(stderr,"Unexpected case %d\n", period);
1762
        abort();
1763
    }
1764
    return 0;
1765
}