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

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

Torque/PBS DRMAA initial commit

Line 
1/* $Id: conf_tab.y 2172 2009-02-28 14:26:23Z 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_MALLOC_H
22#       include <malloc.h>
23#endif
24#include <drmaa_utils/conf_impl.h>
25#include <drmaa_utils/conf_tab.h>
26%}
27
28%pure-parser
29%locations
30%name-prefix="fsd_conf_"
31%parse-param { fsd_conf_parser_t *parser }
32%parse-param { fsd_conf_lexer_t *lexer }
33%lex-param { fsd_conf_lexer_t *lexer }
34
35
36%union {
37        int integer;
38        char *string;
39        fsd_conf_option_t *option;
40        fsd_conf_dict_t *dictionary;
41        fsd_conf_pair_t pair;
42}
43
44%type<option> value
45%destructor { fsd_conf_option_destroy($$); } value
46%type<dictionary> start conf dict dict_body pair_list
47%destructor { fsd_conf_dict_destroy($$); } conf dict dict_body pair_list
48%type<pair> pair
49%token<integer> INTEGER
50%token<string> STRING
51%destructor { free($$); } STRING
52%token LEXER_ERROR
53
54
55%%
56
57start
58        : conf { parser->result = $1;  $$ = NULL; }
59        ;
60
61conf
62        : dict
63        | dict_body
64        ;
65
66dict
67        : '{' dict_body '}' { $$ = $2; }
68        ;
69
70dict_body
71        : pair_list  { $$ = $1; }
72        | pair_list ','  { $$ = $1; }
73        | {
74                $$ = fsd_conf_dict_create_noraise();
75                if( $$ == NULL )  YYABORT;
76        }
77        ;
78
79pair_list
80        : pair
81                 {
82                        fsd_conf_dict_t *dict = NULL;
83                        int rc;
84                        dict = fsd_conf_dict_create_noraise();
85                        if( dict == NULL )
86                                YYABORT;
87                        rc = fsd_conf_dict_set_noraise( dict, $1.key, $1.value );
88                        if( rc )
89                         {
90                                fsd_conf_dict_destroy( dict );
91                                YYABORT;
92                         }
93                        $$ = dict;
94                 }
95        | pair_list ',' pair
96                 {
97                        int rc;
98                        rc = fsd_conf_dict_set_noraise( $1, $3.key, $3.value );
99                        if( rc )
100                                YYABORT;
101                        $$ = $1; /* explicit no op */
102                 }
103        ;
104
105pair
106        : STRING ':' value { $$.key = $1;  $$.value = $3; }
107        ;
108
109value
110        : INTEGER
111                 {
112                        fsd_conf_option_t *o;
113                        o = fsd_conf_option_create_noraise( FSD_CONF_INTEGER, &$1 );
114                        if( o )
115                                $$ = o;
116                        else
117                                YYABORT;
118                 }
119        | STRING
120                 {
121                        fsd_conf_option_t *o;
122                        o = fsd_conf_option_create_noraise( FSD_CONF_STRING, $1 );
123                        if( o )
124                                $$ = o;
125                        else
126                                YYABORT;
127                 }
128        | dict
129                 {
130                        fsd_conf_option_t *o;
131                        o = fsd_conf_option_create_noraise( FSD_CONF_DICT, $1 );
132                        if( o )
133                                $$ = o;
134                        else
135                                YYABORT;
136                 }
137        ;
138
139%%
Note: See TracBrowser for help on using the repository browser.