5 Copyright 1992, 1993, 1994 Sun Microsystems, Inc. Printed in the United
6 States of America. All Rights Reserved.
8 This product is protected by copyright and distributed under the following
9 license restricting its use.
11 The Interface Definition Language Compiler Front End (CFE) is made
12 available for your use provided that you include this license and copyright
13 notice on all media and documentation and the software program in whichlong
14 this product is incorporated in whole or part. You may copy and extend
15 functionality (but may not remove functionality) of the Interface
16 Definition Language CFE without charge, but you are not authorized to
17 license or distribute it to anyone else except as part of a product or
18 program developed by you or with the express written consent of Sun
19 Microsystems, Inc. ("Sun").
21 The names of Sun Microsystems, Inc. and any of its subsidiaries or
22 affiliates may not be used in advertising or publicity pertaining to
23 distribution of Interface Definition Language CFE as permitted herein.
25 This license is effective until terminated by Sun for failure to comply
26 with this license. Upon termination, you shall destroy or return all code
27 and documentation for the Interface Definition Language CFE.
29 INTERFACE DEFINITION LANGUAGE CFE IS PROVIDED AS IS WITH NO WARRANTIES OF
30 ANY KIND INCLUDING THE WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS
31 FOR A PARTICULAR PURPOSE, NONINFRINGEMENT, OR ARISING FROM A COURSE OF
32 DEALING, USAGE OR TRADE PRACTICE.
34 INTERFACE DEFINITION LANGUAGE CFE IS PROVIDED WITH NO SUPPORT AND WITHOUT
35 ANY OBLIGATION ON THE PART OF Sun OR ANY OF ITS SUBSIDIARIES OR AFFILIATES
36 TO ASSIST IN ITS USE, CORRECTION, MODIFICATION OR ENHANCEMENT.
38 SUN OR ANY OF ITS SUBSIDIARIES OR AFFILIATES SHALL HAVE NO LIABILITY WITH
39 RESPECT TO THE INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY
40 INTERFACE DEFINITION LANGUAGE CFE OR ANY PART THEREOF.
42 IN NO EVENT WILL SUN OR ANY OF ITS SUBSIDIARIES OR AFFILIATES BE LIABLE FOR
43 ANY LOST REVENUE OR PROFITS OR OTHER SPECIAL, INDIRECT AND CONSEQUENTIAL
44 DAMAGES, EVEN IF SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
46 Use, duplication, or disclosure by the government is subject to
47 restrictions as set forth in subparagraph (c)(1)(ii) of the Rights in
48 Technical Data and Computer Software clause at DFARS 252.227-7013 and FAR
51 Sun, Sun Microsystems and the Sun logo are trademarks or registered
52 trademarks of Sun Microsystems, Inc.
56 Mountain View, California 94043
60 SunOS, SunSoft, Sun, Solaris, Sun Microsystems or the Sun logo are
61 trademarks or registered trademarks of Sun Microsystems, Inc.
67 * \brief Bison grammar for IDL
73 #include <utl_identifier.h>
75 #include <utl_string.h>
76 #include <utl_strlist.h>
77 #include <utl_namelist.h>
78 #include <utl_exprlist.h>
79 #include <utl_labellist.h>
80 #include <utl_decllist.h>
82 #include <global_extern.h>
83 #include <nr_extern.h>
85 #include <ast_argument.h>
86 #include <ast_array.h>
87 #include <ast_attribute.h>
88 #include <ast_field.h>
89 #include <ast_fixed.h>
90 #include <ast_expression.h>
91 #include <ast_operation.h>
92 #include <ast_generator.h>
93 #include <ast_template_module.h>
94 #include <ast_template_module_inst.h>
95 #include <ast_template_module_ref.h>
96 #include <ast_typedef.h>
97 #include <ast_valuebox.h>
98 #include <ast_valuetype.h>
99 #include <ast_valuetype_fwd.h>
100 #include <ast_eventtype.h>
101 #include <ast_eventtype_fwd.h>
102 #include <ast_component.h>
103 #include <ast_component_fwd.h>
104 #include <ast_home.h>
105 #include <ast_porttype.h>
106 #include <ast_connector.h>
107 #include <ast_uses.h>
108 #include <ast_constant.h>
109 #include <ast_union.h>
110 #include <ast_union_fwd.h>
111 #include <ast_structure_fwd.h>
112 #include <ast_extern.h>
113 #include <ast_enum.h>
114 #include <ast_root.h>
115 #include <ast_sequence.h>
116 #include <ast_string.h>
117 #include <ast_factory.h>
118 #include <ast_finder.h>
119 #include <ast_exception.h>
120 #include <ast_param_holder.h>
121 #include <ast_visitor_tmpl_module_inst.h>
122 #include <ast_visitor_tmpl_module_ref.h>
123 #include <ast_visitor_context.h>
124 #include <ast_annotation_appl.h>
125 #include <ast_union_branch.h>
126 #include <ast_enum_val.h>
127 #include <ast_annotation_member.h>
128 #include <ast_provides.h>
129 #include <ast_emits.h>
130 #include <ast_publishes.h>
131 #include <ast_consumes.h>
132 #include <ast_extended_port.h>
133 #include <ast_mirror_port.h>
136 #include <fe_declarator.h>
137 #include <fe_interface_header.h>
138 #include <fe_obv_header.h>
139 #include <fe_component_header.h>
140 #include <fe_home_header.h>
141 #include <fe_utils.h>
143 void tao_yyerror (const char *);
144 int tao_yylex (void);
145 extern "C" int tao_yywrap (void);
147 extern char tao_yytext[];
148 extern int tao_yyleng;
150 AST_Enum *tao_enum_constant_decl = 0;
151 AST_String *tao_string_decl = 0;
152 AST_Expression::ExprType t_param_const_type = AST_Expression::EV_none;
153 bool stack_based_lookup_for_primary_expr = false;
155 #define TAO_YYDEBUG_LEXER_TEXT (tao_yytext[tao_yyleng] = '\0', tao_yytext)
156 // Compile Optional Tracing Output for Parser, can be enabled with --bison-trace
161 * Declare the type of values in the grammar
165 AST_Decl *dcval; /* Decl value */
166 UTL_StrList *slval; /* String list */
167 UTL_NameList *nlval; /* Name list */
168 UTL_ExprList *elval; /* Expression list */
169 UTL_LabelList *llval; /* Label list */
170 UTL_DeclList *dlval; /* Declaration list */
171 FE_InterfaceHeader *ihval; /* Interface header */
172 FE_OBVHeader *vhval; /* Valuetype header */
173 FE_ComponentHeader *chval; /* Component header */
174 FE_HomeHeader *hhval; /* Home header */
175 AST_Expression *exval; /* Expression value */
176 AST_UnionLabel *ulval; /* Union label */
177 AST_Field *ffval; /* Field value */
178 AST_Field::Visibility vival; /* N/A, pub or priv */
179 AST_Expression::ExprType etval; /* Expression type */
180 AST_Argument::Direction dival; /* Argument direction */
181 AST_Operation::Flags ofval; /* Operation flags */
182 FE_Declarator *deval; /* Declarator value */
183 ACE_CDR::Boolean bval; /* Boolean value */
184 ACE_CDR::LongLong ival; /* Long Long value */
185 ACE_CDR::ULongLong uival; /* Unsigned long long */
186 ACE_CDR::Double dval; /* Double value */
187 ACE_CDR::Float fval; /* Float value */
188 ACE_CDR::Char cval; /* Char value */
189 ACE_CDR::WChar wcval; /* WChar value */
190 ACE_CDR::Fixed fixval; /* Fixed point value */
191 UTL_String *sval; /* String value */
192 char *wsval; /* WString value */
193 char *strval; /* char * value */
194 Identifier *idval; /* Identifier */
195 UTL_IdList *idlist; /* Identifier list */
196 AST_Decl::NodeType ntval; /* Node type value */
197 FE_Utils::T_Param_Info *pival; /* Template interface param */
198 FE_Utils::T_PARAMLIST_INFO *plval; /* List of template params */
199 FE_Utils::T_ARGLIST *alval; /* List of template args */
200 AST_Annotation_Appl *annotation_val;
201 AST_Annotation_Appls *annotations_val;
202 AST_Annotation_Appl::Param *annotation_param_val;
203 AST_Annotation_Appl::Params *annotation_params_val;
204 AST_Annotation_Decl *annotation_decl_val;
205 AST_Decls *decls_val;
206 Decl_Annotations_Pair *decl_annotations_pair_val;
207 Decl_Annotations_Pair_Pair* decl_annotations_pair_val_pair;
211 * Token types: These are returned by the lexer
214 %token <strval> IDENTIFIER
246 %token IDL_IDEMPOTENT
262 %token IDL_TRUNCATABLE
264 /* Component tokens */
274 %token IDL_PRIMARYKEY
279 %token IDL_TYPEPREFIX
282 /* Extended ports tokens */
285 %token IDL_MIRRORPORT
290 %token <ival> IDL_INTEGER_LITERAL
291 %token <uival> IDL_UINTEGER_LITERAL
292 %token <sval> IDL_STRING_LITERAL
293 %token <cval> IDL_CHARACTER_LITERAL
294 %token <dval> IDL_FLOATING_PT_LITERAL
295 %token <fixval> IDL_FIXED_PT_LITERAL
299 /* stdint like types defined in IDL4.2 7.4.13 */
309 %token <strval> IDL_SCOPE_DELIMITOR
310 %token IDL_LEFT_SHIFT
311 %token IDL_RIGHT_SHIFT
312 %token <wcval> IDL_WCHAR_LITERAL
313 %token <wsval> IDL_WSTRING_LITERAL
315 %token IDL_ANNOTATION_DECL
316 %token IDL_ANNOTATION_SYMBOL
319 * These are production names:
322 %type <dcval> type_spec simple_type_spec constructed_type_spec
323 %type <dcval> template_type_spec sequence_type_spec string_type_spec map_type_spec
324 %type <dcval> struct_type enum_type switch_type_spec union_type
325 %type <dcval> array_declarator op_type_spec wstring_type_spec
326 %type <dcval> param_type_spec type_dcl type_declarator actual_parameter
327 %type <dcval> fixed_type_spec
328 %type <dcval> definition fixed_definition module const_dcl struct_forward_type
329 %type <dcval> interface_def interface interface_forward
330 %type <dcval> export operation attribute attribute_readonly attribute_readwrite
331 %type <dcval> template_module template_module_inst annotation_dcl typeid_dcl
332 %type <dcval> typeprefix_dcl exception component home_decl
333 %type <dcval> event_decl event_abs_decl event_forward_decl
334 %type <dcval> event_abs_forward_decl event_concrete_forward_decl
335 %type <dcval> porttype_decl connector_decl value_def
336 %type <dcval> valuetype value_abs_decl value_forward_decl value_box_decl
337 %type <dcval> value_concrete_decl component_forward_decl component_decl
338 %type <dcval> init_decl provides_decl uses_decl port_export
339 %type <dcval> component_export emits_decl publishes_decl consumes_decl
340 %type <dcval> extended_port_decl
342 %type <idlist> scoped_name interface_type component_inheritance_spec
343 %type <idlist> home_inheritance_spec primary_key_spec module_header
344 %type <idlist> template_module_header
346 %type <slval> opt_context at_least_one_string_literal
347 %type <slval> string_literals formal_parameter_names
348 %type <slval> at_least_one_formal_parameter_name
350 %type <nlval> at_least_one_scoped_name scoped_names inheritance_spec
351 %type <nlval> opt_raises opt_getraises opt_setraises supports_spec
353 %type <elval> at_least_one_array_dim array_dims
355 %type <llval> at_least_one_case_label case_labels
357 %type <dlval> at_least_one_declarator declarators
358 %type <dlval> at_least_one_simple_declarator simple_declarators
360 %type <ihval> interface_header
362 %type <vhval> value_header event_rest_of_header
364 %type <chval> component_header
366 %type <hhval> home_header
368 %type <exval> expression const_expr or_expr xor_expr and_expr shift_expr
369 %type <exval> add_expr mult_expr unary_expr primary_expr literal
370 %type <exval> positive_int_expr array_dim annotation_member_default
372 %type <ulval> case_label
374 %type <ffval> element_spec
376 %type <etval> const_type integer_type char_type boolean_type
377 %type <etval> floating_pt_type fixed_type any_type signed_int
378 %type <etval> unsigned_int base_type_spec octet_type object_type
379 %type <etval> annotation_member_type
381 %type <dival> direction
383 %type <ofval> opt_op_attribute
385 %type <deval> declarator simple_declarator complex_declarator
387 %type <bval> opt_truncatable opt_multiple uses_opt_multiple
389 %type <idval> interface_decl value_decl union_decl struct_decl id
390 %type <idval> defining_id
391 %type <idval> event_header event_plain_header event_custom_header
392 %type <idval> event_abs_header
394 %type <ntval> formal_parameter_type
396 %type <pival> formal_parameter
397 %type <plval> formal_parameters at_least_one_formal_parameter
399 %type <sval> formal_parameter_name
401 %type <alval> actual_parameters at_least_one_actual_parameter
403 %type <annotations_val> at_least_one_annotation annotations_maybe
404 %type <annotation_val> annotation_appl
405 %type <annotation_params_val> annotation_appl_params_maybe annotation_appl_params
406 %type <annotation_params_val> named_annotation_appl_params more_named_annotation_appl_params
407 %type <annotation_param_val> named_annotation_appl_param
408 %type <decl_annotations_pair_val> seq_head
410 %type <decl_annotations_pair_val_pair> map_head
412 %type <decls_val> member_i state_member value_element
413 %type <vival> visibility
417 * Production starts here.
419 start : definitions ;
422 : at_least_one_definition
426 at_least_one_definition
428 * This is broken up into 2 rules to avoid a grammer ambiguity which
429 * manifests as bison complaining about shift/reduce conflicts.
431 : definitions at_least_one_annotation definition
433 AST_Annotation_Appls *&annotations = $2;
434 AST_Decl *&node = $3;
437 node->annotation_appls (*annotations);
441 idl_global->err ()-> unsupported_warning (
442 "Annotating this is not supported");
446 | definitions definition
451 | template_module ';'
452 | template_module_inst ';'
458 idl_global->set_parse_state (IDL_GlobalData::PS_AnnotationDeclSeen);
462 idl_global->set_parse_state (IDL_GlobalData::PS_NoState);
466 idl_global->set_parse_state (IDL_GlobalData::PS_TypeDeclSeen);
470 idl_global->set_parse_state (IDL_GlobalData::PS_NoState);
474 idl_global->set_parse_state (IDL_GlobalData::PS_TypeIdDeclSeen);
478 idl_global->set_parse_state (IDL_GlobalData::PS_NoState);
482 idl_global->set_parse_state (IDL_GlobalData::PS_TypePrefixDeclSeen);
486 idl_global->set_parse_state (IDL_GlobalData::PS_NoState);
490 idl_global->set_parse_state (IDL_GlobalData::PS_ConstDeclSeen);
494 idl_global->set_parse_state (IDL_GlobalData::PS_NoState);
498 idl_global->set_parse_state (IDL_GlobalData::PS_ExceptDeclSeen);
502 idl_global->set_parse_state (IDL_GlobalData::PS_NoState);
506 idl_global->set_parse_state (IDL_GlobalData::PS_InterfaceDeclSeen);
510 idl_global->set_parse_state (IDL_GlobalData::PS_NoState);
514 idl_global->set_parse_state (IDL_GlobalData::PS_ModuleDeclSeen);
518 idl_global->set_parse_state (IDL_GlobalData::PS_NoState);
522 idl_global->set_parse_state (IDL_GlobalData::PS_ValueTypeDeclSeen);
526 idl_global->set_parse_state (IDL_GlobalData::PS_NoState);
530 idl_global->set_parse_state (IDL_GlobalData::PS_ComponentDeclSeen);
534 idl_global->set_parse_state (IDL_GlobalData::PS_NoState);
538 idl_global->set_parse_state (IDL_GlobalData::PS_HomeDeclSeen);
542 idl_global->set_parse_state (IDL_GlobalData::PS_NoState);
546 idl_global->set_parse_state (IDL_GlobalData::PS_EventDeclSeen);
550 idl_global->set_parse_state (IDL_GlobalData::PS_NoState);
554 idl_global->set_parse_state (IDL_GlobalData::PS_PorttypeDeclSeen);
558 idl_global->set_parse_state (IDL_GlobalData::PS_NoState);
562 idl_global->set_parse_state (IDL_GlobalData::PS_ConnectorDeclSeen);
566 idl_global->set_parse_state (IDL_GlobalData::PS_NoState);
570 idl_global->err ()->syntax_error (idl_global->parse_state ());
574 idl_global->set_parse_state (IDL_GlobalData::PS_NoState);
583 idl_global->set_parse_state (IDL_GlobalData::PS_ModuleSeen);
594 idl_global->set_parse_state (IDL_GlobalData::PS_ModuleIDSeen);
596 // The module_header rule is common to template module, fixed
597 // module and instantiated template module. In the last
598 // case, a fully scoped name is allowed, but here we
599 // allow only an identifier (a scoped name of length
600 // 1). If not satisfied, we output a parse error with
601 // the appropriate message.
602 if ($1->length () != 1)
604 idl_global->err ()->syntax_error (
605 IDL_GlobalData::PS_ModuleIDSeen);
609 UTL_Scope *s = idl_global->scopes ().top_non_null ();
612 * Make a new module and add it to the enclosing scope
616 m = idl_global->gen ()->create_module (s, $1);
617 (void) s->fe_add_module (m);
625 * Push it on the stack
627 idl_global->scopes ().push (m);
633 idl_global->set_parse_state (IDL_GlobalData::PS_ModuleSqSeen);
635 at_least_one_definition
637 idl_global->set_parse_state (IDL_GlobalData::PS_ModuleBodySeen);
641 idl_global->set_parse_state (IDL_GlobalData::PS_ModuleQsSeen);
643 * Finished with this module - pop it from the scope stack.
646 idl_global->scopes ().pop ();
651 template_module_header
654 idl_global->set_parse_state (IDL_GlobalData::PS_TmplModuleIDSeen);
659 : template_module_header
661 // The module_header rule is common to template module, fixed
662 // module and instantiated template module. In the last
663 // case, a fully scoped name is allowed, but here we
664 // allow only an identifier (a scoped name of length
665 // 1). If not satisfied, we output a syntax error with
666 // the appropriate message.
667 if ($1->length () != 1)
669 idl_global->err ()->syntax_error (
670 IDL_GlobalData::PS_ModuleIDSeen);
673 at_least_one_formal_parameter
675 if (FE_Utils::duplicate_param_id ($3))
677 idl_global->err ()->duplicate_param_id (
685 idl_global->set_parse_state (IDL_GlobalData::PS_TmplModuleParamsSeen);
687 AST_Template_Module *tm =
688 idl_global->gen ()->create_template_module ($1,
691 UTL_Scope *s = idl_global->scopes ().top_non_null ();
692 AST_Module *m = s->fe_add_module (tm);
694 // We've probably tried to reopen a template module,
695 // going further will cause a crash.
702 * Push it on the stack
704 idl_global->scopes ().push (tm);
706 // Contained items not part of an alias will get flag set.
707 idl_global->in_tmpl_mod_no_alias (true);
709 // Store these for reference as we parse the scope
710 // of the template module.
711 idl_global->current_params ($3);
715 idl_global->set_parse_state (IDL_GlobalData::PS_TmplModuleSqSeen);
717 at_least_one_tpl_definition
719 idl_global->set_parse_state (IDL_GlobalData::PS_TmplModuleBodySeen);
723 idl_global->set_parse_state (IDL_GlobalData::PS_TmplModuleQsSeen);
726 * Finished with this module - pop it from the scope stack.
728 idl_global->scopes ().pop ();
730 // Unset the flag, the no_alias version because any scope
731 // traversal triggered by an alias would have ended by now.
732 idl_global->in_tmpl_mod_no_alias (false);
734 // Clear the pointer so scoped name lookup will know
735 // that we are no longer in a template module scope.
736 idl_global->current_params (0);
742 at_least_one_tpl_definition
743 : tpl_definition tpl_definitions
747 : tpl_definitions tpl_definition
753 | template_module_ref ';'
757 : IDL_ALIAS scoped_name
759 idl_global->set_parse_state (
760 IDL_GlobalData::PS_ModuleRefSeen);
762 '<' at_least_one_formal_parameter_name '>'
764 idl_global->set_parse_state (
765 IDL_GlobalData::PS_ModuleRefParamsSeen);
769 idl_global->set_parse_state (
770 IDL_GlobalData::PS_ModuleRefIDSeen);
772 UTL_Scope *s = idl_global->scopes ().top_non_null ();
774 s->lookup_by_name ($2);
778 idl_global->err ()->lookup_error ($2);
782 AST_Template_Module *ref =
783 dynamic_cast<AST_Template_Module*> (d);
787 idl_global->err ()->template_module_expected (d);
792 ref->match_param_refs ($5,
797 // Error message is already output.
801 UTL_ScopedName sn ($8, 0);
803 AST_Template_Module_Ref *tmr =
804 idl_global->gen ()->create_template_module_ref (
809 (void) s->fe_add_template_module_ref (tmr);
816 // Save the current flag value to be restored below.
817 bool itmna_flag = idl_global->in_tmpl_mod_no_alias ();
818 idl_global->in_tmpl_mod_no_alias (false);
819 idl_global->in_tmpl_mod_alias (true);
821 ast_visitor_context ctx;
822 ctx.template_params (ref->template_params ());
823 ast_visitor_tmpl_module_ref v (&ctx);
825 // The implied IDL resulting from this reference is
826 // created here, in the template module scope. Upon
827 // instantiation of the enclosing template module, the
828 // visitor copies this implied IDL to the instantiated
829 // module scope. The extra copy is less than ideal, but
830 // otherwise we have ugly lookup issues when the
831 // referenced template module's contents are referenced
832 // using the aliased scoped name.
833 if (v.visit_template_module_ref (tmr) != 0)
835 ACE_ERROR ((LM_ERROR,
836 ACE_TEXT ("visit_template_module_ref")
837 ACE_TEXT (" failed\n")));
839 idl_global->set_err_count (idl_global->err_count () + 1);
842 idl_global->in_tmpl_mod_no_alias (itmna_flag);
843 idl_global->in_tmpl_mod_alias (false);
848 : template_module_header
850 idl_global->set_parse_state (
851 IDL_GlobalData::PS_InstModuleSeen);
853 at_least_one_actual_parameter '>'
855 idl_global->set_parse_state (
856 IDL_GlobalData::PS_InstModuleArgsSeen);
860 idl_global->set_parse_state (
861 IDL_GlobalData::PS_InstModuleIDSeen);
863 UTL_Scope *s = idl_global->scopes ().top_non_null ();
864 UTL_ScopedName *sn = $1;
865 AST_Template_Module *ref = 0;
866 AST_Decl *d = s->lookup_by_name (sn);
870 idl_global->err ()->lookup_error (sn);
875 ref = dynamic_cast<AST_Template_Module*> (d);
879 idl_global->err ()->template_module_expected (d);
889 if (! ref->match_arg_names ($3))
899 AST_Template_Module_Inst *tmi =
900 idl_global->gen ()->create_template_module_inst (
905 (void) s->fe_add_template_module_inst (tmi);
907 ast_visitor_context ctx;
908 ctx.template_args ($3);
909 ast_visitor_tmpl_module_inst v (&ctx);
911 if (v.visit_template_module_inst (tmi) != 0)
913 ACE_ERROR ((LM_ERROR,
914 ACE_TEXT ("visit_template_module_inst")
915 ACE_TEXT (" failed\n")));
917 idl_global->set_err_count (idl_global->err_count () + 1);
932 UTL_Scope *s = idl_global->scopes ().top_non_null ();
933 AST_Interface *i = 0;
935 FE_InterfaceHeader *header = $1;
939 * Make a new interface node and add it to its enclosing scope.
943 i = idl_global->gen ()->create_interface (
946 header->n_inherits (),
947 header->inherits_flat (),
948 header->n_inherits_flat (),
950 header->is_abstract ()
952 AST_Interface::fwd_redefinition_helper (i, s);
954 * Add the interface to its definition scope.
956 s->fe_add_interface (i);
958 // This FE_InterfaceHeader class isn't destroyed with the AST.
964 * Push it on the scope stack.
966 idl_global->scopes ().push (i);
970 idl_global->set_parse_state (IDL_GlobalData::PS_InterfaceSqSeen);
974 idl_global->set_parse_state (IDL_GlobalData::PS_InterfaceBodySeen);
978 idl_global->set_parse_state (IDL_GlobalData::PS_InterfaceQsSeen);
980 $$ = dynamic_cast<AST_Decl *> (idl_global->scopes ().top_non_null ());
982 * Done with this interface - pop it off the scopes stack
984 idl_global->scopes ().pop ();
991 idl_global->set_parse_state (IDL_GlobalData::PS_InterfaceSeen);
995 idl_global->set_parse_state (IDL_GlobalData::PS_InterfaceIDSeen);
1001 interface_decl inheritance_spec
1003 idl_global->set_parse_state (IDL_GlobalData::PS_InheritSpecSeen);
1005 if ($2 != 0 && $2->truncatable ())
1007 idl_global->err ()->syntax_error (
1008 IDL_GlobalData::PS_InheritColonSeen
1013 * Create an AST representation of the information in the header
1014 * part of an interface - this representation contains a computed
1015 * list of all interfaces which this interface inherits from,
1018 UTL_ScopedName *n = 0;
1020 UTL_ScopedName ($1, 0),
1023 FE_InterfaceHeader (n,
1038 IDL_LOCAL interface_decl inheritance_spec
1040 idl_global->set_parse_state (IDL_GlobalData::PS_InheritSpecSeen);
1043 * Create an AST representation of the information in the header
1044 * part of an interface - this representation contains a computed
1045 * list of all interfaces which this interface inherits from,
1048 UTL_ScopedName *n = 0;
1050 UTL_ScopedName ($2, 0),
1053 FE_InterfaceHeader (n,
1068 IDL_ABSTRACT interface_decl inheritance_spec
1070 idl_global->set_parse_state (IDL_GlobalData::PS_InheritSpecSeen);
1073 * Create an AST representation of the information in the header
1074 * part of an interface - this representation contains a computed
1075 * list of all interfaces which this interface inherits from,
1078 UTL_ScopedName *n = 0;
1080 UTL_ScopedName ($2, 0),
1083 FE_InterfaceHeader (n,
1100 : ':' opt_truncatable
1102 idl_global->set_parse_state (IDL_GlobalData::PS_InheritColonSeen);
1104 at_least_one_scoped_name
1106 $4->truncatable ($2);
1118 | value_forward_decl
1123 : IDL_CUSTOM value_concrete_decl
1125 idl_global->err ()->unsupported_error ("custom is not supported");
1128 | value_concrete_decl
1131 value_concrete_decl :
1134 FE_OBVHeader *&valuetype_header = $1;
1135 UTL_Scope *scope = idl_global->scopes ().top_non_null ();
1136 AST_ValueType *valuetype = 0;
1138 if (scope && valuetype_header)
1140 valuetype = idl_global->gen ()->create_valuetype (
1141 valuetype_header->name (),
1142 valuetype_header->inherits (),
1143 valuetype_header->n_inherits (),
1144 valuetype_header->inherits_concrete (),
1145 valuetype_header->inherits_flat (),
1146 valuetype_header->n_inherits_flat (),
1147 valuetype_header->supports (),
1148 valuetype_header->n_supports (),
1149 valuetype_header->supports_concrete (),
1151 valuetype_header->truncatable (),
1154 AST_Interface *valuetype_as_interface =
1155 dynamic_cast<AST_Interface *> (valuetype);
1156 AST_Interface::fwd_redefinition_helper (
1157 valuetype_as_interface, scope);
1158 valuetype = dynamic_cast<AST_ValueType *> (
1159 valuetype_as_interface);
1162 * Add the valuetype to its definition scope
1164 scope->fe_add_valuetype (valuetype);
1166 // FE_OBVHeader is not automatically destroyed in the AST
1167 valuetype_header->destroy ();
1168 delete valuetype_header;
1169 valuetype_header = 0;
1173 * Push it on the scope stack
1175 idl_global->scopes ().push (valuetype);
1177 $<dcval>$ = valuetype;
1181 idl_global->set_parse_state (IDL_GlobalData::PS_ValueTypeSqSeen);
1185 idl_global->set_parse_state (IDL_GlobalData::PS_ValueTypeBodySeen);
1189 idl_global->set_parse_state (IDL_GlobalData::PS_ValueTypeQsSeen);
1192 dynamic_cast<AST_ValueType*> (
1193 idl_global->scopes ().top_non_null ()
1196 if (vt != 0 && vt->will_have_factory ())
1198 idl_global->valuefactory_seen_ = true;
1202 * Done with this value type - pop it off the scopes stack
1204 idl_global->scopes ().pop ();
1214 UTL_Scope *s = idl_global->scopes ().top_non_null ();
1215 AST_ValueType *v = 0;
1216 AST_Interface *i = 0;
1218 if (s != 0 && $2 != 0)
1221 idl_global->gen ()->create_valuetype (
1225 $2->inherits_concrete (),
1226 $2->inherits_flat (),
1227 $2->n_inherits_flat (),
1230 $2->supports_concrete (),
1235 i = dynamic_cast<AST_Interface*> (v);
1236 AST_Interface::fwd_redefinition_helper (i,
1239 * Add the valuetype to its definition scope
1241 v = dynamic_cast<AST_ValueType*> (i);
1242 (void) s->fe_add_valuetype (v);
1244 // FE_OBVHeader is not automatically destroyed in the AST
1251 * Push it on the scope stack.
1253 idl_global->scopes ().push (v);
1257 idl_global->set_parse_state (IDL_GlobalData::PS_ValueTypeSqSeen);
1261 idl_global->set_parse_state (IDL_GlobalData::PS_ValueTypeBodySeen);
1265 idl_global->set_parse_state (IDL_GlobalData::PS_ValueTypeQsSeen);
1268 * Done with this valuetype - pop it off the scopes stack.
1270 idl_global->scopes ().pop ();
1280 idl_global->set_parse_state (IDL_GlobalData::PS_InheritSpecSeen);
1284 idl_global->set_parse_state (IDL_GlobalData::PS_SupportSpecSeen);
1286 UTL_ScopedName *sn = 0;
1288 UTL_ScopedName ($1, 0),
1295 ? $2->truncatable ()
1318 idl_global->set_parse_state (IDL_GlobalData::PS_ValueTypeSeen);
1322 idl_global->set_parse_state (IDL_GlobalData::PS_ValueTypeIDSeen);
1340 at_least_one_scoped_name
1350 value_forward_decl :
1354 UTL_Scope *s = idl_global->scopes ().top_non_null ();
1355 UTL_ScopedName n ($2,
1357 AST_ValueTypeFwd *f = 0;
1358 idl_global->set_parse_state (IDL_GlobalData::PS_ValueTypeForwardSeen);
1361 * Create a node representing a forward declaration of an
1362 * valuetype. Store it in the enclosing scope
1366 f = idl_global->gen ()->create_valuetype_fwd (&n,
1368 (void) s->fe_add_valuetype_fwd (f);
1378 UTL_Scope *s = idl_global->scopes ().top_non_null ();
1379 UTL_ScopedName n ($1,
1381 AST_ValueTypeFwd *f = 0;
1382 idl_global->set_parse_state (IDL_GlobalData::PS_ValueTypeForwardSeen);
1385 * Create a node representing a forward declaration of an
1386 * valuetype. Store it in the enclosing scope
1390 f = idl_global->gen ()->create_valuetype_fwd (&n,
1392 (void) s->fe_add_valuetype_fwd (f);
1404 : value_decl type_spec /* in this order %!?*/
1406 idl_global->set_parse_state (IDL_GlobalData::PS_ValueBoxDeclSeen);
1408 UTL_Scope *s = idl_global->scopes ().top_non_null ();
1409 UTL_ScopedName n ($1,
1412 if (s != 0 && $2 != 0)
1415 * Get the type_spec associated with the valuebox
1419 = dynamic_cast<AST_Typedef*> ($2);
1423 tp = dynamic_cast<AST_Type*> ($2);
1427 tp = td->primitive_base_type ();
1432 // The <type_spec> given is a valid type
1433 idl_global->err ()->not_a_type ($2);
1437 AST_Decl::NodeType nt = tp->node_type ();
1439 if (nt == AST_Decl::NT_valuetype
1440 || nt == AST_Decl::NT_eventtype)
1442 // valuetype is not allowed as <type_spec>
1444 idl_global->err ()->error0 (
1445 UTL_Error::EIDL_ILLEGAL_BOXED_TYPE
1451 * Add the valuebox to its definition scope
1454 idl_global->gen ()->create_valuebox (&n,
1456 (void) s->fe_add_valuebox (vb);
1470 : value_elements at_least_one_annotation value_element
1472 AST_Annotation_Appls *&annotations = $2;
1473 AST_Decls *&decls = $3;
1476 for (size_t i = 0; i < decls->size (); i++)
1478 (*decls)[i]->annotation_appls (*annotations);
1483 idl_global->err ()-> unsupported_warning (
1484 "Annotating this is not supported");
1489 | value_elements value_element
1500 AST_Decl *&node = $1;
1501 AST_Decls *value = 0;
1504 value = new AST_Decls;
1505 value->push_back (node);
1511 AST_Decl *&node = $1;
1512 AST_Decls *value = 0;
1515 value = new AST_Decls;
1516 value->push_back (node);
1518 $<decls_val>$ = value;
1529 $$ = AST_Field::vis_PUBLIC;
1533 $$ = AST_Field::vis_PRIVATE;
1538 : visibility member_i
1540 AST_Field::Visibility &visibility = $1;
1541 AST_Decls *&decls_ptr = $2;
1544 AST_Decls &decls = *decls_ptr;
1545 for (size_t i = 0; i < decls.size (); i++)
1547 AST_Field *field = dynamic_cast<AST_Field *> (decls[i]);
1550 field->visibility (visibility);
1559 : at_least_one_export
1564 : exports at_least_one_annotation export
1566 AST_Annotation_Appls *annotations = $2;
1570 d->annotation_appls (*annotations);
1574 idl_global->err ()-> unsupported_warning (
1575 "Annotating this is not supported");
1585 idl_global->set_parse_state (IDL_GlobalData::PS_TypeDeclSeen);
1589 idl_global->set_parse_state (IDL_GlobalData::PS_NoState);
1593 idl_global->set_parse_state (IDL_GlobalData::PS_TypeIdDeclSeen);
1597 idl_global->set_parse_state (IDL_GlobalData::PS_NoState);
1601 idl_global->set_parse_state (IDL_GlobalData::PS_TypePrefixDeclSeen);
1605 idl_global->set_parse_state (IDL_GlobalData::PS_NoState);
1609 idl_global->set_parse_state (IDL_GlobalData::PS_ConstDeclSeen);
1613 idl_global->set_parse_state (IDL_GlobalData::PS_NoState);
1617 idl_global->set_parse_state (IDL_GlobalData::PS_ExceptDeclSeen);
1621 idl_global->set_parse_state (IDL_GlobalData::PS_NoState);
1625 idl_global->set_parse_state (IDL_GlobalData::PS_AttrDeclSeen);
1629 idl_global->set_parse_state (IDL_GlobalData::PS_NoState);
1633 idl_global->set_parse_state (IDL_GlobalData::PS_OpDeclSeen);
1637 idl_global->set_parse_state (IDL_GlobalData::PS_NoState);
1641 idl_global->err ()->syntax_error (idl_global->parse_state ());
1645 idl_global->set_parse_state (IDL_GlobalData::PS_NoState);
1651 at_least_one_scoped_name :
1652 scoped_name scoped_names
1654 ACE_NEW_RETURN ($<nlval>$,
1665 idl_global->set_parse_state (IDL_GlobalData::PS_SNListCommaSeen);
1669 idl_global->set_parse_state (IDL_GlobalData::PS_ScopedNameSeen);
1671 UTL_NameList *nl = 0;
1696 idl_global->set_parse_state (IDL_GlobalData::PS_SN_IDSeen);
1703 | IDL_SCOPE_DELIMITOR
1705 idl_global->set_parse_state (IDL_GlobalData::PS_ScopeDelimSeen);
1709 idl_global->set_parse_state (IDL_GlobalData::PS_SN_IDSeen);
1715 ACE::strdelete ($1);
1722 ACE_NEW_RETURN ($<idlist>$,
1730 idl_global->set_parse_state (IDL_GlobalData::PS_ScopeDelimSeen);
1732 // This cleans up all the non-global "::"s in scoped names.
1733 // If there is a global one, it gets put into the UTL_IdList,
1734 // so we clean it up in the case above.
1735 ACE::strdelete ($2);
1740 idl_global->set_parse_state (IDL_GlobalData::PS_SN_IDSeen);
1757 ACE::strdelete ($1);
1762 defining_id : IDENTIFIER
1764 /* defining_id is a defining identifier
1765 whereas id is usually a reference to a defining identifier */
1766 ACE_NEW_RETURN ($$, Identifier ($1), 1);
1767 ACE::strdelete ($1);
1775 UTL_Scope *s = idl_global->scopes ().top_non_null ();
1776 UTL_ScopedName n ($1, 0);
1778 if (ACE_OS::strcmp ($1->get_string (),
1780 && !idl_global->in_main_file ())
1782 AST_PredefinedType *pdt =
1783 idl_global->gen ()->create_predefined_type (
1784 AST_PredefinedType::PT_pseudo,
1788 s->add_to_scope (pdt);
1797 AST_InterfaceFwd *f = 0;
1798 idl_global->set_parse_state (IDL_GlobalData::PS_InterfaceForwardSeen);
1801 * Create a node representing a forward declaration of an
1802 * interface. Store it in the enclosing scope
1806 f = idl_global->gen ()->create_interface_fwd (&n,
1809 (void) s->fe_add_interface_fwd (f);
1817 IDL_LOCAL interface_decl
1819 UTL_Scope *s = idl_global->scopes ().top_non_null ();
1820 UTL_ScopedName n ($2,
1822 AST_InterfaceFwd *f = 0;
1823 idl_global->set_parse_state (
1824 IDL_GlobalData::PS_InterfaceForwardSeen
1828 * Create a node representing a forward declaration of an
1829 * interface. Store it in the enclosing scope
1833 f = idl_global->gen ()->create_interface_fwd (&n,
1836 (void) s->fe_add_interface_fwd (f);
1844 IDL_ABSTRACT interface_decl
1846 UTL_Scope *s = idl_global->scopes ().top_non_null ();
1847 UTL_ScopedName n ($2,
1849 AST_InterfaceFwd *f = 0;
1850 idl_global->set_parse_state (
1851 IDL_GlobalData::PS_InterfaceForwardSeen
1855 * Create a node representing a forward declaration of an
1856 * interface. Store it in the enclosing scope
1860 f = idl_global->gen ()->create_interface_fwd (&n,
1863 (void) s->fe_add_interface_fwd (f);
1870 $$ = dynamic_cast<AST_Decl *> (f);
1877 idl_global->set_parse_state (IDL_GlobalData::PS_ConstSeen);
1881 idl_global->set_parse_state (IDL_GlobalData::PS_ConstTypeSeen);
1885 idl_global->set_parse_state (IDL_GlobalData::PS_ConstIDSeen);
1889 idl_global->set_parse_state (IDL_GlobalData::PS_ConstAssignSeen);
1894 UTL_ScopedName n ($5, 0);
1896 UTL_Scope *s = idl_global->scopes ().top_non_null ();
1897 AST_Constant *c = 0;
1898 idl_global->set_parse_state (IDL_GlobalData::PS_ConstExprSeen);
1901 * Create a node representing a constant declaration. Store
1902 * it in the enclosing scope.
1904 if ($9 != 0 && s != 0)
1906 AST_Param_Holder *param_holder = $9->param_holder ();
1908 AST_Expression::AST_ExprValue *result =
1909 $9->check_and_coerce ($3, tao_enum_constant_decl);
1910 tao_enum_constant_decl = 0;
1912 // If the expression is a template parameter place
1913 // holder, 'result' will be 0, but it's ok.
1914 if (result == 0 && param_holder == 0)
1916 idl_global->err ()->coercion_error ($9, $3);
1923 AST_Expression::ExprType et = $3;
1925 if (param_holder != 0
1926 && et != param_holder->info ()->const_type_)
1928 idl_global->err ()->mismatched_template_param (
1929 param_holder->info ()->name_.c_str ());
1933 c = idl_global->gen ()->create_constant ($3, $9, &n);
1934 (void) s->fe_add_constant (c);
1958 $$ = AST_Expression::EV_string;
1962 $$ = AST_Expression::EV_wstring;
1966 UTL_Scope *s = idl_global->scopes ().top_non_null ();
1967 AST_PredefinedType *c = 0;
1969 UTL_ScopedName *sn = $1;
1972 * If the constant's type is a scoped name, it must resolve
1973 * to a scalar constant type
1976 s->lookup_by_name (sn);
1978 if (s != 0 && d != 0)
1981 * Look through typedefs.
1983 while (d->node_type () == AST_Decl::NT_typedef)
1985 t = dynamic_cast<AST_Typedef*> (d);
1992 d = t->base_type ();
1995 if (d->node_type () == AST_Decl::NT_pre_defined)
1997 c = dynamic_cast<AST_PredefinedType*> (d);
1999 $$ = FE_Utils::PredefinedTypeToExprType (c->pt ());
2001 else if (d->node_type () == AST_Decl::NT_string)
2003 $$ = AST_Expression::EV_string;
2005 else if (d->node_type () == AST_Decl::NT_wstring)
2007 $$ = AST_Expression::EV_wstring;
2009 else if (d->node_type () == AST_Decl::NT_enum)
2011 $$ = AST_Expression::EV_enum;
2012 tao_enum_constant_decl =
2013 dynamic_cast<AST_Enum*> (d);
2017 idl_global->err ()->constant_expected (sn, d);
2022 idl_global->err ()->lookup_error (sn);
2032 expression : const_expr ;
2034 const_expr : or_expr ;
2037 | or_expr '|' xor_expr
2040 idl_global->gen ()->create_expr (
2041 AST_Expression::EC_or,
2050 | xor_expr '^' and_expr
2053 idl_global->gen ()->create_expr (
2054 AST_Expression::EC_xor,
2063 | and_expr '&' shift_expr
2066 idl_global->gen ()->create_expr (
2067 AST_Expression::EC_and,
2076 | shift_expr IDL_LEFT_SHIFT add_expr
2079 idl_global->gen ()->create_expr (
2080 AST_Expression::EC_left,
2085 | shift_expr IDL_RIGHT_SHIFT add_expr
2088 idl_global->gen ()->create_expr (
2089 AST_Expression::EC_right,
2098 | add_expr '+' mult_expr
2101 idl_global->gen ()->create_expr (
2102 AST_Expression::EC_add,
2107 | add_expr '-' mult_expr
2110 idl_global->gen ()->create_expr (
2111 AST_Expression::EC_minus,
2120 | mult_expr '*' unary_expr
2123 idl_global->gen ()->create_expr (
2124 AST_Expression::EC_mul,
2129 | mult_expr '/' unary_expr
2132 idl_global->gen ()->create_expr (
2133 AST_Expression::EC_div,
2138 | mult_expr '%' unary_expr
2141 idl_global->gen ()->create_expr (
2142 AST_Expression::EC_mod,
2154 idl_global->gen ()->create_expr (
2155 AST_Expression::EC_u_plus,
2163 idl_global->gen ()->create_expr (
2164 AST_Expression::EC_u_minus,
2172 idl_global->gen ()->create_expr (
2173 AST_Expression::EC_bit_neg,
2183 UTL_ScopedName *name = $1;
2186 * An expression which is a scoped name is not resolved now,
2187 * but only when it is evaluated (such as when it is assigned
2188 * as a constant value).
2190 AST_Expression *expr = 0;
2192 AST_Decl *node = stack_based_lookup_for_primary_expr ?
2193 idl_global->scopes ().lookup_by_name (name) :
2194 idl_global->scopes ().top_non_null ()->lookup_by_name (name);
2197 if (!idl_global->ignore_lookup_errors_)
2199 idl_global->err ()->lookup_error (name);
2203 else if (node->node_type () == AST_Decl::NT_const)
2206 * If the scoped name is an IDL constant, it
2207 * may be used in an array dim, a string
2208 * bound, or a sequence bound. If so, it
2209 * must be unsigned and > 0. We assign the
2210 * constant's value and type to the
2211 * expression created here so we can check
2214 AST_Constant *c = dynamic_cast<AST_Constant *> (node);
2215 expr = idl_global->gen ()->create_expr (
2216 c->constant_value (),
2221 // An AST_Expression owns the scoped name
2222 // passed in this constructor, so we copy it
2223 // and destroy it below no matter which case
2225 expr = idl_global->gen ()->create_expr (name->copy ());
2226 if (node->node_type () == AST_Decl::NT_enum_val)
2229 dynamic_cast<AST_EnumVal *> (node)->enum_parent ());
2239 | '(' const_expr ')'
2246 : IDL_INTEGER_LITERAL
2248 $$ = idl_global->gen ()->create_expr ($1);
2250 | IDL_UINTEGER_LITERAL
2253 idl_global->gen ()->create_expr ($1);
2255 | IDL_STRING_LITERAL
2257 $$ = idl_global->gen ()->create_expr ($1);
2262 | IDL_WSTRING_LITERAL
2264 char *wide_string = $1;
2265 $$ = idl_global->gen ()->create_expr (wide_string);
2266 ACE_OS::free (wide_string);
2269 | IDL_CHARACTER_LITERAL
2271 $$ = idl_global->gen ()->create_expr ($1);
2275 ACE_OutputCDR::from_wchar wc ($1);
2276 $$ = idl_global->gen ()->create_expr (wc);
2278 | IDL_FIXED_PT_LITERAL
2280 $$ = idl_global->gen ()->create_expr ($1);
2282 | IDL_FLOATING_PT_LITERAL
2284 $$ = idl_global->gen ()->create_expr ($1);
2288 $$ = idl_global->gen ()->create_expr (true);
2292 $$ = idl_global->gen ()->create_expr (false);
2299 int good_expression = 1;
2300 $1->evaluate (AST_Expression::EK_positive_int);
2301 AST_Expression::AST_ExprValue *ev = $1->ev ();
2304 * If const_expr is an enum value (AST_EnumVal inherits from
2305 * AST_Constant), the AST_ExprValue will probably not be set,
2306 * but there's no need to check anyway
2312 case AST_Expression::EV_ushort:
2313 if (ev->u.usval == 0)
2315 good_expression = 0;
2319 case AST_Expression::EV_ulong:
2320 if (ev->u.ulval == 0)
2322 good_expression = 0;
2326 case AST_Expression::EV_ulonglong:
2327 if (ev->u.ullval == 0)
2329 good_expression = 0;
2333 case AST_Expression::EV_octet:
2334 if (ev->u.oval == 0)
2336 good_expression = 0;
2340 case AST_Expression::EV_bool:
2341 if (ev->u.bval == 0)
2343 good_expression = 0;
2348 good_expression = 0;
2353 if (good_expression)
2359 idl_global->err ()->syntax_error (idl_global->parse_state ());
2365 : IDL_ANNOTATION_DECL defining_id '{'
2367 if (idl_global->idl_version_ < IDL_VERSION_4)
2369 idl_global->err ()->idl_version_error (
2370 "Annotations are an IDL4 feature");
2373 Identifier *id = $2;
2374 UTL_ScopedName name (id, 0);
2375 AST_Annotation_Decl::escape_name (&name);
2376 AST_Annotation_Decl *annotation_decl = idl_global->gen ()->
2377 create_annotation_decl (&name);
2378 idl_global->scopes ().top_non_null ()->
2379 fe_add_annotation_decl (annotation_decl);
2380 idl_global->scopes ().push (annotation_decl);
2384 Identifier *id = $2;
2385 idl_global->scopes ().pop ();
2394 : annotation_body annotation_statement
2398 annotation_statement
2404 idl_global->set_parse_state (IDL_GlobalData::PS_TypedefSeen);
2405 idl_global->in_typedef (true);
2410 annotation_member_type
2416 : annotation_member_type defining_id annotation_member_default ';'
2418 UTL_Scope *scope = idl_global->scopes ().top_non_null ();
2419 UTL_Scope *root = idl_global->scopes ().bottom ();
2421 AST_Expression::ExprType type = $1;
2422 Identifier *name = $2;
2423 // Annotation member names can't clash with C++ keywords
2424 FE_Utils::original_local_name (name);
2425 UTL_ScopedName *scoped_name = new UTL_ScopedName (name, 0);
2426 AST_Expression *default_value = $3;
2428 AST_Decl * type_obj;
2431 case AST_Expression::EV_string:
2432 case AST_Expression::EV_wstring:
2433 type_obj = tao_string_decl;
2435 case AST_Expression::EV_enum:
2436 type_obj = tao_enum_constant_decl;
2439 type_obj = root->lookup_primitive_type (type);
2442 FE_Declarator *declarator = new FE_Declarator (
2443 scoped_name, FE_Declarator::FD_simple, 0);
2444 AST_Annotation_Member *member = idl_global->gen ()->
2445 create_annotation_member (
2446 type, declarator->compose (type_obj), declarator->name ());
2447 scope->fe_add_annotation_member (member);
2449 declarator->destroy ();
2454 // Check if types are compatible, else report error
2455 AST_Expression::AST_ExprValue *result =
2456 default_value->check_and_coerce (type, tao_enum_constant_decl);
2457 tao_enum_constant_decl = 0;
2460 member->value (default_value);
2464 idl_global->err ()->coercion_error (default_value, type);
2471 annotation_member_default
2472 : IDL_DEFAULT const_expr
2482 at_least_one_annotation
2483 : annotations_maybe annotation_appl
2485 AST_Annotation_Appls *annotations = $1;
2486 AST_Annotation_Appl *annotation = $2;
2489 annotations->add (annotation);
2496 : annotations_maybe annotation_appl
2498 AST_Annotation_Appls *annotations = $1;
2499 AST_Annotation_Appl *annotation = $2;
2502 annotations->add (annotation);
2508 $$ = new AST_Annotation_Appls ();
2513 : IDL_ANNOTATION_SYMBOL scoped_name
2515 if (idl_global->idl_version_ < IDL_VERSION_4)
2517 idl_global->err ()->idl_version_error (
2518 "Annotations are an IDL4 feature");
2521 AST_Annotation_Decl *decl = 0;
2522 UTL_ScopedName *name = $2;
2523 AST_Annotation_Decl::escape_name (name);
2525 // Check for Matching Annotation Declaration
2526 AST_Decl *d = idl_global->scopes ().top_non_null ()->
2527 lookup_by_name (name);
2530 decl = dynamic_cast<AST_Annotation_Decl*> (d);
2533 idl_global->scopes ().push (decl);
2538 Identifier &id = *name->last_component ();
2539 switch (idl_global->unknown_annotations_)
2542 case IDL_GlobalData::UNKNOWN_ANNOTATIONS_WARN_ONCE:
2543 if (idl_global->unknown_annotations_seen_.insert (id) == 1)
2547 idl_global->err ()->lookup_warning (name);
2549 case IDL_GlobalData::UNKNOWN_ANNOTATIONS_WARN_ALL:
2550 idl_global->err ()->lookup_warning (name);
2552 case IDL_GlobalData::UNKNOWN_ANNOTATIONS_ERROR:
2553 idl_global->err ()->lookup_error (name);
2555 case IDL_GlobalData::UNKNOWN_ANNOTATIONS_IGNORE:
2560 * Ignore lookup errors for parameter values that might depend on
2561 * constants or enums from the missing annotation declaration.
2563 idl_global->ignore_lookup_errors_ = true;
2566 stack_based_lookup_for_primary_expr = true;
2568 $<annotation_decl_val>$ = decl;
2570 annotation_appl_params_maybe
2572 idl_global->ignore_lookup_errors_ = false;
2573 stack_based_lookup_for_primary_expr = false;
2574 AST_Annotation_Appl *appl = 0;
2575 UTL_ScopedName *name = $2;
2576 AST_Annotation_Decl *decl = $<annotation_decl_val>3;
2577 AST_Annotation_Appl::Params *params = $4;
2581 appl = idl_global->gen ()->create_annotation_appl (name, params);
2582 appl->apply_from (decl);
2583 idl_global->scopes ().pop ();
2587 AST_Annotation_Appl::delete_params (params);
2600 annotation_appl_params_maybe
2601 : '(' annotation_appl_params ')'
2611 annotation_appl_params
2614 AST_Annotation_Appl::Params *params = new AST_Annotation_Appl::Params;
2615 AST_Annotation_Appl::Param *param = new AST_Annotation_Appl::Param;
2618 params->push (param);
2621 | named_annotation_appl_params
2627 named_annotation_appl_params
2628 : named_annotation_appl_param more_named_annotation_appl_params
2630 AST_Annotation_Appl::Params *params = $2;
2635 more_named_annotation_appl_params
2636 : ',' named_annotation_appl_param more_named_annotation_appl_params
2638 AST_Annotation_Appl::Params *params = $3;
2644 $$ = new AST_Annotation_Appl::Params;
2648 named_annotation_appl_param
2651 AST_Annotation_Appl::Param *param = new AST_Annotation_Appl::Param;
2653 // Annotation Member Names Can't Clash with C++ keywords
2654 FE_Utils::original_local_name (param->id);
2663 idl_global->set_parse_state (IDL_GlobalData::PS_TypedefSeen);
2664 idl_global->in_typedef (true);
2682 | IDL_NATIVE simple_declarator
2684 UTL_Scope *s = idl_global->scopes ().top_non_null ();
2685 AST_Native *node = 0;
2686 idl_global->set_parse_state (IDL_GlobalData::PS_NativeSeen);
2689 * Create a node representing a Native and add it to its
2695 idl_global->gen ()->create_native (
2699 * Add it to its defining scope
2701 (void) s->fe_add_native (node);
2710 | constructed_forward_type_spec
2719 idl_global->set_parse_state (IDL_GlobalData::PS_TypeSpecSeen);
2721 at_least_one_declarator
2723 AST_Decl *type_spec = $1;
2724 UTL_DeclList *decls = $3;
2726 UTL_Scope *s = idl_global->scopes ().top_non_null ();
2727 FE_Declarator *d = 0;
2729 unsigned long index = 0UL;
2730 idl_global->set_parse_state (IDL_GlobalData::PS_DeclaratorsSeen);
2733 * Create a list of type renamings. Add them to the
2736 if (s && type_spec && decls)
2738 for (UTL_DecllistActiveIterator l (decls); !l.is_done (); l.next ())
2746 AST_Type *tp = d->compose (type_spec);
2752 if (AST_Decl::NT_except == tp->node_type ())
2754 idl_global->err ()->not_a_type (tp);
2758 t = idl_global->gen ()->create_typedef (tp,
2763 // If the base type is a sequence or array, the typedef
2764 // constructor sets owns_base_type_ to true. But if
2765 // there is a comma-separated list of such typedefs,
2766 // the base type can be destroyed only once. In all
2767 // other cases, the line below has no effect.
2770 t->owns_base_type (false);
2773 (void) s->fe_add_typedef (t);
2774 idl_global->in_typedef (false);
2777 // This FE_Declarator class isn't destroyed with the AST.
2789 | constructed_type_spec
2796 idl_global->scopes ().bottom ()->lookup_primitive_type (
2800 | template_type_spec
2803 UTL_Scope *s = idl_global->scopes ().top_non_null ();
2809 s->lookup_by_name ($1);
2814 idl_global->err ()->lookup_error ($1);
2818 d->last_referenced_as ($1);
2838 : sequence_type_spec
2845 constructed_type_spec
2851 constructed_forward_type_spec
2852 : struct_forward_type
2853 | union_forward_type
2856 at_least_one_declarator :
2857 declarator declarators
2870 idl_global->set_parse_state (IDL_GlobalData::PS_DeclsCommaSeen);
2874 idl_global->set_parse_state (IDL_GlobalData::PS_DeclsDeclSeen);
2876 UTL_DeclList *dl = 0;
2900 | complex_declarator
2903 at_least_one_simple_declarator :
2904 simple_declarator simple_declarators
2906 ACE_NEW_RETURN ($<dlval>$,
2914 : simple_declarators
2917 idl_global->set_parse_state (IDL_GlobalData::PS_DeclsCommaSeen);
2921 idl_global->set_parse_state (IDL_GlobalData::PS_DeclsDeclSeen);
2923 UTL_DeclList *dl = 0;
2948 UTL_ScopedName *sn = 0;
2953 ACE_NEW_RETURN ($<deval>$,
2955 FE_Declarator::FD_simple,
2961 complex_declarator :
2964 UTL_ScopedName *sn = 0;
2967 $1->local_name ()->copy (),
2971 ACE_NEW_RETURN ($<deval>$,
2973 FE_Declarator::FD_complex,
2987 $$ = AST_Expression::EV_long;
2991 $$ = AST_Expression::EV_longlong;
2995 $$ = AST_Expression::EV_short;
2999 $$ = AST_Expression::EV_int8;
3003 $$ = AST_Expression::EV_short;
3007 $$ = AST_Expression::EV_long;
3011 $$ = AST_Expression::EV_longlong;
3016 : IDL_UNSIGNED IDL_LONG
3018 $$ = AST_Expression::EV_ulong;
3020 | IDL_UNSIGNED IDL_LONG IDL_LONG
3022 $$ = AST_Expression::EV_ulonglong;
3024 | IDL_UNSIGNED IDL_SHORT
3026 $$ = AST_Expression::EV_ushort;
3030 $$ = AST_Expression::EV_uint8;
3034 $$ = AST_Expression::EV_ushort;
3038 $$ = AST_Expression::EV_ulong;
3042 $$ = AST_Expression::EV_ulonglong;
3049 $$ = AST_Expression::EV_double;
3053 $$ = AST_Expression::EV_float;
3055 | IDL_LONG IDL_DOUBLE
3057 $$ = AST_Expression::EV_longdouble;
3064 $$ = AST_Expression::EV_fixed;
3071 $$ = AST_Expression::EV_char;
3075 $$ = AST_Expression::EV_wchar;
3082 $$ = AST_Expression::EV_octet;
3089 $$ = AST_Expression::EV_bool;
3096 $$ = AST_Expression::EV_any;
3103 $$ = AST_Expression::EV_object;
3110 idl_global->set_parse_state (IDL_GlobalData::PS_StructSeen);
3114 idl_global->set_parse_state (IDL_GlobalData::PS_StructIDSeen);
3123 UTL_Scope *s = idl_global->scopes ().top_non_null ();
3124 UTL_ScopedName n ($1, 0);
3125 AST_Structure *d = 0;
3128 * Create a node representing a struct declaration. Add it
3129 * to the enclosing scope
3134 idl_global->gen ()->create_structure (
3139 AST_Structure::fwd_redefinition_helper (d, s);
3140 (void) s->fe_add_structure (d);
3144 * Push the scope of the struct on the scopes stack.
3146 idl_global->scopes ().push (d);
3154 idl_global->set_parse_state (IDL_GlobalData::PS_StructSqSeen);
3158 idl_global->set_parse_state (IDL_GlobalData::PS_StructBodySeen);
3162 idl_global->set_parse_state (IDL_GlobalData::PS_StructQsSeen);
3165 * Done with this struct. Pop its scope off the scopes stack.
3167 $$ = dynamic_cast<AST_Structure*> (
3168 idl_global->scopes ().top_non_null ()
3170 idl_global->scopes ().pop ();
3174 at_least_one_member : member members ;
3182 : annotations_maybe member_i
3184 AST_Annotation_Appls *annotations = $1;
3185 AST_Decls *members = $2;
3186 if (annotations && members)
3188 for (size_t i = 0; i < members->size (); i++)
3190 (*members)[i]->annotation_appls (*annotations);
3201 idl_global->set_parse_state (IDL_GlobalData::PS_MemberTypeSeen);
3203 at_least_one_declarator
3205 idl_global->set_parse_state (IDL_GlobalData::PS_MemberDeclsSeen);
3209 UTL_Scope *s = idl_global->scopes ().top_non_null ();
3210 FE_Declarator *d = 0;
3212 idl_global->set_parse_state (IDL_GlobalData::PS_MemberDeclsCompleted);
3213 AST_Decls *members = 0;
3216 * Check for illegal recursive use of type.
3219 && AST_illegal_recursive_type ($1))
3221 idl_global->err ()->error1 (UTL_Error::EIDL_RECURSIVE_TYPE,
3225 * Create a node representing a struct or exception member
3226 * Add it to the enclosing scope.
3228 else if (s && $1 && $3)
3230 members = new AST_Decls;
3231 for (UTL_DecllistActiveIterator l ($3);
3242 AST_Type *tp = d->compose ($1);
3249 f = idl_global->gen ()->create_field (tp, d->name ());
3250 members->push_back (f);
3251 (void) s->fe_add_field (f);
3263 idl_global->err ()->syntax_error (idl_global->parse_state ());
3267 idl_global->set_parse_state (IDL_GlobalData::PS_NoState);
3275 idl_global->set_parse_state (IDL_GlobalData::PS_UnionSeen);
3279 idl_global->set_parse_state (IDL_GlobalData::PS_UnionIDSeen);
3285 : union_decl IDL_SWITCH
3287 idl_global->set_parse_state (IDL_GlobalData::PS_SwitchSeen);
3291 UTL_Scope *s = idl_global->scopes ().top_non_null ();
3292 UTL_ScopedName n ($1, 0);
3294 idl_global->set_parse_state (IDL_GlobalData::PS_SwitchOpenParSeen);
3297 * Create a node representing an empty union. Add it to its enclosing
3302 u = idl_global->gen ()->create_union (0,
3307 AST_Structure *st = dynamic_cast<AST_Structure*> (u);
3308 AST_Structure::fwd_redefinition_helper (st, s);
3309 u = dynamic_cast<AST_Union*> (st);
3310 (void) s->fe_add_union (u);
3314 * Push the scope of the union on the scopes stack
3316 idl_global->scopes ().push (u);
3319 * Don't delete $1 yet; we'll need it a bit later.
3322 annotations_maybe switch_type_spec
3324 idl_global->set_parse_state (IDL_GlobalData::PS_SwitchTypeSeen);
3329 * The top of the scopes must be an empty union we added after we
3330 * encountered 'union <id> switch ('. Now we are ready to add a
3331 * correct one. Temporarily remove the top so that we setup the
3332 * correct union in a right scope.
3334 UTL_Scope *top = idl_global->scopes ().top_non_null ();
3335 idl_global->scopes ().pop ();
3336 AST_Annotation_Appls *disc_annotations = $6;
3338 UTL_Scope *s = idl_global->scopes ().top_non_null ();
3339 UTL_ScopedName n ($1, 0);
3340 idl_global->set_parse_state (IDL_GlobalData::PS_SwitchCloseParSeen);
3343 * Create a node representing a union.
3345 if ($7 != 0 && s != 0)
3347 AST_ConcreteType *tp =
3348 dynamic_cast<AST_ConcreteType*> ($7);
3352 idl_global->err ()->not_a_type ($7);
3356 /* Create a union with a correct discriminator. */
3358 u = idl_global->gen ()->create_union (tp,
3363 /* Narrow the enclosing scope. */
3364 AST_Union *e = dynamic_cast<AST_Union*> (top);
3367 e->disc_annotations (*disc_annotations); // Set Discriminator Annotations
3377 idl_global->scopes ().push (top);
3383 delete disc_annotations;
3387 idl_global->set_parse_state (IDL_GlobalData::PS_UnionSqSeen);
3389 at_least_one_case_branch
3391 idl_global->set_parse_state (IDL_GlobalData::PS_UnionBodySeen);
3395 idl_global->set_parse_state (IDL_GlobalData::PS_UnionQsSeen);
3398 * Done with this union. Pop its scope from the scopes stack.
3400 $$ = dynamic_cast<AST_Union*> (
3401 idl_global->scopes ().top_non_null ()
3406 idl_global->scopes ().pop ();
3415 idl_global->scopes ().bottom ()->lookup_primitive_type (
3421 /* wchars are not allowed. */
3422 if ($1 == AST_Expression::EV_wchar)
3424 idl_global->err ()->error0 (UTL_Error::EIDL_DISC_TYPE);
3428 idl_global->scopes ().bottom ()->lookup_primitive_type (
3434 /* octets are not allowed. */
3435 idl_global->err ()->error0 (UTL_Error::EIDL_DISC_TYPE);
3437 idl_global->scopes ().bottom ()->lookup_primitive_type (
3444 idl_global->scopes ().bottom ()->lookup_primitive_type (
3451 UTL_Scope *s = idl_global->scopes ().top_non_null ();
3453 AST_PredefinedType *p = 0;
3458 * The discriminator is a scoped name. Try to resolve to
3459 * one of the scalar types or to an enum. Thread through
3460 * typedef's to arrive at the base type at the end of the
3464 s->lookup_by_name ($1);
3466 if (s != 0 && d != 0)
3470 switch (d->node_type ())
3472 case AST_Decl::NT_enum:
3476 case AST_Decl::NT_pre_defined:
3477 p = dynamic_cast<AST_PredefinedType*> (d);
3483 case AST_PredefinedType::PT_long:
3484 case AST_PredefinedType::PT_ulong:
3485 case AST_PredefinedType::PT_longlong:
3486 case AST_PredefinedType::PT_ulonglong:
3487 case AST_PredefinedType::PT_short:
3488 case AST_PredefinedType::PT_ushort:
3489 case AST_PredefinedType::PT_char:
3490 case AST_PredefinedType::PT_boolean:
3494 case AST_PredefinedType::PT_wchar:
3495 case AST_PredefinedType::PT_octet:
3496 /* octets and wchars are not allowed */
3497 idl_global->err ()->error0 (
3498 UTL_Error::EIDL_DISC_TYPE
3516 case AST_Decl::NT_typedef:
3517 t = dynamic_cast<AST_Typedef*> (d);
3521 d = t->base_type ();
3539 idl_global->err ()->lookup_error ($1);
3545 /* If we don't return here, we'll crash later.*/
3546 if (!idl_global->ignore_lookup_errors_)
3558 at_least_one_case_branch : case_branch case_branches ;
3561 : case_branches case_branch
3566 at_least_one_case_label
3568 idl_global->set_parse_state (IDL_GlobalData::PS_UnionLabelSeen);
3570 annotations_maybe element_spec
3572 idl_global->set_parse_state (IDL_GlobalData::PS_UnionElemSeen);
3576 UTL_Scope *s = idl_global->scopes ().top_non_null ();
3577 AST_UnionBranch *b = 0;
3578 AST_Annotation_Appls *annotations = $3;
3580 idl_global->set_parse_state (IDL_GlobalData::PS_UnionElemCompleted);
3583 * Create several nodes representing branches of a union.
3584 * Add them to the enclosing scope (the union scope)
3586 if (s != 0 && $1 != 0 && $4 != 0)
3589 idl_global->gen ()->create_union_branch (
3594 b->annotation_appls (*annotations);
3595 (void) s->fe_add_union_branch (b);
3597 // f has passed its field type to the union branch,
3598 // but the rest still needs to be cleaned up.
3599 f->AST_Decl::destroy ();
3608 idl_global->err ()->syntax_error (idl_global->parse_state ());
3612 idl_global->set_parse_state (IDL_GlobalData::PS_NoState);
3617 at_least_one_case_label :
3618 case_label case_labels
3620 ACE_NEW_RETURN ($<llval>$,
3628 : case_labels case_label
3630 UTL_LabelList *ll = 0;
3655 idl_global->set_parse_state (IDL_GlobalData::PS_DefaultSeen);
3659 idl_global->set_parse_state (IDL_GlobalData::PS_LabelColonSeen);
3661 $$ = idl_global->gen ()->create_union_label (
3662 AST_UnionLabel::UL_default,
3668 idl_global->set_parse_state (IDL_GlobalData::PS_CaseSeen);
3672 idl_global->set_parse_state (IDL_GlobalData::PS_LabelExprSeen);
3676 idl_global->set_parse_state (IDL_GlobalData::PS_LabelColonSeen);
3678 $$ = idl_global->gen ()->create_union_label (
3679 AST_UnionLabel::UL_label,
3688 idl_global->set_parse_state (IDL_GlobalData::PS_UnionElemTypeSeen);
3692 idl_global->set_parse_state (IDL_GlobalData::PS_UnionElemDeclSeen);
3695 * Check for illegal recursive use of type
3698 && AST_illegal_recursive_type ($1))
3700 idl_global->err ()->error1 (UTL_Error::EIDL_RECURSIVE_TYPE, $1);
3705 * Create a field in a union branch
3714 AST_Type *tp = $3->compose ($1);
3722 $$ = idl_global->gen ()->create_field (
3738 UTL_Scope *s = idl_global->scopes ().top_non_null ();
3739 UTL_ScopedName n ($1,
3741 AST_StructureFwd *d = 0;
3744 * Create a node representing a forward declaration of a struct.
3748 d = idl_global->gen ()->create_structure_fwd (&n);
3749 (void) s->fe_add_structure_fwd (d);
3763 UTL_Scope *s = idl_global->scopes ().top_non_null ();
3764 UTL_ScopedName n ($1,
3766 AST_UnionFwd *u = 0;
3769 * Create a node representing a forward declaration of a union.
3773 u = idl_global->gen ()->create_union_fwd (&n);
3774 (void) s->fe_add_union_fwd (u);
3786 idl_global->set_parse_state (IDL_GlobalData::PS_EnumSeen);
3790 UTL_Scope *s = idl_global->scopes ().top_non_null ();
3791 UTL_ScopedName n ($3, 0);
3793 idl_global->set_parse_state (IDL_GlobalData::PS_EnumIDSeen);
3796 * Create a node representing an enum and add it to its
3801 e = idl_global->gen ()->create_enum (&n,
3805 * Add it to its defining scope
3807 (void) s->fe_add_enum (e);
3811 * Push the enum scope on the scopes stack.
3813 idl_global->scopes ().push (e);
3821 idl_global->set_parse_state (IDL_GlobalData::PS_EnumSqSeen);
3823 at_least_one_enumerator
3825 idl_global->set_parse_state (IDL_GlobalData::PS_EnumBodySeen);
3829 idl_global->set_parse_state (IDL_GlobalData::PS_EnumQsSeen);
3832 * Done with this enum. Pop its scope from the scopes stack.
3834 if (idl_global->scopes ().top () == 0)
3840 $$ = dynamic_cast<AST_Enum*> (
3841 idl_global->scopes ().top_non_null ()
3843 idl_global->scopes ().pop ();
3848 at_least_one_enumerator : enumerator enumerators ;
3854 idl_global->set_parse_state (IDL_GlobalData::PS_EnumCommaSeen);
3861 annotations_maybe IDENTIFIER
3863 UTL_Scope *s = idl_global->scopes ().top_non_null ();
3864 AST_Annotation_Appls *annotations = $1;
3866 ACE::strdelete ($2);
3868 UTL_ScopedName n (&id, 0);
3873 * Create a node representing one enumerator in an enum
3874 * Add it to the enclosing scope (the enum scope)
3877 && s->scope_node_type () == AST_Decl::NT_enum)
3879 c = dynamic_cast<AST_Enum*> (s);
3883 e = idl_global->gen ()->create_enum_val (
3884 c->next_enum_val (),
3888 e->annotation_appls (*annotations);
3891 (void) s->fe_add_enum_val (e);
3903 Decl_Annotations_Pair_Pair* type_pair = $1;
3904 Decl_Annotations_Pair *key_type = type_pair->first;
3905 Decl_Annotations_Pair *val_type = type_pair->second;
3908 * Remove map marker from scopes stack.
3910 if (idl_global->scopes ().top () == 0)
3912 idl_global->scopes ().pop ();
3915 UTL_Scope *s = idl_global->scopes ().top_non_null ();
3918 * Create a node representing a map.
3920 if (key_type && val_type)
3922 AST_Type *ktp = dynamic_cast<AST_Type*> (key_type->decl);
3923 AST_Type *vtp = dynamic_cast<AST_Type*> (val_type->decl);
3925 if (ktp == 0 || vtp == 0)
3927 ; // Error will be caught in FE_Declarator.
3931 Identifier id ("map");
3932 UTL_ScopedName sn (&id, 0);
3933 ACE_CDR::ULong bound = 0UL;
3936 idl_global->gen ()->create_map (
3937 idl_global->gen ()->create_expr (
3939 AST_Expression::EV_ulong
3947 map->key_type_annotations (*key_type->annotations);
3948 map->value_type_annotations (*val_type->annotations);
3950 idl_global->err ()->anonymous_type_diagnostic ();
3954 delete key_type->annotations;
3955 delete val_type->annotations;
3964 idl_global->set_parse_state (IDL_GlobalData::PS_MapSeen);
3967 * Push a map marker on scopes stack.
3969 idl_global->scopes ().push (0);
3972 annotations_maybe simple_type_spec
3974 idl_global->set_parse_state(IDL_GlobalData::PS_MapKeyTypeSeen);
3977 annotations_maybe simple_type_spec
3979 idl_global->set_parse_state(IDL_GlobalData::PS_MapValueTypeSeen);
3980 Decl_Annotations_Pair *key = new Decl_Annotations_Pair;
3982 key->annotations = $4;
3984 Decl_Annotations_Pair *value = new Decl_Annotations_Pair;
3986 value->annotations = $8;
3988 Decl_Annotations_Pair_Pair* pairs = new Decl_Annotations_Pair_Pair;
3990 pairs->second = value;
3999 idl_global->set_parse_state (IDL_GlobalData::PS_SequenceCommaSeen);
4003 idl_global->set_parse_state (IDL_GlobalData::PS_SequenceExprSeen);
4007 idl_global->set_parse_state (IDL_GlobalData::PS_SequenceQsSeen);
4009 AST_Sequence *seq = 0;
4010 Decl_Annotations_Pair *seq_head = $1;
4012 AST_Annotation_Appls *type_annotations = 0;
4015 type = seq_head->decl;
4016 type_annotations = seq_head->annotations;
4021 * Remove sequence marker from scopes stack.
4023 if (idl_global->scopes ().top () == 0)
4025 idl_global->scopes ().pop ();
4028 UTL_Scope *s = idl_global->scopes ().top_non_null ();
4031 * Create a node representing a sequence
4033 AST_Expression::AST_ExprValue *ev = 0;
4034 AST_Param_Holder *param_holder = 0;
4039 $4->param_holder ();
4041 ev = $4->coerce (AST_Expression::EV_ulong);
4044 // If the expression corresponds to a template parameter,
4045 // it's ok for the coercion to fail at this point. We check
4046 // for a type mismatch below.
4048 || (0 == ev && 0 == param_holder))
4050 idl_global->err ()->coercion_error ($4,
4051 AST_Expression::EV_ulong);
4055 AST_Type *tp = dynamic_cast<AST_Type*> (type);
4059 ; // Error will be caught in FE_Declarator.
4063 Identifier id ("sequence");
4064 UTL_ScopedName sn (&id,
4068 idl_global->gen ()->create_sequence (
4075 seq->base_type_annotations (*type_annotations);
4077 idl_global->err ()->anonymous_type_diagnostic ();
4081 delete type_annotations;
4089 idl_global->set_parse_state (IDL_GlobalData::PS_SequenceQsSeen);
4091 AST_Sequence *seq = 0;
4092 Decl_Annotations_Pair *seq_head = $1;
4094 AST_Annotation_Appls *type_annotations = 0;
4097 type = seq_head->decl;
4098 type_annotations = seq_head->annotations;
4103 * Remove sequence marker from scopes stack.
4105 if (idl_global->scopes ().top () == 0)
4107 idl_global->scopes ().pop ();
4110 UTL_Scope *s = idl_global->scopes ().top_non_null ();
4113 * Create a node representing a sequence.
4117 AST_Type *tp = dynamic_cast<AST_Type*> (type);
4121 ; // Error will be caught in FE_Declarator.
4125 Identifier id ("sequence");
4126 UTL_ScopedName sn (&id, 0);
4127 ACE_CDR::ULong bound = 0UL;
4130 idl_global->gen ()->create_sequence (
4131 idl_global->gen ()->create_expr (
4133 AST_Expression::EV_ulong
4140 seq->base_type_annotations (*type_annotations);
4142 idl_global->err ()->anonymous_type_diagnostic ();
4146 delete type_annotations;
4154 idl_global->set_parse_state (IDL_GlobalData::PS_SequenceSeen);
4157 * Push a sequence marker on scopes stack.
4159 idl_global->scopes ().push (0);
4163 idl_global->set_parse_state (IDL_GlobalData::PS_SequenceSqSeen);
4165 annotations_maybe simple_type_spec
4167 idl_global->set_parse_state (IDL_GlobalData::PS_SequenceTypeSeen);
4168 Decl_Annotations_Pair *seq_head = new Decl_Annotations_Pair;
4169 seq_head->decl = $6;
4170 seq_head->annotations = $5;
4176 : IDL_FIXED '<' positive_int_expr ',' const_expr '>'
4178 $5->evaluate (AST_Expression::EK_positive_int);
4179 $$ = idl_global->gen ()->create_fixed ($3, $5);
4187 idl_global->set_parse_state (IDL_GlobalData::PS_StringSqSeen);
4191 idl_global->set_parse_state (IDL_GlobalData::PS_StringExprSeen);
4195 idl_global->set_parse_state (IDL_GlobalData::PS_StringQsSeen);
4198 * Create a node representing a string.
4200 AST_Expression::AST_ExprValue *ev = 0;
4204 ev = $4->coerce (AST_Expression::EV_ulong);
4207 if (0 == $4 || 0 == ev)
4209 idl_global->err ()->coercion_error ($4,
4210 AST_Expression::EV_ulong);
4215 tao_string_decl = idl_global->gen ()->create_string ($4);
4218 * Add this AST_String to the types defined in the global scope.
4220 idl_global->root ()->fe_add_string (
4221 dynamic_cast<AST_String*> (
4224 idl_global->err ()->anonymous_type_diagnostic ();
4226 $$ = tao_string_decl;
4234 idl_global->set_parse_state (IDL_GlobalData::PS_StringCompleted);
4237 * Create a node representing a string.
4239 ACE_CDR::ULong bound = 0UL;
4241 idl_global->gen ()->create_string (
4242 idl_global->gen ()->create_expr (bound,
4243 AST_Expression::EV_ulong)
4247 * Add this AST_String to the types defined in the global scope.
4249 idl_global->root ()->fe_add_string (
4250 dynamic_cast<AST_String*> (
4253 $$ = tao_string_decl;
4260 idl_global->set_parse_state (IDL_GlobalData::PS_StringSeen);
4268 idl_global->set_parse_state (IDL_GlobalData::PS_StringSqSeen);
4272 idl_global->set_parse_state (IDL_GlobalData::PS_StringExprSeen);
4276 idl_global->set_parse_state (IDL_GlobalData::PS_StringQsSeen);
4279 * Create a node representing a string.
4281 AST_Expression::AST_ExprValue *ev = 0;
4285 ev = $4->coerce (AST_Expression::EV_ulong);
4288 if (0 == $4 || 0 == ev)
4290 idl_global->err ()->coercion_error ($4,
4291 AST_Expression::EV_ulong);
4296 AST_String *string = idl_global->gen ()->create_wstring ($4);
4299 * Add this AST_String to the types defined in the global scope.
4301 idl_global->root ()->fe_add_string (
4302 dynamic_cast<AST_String*> (
4305 idl_global->err ()->anonymous_type_diagnostic ();
4315 idl_global->set_parse_state (IDL_GlobalData::PS_StringCompleted);
4318 * Create a node representing a wstring.
4320 ACE_CDR::ULong bound = 0UL;
4321 AST_String *string =
4322 idl_global->gen ()->create_wstring (
4323 idl_global->gen ()->create_expr (bound,
4324 AST_Expression::EV_ulong)
4328 * Add this AST_String to the types defined in the global scope.
4330 idl_global->root ()->fe_add_string (
4331 dynamic_cast<AST_String*> (
4341 idl_global->set_parse_state (IDL_GlobalData::PS_StringSeen);
4348 idl_global->set_parse_state (IDL_GlobalData::PS_ArrayIDSeen);
4350 annotations_maybe at_least_one_array_dim
4352 idl_global->set_parse_state (IDL_GlobalData::PS_ArrayCompleted);
4354 AST_Array *array = 0;
4355 AST_Annotation_Appls *base_type_annotations = $3;
4356 UTL_ExprList *array_dims = $4;
4359 * Create a node representing an array.
4363 UTL_ScopedName sn ($1,
4366 idl_global->gen ()->create_array (
4368 array_dims->length (),
4373 array->base_type_annotations (*base_type_annotations);
4376 idl_global->err ()->anonymous_type_diagnostic ();
4379 array_dims->destroy ();
4382 delete base_type_annotations;
4388 at_least_one_array_dim :
4389 array_dim array_dims
4399 : array_dims array_dim
4401 UTL_ExprList *el = 0;
4426 idl_global->set_parse_state (IDL_GlobalData::PS_DimSqSeen);
4430 idl_global->set_parse_state (IDL_GlobalData::PS_DimExprSeen);
4434 idl_global->set_parse_state (IDL_GlobalData::PS_DimQsSeen);
4437 * Array dimensions are expressions which must be coerced to
4438 * positive integers.
4440 AST_Expression::AST_ExprValue *ev = 0;
4441 AST_Param_Holder *param_holder = 0;
4446 $3->param_holder ();
4449 $3->coerce (AST_Expression::EV_ulong);
4453 || (ev == 0 && param_holder == 0))
4455 idl_global->err ()->coercion_error ($3,
4456 AST_Expression::EV_ulong);
4461 if (param_holder != 0)
4463 AST_Expression::ExprType et =
4464 param_holder->info ()->const_type_;
4466 // If the bound expression represents a
4467 // template parameter, it must be a const
4468 // and of type unsigned long.
4469 if (et != AST_Expression::EV_ulong)
4471 idl_global->err ()->mismatched_template_param (
4472 param_holder->info ()->name_.c_str ());
4489 : attribute_readonly
4490 | attribute_readwrite
4493 attribute_readonly :
4496 idl_global->set_parse_state (IDL_GlobalData::PS_AttrROSeen);
4500 idl_global->set_parse_state (IDL_GlobalData::PS_AttrSeen);
4504 idl_global->set_parse_state (IDL_GlobalData::PS_AttrTypeSeen);
4506 at_least_one_simple_declarator
4508 idl_global->set_parse_state (IDL_GlobalData::PS_AttrDeclsSeen);
4512 UTL_Scope *s = idl_global->scopes ().top_non_null ();
4513 AST_Attribute *a = 0;
4514 FE_Declarator *d = 0;
4516 idl_global->set_parse_state (IDL_GlobalData::PS_OpRaiseCompleted);
4519 * Create nodes representing attributes and add them to the
4522 if (s != 0 && $5 != 0 && $7 != 0)
4524 for (UTL_DecllistActiveIterator l ($7); !l.is_done (); l.next ())
4533 AST_Type *tp = d->compose ($5);
4540 a = idl_global->gen ()->create_attribute (
4541 true, tp, d->name (), s->is_local (), s->is_abstract ());
4545 (void) a->fe_add_get_exceptions ($9);
4552 (void) s->fe_add_attribute (a);
4564 attribute_readwrite :
4567 idl_global->set_parse_state (IDL_GlobalData::PS_AttrSeen);
4571 idl_global->set_parse_state (IDL_GlobalData::PS_AttrTypeSeen);
4573 at_least_one_simple_declarator
4575 idl_global->set_parse_state (IDL_GlobalData::PS_AttrDeclsSeen);
4579 idl_global->set_parse_state (IDL_GlobalData::PS_OpGetRaiseCompleted);
4583 UTL_Scope *s = idl_global->scopes ().top_non_null ();
4584 AST_Attribute *a = 0;
4585 FE_Declarator *d = 0;
4587 idl_global->set_parse_state (IDL_GlobalData::PS_OpSetRaiseCompleted);
4590 * Create nodes representing attributes and add them to the
4593 if (s != 0 && $3 != 0 && $5 != 0)
4595 for (UTL_DecllistActiveIterator l ($5); !l.is_done (); l.next ())
4604 AST_Type *tp = d->compose ($3);
4611 a = idl_global->gen ()->create_attribute (
4612 false, tp, d->name (), s->is_local (), s->is_abstract ());
4616 (void) a->fe_add_get_exceptions ($7);
4625 (void) a->fe_add_set_exceptions ($9);
4632 (void) s->fe_add_attribute (a);
4647 idl_global->set_parse_state (IDL_GlobalData::PS_ExceptSeen);
4651 Identifier *&id = $3;
4652 UTL_Scope *scope = idl_global->scopes ().top_non_null ();
4653 UTL_ScopedName scoped_name (id, 0);
4654 AST_Exception *exception = 0;
4655 idl_global->set_parse_state (IDL_GlobalData::PS_ExceptIDSeen);
4658 * Create a node representing an exception and add it to
4659 * the enclosing scope.
4663 exception = idl_global->gen ()->create_exception (
4666 scope->is_abstract ());
4667 scope->fe_add_exception (exception);
4671 * Push the exception scope on the scope stack.
4673 idl_global->scopes ().push (exception);
4679 $<dcval>$ = exception;
4683 idl_global->set_parse_state (IDL_GlobalData::PS_ExceptSqSeen);
4687 idl_global->set_parse_state (IDL_GlobalData::PS_ExceptBodySeen);
4691 idl_global->set_parse_state (IDL_GlobalData::PS_ExceptQsSeen);
4693 * Done with this exception. Pop its scope from the scope stack.
4695 idl_global->scopes ().pop ();
4702 : opt_op_attribute op_type_spec
4704 idl_global->set_parse_state (IDL_GlobalData::PS_OpTypeSeen);
4708 AST_Operation *op = 0;
4709 UTL_Scope *scope = idl_global->scopes ().top_non_null ();
4711 AST_Operation::Flags op_flags = $1;
4712 AST_Decl *type_node = $2;
4715 ACE::strdelete ($4);
4718 UTL_ScopedName name (&id, 0);
4719 idl_global->set_parse_state (IDL_GlobalData::PS_OpIDSeen);
4722 * Create a node representing an operation on an interface
4723 * and add it to its enclosing scope.
4725 if (scope != 0 && type_node != 0)
4727 AST_Type *type = dynamic_cast<AST_Type*> (type_node);
4731 idl_global->err ()->not_a_type (type_node);
4733 else if (type->node_type () == AST_Decl::NT_except)
4735 idl_global->err ()->not_a_type (type_node);
4739 AST_Decl *d = ScopeAsDecl (scope);
4740 AST_Decl::NodeType nt = d->node_type ();
4741 const bool local = scope->is_local ()
4742 || nt == AST_Decl::NT_valuetype
4743 || nt == AST_Decl::NT_eventtype;
4745 op = idl_global->gen ()->create_operation (
4746 type, op_flags, &name, local, scope->is_abstract ());
4748 if (!local && type->is_local ())
4750 idl_global->err ()->local_remote_mismatch (type, op);
4757 scope->fe_add_operation (op);
4763 * Push the operation scope onto the scopes stack.
4765 idl_global->scopes ().push (op);
4769 idl_global->set_parse_state (IDL_GlobalData::PS_OpParsCompleted);
4773 idl_global->set_parse_state (IDL_GlobalData::PS_OpRaiseCompleted);
4777 UTL_Scope *s = idl_global->scopes ().top_non_null ();
4778 AST_Operation *o = 0;
4779 idl_global->set_parse_state (IDL_GlobalData::PS_OpCompleted);
4782 * Add exceptions and context to the operation.
4784 if (s != 0 && s->scope_node_type () == AST_Decl::NT_op)
4786 o = dynamic_cast<AST_Operation*> (s);
4788 if ($8 != 0 && o != 0)
4790 (void) o->fe_add_exceptions ($8);
4795 (void) o->fe_add_context ($10);
4800 * Done with this operation. Pop its scope from the scopes stack.
4802 idl_global->scopes ().pop ();
4811 idl_global->set_parse_state (IDL_GlobalData::PS_OpAttrSeen);
4812 $$ = AST_Operation::OP_oneway;
4816 idl_global->set_parse_state (IDL_GlobalData::PS_OpAttrSeen);
4817 $$ = AST_Operation::OP_idempotent;
4821 $$ = AST_Operation::OP_noflags;
4830 idl_global->scopes ().bottom ()->lookup_primitive_type (
4831 AST_Expression::EV_void
4839 //@@ PS_FactorySeen?
4840 idl_global->set_parse_state (IDL_GlobalData::PS_OpTypeSeen);
4844 UTL_Scope *s = idl_global->scopes ().top_non_null ();
4846 if (s->is_abstract ())
4849 ACE_ERROR ((LM_ERROR,
4850 ACE_TEXT ("error in %C line %d:\n")
4851 ACE_TEXT ("Abstract valuetype can't have a ")
4852 ACE_TEXT ("factory construct.\n"),
4853 idl_global->filename ()->get_string (),
4854 idl_global->lineno ()));
4856 idl_global->set_err_count (idl_global->err_count () + 1);
4860 ACE::strdelete ($3);
4863 UTL_ScopedName n (&id,
4865 AST_Factory *factory = 0;
4866 idl_global->set_parse_state (IDL_GlobalData::PS_OpIDSeen);
4869 * Create a node representing an factory construct
4870 * and add it to its enclosing scope
4874 factory = idl_global->gen ()->create_factory (&n);
4875 (void) s->fe_add_factory (factory);
4879 * Push the operation scope onto the scopes stack.
4881 idl_global->scopes ().push (factory);
4883 $<dcval>$ = factory;
4887 idl_global->set_parse_state (IDL_GlobalData::PS_OpParsCompleted);
4891 idl_global->set_parse_state (IDL_GlobalData::PS_OpRaiseCompleted);
4895 UTL_Scope *s = idl_global->scopes ().top_non_null ();
4896 AST_Factory *f = dynamic_cast<AST_Factory*> (s);
4897 (void) f->fe_add_exceptions ($7);
4900 idl_global->scopes ().pop ();
4909 idl_global->set_parse_state (IDL_GlobalData::PS_OpSqSeen);
4913 idl_global->set_parse_state (IDL_GlobalData::PS_OpQsSeen);
4917 idl_global->set_parse_state (IDL_GlobalData::PS_OpSqSeen);
4919 at_least_one_in_parameter
4922 idl_global->set_parse_state (IDL_GlobalData::PS_OpQsSeen);
4926 at_least_one_in_parameter : in_parameter in_parameters ;
4932 idl_global->set_parse_state (IDL_GlobalData::PS_OpParCommaSeen);
4941 idl_global->set_parse_state (IDL_GlobalData::PS_OpParDirSeen);
4945 idl_global->set_parse_state (IDL_GlobalData::PS_OpParTypeSeen);
4949 UTL_Scope *s = idl_global->scopes ().top_non_null ();
4950 AST_Argument *a = 0;
4951 idl_global->set_parse_state (IDL_GlobalData::PS_OpParDeclSeen);
4954 * Create a node representing an argument to an operation
4955 * Add it to the enclosing scope (the operation scope).
4961 AST_Type *tp = $5->compose ($3);
4965 a = idl_global->gen ()->create_argument (
4966 AST_Argument::dir_IN,
4971 (void) s->fe_add_argument (a);
4984 idl_global->set_parse_state (IDL_GlobalData::PS_OpSqSeen);
4988 idl_global->set_parse_state (IDL_GlobalData::PS_OpQsSeen);
4992 idl_global->set_parse_state (IDL_GlobalData::PS_OpSqSeen);
4994 at_least_one_parameter
4997 idl_global->set_parse_state (IDL_GlobalData::PS_OpQsSeen);
5001 at_least_one_parameter : parameter parameters ;
5007 idl_global->set_parse_state (IDL_GlobalData::PS_OpParCommaSeen);
5016 idl_global->set_parse_state (IDL_GlobalData::PS_OpParDirSeen);
5020 idl_global->set_parse_state (IDL_GlobalData::PS_OpParTypeSeen);
5024 UTL_Scope *s = idl_global->scopes ().top_non_null ();
5025 AST_Argument *a = 0;
5026 idl_global->set_parse_state (IDL_GlobalData::PS_OpParDeclSeen);
5029 * Create a node representing an argument to an operation
5030 * Add it to the enclosing scope (the operation scope).
5036 AST_Type *tp = $5->compose ($3);
5040 if (!s->is_local () && tp->is_local ())
5042 idl_global->err ()->local_remote_mismatch (tp, s);
5047 idl_global->gen ()->create_argument (
5052 (void) s->fe_add_argument (a);
5067 idl_global->scopes ().bottom ()->lookup_primitive_type (
5075 UTL_Scope *s = idl_global->scopes ().top_non_null ();
5077 UTL_ScopedName *n = $1;
5081 d = s->lookup_by_name (n, false, false);
5086 idl_global->err ()->lookup_error (n);
5090 /* If we don't return here, we'll crash later.*/
5095 d->last_referenced_as ($1);
5096 AST_Decl::NodeType nt = d->node_type ();
5097 AST_Type *t = dynamic_cast<AST_Type*> (d);
5098 AST_Typedef *td = 0;
5099 bool can_be_undefined = false;
5101 if (nt == AST_Decl::NT_typedef)
5103 // This code block ensures that a sequence of
5104 // as-yet-undefined struct or union isn't used
5105 // as a return type or argument.
5106 td = dynamic_cast<AST_Typedef*> (d);
5107 AST_Type *pbt = td->primitive_base_type ();
5109 if (pbt->node_type () == AST_Decl::NT_sequence)
5112 AST_Sequence *seq_type =
5113 dynamic_cast<AST_Sequence*> (pbt);
5114 AST_Type *elem_type =
5115 seq_type->base_type ();
5116 AST_Decl::NodeType elem_nt =
5117 elem_type->node_type ();
5119 if (elem_nt == AST_Decl::NT_typedef)
5121 AST_Typedef *elem_td =
5122 dynamic_cast<AST_Typedef*> (elem_type);
5123 elem_type = elem_td->primitive_base_type ();
5124 elem_nt = elem_type->node_type ();
5127 if (elem_nt == AST_Decl::NT_interface
5128 || elem_nt == AST_Decl::NT_interface_fwd
5129 || elem_nt == AST_Decl::NT_valuetype
5130 || elem_nt == AST_Decl::NT_valuetype_fwd
5131 || elem_nt == AST_Decl::NT_component
5132 || elem_nt == AST_Decl::NT_component_fwd)
5134 can_be_undefined = true;
5138 if (pbt->node_type() == AST_Decl::NT_map)
5142 dynamic_cast<AST_Map*> (pbt);
5143 AST_Type *key_type =
5144 map_type->key_type ();
5145 AST_Type *val_type =
5146 map_type->value_type ();
5148 AST_Decl::NodeType key_nt =
5149 key_type->node_type ();
5150 AST_Decl::NodeType val_nt =
5151 val_type->node_type ();
5153 if (key_nt == AST_Decl::NT_typedef)
5155 AST_Typedef *key_td =
5156 dynamic_cast<AST_Typedef*> (key_type);
5157 key_type = key_td->primitive_base_type ();
5158 key_nt = key_type->node_type ();
5161 if (val_nt == AST_Decl::NT_typedef)
5163 AST_Typedef *val_td =
5164 dynamic_cast<AST_Typedef*> (val_type);
5165 val_type = val_td->primitive_base_type ();
5166 val_nt = val_type->node_type ();
5169 if (key_nt == AST_Decl::NT_interface
5170 || key_nt == AST_Decl::NT_interface_fwd
5171 || key_nt == AST_Decl::NT_valuetype
5172 || key_nt == AST_Decl::NT_valuetype_fwd
5173 || key_nt == AST_Decl::NT_component
5174 || key_nt == AST_Decl::NT_component_fwd
5175 || val_nt == AST_Decl::NT_interface
5176 || val_nt == AST_Decl::NT_interface_fwd
5177 || val_nt == AST_Decl::NT_valuetype
5178 || val_nt == AST_Decl::NT_valuetype_fwd
5179 || val_nt == AST_Decl::NT_component
5180 || val_nt == AST_Decl::NT_component_fwd)
5182 can_be_undefined = true;
5186 if (! t->is_defined () && ! can_be_undefined)
5188 idl_global->err ()->error1 (
5189 UTL_Error::EIDL_ILLEGAL_ADD,
5190 (nt == AST_Decl::NT_typedef ? td : t));
5192 /* If we don't return here, we'll crash later.*/
5198 // For forward declared structs and unions, we
5199 // want the full definition, but we need to
5200 // check that it's been fully defined.
5201 AST_StructureFwd *fwd =
5202 dynamic_cast<AST_StructureFwd*> (d);
5206 t = fwd->full_definition ();
5208 if (! t->is_defined ())
5210 idl_global->err ()->error1 (
5211 UTL_Error::EIDL_ILLEGAL_ADD,
5214 /* If we don't return here, we'll crash later.*/
5230 $$ = AST_Argument::dir_IN;
5234 $$ = AST_Argument::dir_OUT;
5238 $$ = AST_Argument::dir_INOUT;
5245 idl_global->set_parse_state (IDL_GlobalData::PS_OpRaiseSeen);
5249 idl_global->set_parse_state (IDL_GlobalData::PS_OpRaiseSqSeen);
5251 at_least_one_scoped_name
5254 idl_global->set_parse_state (IDL_GlobalData::PS_OpRaiseQsSeen);
5266 idl_global->set_parse_state (IDL_GlobalData::PS_OpGetRaiseSeen);
5270 idl_global->set_parse_state (IDL_GlobalData::PS_OpGetRaiseSqSeen);
5272 at_least_one_scoped_name
5275 idl_global->set_parse_state (IDL_GlobalData::PS_OpGetRaiseQsSeen);
5287 idl_global->set_parse_state (IDL_GlobalData::PS_OpSetRaiseSeen);
5291 idl_global->set_parse_state (IDL_GlobalData::PS_OpSetRaiseSqSeen);
5293 at_least_one_scoped_name
5296 idl_global->set_parse_state (IDL_GlobalData::PS_OpSetRaiseQsSeen);
5308 idl_global->set_parse_state (IDL_GlobalData::PS_OpContextSeen);
5312 idl_global->set_parse_state (IDL_GlobalData::PS_OpContextSqSeen);
5314 at_least_one_string_literal
5317 idl_global->set_parse_state (IDL_GlobalData::PS_OpContextQsSeen);
5326 at_least_one_string_literal :
5327 IDL_STRING_LITERAL string_literals
5329 ACE_NEW_RETURN ($<slval>$,
5340 idl_global->set_parse_state (IDL_GlobalData::PS_OpContextCommaSeen);
5344 UTL_StrList *sl = 0;
5367 : IDL_TYPEID scoped_name IDL_STRING_LITERAL
5369 UTL_Scope *s = idl_global->scopes ().top_non_null ();
5371 s->lookup_by_name ($2);
5375 idl_global->err ()->lookup_error ($2);
5379 d->set_id_with_typeid (
5397 : IDL_TYPEPREFIX scoped_name IDL_STRING_LITERAL
5399 UTL_Scope *s = idl_global->scopes ().top_non_null ();
5400 AST_Decl *d = ScopeAsDecl (s);
5402 // If we are in a module, we want to avoid a lookup unless the
5403 // typeprefix is to be applied to some other scope, since we
5404 // might get a previous opening of the module, and the prefix
5405 // of this opening would never get checked or set.
5406 if (d->name ()->compare ($2) != 0)
5409 s->lookup_by_name ($2);
5414 idl_global->err ()->lookup_error ($2);
5418 d->set_prefix_with_typeprefix (
5437 | component_forward_decl
5440 component_forward_decl :
5444 UTL_Scope *s = idl_global->scopes ().top_non_null ();
5445 UTL_ScopedName n ($2,
5447 AST_ComponentFwd *f = 0;
5448 idl_global->set_parse_state (
5449 IDL_GlobalData::PS_ComponentForwardSeen
5453 * Create a node representing a forward declaration of a
5454 * component. Store it in the enclosing scope.
5458 f = idl_global->gen ()->create_component_fwd (&n);
5459 (void) s->fe_add_component_fwd (f);
5473 FE_ComponentHeader *&component_header = $1;
5474 UTL_Scope *scope = idl_global->scopes ().top_non_null ();
5475 AST_Component *component = 0;
5478 * Make a new component node and add it to the enclosing scope.
5480 if (scope && component_header)
5482 component = idl_global->gen ()->create_component (
5483 component_header->name (),
5484 component_header->base_component (),
5485 component_header->supports (),
5486 component_header->n_supports (),
5487 component_header->supports_flat (),
5488 component_header->n_supports_flat ());
5489 AST_Interface *component_as_interface =
5490 dynamic_cast<AST_Interface *> (component);
5491 AST_Interface::fwd_redefinition_helper (
5492 component_as_interface, scope);
5493 component = dynamic_cast<AST_Component *> (component_as_interface);
5496 * Add the component to its definition scope.
5498 scope->fe_add_component (component);
5500 // This FE_ComponentHeader class isn't destroyed with the AST.
5501 component_header->destroy ();
5502 delete component_header;
5503 component_header = 0;
5507 * Push it on the scope stack.
5509 idl_global->scopes ().push (component);
5511 $<dcval>$ = component;
5515 idl_global->set_parse_state (IDL_GlobalData::PS_ComponentSqSeen);
5519 idl_global->set_parse_state (IDL_GlobalData::PS_ComponentBodySeen);
5523 idl_global->set_parse_state (IDL_GlobalData::PS_ComponentQsSeen);
5526 * Done with this component - pop it off the scopes stack.
5528 idl_global->scopes ().pop ();
5538 idl_global->set_parse_state (IDL_GlobalData::PS_ComponentIDSeen);
5540 component_inheritance_spec
5542 idl_global->set_parse_state (IDL_GlobalData::PS_InheritSpecSeen);
5546 idl_global->set_parse_state (IDL_GlobalData::PS_SupportSpecSeen);
5549 * Create an AST representation of the information in the header
5550 * part of a component.
5552 UTL_ScopedName *n = 0;
5557 ACE_NEW_RETURN ($<chval>$,
5558 FE_ComponentHeader (n,
5580 component_inheritance_spec
5583 idl_global->set_parse_state (IDL_GlobalData::PS_InheritColonSeen);
5596 : component_exports at_least_one_annotation component_export
5598 AST_Annotation_Appls *&annotations = $2;
5599 AST_Decl *&node = $3;
5602 node->annotation_appls (*annotations);
5606 idl_global->err ()-> unsupported_warning (
5607 "Annotating this is not supported");
5611 | component_exports component_export
5618 idl_global->set_parse_state (IDL_GlobalData::PS_ProvidesDeclSeen);
5622 idl_global->set_parse_state (IDL_GlobalData::PS_NoState);
5627 idl_global->set_parse_state (IDL_GlobalData::PS_UsesDeclSeen);
5631 idl_global->set_parse_state (IDL_GlobalData::PS_NoState);
5636 idl_global->set_parse_state (IDL_GlobalData::PS_EmitsDeclSeen);
5640 idl_global->set_parse_state (IDL_GlobalData::PS_NoState);
5645 idl_global->set_parse_state (IDL_GlobalData::PS_PublishesDeclSeen);
5649 idl_global->set_parse_state (IDL_GlobalData::PS_NoState);
5654 idl_global->set_parse_state (IDL_GlobalData::PS_ConsumesDeclSeen);
5658 idl_global->set_parse_state (IDL_GlobalData::PS_NoState);
5663 idl_global->set_parse_state (IDL_GlobalData::PS_AttrDeclSeen);
5667 idl_global->set_parse_state (IDL_GlobalData::PS_NoState);
5670 | extended_port_decl
5672 idl_global->set_parse_state (IDL_GlobalData::PS_ExtendedPortDeclSeen);
5676 idl_global->set_parse_state (IDL_GlobalData::PS_NoState);
5681 provides_decl : IDL_PROVIDES interface_type id
5683 UTL_Scope *s = idl_global->scopes ().top_non_null ();
5684 bool so_far_so_good = true;
5685 AST_Decl::NodeType nt = AST_Decl::NT_type;
5686 AST_Param_Holder *ph = 0;
5689 s->lookup_by_name ($2, true, false);
5693 idl_global->err ()->lookup_error ($2);
5694 so_far_so_good = false;
5699 nt = d->node_type ();
5703 case AST_Decl::NT_interface:
5705 case AST_Decl::NT_param_holder:
5706 ph = dynamic_cast<AST_Param_Holder*> (d);
5707 nt = ph->info ()->type_;
5709 if (nt != AST_Decl::NT_type
5710 && nt != AST_Decl::NT_interface)
5712 idl_global->err ()->mismatched_template_param (
5713 ph->info ()->name_.c_str ());
5715 so_far_so_good = false;
5719 case AST_Decl::NT_pre_defined:
5720 // Nothing else but CORBA::Object can have
5723 ACE_OS::strcmp (d->local_name ()->get_string (),
5726 // Simple provides port must use IDL interface
5727 // or CORBA::Object.
5730 idl_global->err ()->interface_expected (d);
5731 so_far_so_good = false;
5736 idl_global->err ()->interface_expected (d);
5737 so_far_so_good = false;
5742 AST_Provides *provides = 0;
5746 AST_Type *port_interface_type =
5747 dynamic_cast<AST_Type*> (d);
5749 // Strip off _cxx_, if any, for port name.
5750 FE_Utils::original_local_name ($3);
5752 UTL_ScopedName sn ($3,
5755 provides = idl_global->gen ()->create_provides (
5756 &sn, port_interface_type);
5758 (void) s->fe_add_provides (provides);
5769 $$ = dynamic_cast<AST_Decl *> (provides);
5776 // Lookups and checking are done where the 'interface_type'
5777 // token is used, in 'provides_decl' and 'uses_decl'.
5782 Identifier *corba_id = 0;
5784 ACE_NEW_RETURN (corba_id,
5785 Identifier ("Object"),
5788 UTL_IdList *conc_name = 0;
5789 ACE_NEW_RETURN (conc_name,
5790 UTL_IdList (corba_id,
5794 ACE_NEW_RETURN (corba_id,
5795 Identifier ("CORBA"),
5798 ACE_NEW_RETURN ($<idlist>$,
5799 UTL_IdList (corba_id,
5805 uses_decl : uses_opt_multiple interface_type id
5807 UTL_Scope *s = idl_global->scopes ().top_non_null ();
5808 bool so_far_so_good = true;
5809 AST_Decl::NodeType nt = AST_Decl::NT_type;
5810 AST_Param_Holder *ph = 0;
5813 s->lookup_by_name ($2, true, false);
5817 idl_global->err ()->lookup_error ($2);
5818 so_far_so_good = false;
5823 nt = d->node_type ();
5827 case AST_Decl::NT_interface:
5829 case AST_Decl::NT_param_holder:
5830 ph = dynamic_cast<AST_Param_Holder*> (d);
5831 nt = ph->info ()->type_;
5833 if (nt != AST_Decl::NT_type
5834 && nt != AST_Decl::NT_interface)
5836 idl_global->err ()->mismatched_template_param (
5837 ph->info ()->name_.c_str ());
5839 so_far_so_good = false;
5843 case AST_Decl::NT_pre_defined:
5844 // Nothing else but CORBA::Object can have
5847 ACE_OS::strcmp (d->local_name ()->get_string (),
5850 // Simple provides port must use IDL interface
5851 // or CORBA::Object.
5854 idl_global->err ()->interface_expected (d);
5855 so_far_so_good = false;
5860 idl_global->err ()->interface_expected (d);
5861 so_far_so_good = false;
5870 AST_Type *port_interface_type =
5871 dynamic_cast<AST_Type*> (d);
5873 // Strip off _cxx_, if any, for port name.
5874 FE_Utils::original_local_name ($3);
5876 UTL_ScopedName sn ($3,
5879 uses = idl_global->gen ()->create_uses (
5880 &sn, port_interface_type, $1);
5881 s->fe_add_uses (uses);
5884 dynamic_cast<AST_Component*> (s);
5887 && uses->is_multiple ()
5888 && !idl_global->using_ifr_backend ()
5889 && !idl_global->ignore_idl3 ()
5890 && nt != AST_Decl::NT_param_holder)
5892 // These datatypes must be created in the
5893 // front end so they can be looked up
5894 // when compiling the generated executor IDL.
5895 FE_Utils::create_uses_multiple_stuff (c, uses);
5912 : IDL_USES opt_multiple
5914 // We use this extra rule here to use in both uses_decl and
5915 // extended_uses_decl, so the LALR(1) parser can avoid conflicts.
5932 : IDL_EMITS scoped_name id
5934 UTL_Scope *s = idl_global->scopes ().top_non_null ();
5935 bool so_far_so_good = true;
5936 AST_Decl::NodeType nt = AST_Decl::NT_type;
5937 AST_Param_Holder *ph = 0;
5940 s->lookup_by_name ($2, true, false);
5944 idl_global->err ()->lookup_error ($2);
5945 so_far_so_good = false;
5949 nt = d->node_type ();
5953 case AST_Decl::NT_eventtype:
5955 case AST_Decl::NT_param_holder:
5956 ph = dynamic_cast<AST_Param_Holder*> (d);
5957 nt = ph->info ()->type_;
5959 if (nt != AST_Decl::NT_type
5960 && nt != AST_Decl::NT_eventtype)
5962 idl_global->err ()->mismatched_template_param (
5963 ph->info ()->name_.c_str ());
5965 so_far_so_good = false;
5970 idl_global->err ()->eventtype_expected (d);
5971 so_far_so_good = false;
5980 AST_Type *event_type =
5981 dynamic_cast<AST_Type*> (d);
5983 // Strip off _cxx_, if any, for port name.
5984 FE_Utils::original_local_name ($3);
5986 UTL_ScopedName sn ($3,
5989 e = idl_global->gen ()->create_emits (&sn, event_type);
5991 (void) s->fe_add_emits (e);
6007 : IDL_PUBLISHES scoped_name id
6009 UTL_Scope *s = idl_global->scopes ().top_non_null ();
6010 bool so_far_so_good = true;
6011 AST_Decl::NodeType nt = AST_Decl::NT_type;
6012 AST_Param_Holder *ph = 0;
6015 s->lookup_by_name ($2, true, false);
6019 idl_global->err ()->lookup_error ($2);
6020 so_far_so_good = false;
6024 nt = d->node_type ();
6028 case AST_Decl::NT_eventtype:
6030 case AST_Decl::NT_param_holder:
6031 ph = dynamic_cast<AST_Param_Holder*> (d);
6032 nt = ph->info ()->type_;
6034 if (nt != AST_Decl::NT_type
6035 && nt != AST_Decl::NT_eventtype)
6037 idl_global->err ()->mismatched_template_param (
6038 ph->info ()->name_.c_str ());
6040 so_far_so_good = false;
6045 idl_global->err ()->eventtype_expected (d);
6046 so_far_so_good = false;
6051 AST_Publishes *p = 0;
6055 AST_Type *event_type =
6056 dynamic_cast<AST_Type*> (d);
6058 // Strip off _cxx_, if any, for port name.
6059 FE_Utils::original_local_name ($3);
6061 UTL_ScopedName sn ($3, 0);
6062 p = idl_global->gen ()->create_publishes (&sn, event_type);
6063 s->fe_add_publishes (p);
6079 : IDL_CONSUMES scoped_name id
6081 UTL_Scope *s = idl_global->scopes ().top_non_null ();
6082 bool so_far_so_good = true;
6083 AST_Decl::NodeType nt = AST_Decl::NT_type;
6084 AST_Param_Holder *ph = 0;
6087 s->lookup_by_name ($2, true, false);
6091 idl_global->err ()->lookup_error ($2);
6092 so_far_so_good = false;
6096 nt = d->node_type ();
6100 case AST_Decl::NT_eventtype:
6102 case AST_Decl::NT_param_holder:
6103 ph = dynamic_cast<AST_Param_Holder*> (d);
6104 nt = ph->info ()->type_;
6106 if (nt != AST_Decl::NT_type
6107 && nt != AST_Decl::NT_eventtype)
6109 idl_global->err ()->mismatched_template_param (
6110 ph->info ()->name_.c_str ());
6112 so_far_so_good = false;
6117 idl_global->err ()->eventtype_expected (d);
6118 so_far_so_good = false;
6123 AST_Consumes *c = 0;
6127 AST_Type *event_type =
6128 dynamic_cast<AST_Type*> (d);
6130 // Strip off _cxx_, if any, for port name.
6131 FE_Utils::original_local_name ($3);
6133 UTL_ScopedName sn ($3,
6136 c = idl_global->gen ()->create_consumes (&sn, event_type);
6138 (void) s->fe_add_consumes (c);
6156 UTL_Scope *s = idl_global->scopes ().top_non_null ();
6160 * Make a new home node and add it to the enclosing scope.
6162 if (s != 0 && $1 != 0)
6165 idl_global->gen ()->create_home (
6168 $1->managed_component (),
6172 $1->supports_flat (),
6173 $1->n_supports_flat ()
6176 * Add the home to its definition scope.
6178 (void) s->fe_add_home (h);
6180 // This FE_HomeHeader class isn't destroyed with the AST.
6187 * Push it on the scope stack.
6189 idl_global->scopes ().push (h);
6194 * Done with this component - pop it off the scopes stack.
6196 idl_global->scopes ().pop ();
6205 idl_global->set_parse_state (IDL_GlobalData::PS_HomeSeen);
6209 idl_global->set_parse_state (IDL_GlobalData::PS_HomeIDSeen);
6211 home_inheritance_spec
6213 idl_global->set_parse_state (IDL_GlobalData::PS_InheritSpecSeen);
6217 idl_global->set_parse_state (IDL_GlobalData::PS_SupportSpecSeen);
6221 idl_global->set_parse_state (IDL_GlobalData::PS_ManagesSeen);
6225 idl_global->set_parse_state (IDL_GlobalData::PS_ManagesIDSeen);
6229 idl_global->set_parse_state (IDL_GlobalData::PS_PrimaryKeySpecSeen);
6232 * Create an AST representation of the information in the header
6233 * part of a component home.
6235 UTL_ScopedName *n = 0;
6237 UTL_ScopedName ($3, 0),
6240 ACE_NEW_RETURN ($<hhval>$,
6275 home_inheritance_spec
6278 idl_global->set_parse_state (IDL_GlobalData::PS_InheritColonSeen);
6305 idl_global->set_parse_state (IDL_GlobalData::PS_HomeSqSeen);
6309 idl_global->set_parse_state (IDL_GlobalData::PS_HomeBodySeen);
6313 idl_global->set_parse_state (IDL_GlobalData::PS_HomeQsSeen);
6318 : home_exports home_export
6326 idl_global->set_parse_state (IDL_GlobalData::PS_FactoryDeclSeen);
6330 idl_global->set_parse_state (IDL_GlobalData::PS_NoState);
6334 idl_global->set_parse_state (IDL_GlobalData::PS_FinderDeclSeen);
6338 idl_global->set_parse_state (IDL_GlobalData::PS_NoState);
6346 UTL_Scope *s = idl_global->scopes ().top_non_null ();
6347 UTL_ScopedName n ($2,
6349 idl_global->set_parse_state (IDL_GlobalData::PS_OpIDSeen);
6352 * Create a node representing a factory operation
6353 * and add it to the enclosing scope.
6355 AST_Factory *f = idl_global->gen ()->create_factory (&n);
6356 (void) s->fe_add_factory (f);
6363 * Push the factory scope onto the scopes stack.
6365 idl_global->scopes ().push (f);
6369 idl_global->set_parse_state (IDL_GlobalData::PS_OpParsCompleted);
6373 UTL_Scope *s = idl_global->scopes ().top_non_null ();
6374 idl_global->set_parse_state (IDL_GlobalData::PS_OpRaiseCompleted);
6377 * Add exceptions and context to the factory.
6381 (void) s->fe_add_exceptions ($6);
6385 * Done with this factory. Pop its scope from the scopes stack.
6387 idl_global->scopes ().pop ();
6395 UTL_Scope *s = idl_global->scopes ().top_non_null ();
6396 UTL_ScopedName n ($2,
6399 idl_global->set_parse_state (IDL_GlobalData::PS_OpIDSeen);
6402 * Create a node representing a home finder
6403 * and add it to the enclosing scope.
6406 idl_global->gen ()->create_finder (&n);
6408 (void) s->fe_add_finder (f);
6416 * Push the operation scope onto the scopes stack.
6418 idl_global->scopes ().push (f);
6422 idl_global->set_parse_state (IDL_GlobalData::PS_OpParsCompleted);
6426 UTL_Scope *s = idl_global->scopes ().top_non_null ();
6427 idl_global->set_parse_state (IDL_GlobalData::PS_OpRaiseCompleted);
6430 * Add exceptions and context to the finder.
6434 (void) s->fe_add_exceptions ($6);
6438 * Done with this operation. Pop its scope from the scopes stack.
6440 idl_global->scopes ().pop ();
6447 | event_forward_decl
6451 : event_abs_forward_decl
6452 | event_concrete_forward_decl
6455 event_concrete_forward_decl :
6459 UTL_Scope *s = idl_global->scopes ().top_non_null ();
6460 UTL_ScopedName n ($2,
6462 AST_EventTypeFwd *f = 0;
6463 idl_global->set_parse_state (IDL_GlobalData::PS_EventTypeForwardSeen);
6466 * Create a node representing a forward declaration of an
6467 * eventtype. Store it in the enclosing scope
6471 f = idl_global->gen ()->create_eventtype_fwd (&n,
6473 (void) s->fe_add_valuetype_fwd (f);
6484 event_abs_forward_decl :
6489 UTL_Scope *s = idl_global->scopes ().top_non_null ();
6490 UTL_ScopedName n ($3,
6492 AST_EventTypeFwd *f = 0;
6493 idl_global->set_parse_state (IDL_GlobalData::PS_EventTypeForwardSeen);
6496 * Create a node representing a forward declaration of an
6497 * eventtype. Store it in the enclosing scope
6501 f = idl_global->gen ()->create_eventtype_fwd (&n,
6503 (void) s->fe_add_valuetype_fwd (f);
6516 event_rest_of_header
6518 UTL_Scope *s = idl_global->scopes ().top_non_null ();
6519 AST_EventType *e = 0;
6520 AST_Interface *i = 0;
6522 if (s != 0 && $1 != 0)
6524 UTL_ScopedName sn ($1,
6527 idl_global->gen ()->create_eventtype (
6531 $2->inherits_concrete (),
6532 $2->inherits_flat (),
6533 $2->n_inherits_flat (),
6536 $2->supports_concrete (),
6541 i = dynamic_cast<AST_Interface*> (e);
6542 AST_Interface::fwd_redefinition_helper (i,
6545 * Add the eventetype to its definition scope
6547 e = dynamic_cast<AST_EventType*> (i);
6548 (void) s->fe_add_eventtype (e);
6552 * Push it on the scope stack.
6554 idl_global->scopes ().push (e);
6562 idl_global->set_parse_state (IDL_GlobalData::PS_EventTypeSqSeen);
6566 idl_global->set_parse_state (IDL_GlobalData::PS_EventTypeBodySeen);
6570 idl_global->set_parse_state (IDL_GlobalData::PS_EventTypeQsSeen);
6573 * Done with this eventtype - pop it off the scopes stack.
6575 idl_global->scopes ().pop ();
6590 event_custom_header :
6595 idl_global->set_parse_state (IDL_GlobalData::PS_EventTypeIDSeen);
6597 ACE_DEBUG ((LM_DEBUG,
6598 ACE_TEXT ("error in %C line %d\n"),
6599 idl_global->filename ()->get_string (),
6600 idl_global->lineno ()));
6601 ACE_DEBUG ((LM_DEBUG,
6602 ACE_TEXT ("Sorry, I (TAO_IDL) can't handle")
6603 ACE_TEXT (" custom yet\n")));
6608 event_plain_header :
6612 idl_global->set_parse_state (IDL_GlobalData::PS_EventTypeIDSeen);
6618 event_rest_of_header :
6621 idl_global->set_parse_state (IDL_GlobalData::PS_InheritSpecSeen);
6625 idl_global->set_parse_state (IDL_GlobalData::PS_SupportSpecSeen);
6627 ACE_NEW_RETURN ($<vhval>$,
6633 ? $1->truncatable ()
6656 event_rest_of_header
6658 UTL_Scope *scope = idl_global->scopes ().top_non_null ();
6659 Identifier *&event_id = $1;
6660 FE_OBVHeader *&event_header = $2;
6661 AST_EventType *eventtype = 0;
6663 if (scope && event_header)
6665 // We create the scoped name here instead of with the
6666 // FE_OBVHeader because there is a token for it only here.
6667 UTL_ScopedName sn (event_id, 0);
6668 eventtype = idl_global->gen ()->create_eventtype (
6670 event_header->inherits (),
6671 event_header->n_inherits (),
6672 event_header->inherits_concrete (),
6673 event_header->inherits_flat (),
6674 event_header->n_inherits_flat (),
6675 event_header->supports (),
6676 event_header->n_supports (),
6677 event_header->supports_concrete (),
6679 event_header->truncatable (),
6681 AST_Interface *eventtype_as_interface =
6682 dynamic_cast<AST_Interface *> (eventtype);
6683 AST_Interface::fwd_redefinition_helper (
6684 eventtype_as_interface, scope);
6685 eventtype = dynamic_cast<AST_EventType *> (eventtype_as_interface);
6688 * Add the eventetype to its definition scope
6690 scope->fe_add_eventtype (eventtype);
6692 // FE_OBVHeader is not automatically destroyed in the AST
6693 event_header->destroy ();
6694 delete event_header;
6701 * Push it on the scope stack.
6703 idl_global->scopes ().push (eventtype);
6705 $<dcval>$ = eventtype;
6709 idl_global->set_parse_state (IDL_GlobalData::PS_EventTypeSqSeen);
6713 idl_global->set_parse_state (IDL_GlobalData::PS_EventTypeBodySeen);
6717 idl_global->set_parse_state (IDL_GlobalData::PS_EventTypeQsSeen);
6720 * Done with this eventtype - pop it off the scopes stack.
6722 idl_global->scopes ().pop ();
6729 : event_custom_header
6733 | event_plain_header
6739 formal_parameter_type
6742 $<ntval>$ = AST_Decl::NT_type;
6746 $<ntval>$ = AST_Decl::NT_struct;
6750 $<ntval>$ = AST_Decl::NT_union;
6754 $<ntval>$ = AST_Decl::NT_eventtype;
6758 $<ntval>$ = AST_Decl::NT_sequence;
6762 $<ntval>$ = AST_Decl::NT_map;
6766 $<ntval>$ = AST_Decl::NT_interface;
6770 $<ntval>$ = AST_Decl::NT_valuetype;
6774 $<ntval>$ = AST_Decl::NT_enum;
6778 $<ntval>$ = AST_Decl::NT_except;
6780 | IDL_CONST const_type
6782 $<ntval>$ = AST_Decl::NT_const;
6783 t_param_const_type = $2;
6787 at_least_one_formal_parameter
6788 : formal_parameter formal_parameters
6792 ACE_NEW_RETURN ($2, FE_Utils::T_PARAMLIST_INFO, 1);
6795 $2->enqueue_head (*$1);
6799 // The param added above is always the last one parsed,
6800 // so we check for matches between sequence<T> & T here.
6801 ACE_CString bad_id =
6802 FE_Utils::check_for_seq_of_param (
6805 if (!bad_id.empty ())
6810 idl_global->err ()->mismatch_seq_of_param (bad_id.c_str ());
6819 : formal_parameters ',' formal_parameter
6823 ACE_NEW_RETURN ($1, FE_Utils::T_PARAMLIST_INFO, 1);
6826 $1->enqueue_tail (*$3);
6839 : formal_parameter_type IDENTIFIER
6843 FE_Utils::T_Param_Info,
6846 AST_Decl::NodeType nt = $1;
6850 ACE::strdelete ($2);
6853 if (nt == AST_Decl::NT_const)
6855 $$->const_type_ = t_param_const_type;
6856 $$->enum_const_type_decl_ =
6857 tao_enum_constant_decl;
6859 // Reset these values.
6860 t_param_const_type = AST_Expression::EV_none;
6861 tao_enum_constant_decl = 0;
6864 | IDL_SEQUENCE '<' IDENTIFIER '>' IDENTIFIER
6867 FE_Utils::T_Param_Info,
6870 $$->type_ = AST_Decl::NT_sequence;
6871 $$->seq_param_ref_ = $3;
6874 ACE::strdelete ($3);
6876 ACE::strdelete ($5);
6881 at_least_one_formal_parameter_name
6882 : formal_parameter_name formal_parameter_names
6884 ACE_NEW_RETURN ($$, UTL_StrList ($1, $2), 1);
6888 formal_parameter_names
6889 : formal_parameter_names ',' formal_parameter_name
6891 UTL_StrList *sl = 0;
6892 ACE_NEW_RETURN (sl, UTL_StrList ($3, 0), 1);
6910 formal_parameter_name
6914 UTL_String ($1, true),
6922 idl_global->set_parse_state (IDL_GlobalData::PS_PorttypeSeen);
6926 char *&id_value = $3;
6927 idl_global->set_parse_state (IDL_GlobalData::PS_PorttypeIDSeen);
6928 UTL_Scope *scope = idl_global->scopes ().top_non_null ();
6930 Identifier id (id_value);
6931 ACE::strdelete (id_value);
6934 UTL_ScopedName scoped_name (&id, 0);
6935 AST_PortType *porttype = idl_global->gen ()->create_porttype (
6937 scope->fe_add_porttype (porttype);
6938 $<dcval>$ = porttype;
6940 // Push it on the scopes stack.
6941 idl_global->scopes ().push (porttype);
6945 idl_global->set_parse_state (IDL_GlobalData::PS_PorttypeSqSeen);
6948 * NOTE: IDL4.2 spec has a different definition of what can go inside a
6951 at_least_one_port_export
6953 idl_global->set_parse_state (IDL_GlobalData::PS_PorttypeBodySeen);
6957 idl_global->set_parse_state (IDL_GlobalData::PS_PorttypeQsSeen);
6959 // Done with this port type - pop it off the scopes stack.
6960 idl_global->scopes ().pop ();
6966 at_least_one_port_export
6967 : port_exports at_least_one_annotation port_export
6969 AST_Annotation_Appls *&annotations = $2;
6970 AST_Decl *&node = $3;
6973 node->annotation_appls (*annotations);
6977 idl_global->err ()-> unsupported_warning (
6978 "Annotating this is not supported");
6982 | port_exports port_export
6986 : at_least_one_port_export
6995 idl_global->set_parse_state (IDL_GlobalData::PS_AttrDeclSeen);
7004 : IDL_PORT scoped_name IDENTIFIER
7006 idl_global->set_parse_state (IDL_GlobalData::PS_ExtendedPortDeclSeen);
7007 UTL_Scope *s = idl_global->scopes ().top_non_null ();
7009 s->lookup_by_name ($2);
7010 AST_PortType *pt = 0;
7011 bool so_far_so_good = true;
7015 idl_global->err ()->lookup_error ($2);
7016 so_far_so_good = false;
7020 pt = dynamic_cast<AST_PortType*> (d);
7024 idl_global->err ()->error1 (UTL_Error::EIDL_PORTTYPE_EXPECTED,
7026 so_far_so_good = false;
7030 AST_Extended_Port *ep = 0;
7035 ACE::strdelete ($3);
7038 UTL_ScopedName sn (&id, 0);
7039 ep = idl_global->gen ()->create_extended_port (&sn, pt);
7040 s->fe_add_extended_port (ep);
7042 // Create (in the AST) the struct(s) and sequence(s)
7043 // needed for multiplex uses ports, if any.
7044 for (UTL_ScopeActiveIterator i (pt, UTL_Scope::IK_decls);
7050 AST_Uses *u = dynamic_cast<AST_Uses*> (d);
7052 if (u != 0 && u->is_multiple ())
7055 dynamic_cast<AST_Component*> (s);
7057 FE_Utils::create_uses_multiple_stuff (
7071 | IDL_MIRRORPORT scoped_name IDENTIFIER
7073 idl_global->set_parse_state (IDL_GlobalData::PS_MirrorPortDeclSeen);
7074 UTL_Scope *s = idl_global->scopes ().top_non_null ();
7076 s->lookup_by_name ($2);
7077 AST_PortType *pt = 0;
7078 bool so_far_so_good = true;
7082 idl_global->err ()->lookup_error ($2);
7083 so_far_so_good = false;
7087 pt = dynamic_cast<AST_PortType*> (d);
7091 idl_global->err ()->error1 (UTL_Error::EIDL_PORTTYPE_EXPECTED,
7093 so_far_so_good = false;
7097 AST_Mirror_Port *mp = 0;
7102 ACE::strdelete ($3);
7105 UTL_ScopedName sn (&id, 0);
7106 mp = idl_global->gen ()->create_mirror_port (&sn, pt);
7107 s->fe_add_mirror_port (mp);
7118 at_least_one_actual_parameter
7119 : annotations_maybe actual_parameter actual_parameters
7124 FE_Utils::T_ARGLIST,
7129 $3->enqueue_head ($2);
7135 : actual_parameters ',' annotations_maybe actual_parameter
7140 FE_Utils::T_ARGLIST,
7145 $1->enqueue_tail ($4);
7157 // To avoid grammar conflicts with this LALR(1) parser,
7158 // we take advantage of the fact that an expression can
7159 // be a scoped name. At that lower level, we create an
7160 // expression containing the scoped name, and at a
7161 // higher lever, deduce that it's not supposed to be
7162 // a constant and look up the type to add to the template
7164 AST_Expression *ex = $1;
7165 UTL_ScopedName *sn = ex->n ();
7167 UTL_Scope *s = idl_global->scopes ().top_non_null ();
7171 d = s->lookup_by_name (sn);
7175 idl_global->err ()->lookup_error (sn);
7180 AST_Decl::NodeType nt = d->node_type ();
7182 if (nt == AST_Decl::NT_enum_val)
7185 AST_Expression::EK_const);
7188 idl_global->gen ()->create_constant (
7202 AST_Expression::EK_const);
7205 idl_global->gen ()->create_constant (
7214 : connector_header connector_body
7223 idl_global->set_parse_state (IDL_GlobalData::PS_ConnectorSeen);
7225 annotations_maybe IDENTIFIER
7227 idl_global->set_parse_state (IDL_GlobalData::PS_ConnectorIDSeen);
7229 component_inheritance_spec
7231 UTL_Scope *s = idl_global->scopes ().top_non_null ();
7232 AST_Connector *parent = 0;
7233 bool so_far_so_good = true;
7236 ACE::strdelete ($4);
7239 UTL_ScopedName sn (&id, 0);
7244 s->lookup_by_name ($6);
7248 idl_global->err ()->lookup_error ($6);
7249 so_far_so_good = false;
7253 dynamic_cast<AST_Connector*> (d);
7257 idl_global->err ()->error1 (
7258 UTL_Error::EIDL_CONNECTOR_EXPECTED,
7261 so_far_so_good = false;
7272 idl_global->gen ()->create_connector (&sn,
7275 (void) s->fe_add_connector (c);
7277 // Push it on the scopes stack.
7278 idl_global->scopes ().push (c);
7288 idl_global->set_parse_state (IDL_GlobalData::PS_ConnectorSqSeen);
7292 idl_global->set_parse_state (IDL_GlobalData::PS_ConnectorBodySeen);
7296 idl_global->set_parse_state (IDL_GlobalData::PS_ConnectorQsSeen);
7298 // Done with this connector - pop it off the scope stack.
7299 idl_global->scopes ().pop ();
7304 : connector_exports connector_export
7311 idl_global->set_parse_state (IDL_GlobalData::PS_ProvidesDeclSeen);
7315 idl_global->set_parse_state (IDL_GlobalData::PS_NoState);
7319 idl_global->set_parse_state (IDL_GlobalData::PS_UsesDeclSeen);
7323 idl_global->set_parse_state (IDL_GlobalData::PS_NoState);
7327 idl_global->set_parse_state (IDL_GlobalData::PS_AttrDeclSeen);
7331 idl_global->set_parse_state (IDL_GlobalData::PS_NoState);
7333 | extended_port_decl
7335 idl_global->set_parse_state (IDL_GlobalData::PS_ExtendedPortDeclSeen);
7339 idl_global->set_parse_state (IDL_GlobalData::PS_NoState);
7356 * Report an error situation discovered in a production
7359 tao_yyerror (const char *msg)
7361 ACE_ERROR ((LM_ERROR, "%C\n", msg));