aboutsummaryrefslogtreecommitdiff
path: root/gconf/gconf-gram.y
diff options
context:
space:
mode:
Diffstat (limited to 'gconf/gconf-gram.y')
-rw-r--r--gconf/gconf-gram.y891
1 files changed, 0 insertions, 891 deletions
diff --git a/gconf/gconf-gram.y b/gconf/gconf-gram.y
deleted file mode 100644
index c2d833b..0000000
--- a/gconf/gconf-gram.y
+++ /dev/null
@@ -1,891 +0,0 @@
1%{
2/* gconf - General purpose configuration parser.
3 Copyright (C) 2007, 2008, 2009 Sergey Poznyakoff
4
5 This program is free software; you can redistribute it and/or modify it
6 under the terms of the GNU General Public License as published by the
7 Free Software Foundation; either version 3 of the License, or (at your
8 option) any later version.
9
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License along
16 with this program. If not, see <http://www.gnu.org/licenses/>. */
17
18#ifdef HAVE_CONFIG_H
19# include <config.h>
20#endif
21#include <gconf.h>
22#include <gconf-gram.h>
23#include <stdlib.h>
24#include <sys/types.h>
25#include <sys/socket.h>
26#include <sys/time.h>
27#include <sys/un.h>
28#include <netinet/in.h>
29#include <arpa/inet.h>
30#include <netdb.h>
31
32#include <xalloc.h>
33#include <inttypes.h>
34
35#if ENABLE_NLS
36# include "gettext.h"
37# define _(msgid) gettext (msgid)
38#else
39# define _(msgid) msgid
40#endif
41
42typedef union
43{
44 struct sockaddr s;
45 struct sockaddr_in s_in;
46 struct sockaddr_un s_un;
47} sockaddr_union_t;
48
49static struct gconf_keyword config_keywords;
50static struct gconf_keyword *cursect;
51static gl_list_t sections;
52int gconf_error_count;
53
54int gconf_default_port = 0;
55
56static void *target_ptr(struct gconf_keyword *kwp);
57static void stmt_begin(struct gconf_keyword *kwp, gconf_value_t tag);
58static void stmt_end(struct gconf_keyword *kwp);
59static struct gconf_keyword *find_keyword(const char *ident);
60
61static void process_ident(struct gconf_keyword *kwp, gconf_value_t *value);
62static gl_list_t simple_list_create (bool dispose);
63%}
64
65%union {
66 char *string;
67 gconf_value_t value;
68 gl_list_t list;
69 struct gconf_keyword *kw;
70}
71
72%token <string> IDENT STRING QSTRING MSTRING
73%type <string> string slist
74%type <list> slist0
75%type <value> value tag vallist
76%type <list> values list vlist
77%type <kw> ident
78
79%%
80
81input : stmtlist
82 ;
83
84stmtlist: stmt
85 | stmtlist stmt
86 ;
87
88stmt : simple
89 | block
90 ;
91
92simple : ident vallist ';'
93 {
94 process_ident($1, &$2);
95 }
96 ;
97
98block : ident tag { stmt_begin($<kw>1, $<value>2); } '{' stmtlist '}' opt_sc
99 {
100 stmt_end($1);
101 }
102 ;
103
104ident : IDENT
105 {
106 $$ = find_keyword($1);
107 if (!$$)
108 gconf_error(&gconf_current_locus, 0, _("Unknown keyword"));
109 }
110 ;
111
112tag : /* empty */
113 {
114 $$.type = GCONF_TYPE_STRING;
115 $$.v.string = NULL;
116 }
117 | value
118 ;
119
120vallist : vlist
121 {
122 size_t n;
123
124 if ((n = gl_list_size ($1)) == 1)
125 {
126 $$ = *(gconf_value_t *)gl_list_get_at ($1, 0);
127 }
128 else
129 {
130 size_t i;
131
132 $$.type = GCONF_TYPE_ARRAY;
133 $$.v.arg.c = n;
134 $$.v.arg.v = xcalloc (n, sizeof ($$.v.arg.v[0]));
135 for (i = 0; i < n; i++)
136 $$.v.arg.v[i] = *(gconf_value_t *)gl_list_get_at ($1, i);
137 }
138 gl_list_free ($1);
139 }
140 ;
141
142vlist : value
143 {
144 $$ = simple_list_create (false);
145 gl_list_add_last ($$, gconf_value_dup (&$1));
146 }
147 | vlist value
148 {
149 gl_list_add_last ($1, gconf_value_dup (&$2));
150 }
151 ;
152
153value : string
154 {
155 $$.type = GCONF_TYPE_STRING;
156 $$.v.string = $1;
157 }
158 | list
159 {
160 $$.type = GCONF_TYPE_LIST;
161 $$.v.list = $1;
162 }
163 | MSTRING
164 {
165 $$.type = GCONF_TYPE_STRING;
166 $$.v.string = $1;
167 }
168 ;
169
170string : STRING
171 | IDENT
172 | slist
173 ;
174
175slist : slist0
176 {
177 const void *p;
178 gl_list_iterator_t itr = gl_list_iterator ($1);
179
180 gconf_line_begin ();
181 while (gl_list_iterator_next (&itr, &p, NULL))
182 gconf_line_add (p, strlen (p));
183 $$ = gconf_line_finish ();
184 gl_list_iterator_free (&itr);
185 gl_list_free ($1);
186 }
187 ;
188
189slist0 : QSTRING
190 {
191 $$ = simple_list_create (false);
192 gl_list_add_last ($$, $1);
193 }
194 | slist0 QSTRING
195 {
196 gl_list_add_last ($1, $2);
197 $$ = $1;
198 }
199 ;
200
201list : '(' ')'
202 {
203 $$ = NULL;
204 }
205 | '(' values ')'
206 {
207 $$ = $2;
208 }
209 | '(' values ',' ')'
210 {
211 $$ = $2;
212 }
213 ;
214
215values : value
216 {
217 $$ = simple_list_create (true);
218 gl_list_add_last ($$, gconf_value_dup (&$1));
219 }
220 | values ',' value
221 {
222 gl_list_add_last ($1, gconf_value_dup (&$3));
223 $$ = $1;
224 }
225 ;
226
227opt_sc : /* empty */
228 | ';'
229 ;
230
231%%
232
233int
234yyerror(char *s)
235{
236 gconf_error (&gconf_current_locus, 0, "%s", s);
237 return 0;
238}
239
240static void
241listel_dispose(const void *el)
242{
243 free((void*)el);
244}
245
246static gl_list_t
247simple_list_create (bool dispose)
248{
249 return gl_list_create_empty(&gl_linked_list_implementation,
250 NULL,