[7297] Fixed profession spells sorting in trainer spell list at client.
[getmangos.git] / dep / ACE_wrappers / ace / Svc_Conf.y
blobcc46e2d2bb3876ce536d44e36e8f18247b16e872
1 %{
2 // $Id: Svc_Conf.y 82136 2008-06-23 15:28:40Z sma $
4 #include "ace/Svc_Conf.h"
6 #if (ACE_USES_CLASSIC_SVC_CONF == 1)
8 #include "ace/Module.h"
9 #include "ace/Stream.h"
10 #include "ace/Service_Types.h"
11 #include "ace/ace_wchar.h"
13 ACE_RCSID (ace,
14 Svc_Conf_y,
15 "$Id: Svc_Conf.y 82136 2008-06-23 15:28:40Z sma $")
17 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
19 // Prototypes.
21 static ACE_Module_Type *
22 ace_get_module (ACE_Service_Type const * sr,
23 ACE_TCHAR const * svc_name,
24 int & ace_yyerrno);
26 #define YYDEBUG_LEXER_TEXT (yytext[yyleng] = '\0', yytext)
28 // Force the pretty debugging code to compile.
29 // #define YYDEBUG 1
31 // Bison 2.3 template contains switch statement with a "default:", but
32 // without a "case:" label. Suppressing a compiler warning for Visual
33 // C++.
34 #if defined (_MSC_VER)
35 # pragma warning ( disable : 4065 )
36 #endif
38 // Normalize the message literal's type to match yyerror() prototype
39 #define YY_ ACE_TEXT
41 // Prevent yacc(1) from declaring a trivial YYSTYPE just because
42 // YYSTYPE is not a macro definition. On the other hand we want
43 // YYSTYPE_IS_DECLARED to be as localized as possible to avoid
44 // poluting the global namespace - there may be other yacc(1) parsers
45 // that want to play nice with ACE
46 #define YYSTYPE_IS_DECLARED
48 ACE_END_VERSIONED_NAMESPACE_DECL
52 %token ACE_DYNAMIC ACE_STATIC ACE_SUSPEND ACE_RESUME ACE_REMOVE ACE_USTREAM
53 %token ACE_MODULE_T ACE_STREAM_T ACE_SVC_OBJ_T ACE_ACTIVE ACE_INACTIVE
54 %token ACE_PATHNAME ACE_IDENT ACE_STRING
56 %start svc_config_entries
58 %type <ident_> ACE_IDENT ACE_STRING ACE_PATHNAME pathname parameters_opt
59 %type <type_> type status
60 %type <parse_node_> dynamic static suspend resume remove module_list stream
61 %type <parse_node_> stream_modules module svc_config_entry
62 %type <static_node_> stream_ops
63 %type <svc_record_> svc_location
64 %type <location_node_> svc_initializer
66 // Generate a pure (reentrant) parser -- GNU Bison only
67 %pure_parser
71 svc_config_entries
72 : svc_config_entries svc_config_entry
74 if ($2 != 0)
76 $2->apply (ACE_SVC_CONF_PARAM->config, ACE_SVC_CONF_PARAM->yyerrno);
77 delete $2;
79 ACE_SVC_CONF_PARAM->obstack.release ();
81 | svc_config_entries error
83 ACE_SVC_CONF_PARAM->obstack.release ();
85 | /* EMPTY */
88 svc_config_entry
89 : dynamic
90 | static
91 | suspend
92 | resume
93 | remove
94 | stream
97 dynamic
98 : ACE_DYNAMIC svc_location parameters_opt
100 if ($2 != 0)
101 $$ = new ACE_Dynamic_Node ($2, $3);
102 else
103 $$ = 0;
107 static
108 : ACE_STATIC ACE_IDENT parameters_opt
110 $$ = new ACE_Static_Node ($2, $3);
114 suspend
115 : ACE_SUSPEND ACE_IDENT
117 $$ = new ACE_Suspend_Node ($2);
121 resume
122 : ACE_RESUME ACE_IDENT
124 $$ = new ACE_Resume_Node ($2);
128 remove
129 : ACE_REMOVE ACE_IDENT
131 $$ = new ACE_Remove_Node ($2);
135 stream
136 : ACE_USTREAM stream_ops stream_modules
138 $$ = new ACE_Stream_Node ($2, $3);
140 | ACE_USTREAM ACE_IDENT { $<static_node_>$ = new ACE_Static_Node ($2); } stream_modules
142 $$ = new ACE_Dummy_Node ($<static_node_>3, $4);
146 stream_ops
147 : dynamic
150 | static
155 stream_modules
156 : '{'
158 // Initialize left context...
159 $<static_node_>$ = $<static_node_>0;
161 module_list '}'
163 ACE_UNUSED_ARG ($2);
164 $$ = $3;
166 | /* EMPTY */ { $$ = 0; }
169 module_list
170 : module_list module
172 if ($2 != 0)
174 $2->link ($1);
175 $$ = $2;
178 | /* EMPTY */ { $$ = 0; }
181 module
182 : dynamic
185 | static
187 ACE_Static_Node *sn = $<static_node_>-1;
188 ACE_Module_Type *mt = ace_get_module (sn->record (ACE_SVC_CONF_PARAM->config),
189 $<static_node_>1->name (),
190 ACE_SVC_CONF_PARAM->yyerrno);
192 if (((ACE_Stream_Type *) sn->record (ACE_SVC_CONF_PARAM->config)->type ())->push (mt) == -1)
194 ACE_ERROR ((LM_ERROR,
195 ACE_TEXT ("Problem with static\n")));
196 ACE_SVC_CONF_PARAM->yyerrno++;
199 | suspend
201 ACE_Static_Node *sn = $<static_node_>-1;
202 ACE_Module_Type *mt = ace_get_module (sn->record (ACE_SVC_CONF_PARAM->config),
203 sn->name (),
204 ACE_SVC_CONF_PARAM->yyerrno);
205 if (mt != 0)
206 mt->suspend ();
208 | resume
210 ACE_Static_Node *sn = $<static_node_>-1;
211 ACE_Module_Type *mt = ace_get_module (sn->record (ACE_SVC_CONF_PARAM->config),
212 $<static_node_>1->name (),
213 ACE_SVC_CONF_PARAM->yyerrno);
214 if (mt != 0)
215 mt->resume ();
217 | remove
219 ACE_Static_Node *stream = $<static_node_>-1;
220 ACE_Static_Node *module = $<static_node_>1;
221 ACE_Module_Type *mt = ace_get_module (stream->record (ACE_SVC_CONF_PARAM->config),
222 module->name (),
223 ACE_SVC_CONF_PARAM->yyerrno);
225 ACE_Stream_Type *st =
226 dynamic_cast<ACE_Stream_Type *> (const_cast<ACE_Service_Type_Impl *> (stream->record (ACE_SVC_CONF_PARAM->config)->type ()));
227 if (!st || (mt != 0 && st->remove (mt) == -1))
229 ACE_ERROR ((LM_ERROR,
230 ACE_TEXT ("cannot remove Module_Type %s from STREAM_Type %s\n"),
231 module->name (),
232 stream->name ()));
233 ACE_SVC_CONF_PARAM->yyerrno++;
238 svc_location
239 : ACE_IDENT type svc_initializer status
241 $$ = new ACE_Service_Type_Factory ($1, $2, $3, $4);
245 status
246 : ACE_ACTIVE
248 $$ = 1;
250 | ACE_INACTIVE
252 $$ = 0;
254 | /* EMPTY */
256 $$ = 1;
260 svc_initializer
261 : pathname ':' ACE_IDENT
263 $$ = new ACE_Object_Node ($1, $3);
265 | pathname ':' ACE_IDENT '(' ')'
267 $$ = new ACE_Function_Node ($1, $3);
269 | ':' ACE_IDENT '(' ')'
271 $$ = new ACE_Static_Function_Node ($2);
275 type
276 : ACE_MODULE_T '*'
278 $$ = ACE_MODULE_T;
280 | ACE_SVC_OBJ_T '*'
282 $$ = ACE_SVC_OBJ_T;
284 | ACE_STREAM_T '*'
286 $$ = ACE_STREAM_T;
290 parameters_opt
291 : ACE_STRING
292 | /* EMPTY */ { $$ = 0; }
295 pathname
296 : ACE_PATHNAME
297 | ACE_IDENT
298 | ACE_STRING
303 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
305 // Prints the error string to standard output. Cleans up the error
306 // messages.
308 void
309 yyerror (int yyerrno, int yylineno, ACE_TCHAR const * s)
311 #if defined (ACE_NLOGGING)
312 ACE_UNUSED_ARG (yyerrno);
313 ACE_UNUSED_ARG (yylineno);
314 ACE_UNUSED_ARG (s);
315 #endif /* ACE_NLOGGING */
317 ACE_ERROR ((LM_ERROR,
318 ACE_TEXT ("ACE (%P|%t) [error %d] on line %d: %C\n"),
319 yyerrno,
320 yylineno,
321 s));
324 void
325 yyerror (ACE_TCHAR const * s)
327 yyerror (-1, -1, s);
330 // Note that SRC_REC represents left context, which is the STREAM *
331 // record.
333 static ACE_Module_Type *
334 ace_get_module (ACE_Service_Type const * sr,
335 ACE_TCHAR const * svc_name,
336 int & yyerrno)
338 ACE_Service_Type_Impl const * const type = sr->type ();
339 ACE_Stream_Type const * const st =
340 (sr == 0
342 : dynamic_cast<ACE_Stream_Type const *> (type));
343 ACE_Module_Type const * const mt = (st == 0 ? 0 : st->find (svc_name));
345 if (sr == 0 || st == 0 || mt == 0)
347 ACE_ERROR ((LM_ERROR,
348 ACE_TEXT ("cannot locate Module_Type %s ")
349 ACE_TEXT ("in STREAM_Type %s\n"),
350 svc_name,
351 (sr ? sr->name () : ACE_TEXT ("(nil)"))));
352 ++yyerrno;
355 return const_cast<ACE_Module_Type *> (mt);
358 #if defined (SVC_CONF_Y_DEBUGGING)
359 // Main driver program.
362 ACE_TMAIN (int argc, ACE_TCHAR *argv[])
364 ACE_Svc_Conf_Param param (0, stdin);
366 // Try to reopen any filename argument to use YYIN.
367 if (argc > 1 && (yyin = freopen (argv[1], "r", stdin)) == 0)
368 (void) ACE_OS::fprintf (stderr, ACE_TEXT ("usage: %s [file]\n"), argv[0]), ACE_OS::exit (1);
370 return ::yyparse (&param);
372 #endif /* SVC_CONF_Y_DEBUGGING */
374 ACE_END_VERSIONED_NAMESPACE_DECL
376 #endif /* ACE_USES_CLASSIC_SVC_CONF == 1 */