2 #include "ace/Svc_Conf.h"
4 #if (ACE_USES_CLASSIC_SVC_CONF == 1)
6 #include "ace/Module.h"
7 #include "ace/Stream.h"
8 #include "ace/Service_Types.h"
9 #include "ace/ace_wchar.h"
11 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
15 static ACE_Module_Type
*
16 ace_get_module
(ACE_Service_Type
const * sr
,
17 ACE_TCHAR
const * svc_name
,
20 #define YYDEBUG_LEXER_TEXT (yytext[yyleng] = '\0', yytext)
22 // Force the pretty debugging code to compile.
25 // Bison 2.3 template contains switch statement with a "default:", but
26 // without a "case:" label. Suppressing a compiler warning for Visual
28 #if defined (_MSC_VER)
29 # pragma warning ( disable : 4065 )
32 // Normalize the message literal's type to match yyerror() prototype
35 // Prevent yacc(1) from declaring a trivial YYSTYPE just because
36 // YYSTYPE is not a macro definition. On the other hand we want
37 // YYSTYPE_IS_DECLARED to be as localized as possible to avoid
38 // poluting the global namespace - there may be other yacc(1) parsers
39 // that want to play nice with ACE
40 #define YYSTYPE_IS_DECLARED
42 ACE_END_VERSIONED_NAMESPACE_DECL
46 %token ACE_DYNAMIC ACE_STATIC ACE_SUSPEND ACE_RESUME ACE_REMOVE ACE_USTREAM
47 %token ACE_MODULE_T ACE_STREAM_T ACE_SVC_OBJ_T ACE_ACTIVE ACE_INACTIVE
48 %token ACE_PATHNAME ACE_IDENT ACE_STRING
50 %start svc_config_entries
52 %type
<ident_
> ACE_IDENT ACE_STRING ACE_PATHNAME pathname parameters_opt
53 %type
<type_
> type status
54 %type
<parse_node_
> dynamic
static suspend resume remove module_list stream
55 %type
<parse_node_
> stream_modules module svc_config_entry
56 %type
<static_node_
> stream_ops
57 %type
<svc_record_
> svc_location
58 %type
<location_node_
> svc_initializer
60 // Generate a pure (reentrant) parser -- GNU Bison only
66 : svc_config_entries svc_config_entry
70 $2->apply
(ACE_SVC_CONF_PARAM
->config
, ACE_SVC_CONF_PARAM
->yyerrno
);
73 ACE_SVC_CONF_PARAM
->obstack.release
();
75 | svc_config_entries
error
77 ACE_SVC_CONF_PARAM
->obstack.release
();
92 : ACE_DYNAMIC svc_location parameters_opt
95 $$
= new ACE_Dynamic_Node
($2, $3);
102 : ACE_STATIC ACE_IDENT parameters_opt
104 $$
= new ACE_Static_Node
($2, $3);
109 : ACE_SUSPEND ACE_IDENT
111 $$
= new ACE_Suspend_Node
($2);
116 : ACE_RESUME ACE_IDENT
118 $$
= new ACE_Resume_Node
($2);
123 : ACE_REMOVE ACE_IDENT
125 $$
= new ACE_Remove_Node
($2);
130 : ACE_USTREAM stream_ops stream_modules
132 $$
= new ACE_Stream_Node
($2, $3);
134 | ACE_USTREAM ACE_IDENT
{ $
<static_node_
>$
= new ACE_Static_Node
($2); } stream_modules
136 $$
= new ACE_Dummy_Node
($
<static_node_
>3, $4);
152 // Initialize left context...
153 $
<static_node_
>$
= $
<static_node_
>0;
160 |
/* EMPTY */ { $$
= 0; }
172 |
/* EMPTY */ { $$
= 0; }
181 ACE_Static_Node
*sn
= $
<static_node_
>-1;
182 ACE_Module_Type
*mt
= ace_get_module
(sn
->record
(ACE_SVC_CONF_PARAM
->config
),
183 $
<static_node_
>1->name
(),
184 ACE_SVC_CONF_PARAM
->yyerrno
);
186 if
(((ACE_Stream_Type
*) sn
->record
(ACE_SVC_CONF_PARAM
->config
)->type
())->push
(mt
) == -1)
188 ACE_ERROR
((LM_ERROR
,
189 ACE_TEXT
("Problem with static\n")));
190 ACE_SVC_CONF_PARAM
->yyerrno
++;
195 ACE_Static_Node
*sn
= $
<static_node_
>-1;
196 ACE_Module_Type
*mt
= ace_get_module
(sn
->record
(ACE_SVC_CONF_PARAM
->config
),
198 ACE_SVC_CONF_PARAM
->yyerrno
);
204 ACE_Static_Node
*sn
= $
<static_node_
>-1;
205 ACE_Module_Type
*mt
= ace_get_module
(sn
->record
(ACE_SVC_CONF_PARAM
->config
),
206 $
<static_node_
>1->name
(),
207 ACE_SVC_CONF_PARAM
->yyerrno
);
213 ACE_Static_Node
*stream
= $
<static_node_
>-1;
214 ACE_Static_Node
*module
= $
<static_node_
>1;
215 ACE_Module_Type
*mt
= ace_get_module
(stream
->record
(ACE_SVC_CONF_PARAM
->config
),
217 ACE_SVC_CONF_PARAM
->yyerrno
);
219 ACE_Stream_Type
*st
=
220 dynamic_cast
<ACE_Stream_Type
*> (const_cast
<ACE_Service_Type_Impl
*> (stream
->record
(ACE_SVC_CONF_PARAM
->config
)->type
()));
221 if
(!st ||
(mt
!= 0 && st
->remove
(mt
) == -1))
223 ACE_ERROR
((LM_ERROR
,
224 ACE_TEXT
("cannot remove Module_Type %s from STREAM_Type %s\n"),
227 ACE_SVC_CONF_PARAM
->yyerrno
++;
233 : ACE_IDENT type svc_initializer status
235 $$
= new ACE_Service_Type_Factory
($1, $2, $3, $4);
255 : pathname
':' ACE_IDENT
257 $$
= new ACE_Object_Node
($1, $3);
259 | pathname
':' ACE_IDENT
'(' ')'
261 $$
= new ACE_Function_Node
($1, $3);
263 |
':' ACE_IDENT
'(' ')'
265 $$
= new ACE_Static_Function_Node
($2);
286 |
/* EMPTY */ { $$
= 0; }
297 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
299 // Prints the error string to standard output. Cleans up the error
303 yyerror (int yyerrno
, int yylineno
, ACE_TCHAR
const * s
)
305 #if defined (ACE_NLOGGING)
306 ACE_UNUSED_ARG
(yyerrno
);
307 ACE_UNUSED_ARG
(yylineno
);
309 #endif /* ACE_NLOGGING */
311 ACE_ERROR
((LM_ERROR
,
312 ACE_TEXT
("ACE (%P|%t) [error %d] on line %d: %C\n"),
319 yyerror (ACE_TCHAR
const * s
)
324 // Note that SRC_REC represents left context, which is the STREAM *
327 static ACE_Module_Type
*
328 ace_get_module
(ACE_Service_Type
const * sr
,
329 ACE_TCHAR
const * svc_name
,
332 ACE_Stream_Type
const * const st
=
335 : dynamic_cast
<ACE_Stream_Type
const *> (sr
->type
()));
336 ACE_Module_Type
const * const mt
= (st
== 0 ?
0 : st
->find
(svc_name
));
338 if
(sr
== 0 || st
== 0 || mt
== 0)
340 ACE_ERROR
((LM_ERROR
,
341 ACE_TEXT
("cannot locate Module_Type %s ")
342 ACE_TEXT
("in STREAM_Type %s\n"),
344 (sr ? sr
->name
() : ACE_TEXT
("(nil)"))));
348 return const_cast
<ACE_Module_Type
*> (mt
);
351 #if defined (SVC_CONF_Y_DEBUGGING)
352 // Main driver program.
355 ACE_TMAIN
(int argc
, ACE_TCHAR
*argv
[])
357 ACE_Svc_Conf_Param param
(0, stdin
);
359 // Try to reopen any filename argument to use YYIN.
360 if
(argc
> 1 && (yyin
= freopen
(argv
[1], "r", stdin
)) == 0)
361 (void) ACE_OS
::fprintf
(stderr
, ACE_TEXT
("usage: %s [file]\n"), argv
[0]), ACE_OS
::exit
(1);
363 return
::yyparse (¶m
);
365 #endif /* SVC_CONF_Y_DEBUGGING */
367 ACE_END_VERSIONED_NAMESPACE_DECL
369 #endif /* ACE_USES_CLASSIC_SVC_CONF == 1 */