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"
15 "$Id: Svc_Conf.y 82136 2008-06-23 15:28:40Z sma $")
17 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
21 static ACE_Module_Type
*
22 ace_get_module
(ACE_Service_Type
const * sr
,
23 ACE_TCHAR
const * svc_name
,
26 #define YYDEBUG_LEXER_TEXT (yytext[yyleng] = '\0', yytext)
28 // Force the pretty debugging code to compile.
31 // Bison 2.3 template contains switch statement with a "default:", but
32 // without a "case:" label. Suppressing a compiler warning for Visual
34 #if defined (_MSC_VER)
35 # pragma warning ( disable : 4065 )
38 // Normalize the message literal's type to match yyerror() prototype
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
72 : svc_config_entries svc_config_entry
76 $2->apply
(ACE_SVC_CONF_PARAM
->config
, ACE_SVC_CONF_PARAM
->yyerrno
);
79 ACE_SVC_CONF_PARAM
->obstack.release
();
81 | svc_config_entries
error
83 ACE_SVC_CONF_PARAM
->obstack.release
();
98 : ACE_DYNAMIC svc_location parameters_opt
101 $$
= new ACE_Dynamic_Node
($2, $3);
108 : ACE_STATIC ACE_IDENT parameters_opt
110 $$
= new ACE_Static_Node
($2, $3);
115 : ACE_SUSPEND ACE_IDENT
117 $$
= new ACE_Suspend_Node
($2);
122 : ACE_RESUME ACE_IDENT
124 $$
= new ACE_Resume_Node
($2);
129 : ACE_REMOVE ACE_IDENT
131 $$
= new ACE_Remove_Node
($2);
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);
158 // Initialize left context...
159 $
<static_node_
>$
= $
<static_node_
>0;
166 |
/* EMPTY */ { $$
= 0; }
178 |
/* EMPTY */ { $$
= 0; }
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
++;
201 ACE_Static_Node
*sn
= $
<static_node_
>-1;
202 ACE_Module_Type
*mt
= ace_get_module
(sn
->record
(ACE_SVC_CONF_PARAM
->config
),
204 ACE_SVC_CONF_PARAM
->yyerrno
);
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
);
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
),
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"),
233 ACE_SVC_CONF_PARAM
->yyerrno
++;
239 : ACE_IDENT type svc_initializer status
241 $$
= new ACE_Service_Type_Factory
($1, $2, $3, $4);
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);
292 |
/* EMPTY */ { $$
= 0; }
303 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
305 // Prints the error string to standard output. Cleans up the error
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
);
315 #endif /* ACE_NLOGGING */
317 ACE_ERROR
((LM_ERROR
,
318 ACE_TEXT
("ACE (%P|%t) [error %d] on line %d: %C\n"),
325 yyerror (ACE_TCHAR
const * s
)
330 // Note that SRC_REC represents left context, which is the STREAM *
333 static ACE_Module_Type
*
334 ace_get_module
(ACE_Service_Type
const * sr
,
335 ACE_TCHAR
const * svc_name
,
338 ACE_Service_Type_Impl
const * const type
= sr
->type
();
339 ACE_Stream_Type
const * const st
=
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"),
351 (sr ? sr
->name
() : ACE_TEXT
("(nil)"))));
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 (¶m
);
372 #endif /* SVC_CONF_Y_DEBUGGING */
374 ACE_END_VERSIONED_NAMESPACE_DECL
376 #endif /* ACE_USES_CLASSIC_SVC_CONF == 1 */