source: trunk/drmaa_utils/drmaa_utils/datetime_tab.y @ 1

Revision 1, 3.0 KB checked in by mmamonski, 13 years ago (diff)

Torque/PBS DRMAA initial commit

Line 
1/* $Id: datetime_tab.y 1450 2008-10-01 22:22:59Z lukasz $ */
2/*
3 *  FedStage DRMAA utilities library
4 *  Copyright (C) 2006-2008  FedStage Systems
5 *
6 *  This program is free software: you can redistribute it and/or modify
7 *  it under the terms of the GNU General Public License as published by
8 *  the Free Software Foundation, either version 3 of the License, or
9 *  (at your option) any later version.
10 *
11 *  This program is distributed in the hope that it will be useful,
12 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
13 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14 *  GNU General Public License for more details.
15 *
16 *  You should have received a copy of the GNU General Public License
17 *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
18 */
19
20%{
21#ifdef HAVE_CONFIG_H
22#       include <config.h>
23#endif
24#include <drmaa_utils/datetime_impl.h>
25%}
26
27/* those are Bison extensions */
28%glr-parser
29%pure-parser
30%name-prefix="fsd_dt_"
31%parse-param { fsd_dt_parser_t *parser }
32%parse-param { fsd_dt_lexer_t *lexer }
33%lex-param { fsd_dt_lexer_t *lexer }
34
35%union {
36        fsd_datetime_t datetime;
37        int              integer;
38}
39
40%type<datetime> datetime date time timezone
41%type<integer>  sign
42%token<integer> NUM
43%token LEXER_ERROR
44
45%%
46
47start : datetime { parser->result = $1; }
48        ;
49
50datetime
51        : time timezone {
52                $$.mask = $1.mask | $2.mask;
53                $$.year = 0;  $$.month = 0;  $$.day = 0;
54                $$.hour   = $1.hour;
55                $$.minute = $1.minute;
56                $$.second = $1.second;
57                $$.tz_delta = $2.tz_delta;
58        }
59        | date opt_sep time timezone {
60                $$.mask = $1.mask | $3.mask | $4.mask;
61                $$.year   = $1.year;
62                $$.month  = $1.month;
63                $$.day    = $1.day;
64                $$.hour   = $3.hour;
65                $$.minute = $3.minute;
66                $$.second = $3.second;
67                $$.tz_delta = $4.tz_delta;
68        }
69        ;
70
71opt_sep
72        :
73        | 'T'
74        ;
75
76date
77        : NUM '-' NUM '-' NUM  { $$.year=$1;  $$.month=$3;  $$.day=$5;
78                                 $$.mask=FSD_DT_YEAR|FSD_DT_MONTH|FSD_DT_DAY; }
79        | NUM '-' NUM          { $$.year=0;   $$.month=$1;  $$.day=$3;
80                                 $$.mask=FSD_DT_MONTH|FSD_DT_DAY; }
81        | NUM '/' NUM '/' NUM  { $$.year=$1;  $$.month=$3;  $$.day=$5;
82                                 $$.mask=FSD_DT_YEAR|FSD_DT_MONTH|FSD_DT_DAY; }
83        | NUM '/' NUM          { $$.year=0;   $$.month=$1;  $$.day=$3;
84                                 $$.mask=FSD_DT_MONTH|FSD_DT_DAY; }
85        | NUM                  { $$.year=0;   $$.month=0;   $$.day=$1;
86                                 $$.mask=FSD_DT_DAY; }
87        ;
88
89
90time
91        : NUM ':' NUM          { $$.hour=$1;  $$.minute=$3;  $$.second=0;
92                                 $$.mask=FSD_DT_HOUR|FSD_DT_MINUTE; }
93        | NUM ':' NUM ':' NUM  { $$.hour=$1;  $$.minute=$3;  $$.second=$5;
94                                 $$.mask=FSD_DT_HOUR|FSD_DT_MINUTE|FSD_DT_SECOND; }
95        ;
96
97timezone
98        :                   { $$.tz_delta=0;  $$.mask=0; }
99        | sign NUM          { $$.tz_delta=$1*3600*$2;  $$.mask=FSD_DT_TZ_DELTA; }
100        | sign NUM ':' NUM  { $$.tz_delta=$1*60*(60*$2+$4);
101                              $$.mask=FSD_DT_TZ_DELTA; }
102        | 'Z'               { $$.tz_delta=0;  $$.mask=FSD_DT_TZ_DELTA; }
103        ;
104
105sign
106        :      { $$ = +1; }
107        | '+'  { $$ = +1; }
108        | '-'  { $$ = -1; }
109        ;
110
Note: See TracBrowser for help on using the repository browser.