2 * This file is part of the LibreOffice project.
4 * This Source Code Form is subject to the terms of the Mozilla Public
5 * License, v. 2.0. If a copy of the MPL was not distributed with this
6 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 * This file incorporates work covered by the following license notice:
10 * Licensed to the Apache Software Foundation (ASF) under one or more
11 * contributor license agreements. See the NOTICE file distributed
12 * with this work for additional information regarding copyright
13 * ownership. The ASF licenses this file to you under the Apache
14 * License, Version 2.0 (the "License"); you may not use this file
15 * except in compliance with the License. You may obtain a copy of
16 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 * parser.yy - BISON grammar for IDLC 1.0
26 #include <idlc/idlc.hxx>
27 #include <idlc/errorhandler.hxx>
28 #include <idlc/fehelper.hxx>
29 #include <idlc/astexpression.hxx>
30 #include <idlc/astconstants.hxx>
31 #include <idlc/astconstant.hxx>
32 #include <idlc/astarray.hxx>
33 #include <idlc/astbasetype.hxx>
34 #include <idlc/asttypedef.hxx>
35 #include <idlc/astexception.hxx>
36 #include <idlc/astmember.hxx>
37 #include <idlc/astenum.hxx>
38 #include <idlc/astsequence.hxx>
39 #include <idlc/astattribute.hxx>
40 #include <idlc/astoperation.hxx>
41 #include <idlc/astparameter.hxx>
42 #include <idlc/astinterfacemember.hxx>
43 #include <idlc/astservicemember.hxx>
44 #include <idlc/astobserves.hxx>
45 #include <idlc/astneeds.hxx>
46 #include <idlc/astunion.hxx>
48 #include "idlc/aststructinstance.hxx"
50 #include "attributeexceptions.hxx"
52 #include "rtl/strbuf.hxx"
59 #if !(defined MACOSX && defined PPC)
60 #define YYERROR_VERBOSE 1
63 using
::rtl
::OUString
;
65 using
::rtl
::OStringToOUString
;
66 using
::rtl
::OStringBuffer
;
68 extern
int yylex(void);
69 void yyerror(char const *);
71 void checkIdentifier
(::rtl
::OString
* id
)
73 static short check
= 0;
75 if
(idlc
()->getOptions
()->isValid
("-cid"))
81 if
( id
->indexOf
('_') >= 0 )
82 if
( (id
->pData
->buffer
[0] >= 97 && id
->pData
->buffer
[0] <= 122)
83 || id
->pData
->buffer
[0] == '_') {
85 ::rtl
::OStringBuffer msg
(25 + id
->getLength
());
86 msg.append
("mismatched identifier '");
89 idlc
()->error()->syntaxError
(idlc
()->getParseState
(),
90 idlc
()->getLineNumber
(),
94 idlc
()->error()->warning0
(WIDL_WRONG_NAMING_CONV
, id
->getStr
());
98 void reportDoubleMemberDeclarations
(
99 AstInterface
::DoubleMemberDeclarations
const & doubleMembers
)
101 for
(AstInterface
::DoubleMemberDeclarations
::const_iterator i
(
102 doubleMembers.begin
());
103 i
!= doubleMembers.end
(); ++i
)
105 idlc
()->error()->error2
(EIDL_DOUBLE_MEMBER
, i
->first
, i
->second
);
109 void addInheritedInterface
(
110 AstInterface
* ifc
, rtl
::OString
const & name
, bool optional
,
111 rtl
::OUString
const & documentation
)
113 AstDeclaration
* decl
= ifc
->lookupByName
(name
);
114 AstDeclaration
const * resolved
= resolveTypedefs
(decl
);
115 if
(resolved
!= 0 && resolved
->getNodeType
() == NT_interface
) {
116 if
(idlc
()->error()->checkPublished
(decl
)) {
117 if
(!static_cast
< AstInterface
const * >(resolved
)->isDefined
()) {
118 idlc
()->error()->inheritanceError
(
119 NT_interface
, &ifc
->getScopedName
(), decl
);
121 AstInterface
::DoubleDeclarations doubleDecls
(
122 ifc
->checkInheritedInterfaceClashes
(
123 static_cast
< AstInterface
const * >(resolved
),
125 if
(doubleDecls.interfaces.empty
()
126 && doubleDecls.members.empty
())
128 ifc
->addInheritedInterface
(
129 static_cast
< AstType
* >(decl
), optional
,
132 for
(AstInterface
::DoubleInterfaceDeclarations
::iterator i
(
133 doubleDecls.interfaces.begin
());
134 i
!= doubleDecls.interfaces.end
(); ++i
)
136 idlc
()->error()->error1
(
137 EIDL_DOUBLE_INHERITANCE
, *i
);
139 reportDoubleMemberDeclarations
(doubleDecls.members
);
144 idlc
()->error()->lookupError
(
145 EIDL_INTERFACEMEMBER_LOOKUP
, name
, scopeAsDecl
(ifc
));
149 AstDeclaration
const * createNamedType
(
150 rtl
::OString
const * scopedName
, DeclList
const * typeArgs
)
152 AstDeclaration
* decl
= idlc
()->scopes
()->topNonNull
()->lookupByName
(
154 AstDeclaration
const * resolved
= resolveTypedefs
(decl
);
156 idlc
()->error()->lookupError
(*scopedName
);
157 } else if
(!idlc
()->error()->checkPublished
(decl
)) {
159 } else if
(resolved
->getNodeType
() == NT_struct
) {
160 if
(static_cast
< AstStruct
const * >(resolved
)->getTypeParameterCount
()
161 != (typeArgs
== 0 ?
0 : typeArgs
->size
()))
163 idlc
()->error()->error0
(EIDL_WRONG_NUMBER_OF_TYPE_ARGUMENTS
);
165 } else if
(typeArgs
!= 0) {
166 AstScope
* global
= idlc
()->scopes
()->bottom
();
167 AstDeclaration
* inst
= new AstStructInstance
(
168 static_cast
< AstType
* >(decl
), typeArgs
, global
);
169 decl
= global
->addDeclaration
(inst
);
174 } else if
(decl
->isType
()) {
176 idlc
()->error()->error0
(EIDL_WRONG_NUMBER_OF_TYPE_ARGUMENTS
);
180 idlc
()->error()->noTypeError
(decl
);
188 bool includes
(AstDeclaration
const * type1
, AstDeclaration
const * type2
) {
189 OSL_ASSERT
(type2
!= 0);
191 if
(type1
->getNodeType
() == NT_instantiated_struct
) {
192 AstStructInstance
const * inst
193 = static_cast
< AstStructInstance
const * >(type1
);
194 if
(inst
->getTypeTemplate
() == type2
) {
197 for
(DeclList
::const_iterator i
(inst
->getTypeArgumentsBegin
());
198 i
!= inst
->getTypeArgumentsEnd
(); ++i
)
200 if
(includes
(*i
, type2
)) {
204 } else if
(type1
== type2
) {
211 // Suppress any warnings from generated code:
212 #if defined __SUNPRO_CC
214 #elif defined _MSC_VER
215 #pragma warning(push, 1)
216 #pragma warning(disable: 4273 4701 4702 4706)
220 * Declare the type of values in the grammar
223 ExprType etval
; /* Expression type */
224 AstDeclaration
* dclval
; /* Declaration */
225 AstDeclaration
const * cdclval
;
227 AstExpression
* exval
; /* expression value */
228 ExprList
* exlval
; /* expression list value */
229 FeDeclarator
* fdval
; /* declarator value */
230 FeDeclList
* dlval
; /* declarator list value */
231 FeInheritanceHeader
* ihval
; /* inheritance header value */
232 ::rtl
::OString
* sval
; /* OString value */
233 std
::vector
< rtl
::OString
> * svals
;
234 sal_Char
* strval
; /* sal_Char* value */
235 bool bval
; /* sal_Boolean* value */
236 sal_Int64 ival
; /* sal_Int64 value */
237 sal_uInt64 uval
; /* sal_uInt64 value */
238 sal_uInt32 ulval
; /* sal_uInt32 value */
239 double dval
; /* double value */
240 float fval
; /* float value */
241 StringList
* slval
; /* StringList value */
242 LabelList
* llval
; /* LabelList value */
243 AstUnionLabel
* lbval
; /* union label value */
244 AstMember
* mval
; /* member value */
245 AttributeExceptions
::Part attexcpval
;
246 AttributeExceptions attexcval
;
250 * Token types: These are returned by the lexer
253 %token
<sval
> IDL_IDENTIFIER
259 %token IDL_CONSTRAINED
264 %token IDL_MAYBEAMBIGUOUS
265 %token IDL_MAYBEDEFAULT
274 %token IDL_REMOVEABLE
312 %token
<strval
> IDL_LEFTSHIFT
313 %token
<strval
> IDL_RIGHTSHIFT
314 %token
<strval
> IDL_SCOPESEPARATOR
316 %token
<ival
> IDL_INTEGER_LITERAL
317 %token
<uval
> IDL_INTEGER_ULITERAL
318 %token
<dval
> IDL_FLOATING_PT_LITERAL
321 * These are production names:
323 %type
<dclval
> type_dcl
324 %type
<dclval
> array_declarator
325 %type
<dclval
> exception_name
326 %type
<cdclval
> array_type constructed_type_spec enum_type op_type_spec
327 %type
<cdclval
> sequence_type_spec simple_type_spec struct_type switch_type_spec
328 %type
<cdclval
> template_type_spec type_spec union_type
329 %type
<cdclval
> fundamental_type type_arg type_or_parameter
330 %type
<dclsval
> opt_raises raises exception_list
331 %type
<attexcpval
> opt_attribute_get_raises attribute_get_raises
332 %type
<attexcpval
> opt_attribute_set_raises attribute_set_raises
333 %type
<dclsval
> opt_type_args type_args
335 %type
<sval
> identifier
336 %type
<sval
> interface_decl
337 %type
<sval
> scoped_name inheritance_spec
338 %type
<slval
> scoped_names at_least_one_scoped_name
340 %type
<etval
> const_type integer_type char_type boolean_type
341 %type
<etval
> floating_pt_type any_type signed_int string_type
342 %type
<etval
> unsigned_int base_type_spec byte_type type_type
344 %type
<exval
> expression const_expr or_expr xor_expr and_expr
345 %type
<exval
> add_expr mult_expr unary_expr primary_expr shift_expr
346 %type
<exval
> literal positive_int_expr array_dim
348 %type
<exlval
> at_least_one_array_dim array_dims
350 %type
<fdval
> declarator simple_declarator complex_declarator
351 %type
<dlval
> declarators at_least_one_declarator
353 %type
<ihval
> exception_header structure_header interfaceheader
355 %type
<ulval
> flag_header opt_attrflags opt_attrflag
356 %type
<ulval
> direction service_interface_header service_service_header
358 %type
<llval
> case_labels at_least_one_case_label
359 %type
<lbval
> case_label
360 %type
<mval
> element_spec
362 %type
<bval
> optional_inherited_interface opt_rest opt_service_body
364 %type
<attexcval
> opt_attribute_block attribute_block_rest opt_attribute_raises
366 %type
<svals
> opt_type_params type_params
375 definition definitions
380 opt_published publishable_definition
383 idlc
()->setParseState
(PS_ModuleDeclSeen
);
387 idlc
()->setParseState
(PS_NoState
);
391 yyerror("definitions");
397 IDL_PUBLISHED
{ idlc
()->setPublished
(true
); }
398 |
/* empty */ { idlc
()->setPublished
(false
); }
401 publishable_definition:
404 idlc
()->setParseState
(PS_TypeDeclSeen
);
408 idlc
()->setParseState
(PS_NoState
);
412 idlc
()->setParseState
(PS_ExceptionDeclSeen
);
416 idlc
()->setParseState
(PS_NoState
);
420 idlc
()->setParseState
(PS_InterfaceDeclSeen
);
424 idlc
()->setParseState
(PS_NoState
);
428 idlc
()->setParseState
(PS_ServiceDeclSeen
);
432 idlc
()->setParseState
(PS_NoState
);
436 idlc
()->setParseState
(PS_SingletonDeclSeen
);
440 idlc
()->setParseState
(PS_NoState
);
444 idlc
()->setParseState
(PS_ConstantsDeclSeen
);
448 idlc
()->setParseState
(PS_NoState
);
455 idlc
()->setParseState
(PS_ModuleSeen
);
456 idlc
()->setPublished
(false
);
460 idlc
()->setParseState
(PS_ModuleIDSeen
);
463 AstScope
* pScope
= idlc
()->scopes
()->topNonNull
();
464 AstModule
* pModule
= NULL
;
465 AstDeclaration
* pExists
= NULL
;
469 pModule
= new AstModule
(*$3, pScope
);
470 if
( (pExists
= pScope
->lookupForAdd
(pModule
)) )
472 pExists
->setInMainfile
(idlc
()->isInMainFile
());
473 pExists
->setFileName
(pModule
->getFileName
());
474 if
(pExists
->isPredefined
())
476 pExists
->setPredefined
(false
);
477 if
(pExists
->getDocumentation
().getLength
() == 0 &&
478 pModule
->getDocumentation
().getLength
() > 0)
480 pExists
->setDocumentation
(pModule
->getDocumentation
());
484 pModule
= (AstModule
*)pExists
;
487 pScope
->addDeclaration
(pModule
);
489 idlc
()->scopes
()->push
(pModule
);
495 idlc
()->setParseState
(PS_ModuleSqSeen
);
499 idlc
()->setParseState
(PS_ModuleBodySeen
);
503 idlc
()->setParseState
(PS_ModuleQsSeen
);
505 * Finished with this module - pop it from the scope stack
507 idlc
()->scopes
()->pop
();
519 idlc
()->setParseState
(PS_InterfaceSeen
);
523 idlc
()->setParseState
(PS_InterfaceIDSeen
);
532 idlc
()->setParseState
(PS_ForwardDeclSeen
);
534 AstScope
* pScope
= idlc
()->scopes
()->topNonNull
();
535 AstInterface
* pForward
= NULL
;
536 AstDeclaration
* pDecl
= NULL
;
539 * Make a new forward interface node and add it to its enclosing scope
543 pForward
= new AstInterface
(*$1, NULL
, pScope
);
545 pDecl
= pScope
->lookupByName
(pForward
->getScopedName
());
548 if
( (pDecl
!= pForward
) &&
549 (pDecl
->getNodeType
() == NT_interface
) )
554 idlc
()->error()->error2
(EIDL_REDEF_SCOPE
, scopeAsDecl
(pScope
), pDecl
);
559 * Add the interface to its definition scope
561 pScope
->addDeclaration
(pForward
);
571 idlc
()->setParseState
(PS_InterfaceHeadSeen
);
573 AstScope
* pScope
= idlc
()->scopes
()->topNonNull
();
574 AstInterface
* pInterface
= NULL
;
575 AstInterface
* pForward
= NULL
;
576 AstDeclaration
* pDecl
= NULL
;
579 * Make a new interface node and add it to its enclosing scope
583 pInterface
= new AstInterface
(
585 static_cast
< AstInterface
* >($1->getInherits
()), pScope
);
587 (pDecl
= pScope
->lookupByName
(pInterface
->getScopedName
())) )
590 * See if we're defining a forward declared interface.
592 if
(pDecl
->getNodeType
() == NT_interface
)
594 pForward
= (AstInterface
*)pDecl
;
595 if
( !pForward
->isDefined
() )
598 * Check if redefining in same scope
600 if
( pForward
->getScope
() != pScope
)
602 if
( pForward
->getScopedName
() != pInterface
->getScopedName
() )
604 idlc
()->error()->error3
(EIDL_SCOPE_CONFLICT
,
605 pInterface
, pForward
, scopeAsDecl
(pScope
));
608 else if
( !pInterface
->isPublished
()
609 && pForward
->isPublished
() )
611 idlc
()->error()->error0
(EIDL_PUBLISHED_FORWARD
);
614 * All OK, set full definition
618 pForward
->forwardDefined
(*pInterface
);
620 pInterface
= pForward
;
623 // special handling for XInterface because it is predefined
624 if
( pForward
->isPredefined
() &&
625 pForward
->getScopedName
() == "com::sun::star::uno::XInterface")
627 /* replace the predefined XInterface */
628 *pForward
= *pInterface
;
630 pInterface
= pForward
;
638 * Add the interface to its definition scope
640 pScope
->addDeclaration
(pInterface
);
644 * Push it on the scope stack
646 idlc
()->scopes
()->push
(pInterface
);
651 idlc
()->setParseState
(PS_InterfaceSqSeen
);
655 AstInterface
* ifc
= static_cast
< AstInterface
* >(
656 idlc
()->scopes
()->topNonNull
());
657 if
(!ifc
->hasMandatoryInheritedInterfaces
()
658 && ifc
->getScopedName
() != "com::sun::star::uno::XInterface")
660 addInheritedInterface
(
661 ifc
, rtl
::OString
("::com::sun::star::uno::XInterface"), false
,
665 idlc
()->setParseState
(PS_InterfaceBodySeen
);
669 idlc
()->setParseState
(PS_InterfaceQsSeen
);
671 * Done with this interface - pop it off the scopes stack
673 idlc
()->scopes
()->pop
();
677 yyerror("interface definition");
683 interface_decl inheritance_spec
685 idlc
()->setParseState
(PS_InheritSpecSeen
);
687 $$
= new FeInheritanceHeader
(NT_interface
, $1, $2, 0);
695 idlc
()->setParseState
(PS_InheritColonSeen
);
715 idlc
()->setParseState
(PS_AttributeDeclSeen
);
719 idlc
()->setParseState
(PS_NoState
);
723 idlc
()->setParseState
(PS_OperationDeclSeen
);
727 idlc
()->setParseState
(PS_NoState
);
729 | interface_inheritance_decl
731 idlc
()->setParseState
(PS_InterfaceInheritanceDeclSeen
);
735 idlc
()->setParseState
(PS_NoState
);
743 idlc
()->setParseState
(PS_AttrTypeSeen
);
747 idlc
()->setParseState
(PS_AttrCompleted
);
748 if
(($1 & ~
(AF_BOUND | AF_READONLY
)) != AF_ATTRIBUTE
) {
749 idlc
()->error()->flagError
(EIDL_BAD_ATTRIBUTE_FLAGS
, $1);
751 AstInterface
* scope
= static_cast
< AstInterface
* >(
752 idlc
()->scopes
()->top
());
753 AstAttribute
* attr
= new AstAttribute
(
754 $1, $4->compose
($2), $4->getName
(), scope
);
756 AstInterface
::DoubleMemberDeclarations doubleMembers
(
757 scope
->checkMemberClashes
(attr
));
758 if
(doubleMembers.empty
()) {
759 scope
->addMember
(attr
);
761 reportDoubleMemberDeclarations
(doubleMembers
);
763 idlc
()->scopes
()->push
(attr
);
767 static_cast
< AstAttribute
* >(idlc
()->scopes
()->top
())->setExceptions
(
768 $6.get.documentation
, $6.get.exceptions
, $6.set.documentation
,
770 delete
$6.get.documentation
;
771 delete
$6.get.exceptions
;
772 delete
$6.set.documentation
;
773 delete
$6.set.exceptions
;
774 idlc
()->scopes
()->pop
();
779 '[' opt_attrflags
']'
781 idlc
()->setParseState
(PS_FlagHeaderSeen
);
787 opt_attrflags
',' opt_attrflag
789 if
( ($1 & $3) == $3 )
790 idlc
()->error()->flagError
(EIDL_DEFINED_ATTRIBUTEFLAG
, $3);
803 idlc
()->setParseState
(PS_AttrSeen
);
808 idlc
()->setParseState
(PS_PropertySeen
);
813 idlc
()->setParseState
(PS_ReadOnlySeen
);
818 idlc
()->setParseState
(PS_OptionalSeen
);
823 idlc
()->setParseState
(PS_MayBeVoidSeen
);
828 idlc
()->setParseState
(PS_BoundSeen
);
833 idlc
()->setParseState
(PS_ConstrainedSeen
);
838 idlc
()->setParseState
(PS_TransientSeen
);
843 idlc
()->setParseState
(PS_MayBeAmbigiousSeen
);
844 $$
= AF_MAYBEAMBIGUOUS
;
848 idlc
()->setParseState
(PS_MayBeDefaultSeen
);
849 $$
= AF_MAYBEDEFAULT
;
853 idlc
()->setParseState
(PS_RemoveableSeen
);
858 yyerror("unknown property|attribute flag");
864 '{' attribute_block_rest
{ $$
= $2; }
867 $$.get.documentation
= 0;
868 $$.get.exceptions
= 0;
869 $$.set.documentation
= 0;
870 $$.set.exceptions
= 0;
874 attribute_block_rest:
875 opt_attribute_raises
'}'
878 yyerror("bad attribute raises block");
880 $$.get.documentation
= 0;
881 $$.get.exceptions
= 0;
882 $$.set.documentation
= 0;
883 $$.set.exceptions
= 0;
887 opt_attribute_raises:
889 opt_attribute_set_raises
894 | attribute_set_raises
895 opt_attribute_get_raises
902 $$.get.documentation
= 0;
903 $$.get.exceptions
= 0;
904 $$.set.documentation
= 0;
905 $$.set.exceptions
= 0;
909 opt_attribute_get_raises:
911 |
/* empty */ { $$.documentation
= 0; $$.exceptions
= 0; }
914 attribute_get_raises:
917 $$.documentation
= new rtl
::OUString
(
918 rtl
::OStringToOUString
(
919 idlc
()->getDocumentation
(), RTL_TEXTENCODING_UTF8
));
924 opt_attribute_set_raises:
926 |
/* empty */ { $$.documentation
= 0; $$.exceptions
= 0; }
929 attribute_set_raises:
932 if
(static_cast
< AstAttribute
* >(idlc
()->scopes
()->top
())->
935 idlc
()->error()->error0
(EIDL_READONLY_ATTRIBUTE_SET_EXCEPTIONS
);
940 $$.documentation
= new rtl
::OUString
(
941 rtl
::OStringToOUString
(
942 idlc
()->getDocumentation
(), RTL_TEXTENCODING_UTF8
));
950 idlc
()->setParseState
(PS_OpTypeSeen
);
954 idlc
()->setParseState
(PS_OpIDSeen
);
957 AstInterface
* pScope
= static_cast
< AstInterface
* >(
958 idlc
()->scopes
()->top
());
959 AstOperation
* pOp
= NULL
;
962 * Create a node representing an operation on an interface
963 * and add it to its enclosing scope
967 AstType
*pType
= (AstType
*)$1;
968 if
( !pType ||
(pType
->getNodeType
() == NT_exception
) )
973 pOp
= new AstOperation
(pType
, *$3, pScope
);
975 AstInterface
::DoubleMemberDeclarations doubleMembers
(
976 pScope
->checkMemberClashes
(pOp
));
977 if
(doubleMembers.empty
()) {
978 pScope
->addMember
(pOp
);
980 reportDoubleMemberDeclarations
(doubleMembers
);
986 * Push the operation scope onto the scopes stack
988 idlc
()->scopes
()->push
(pOp
);
992 idlc
()->setParseState
(PS_OpSqSeen
);
996 idlc
()->setParseState
(PS_OpParsCompleted
);
1000 idlc
()->setParseState
(PS_OpQsSeen
);
1004 AstScope
* pScope
= idlc
()->scopes
()->topNonNull
();
1005 AstOperation
* pOp
= NULL
;
1007 * Add exceptions and context to the operation
1009 if
( pScope
&& pScope
->getScopeNodeType
() == NT_operation
)
1011 pOp
= (AstOperation
*)pScope
;
1014 pOp
->setExceptions
($11);
1018 * Done with this operation. Pop its scope from the scopes stack
1020 idlc
()->scopes
()->pop
();
1028 $$
= idlc
()->scopes
()->bottom
()->lookupPrimitiveType
(ET_void
);
1037 idlc
()->setParseState
(PS_OpParCommaSeen
);
1043 yyerror("parameter definition");
1053 idlc
()->setParseState
(PS_OpParDirSeen
);
1057 idlc
()->setParseState
(PS_OpParTypeSeen
);
1062 idlc
()->setParseState
(PS_OpParDeclSeen
);
1064 AstOperation
* pScope
= static_cast
< AstOperation
* >(
1065 idlc
()->scopes
()->top
());
1066 AstParameter
* pParam
= NULL
;
1069 * Create a node representing an argument to an operation
1070 * Add it to the enclosing scope (the operation scope)
1072 if
( pScope
&& $5 && $8 )
1074 AstType
const * pType
= $8->compose
($5);
1077 if
(pScope
->isConstructor
() && $2 != DIR_IN
) {
1078 idlc
()->error()->error0
(EIDL_CONSTRUCTOR_PARAMETER_NOT_IN
);
1080 if
(pScope
->isVariadic
()) {
1081 idlc
()->error()->error0
(EIDL_REST_PARAMETER_NOT_LAST
);
1084 AstDeclaration
const * type
= resolveTypedefs
(pType
);
1085 if
(type
->getNodeType
() != NT_predefined
1086 ||
(static_cast
< AstBaseType
const * >(type
)->
1087 getExprType
() != ET_any
))
1089 idlc
()->error()->error0
(EIDL_REST_PARAMETER_NOT_ANY
);
1091 if
(pScope
->isConstructor
()) {
1092 if
(pScope
->getIteratorBegin
()
1093 != pScope
->getIteratorEnd
())
1095 idlc
()->error()->error0
(
1096 EIDL_CONSTRUCTOR_REST_PARAMETER_NOT_FIRST
);
1099 idlc
()->error()->error0
(EIDL_METHOD_HAS_REST_PARAMETER
);
1103 pParam
= new AstParameter
(
1104 static_cast
< Direction
>($2), $7, pType
, $8->getName
(),
1107 if
( !$8->checkType
($5) )
1112 pScope
->addDeclaration
(pParam
);
1119 idlc
()->setParseState
(PS_NoState
);
1161 idlc
()->setParseState
(PS_RaiseSeen
);
1165 idlc
()->setParseState
(PS_RaiseSqSeen
);
1170 idlc
()->setParseState
(PS_RaiseQsSeen
);
1181 | exception_list
',' exception_name
1191 // The topmost scope is either an AstOperation (for interface methods
1192 // and service constructors) or an AstAttribute (for interface
1193 // attributes), so look up exception names in the next-to-topmost scope:
1194 AstDeclaration
* decl
= idlc
()->scopes
()->nextToTop
()->lookupByName
(
1197 idlc
()->error()->lookupError
(*$1);
1198 } else if
(!idlc
()->error()->checkPublished
(decl
)) {
1200 } else if
(decl
->getNodeType
() != NT_exception
) {
1201 idlc
()->error()->error1
(EIDL_ILLEGAL_RAISES
, decl
);
1209 interface_inheritance_decl:
1210 optional_inherited_interface
1213 idlc
()->setParseState
(PS_ServiceIFHeadSeen
);
1217 AstInterface
* ifc
= static_cast
< AstInterface
* >(
1218 idlc
()->scopes
()->top
());
1219 if
(ifc
->usesSingleInheritance
()) {
1220 idlc
()->error()->error0
(EIDL_MIXED_INHERITANCE
);
1222 addInheritedInterface
(
1224 rtl
::OStringToOUString
(
1225 idlc
()->getDocumentation
(), RTL_TEXTENCODING_UTF8
));
1231 optional_inherited_interface:
1232 '[' IDL_OPTIONAL
']' { $$
= true
; }
1233 |
/* EMPTY */ { $$
= false
; }
1237 constants_export constants_exports
1244 idlc
()->setParseState
(PS_ConstSeen
);
1248 idlc
()->setParseState
(PS_ConstTypeSeen
);
1252 idlc
()->setParseState
(PS_ConstIDSeen
);
1253 checkIdentifier
($5);
1257 idlc
()->setParseState
(PS_ConstAssignSeen
);
1261 idlc
()->setParseState
(PS_ConstExprSeen
);
1263 AstScope
* pScope
= idlc
()->scopes
()->topNonNull
();
1264 AstConstant
* pConstant
= NULL
;
1268 if
( !$9->coerce
($3) )
1270 idlc
()->error()->coercionError
($9, $3);
1273 pConstant
= new AstConstant
($3, $9, *$5, pScope
);
1274 pScope
->addDeclaration
(pConstant
);
1279 idlc
()->setParseState
(PS_ConstantDeclSeen
);
1287 idlc
()->setParseState
(PS_ConstantsSeen
);
1291 idlc
()->setParseState
(PS_ConstantsIDSeen
);
1292 checkIdentifier
($3);
1296 idlc
()->setParseState
(PS_ConstantsSqSeen
);
1298 AstScope
* pScope
= idlc
()->scopes
()->topNonNull
();
1299 AstConstants
* pConstants
= NULL
;
1300 AstDeclaration
* pExists
= NULL
;
1304 pConstants
= new AstConstants
(*$3, pScope
);
1305 if
( (pExists
= pScope
->lookupForAdd
(pConstants
)) )
1307 pExists
->setInMainfile
(idlc
()->isInMainFile
());
1309 pConstants
= (AstConstants
*)pExists
;
1312 pScope
->addDeclaration
(pConstants
);
1314 idlc
()->scopes
()->push
(pConstants
);
1320 idlc
()->setParseState
(PS_ConstantsBodySeen
);
1324 idlc
()->setParseState
(PS_ConstantsQsSeen
);
1326 * Finished with this constants - pop it from the scope stack
1328 idlc
()->scopes
()->pop
();
1332 expression
: const_expr
;
1334 const_expr
: or_expr
;
1338 | or_expr
'|' xor_expr
1340 $$
= new AstExpression
(EC_or
, $1, $3);
1346 | xor_expr
'^' and_expr
1348 $$
= new AstExpression
(EC_xor
, $1, $3);
1354 | and_expr
'&' shift_expr
1356 $$
= new AstExpression
(EC_and
, $1, $3);
1362 | shift_expr IDL_LEFTSHIFT add_expr
1364 $$
= new AstExpression
(EC_left
, $1, $3);
1366 | shift_expr IDL_RIGHTSHIFT add_expr
1368 $$
= new AstExpression
(EC_right
, $1, $3);
1374 | add_expr
'+' mult_expr
1376 $$
= new AstExpression
(EC_add
, $1, $3);
1378 | add_expr
'-' mult_expr
1380 $$
= new AstExpression
(EC_minus
, $1, $3);
1386 | mult_expr
'*' unary_expr
1388 $$
= new AstExpression
(EC_mul
, $1, $3);
1390 | mult_expr
'/' unary_expr
1392 $$
= new AstExpression
(EC_div
, $1, $3);
1394 | mult_expr
'%' unary_expr
1396 $$
= new AstExpression
(EC_mod
, $1, $3);
1404 $$
= new AstExpression
(EC_u_plus
, $2, NULL
);
1408 $$
= new AstExpression
(EC_u_minus
, $2, NULL
);
1419 * An expression which is a scoped name is not resolved now,
1420 * but only when it is evaluated (such as when it is assigned
1421 * as a constant value)
1423 $$
= new AstExpression
($1);
1426 |
'(' const_expr
')'
1435 $$
= new AstExpression
($1);
1437 | IDL_INTEGER_ULITERAL
1439 $$
= new AstExpression
($1);
1441 | IDL_FLOATING_PT_LITERAL
1443 $$
= new AstExpression
($1);
1447 $$
= new AstExpression
((sal_Int32
)1, ET_boolean
);
1451 $$
= new AstExpression
((sal_Int32
)0, ET_boolean
);
1458 $1->evaluate
(EK_const
);
1459 if
( !$1->coerce
(ET_ulong
) )
1461 idlc
()->error()->coercionError
($1, ET_ulong
);
1475 AstScope
* pScope
= idlc
()->scopes
()->topNonNull
();
1476 AstDeclaration
const * type
= 0;
1479 * If the constant's type is a scoped name, it must resolve
1480 * to a scalar constant type
1482 if
( pScope
&& (type
= pScope
->lookupByName
(*$1)) ) {
1483 if
(!idlc
()->error()->checkPublished
(type
))
1489 type
= resolveTypedefs
(type
);
1490 if
(type
->getNodeType
() == NT_predefined
)
1492 $$
= static_cast
< AstBaseType
const * >(type
)->
1505 idlc
()->setParseState
(PS_ExceptSeen
);
1509 idlc
()->setParseState
(PS_ExceptIDSeen
);
1510 checkIdentifier
($3);
1514 idlc
()->setParseState
(PS_InheritSpecSeen
);
1516 $$
= new FeInheritanceHeader
(NT_exception
, $3, $5, 0);
1524 idlc
()->setParseState
(PS_ExceptHeaderSeen
);
1526 AstScope
* pScope
= idlc
()->scopes
()->topNonNull
();
1527 AstException
* pExcept
= NULL
;
1531 AstException
* pBase
= static_cast
< AstException
* >(
1533 pExcept
= new AstException
(*$1->getName
(), pBase
, pScope
);
1534 pScope
->addDeclaration
(pExcept
);
1537 * Push the scope of the exception on the scopes stack
1539 idlc
()->scopes
()->push
(pExcept
);
1544 idlc
()->setParseState
(PS_ExceptSqSeen
);
1548 idlc
()->setParseState
(PS_ExceptBodySeen
);
1552 idlc
()->setParseState
(PS_ExceptQsSeen
);
1553 /* this exception is finished, pop its scope from the stack */
1554 idlc
()->scopes
()->pop
();
1562 idlc
()->setParseState
(PS_PropertyTypeSeen
);
1564 at_least_one_declarator
1566 idlc
()->setParseState
(PS_PropertyCompleted
);
1568 AstScope
* pScope
= idlc
()->scopes
()->topNonNull
();
1569 AstAttribute
* pAttr
= NULL
;
1570 FeDeclList
* pList
= $4;
1571 FeDeclarator
* pDecl
= NULL
;
1572 AstType
const * pType
= NULL
;
1574 if
( pScope
->getScopeNodeType
() == NT_singleton
)
1576 idlc
()->error()->error0
(EIDL_ILLEGAL_ADD
);
1579 if
( ($1 & AF_ATTRIBUTE
) == AF_ATTRIBUTE
)
1580 idlc
()->error()->flagError
(EIDL_WRONGATTRIBUTEKEYWORD
, AF_ATTRIBUTE
);
1582 if
( ($1 & AF_PROPERTY
) != AF_PROPERTY
)
1583 idlc
()->error()->flagError
(EIDL_MISSINGATTRIBUTEKEYWORD
, AF_PROPERTY
);
1586 * Create nodes representing attributes and add them to the
1589 if
( pScope
&& $2 && pList
)
1591 FeDeclList
::iterator iter
= pList
->begin
();
1592 FeDeclList
::iterator end
= pList
->end
();
1603 pType
= pDecl
->compose
($2);
1611 pAttr
= new AstAttribute
(NT_property
, $1, pType
, pDecl
->getName
(), pScope
);
1613 pScope
->addDeclaration
(pAttr
);
1625 yyerror("property");
1631 service_exports service_export
1636 service_interface_header
1637 at_least_one_scoped_name
1640 idlc
()->setParseState
(PS_ServiceMemberSeen
);
1642 AstScope
* pScope
= idlc
()->scopes
()->topNonNull
();
1643 AstDeclaration
* pDecl
= NULL
;
1644 AstInterfaceMember
* pIMember
= NULL
;
1646 if
( pScope
->getScopeNodeType
() == NT_singleton
)
1648 idlc
()->error()->error0
(EIDL_ILLEGAL_ADD
);
1652 * Create a node representing a class member.
1653 * Store it in the enclosing scope
1657 StringList
::iterator iter
= $2->begin
();
1658 StringList
::iterator end
= $2->end
();
1660 while
( iter
!= end
)
1662 pDecl
= pScope
->lookupByName
(*iter
);
1663 if
( pDecl
&& (pDecl
->getNodeType
() == NT_interface
) )
1665 /* we relax the strict published check and allow to add new
1666 * interfaces if they are optional
1668 bool bOptional
= (($1 & AF_OPTIONAL
) == AF_OPTIONAL
);
1669 if
( idlc
()->error()->checkPublished
(pDecl
, bOptional
) )
1671 pIMember
= new AstInterfaceMember
(
1672 $1, (AstInterface
*)pDecl
, *iter
, pScope
);
1673 pScope
->addDeclaration
(pIMember
);
1678 lookupError
(EIDL_INTERFACEMEMBER_LOOKUP
, *iter
, scopeAsDecl
(pScope
));
1686 | service_service_header
1687 at_least_one_scoped_name
1690 idlc
()->setParseState
(PS_ServiceMemberSeen
);
1692 AstScope
* pScope
= idlc
()->scopes
()->topNonNull
();
1693 AstDeclaration
* pDecl
= NULL
;
1694 AstServiceMember
* pSMember
= NULL
;
1697 * Create a node representing a class member.
1698 * Store it in the enclosing scope
1702 StringList
::iterator iter
= $2->begin
();
1703 StringList
::iterator end
= $2->end
();
1705 while
( iter
!= end
)
1707 pDecl
= pScope
->lookupByName
(*iter
);
1708 if
( pDecl
&& (pDecl
->getNodeType
() == NT_service
) )
1710 if
( static_cast
< AstService
* >(pDecl
)->isSingleInterfaceBasedService
() ||
(pScope
->getScopeNodeType
() == NT_singleton
&& pScope
->nMembers
() > 0) )
1711 idlc
()->error()->error0
(EIDL_ILLEGAL_ADD
);
1712 else if
( idlc
()->error()->checkPublished
(pDecl
) )
1714 pSMember
= new AstServiceMember
(
1715 $1, (AstService
*)pDecl
, *iter
, pScope
);
1716 pScope
->addDeclaration
(pSMember
);
1721 lookupError
(EIDL_SERVICEMEMBER_LOOKUP
, *iter
, scopeAsDecl
(pScope
));
1729 at_least_one_scoped_name
1732 idlc
()->setParseState
(PS_ServiceMemberSeen
);
1734 AstScope
* pScope
= idlc
()->scopes
()->topNonNull
();
1735 AstDeclaration
* pDecl
= NULL
;
1736 AstObserves
* pObserves
= NULL
;
1738 if
( pScope
->getScopeNodeType
() == NT_singleton
)
1740 idlc
()->error()->error0
(EIDL_ILLEGAL_ADD
);
1744 * Create a node representing a class member.
1745 * Store it in the enclosing scope
1749 StringList
::iterator iter
= $2->begin
();
1750 StringList
::iterator end
= $2->end
();
1752 while
( iter
!= end
)
1754 pDecl
= pScope
->lookupByName
(*iter
);
1755 if
( pDecl
&& (pDecl
->getNodeType
() == NT_interface
) )
1757 pObserves
= new AstObserves
((AstInterface
*)pDecl
, *iter
, pScope
);
1758 pScope
->addDeclaration
(pObserves
);
1762 lookupError
(EIDL_INTERFACEMEMBER_LOOKUP
, *iter
, scopeAsDecl
(pScope
));
1771 at_least_one_scoped_name
1774 idlc
()->setParseState
(PS_ServiceMemberSeen
);
1776 AstScope
* pScope
= idlc
()->scopes
()->topNonNull
();
1777 AstDeclaration
* pDecl
= NULL
;
1778 AstNeeds
* pNeeds
= NULL
;
1780 if
( pScope
->getScopeNodeType
() == NT_singleton
)
1782 idlc
()->error()->error0
(EIDL_ILLEGAL_ADD
);
1786 * Create a node representing a class member.
1787 * Store it in the enclosing scope
1791 StringList
::iterator iter
= $2->begin
();
1792 StringList
::iterator end
= $2->end
();
1794 while
( iter
!= end
)
1796 pDecl
= pScope
->lookupByName
(*iter
);
1797 if
( pDecl
&& (pDecl
->getNodeType
() == NT_service
) )
1799 pNeeds
= new AstNeeds
((AstService
*)pDecl
, *iter
, pScope
);
1800 pScope
->addDeclaration
(pNeeds
);
1804 lookupError
(EIDL_SERVICEMEMBER_LOOKUP
, *iter
, scopeAsDecl
(pScope
));
1815 idlc
()->setParseState
(PS_PropertyDeclSeen
);
1819 service_interface_header
:
1822 idlc
()->setParseState
(PS_ServiceIFHeadSeen
);
1828 idlc
()->setParseState
(PS_ServiceIFHeadSeen
);
1829 if
( (AF_OPTIONAL
!= $1) && ( AF_INVALID
!= $1) )
1830 idlc
()->error()->flagError
(EIDL_OPTIONALEXPECTED
, $1);
1835 service_service_header
:
1838 idlc
()->setParseState
(PS_ServiceSHeadSeen
);
1844 idlc
()->setParseState
(PS_ServiceSHeadSeen
);
1845 if
( (AF_OPTIONAL
!= $1) && ( AF_INVALID
!= $1) )
1846 idlc
()->error()->flagError
(EIDL_OPTIONALEXPECTED
, $1);
1854 idlc
()->setParseState
(PS_ServiceSeen
);
1858 idlc
()->setParseState
(PS_ServiceIDSeen
);
1859 checkIdentifier
($3);
1861 AstScope
* pScope
= idlc
()->scopes
()->topNonNull
();
1862 AstService
* pService
= NULL
;
1865 * Make a new service and add it to the enclosing scope
1869 pService
= new AstService
(*$3, pScope
);
1870 pScope
->addDeclaration
(pService
);
1874 * Push it on the stack
1876 idlc
()->scopes
()->push
(pService
);
1880 /* this service is finished, pop its scope from the stack */
1881 idlc
()->scopes
()->pop
();
1886 service_interface_dfn
1887 | service_obsolete_dfn
1890 service_interface_dfn:
1893 AstScope
* scope
= idlc
()->scopes
()->nextToTop
();
1894 // skip the scope pushed by service_dcl
1895 AstDeclaration
* decl
= scope
->lookupByName
(*$2);
1896 if
(decl
!= 0 && resolveTypedefs
(decl
)->getNodeType
() == NT_interface
) {
1897 if
(idlc
()->error()->checkPublished
(decl
)) {
1898 idlc
()->scopes
()->top
()->addDeclaration
(decl
);
1901 idlc
()->error()->lookupError
(
1902 EIDL_INTERFACEMEMBER_LOOKUP
, *$2, scopeAsDecl
(scope
));
1908 AstService
* s
= static_cast
< AstService
* >(idlc
()->scopes
()->top
());
1910 s
->setSingleInterfaceBasedService
();
1911 s
->setDefaultConstructor
(!$4);
1917 service_body
{ $$
= true
; }
1918 |
/* empty */ { $$
= false
; }
1928 constructors constructor
1935 checkIdentifier
($1);
1936 AstScope
* scope
= idlc
()->scopes
()->top
();
1937 AstOperation
* ctor
= new AstOperation
(0, *$1, scope
);
1939 scope
->addDeclaration
(ctor
);
1940 idlc
()->scopes
()->push
(ctor
);
1947 static_cast
< AstOperation
* >(idlc
()->scopes
()->top
())->setExceptions
(
1950 idlc
()->scopes
()->pop
();
1951 if
(static_cast
< AstService
* >(idlc
()->scopes
()->top
())->
1952 checkLastConstructor
())
1954 idlc
()->error()->error0
(EIDL_SIMILAR_CONSTRUCTORS
);
1963 idlc
()->setParseState
(PS_SingletonSeen
);
1967 idlc
()->setParseState
(PS_SingletonIDSeen
);
1968 checkIdentifier
($3);
1970 AstScope
* pScope
= idlc
()->scopes
()->topNonNull
();
1971 AstService
* pService
= NULL
;
1974 * Make a new service and add it to the enclosing scope
1978 pService
= new AstService
(NT_singleton
, *$3, pScope
);
1979 pScope
->addDeclaration
(pService
);
1983 * Push it on the stack
1985 idlc
()->scopes
()->push
(pService
);
1989 /* this singelton is finished, pop its scope from the stack */
1990 idlc
()->scopes
()->pop
();
1995 singleton_interface_dfn
1996 | service_obsolete_dfn
1999 singleton_interface_dfn:
2002 AstScope
* scope
= idlc
()->scopes
()->nextToTop
();
2003 // skip the scope (needlessly) pushed by singleton_dcl
2004 AstDeclaration
* decl
= scope
->lookupByName
(*$2);
2005 if
(decl
!= 0 && resolveTypedefs
(decl
)->getNodeType
() == NT_interface
) {
2006 if
(idlc
()->error()->checkPublished
(decl
)) {
2007 idlc
()->scopes
()->top
()->addDeclaration
(decl
);
2010 idlc
()->error()->lookupError
(
2011 EIDL_INTERFACEMEMBER_LOOKUP
, *$2, scopeAsDecl
(scope
));
2017 service_obsolete_dfn:
2020 idlc
()->setParseState
(
2021 idlc
()->scopes
()->top
()->getScopeNodeType
() == NT_service
2022 ? PS_ServiceSqSeen
: PS_SingletonSqSeen
);
2026 idlc
()->setParseState
(
2027 idlc
()->scopes
()->top
()->getScopeNodeType
() == NT_service
2028 ? PS_ServiceBodySeen
: PS_SingletonBodySeen
);
2032 idlc
()->setParseState
(
2033 idlc
()->scopes
()->top
()->getScopeNodeType
() == NT_service
2034 ? PS_ServiceQsSeen
: PS_SingletonQsSeen
);
2041 idlc
()->setParseState
(PS_TypedefSeen
);
2052 idlc
()->setParseState
(PS_TypeSpecSeen
);
2053 if
($1 != 0 && $1->getNodeType
() == NT_instantiated_struct
) {
2054 idlc
()->error()->error0
(EIDL_INSTANTIATED_STRUCT_TYPE_TYPEDEF
);
2057 at_least_one_declarator
2059 idlc
()->setParseState
(PS_DeclaratorsSeen
);
2061 AstScope
* pScope
= idlc
()->scopes
()->topNonNull
();
2062 AstTypeDef
* pTypeDef
= NULL
;
2063 FeDeclList
* pList
= $3;
2064 FeDeclarator
* pDecl
= NULL
;
2065 AstType
const * pType
= NULL
;
2068 * Create nodes representing typedefs and add them to the
2071 if
( pScope
&& $1 && pList
)
2073 FeDeclList
::iterator iter
= pList
->begin
();
2074 FeDeclList
::iterator end
= pList
->end
();
2085 pType
= pDecl
->compose
($1);
2093 pTypeDef
= new AstTypeDef
(pType
, pDecl
->getName
(), pScope
);
2095 pScope
->addDeclaration
(pTypeDef
);
2104 at_least_one_declarator
:
2105 declarator declarators
2113 FeDeclList
* pList
= new FeDeclList
();
2114 pList
->push_back
($1);
2124 idlc
()->setParseState
(PS_DeclsCommaSeen
);
2128 idlc
()->setParseState
(PS_DeclsDeclSeen
);
2135 FeDeclList
* pList
= new FeDeclList
();
2136 pList
->push_back
($4);
2148 | complex_declarator
2154 // For historic reasons, the struct com.sun.star.uno.Uik contains
2155 // members with illegal names (of the form "m_DataN"); avoid useless
2156 // warnings about them:
2157 AstScope
* scope
= idlc
()->scopes
()->top
();
2158 if
(scope
== 0 || scope
->getScopeNodeType
() != NT_struct
2159 ||
(scopeAsDecl
(scope
)->getScopedName
()
2160 != "com::sun::star::uno::Uik"))
2162 checkIdentifier
($1);
2165 $$
= new FeDeclarator
(*$1, FeDeclarator
::FD_simple
, NULL
);
2170 complex_declarator
:
2173 $$
= new FeDeclarator
($1->getLocalName
(), FeDeclarator
::FD_complex
, $1);
2180 idlc
()->setParseState
(PS_ArrayIDSeen
);
2181 checkIdentifier
($1);
2183 at_least_one_array_dim
2185 idlc
()->setParseState
(PS_ArrayCompleted
);
2186 $$
= new AstArray
(*$1, NULL
, *$3, idlc
()->scopes
()->bottom
());
2191 at_least_one_array_dim
:
2192 array_dim array_dims
2200 ExprList
* pList
= new ExprList
();
2201 pList
->push_back
($1);
2208 array_dims array_dim
2216 ExprList
* pList
= new ExprList
();
2217 pList
->push_back
($2);
2230 idlc
()->setParseState
(PS_DimSqSeen
);
2234 idlc
()->setParseState
(PS_DimExprSeen
);
2238 idlc
()->setParseState
(PS_DimQsSeen
);
2240 * Array dimensions are expressions which must be coerced to
2243 if
( !$3 ||
!$3->coerce
(ET_uhyper
) )
2245 idlc
()->error()->coercionError
($3, ET_uhyper
);
2252 at_least_one_scoped_name
:
2253 scoped_name scoped_names
2257 $2->push_front
(*$1);
2261 StringList
* pNames
= new StringList
();
2262 pNames
->push_back
(*$1);
2273 idlc
()->setParseState
(PS_SNListCommaSeen
);
2277 idlc
()->setParseState
(PS_ScopedNameSeen
);
2284 StringList
* pNames
= new StringList
();
2285 pNames
->push_back
(*$4);
2299 idlc
()->setParseState
(PS_SN_IDSeen
);
2300 checkIdentifier
($1);
2303 | IDL_SCOPESEPARATOR
2305 idlc
()->setParseState
(PS_ScopeDelimSeen
);
2309 checkIdentifier
($3);
2310 OString
* pName
= new OString
("::");
2321 checkIdentifier
($4);
2322 *$1 += ::rtl
::OString
("::");
2331 | constructed_type_spec
2336 | scoped_name opt_type_args
2338 $$
= createNamedType
($1, $2);
2345 $$
= idlc
()->scopes
()->bottom
()->lookupPrimitiveType
($1);
2347 | template_type_spec
2351 '<' type_args
'>' { $$
= $2; }
2352 |
/* empty */ { $$
= 0; }
2359 $$
->push_back
(const_cast
< AstDeclaration
* >($1)); //TODO: const_cast
2361 | type_args
',' type_arg
2363 $1->push_back
(const_cast
< AstDeclaration
* >($3)); //TODO: const_cast
2371 if
($1 != 0 && static_cast
< AstType
const * >($1)->isUnsigned
()) {
2372 idlc
()->error()->error0
(EIDL_UNSIGNED_TYPE_ARGUMENT
);
2410 IDL_UNSIGNED IDL_LONG
2414 | IDL_UNSIGNED IDL_HYPER
2418 | IDL_UNSIGNED IDL_SHORT
2477 template_type_spec
:
2482 constructed_type_spec
:
2491 idlc
()->setParseState
(PS_ArrayTypeSeen
);
2493 at_least_one_array_dim
2495 idlc
()->setParseState
(PS_ArrayCompleted
);
2497 AstScope
* pScope
= idlc
()->scopes
()->bottom
();
2498 AstDeclaration
* pDecl
= NULL
;
2499 AstDeclaration
* pArray
= NULL
;
2503 pArray
= new AstArray
((AstType
*)$1, *$3, idlc
()->scopes
()->bottom
());
2506 pDecl
= pScope
->addDeclaration
(pArray
);
2507 if
( pArray
!= pDecl
)
2509 // if array type already defined then use it
2519 sequence_type_spec
:
2522 idlc
()->setParseState
(PS_SequenceSeen
);
2524 * Push a sequence marker on scopes stack
2526 idlc
()->scopes
()->push
(NULL
);
2530 idlc
()->setParseState
(PS_SequenceSqSeen
);
2534 idlc
()->setParseState
(PS_SequenceTypeSeen
);
2538 idlc
()->setParseState
(PS_SequenceQsSeen
);
2540 * Remove sequence marker from scopes stack
2542 if
(idlc
()->scopes
()->top
() == NULL
)
2543 idlc
()->scopes
()->pop
();
2545 * Create a node representing a sequence
2547 AstScope
* pScope
= idlc
()->scopes
()->bottom
();
2548 AstDeclaration
* pDecl
= NULL
;
2549 AstDeclaration
* pSeq
= NULL
;
2553 AstType
*pType
= (AstType
*)$5;
2556 pSeq
= new AstSequence
(pType
, pScope
);
2558 * Add this AstSequence to the types defined in the global scope
2560 pDecl
= pScope
->addDeclaration
(pSeq
);
2561 if
( pSeq
!= pDecl
)
2563 // if sequence type already defined then use it
2573 yyerror("sequence declaration");
2582 idlc
()->setParseState
(PS_StructHeaderSeen
);
2584 AstScope
* pScope
= idlc
()->scopes
()->topNonNull
();
2585 AstStruct
* pStruct
= NULL
;
2589 AstStruct
* pBase
= static_cast
< AstStruct
* >($1->getInherits
());
2590 pStruct
= new AstStruct
(
2591 *$1->getName
(), $1->getTypeParameters
(), pBase
, pScope
);
2592 pScope
->addDeclaration
(pStruct
);
2595 * Push the scope of the struct on the scopes stack
2597 idlc
()->scopes
()->push
(pStruct
);
2602 idlc
()->setParseState
(PS_StructSqSeen
);
2606 idlc
()->setParseState
(PS_StructBodySeen
);
2610 idlc
()->setParseState
(PS_StructQsSeen
);
2611 /* this exception is finished, pop its scope from the stack */
2612 idlc
()->scopes
()->pop
();
2619 idlc
()->setParseState
(PS_StructSeen
);
2623 idlc
()->setParseState
(PS_StructIDSeen
);
2624 checkIdentifier
($3);
2629 idlc
()->setParseState
(PS_InheritSpecSeen
);
2631 // Polymorphic struct type templates with base types would cause various
2632 // problems in language bindings, so forbid them here. For example,
2633 // GCC prior to version 3.4 fails with code like
2635 // struct Base { ... };
2636 // template< typename typeparam_T > struct Derived: public Base {
2637 // int member1 CPPU_GCC3_ALIGN(Base);
2640 // (Note that plain struct types with instantiated polymorphic struct
2641 // type bases, which might also cause problems in language bindings, are
2642 // already rejected on a syntactic level.)
2643 if
($5 != 0 && $6 != 0) {
2644 idlc
()->error()->error0
(EIDL_STRUCT_TYPE_TEMPLATE_WITH_BASE
);
2647 $$
= new FeInheritanceHeader
(NT_struct
, $3, $6, $5);
2654 '<' type_params
'>' { $$
= $2; }
2655 |
/* empty */ { $$
= 0; }
2661 $$
= new std
::vector
< rtl
::OString
>;
2665 | type_params
',' identifier
2667 if
(std
::find
($1->begin
(), $1->end
(), *$3) != $1->end
()) {
2668 idlc
()->error()->error0
(EIDL_IDENTICAL_TYPE_PARAMETERS
);
2676 at_least_one_member
: member members
;
2686 idlc
()->setParseState
(PS_MemberTypeSeen
);
2688 at_least_one_declarator
2690 idlc
()->setParseState
(PS_MemberDeclsSeen
);
2694 idlc
()->setParseState
(PS_MemberDeclsCompleted
);
2696 AstScope
* pScope
= idlc
()->scopes
()->topNonNull
();
2697 AstMember
* pMember
= NULL
;
2698 FeDeclList
* pList
= $3;
2699 FeDeclarator
* pDecl
= NULL
;
2700 AstType
const * pType
= NULL
;
2702 // !!! check recursive type
2704 if
( pScope
&& pList
&& $1 )
2706 FeDeclList
::iterator iter
= pList
->begin
();
2707 FeDeclList
::iterator end
= pList
->end
();
2717 pType
= pDecl
->compose
($1);
2725 pMember
= new AstMember
(pType
, pDecl
->getName
(), pScope
);
2727 if
( !pDecl
->checkType
($1) )
2732 pScope
->addDeclaration
(pMember
);
2741 yyerror("member definition");
2748 | scoped_name opt_type_args
2750 AstDeclaration
const * decl
= 0;
2751 AstStruct
* scope
= static_cast
< AstStruct
* >(idlc
()->scopes
()->top
());
2752 if
(scope
!= 0 && $2 == 0) {
2753 decl
= scope
->findTypeParameter
(*$1);
2759 decl
= createNamedType
($1, $2);
2760 if
(scope
!= 0 && includes
(decl
, scopeAsDecl
(scope
))) {
2761 idlc
()->error()->error1
(
2762 EIDL_RECURSIVE_TYPE
, scopeAsDecl
(scope
));
2773 idlc
()->setParseState
(PS_EnumSeen
);
2777 idlc
()->setParseState
(PS_EnumIDSeen
);
2778 checkIdentifier
($3);
2780 AstScope
* pScope
= idlc
()->scopes
()->topNonNull
();
2781 AstEnum
* pEnum
= NULL
;
2784 * Create a node representing an enum and add it to its
2789 pEnum
= new AstEnum
(*$3, pScope
);
2791 * Add it to its defining scope
2793 pScope
->addDeclaration
(pEnum
);
2797 * Push the enum scope on the scopes stack
2799 idlc
()->scopes
()->push
(pEnum
);
2804 idlc
()->setParseState
(PS_EnumSqSeen
);
2806 at_least_one_enumerator
2808 idlc
()->setParseState
(PS_EnumBodySeen
);
2812 idlc
()->setParseState
(PS_EnumQsSeen
);
2814 * Done with this enum. Pop its scope from the scopes stack
2816 if
(idlc
()->scopes
()->top
() == NULL
)
2820 $$
= (AstEnum
*)idlc
()->scopes
()->topNonNull
();
2821 idlc
()->scopes
()->pop
();
2826 at_least_one_enumerator
: enumerator enumerators
;
2832 idlc
()->setParseState
(PS_EnumCommaSeen
);
2838 yyerror("enumerator definition");
2846 checkIdentifier
($1);
2848 AstScope
* pScope
= idlc
()->scopes
()->topNonNull
();
2849 AstEnum
* pEnum
= NULL
;
2850 AstConstant
* pEnumVal
= NULL
;
2852 if
( pScope
&& pScope
->getScopeNodeType
() == NT_enum
)
2854 pEnum
= (AstEnum
*)pScope
;
2857 AstExpression
* pExpr
= new AstExpression
(pEnum
->getEnumValueCount
());
2858 pEnumVal
= new AstConstant
(ET_long
, NT_enum_val
,
2859 pExpr
, *$1, pScope
);
2861 if
( pEnum
->checkValue
(pEnumVal
->getConstValue
()) )
2862 idlc
()->error()->error1
(EIDL_EVAL_ERROR
, pEnum
);
2864 pScope
->addDeclaration
(pEnumVal
);
2872 checkIdentifier
($1);
2874 AstScope
* pScope
= idlc
()->scopes
()->topNonNull
();
2875 AstEnum
* pEnum
= NULL
;
2876 AstConstant
* pEnumVal
= NULL
;
2878 if
( $3 && pScope
&& pScope
->getScopeNodeType
() == NT_enum
)
2880 $3->evaluate
(EK_const
);
2881 if
( $3->coerce
(ET_long
) )
2883 pEnum
= (AstEnum
*)pScope
;
2886 pEnumVal
= new AstConstant
(ET_long
, NT_enum_val
,
2889 if
( pEnum
->checkValue
(pEnumVal
->getConstValue
()) )
2890 idlc
()->error()->error1
(EIDL_EVAL_ERROR
, pEnum
);
2892 pScope
->addDeclaration
(pEnumVal
);
2895 idlc
()->error()->coercionError
($3, ET_long
);
2906 idlc
()->setParseState
(PS_UnionSeen
);
2910 idlc
()->setParseState
(PS_UnionIDSeen
);
2911 checkIdentifier
($3);
2915 idlc
()->setParseState
(PS_SwitchSeen
);
2919 idlc
()->setParseState
(PS_SwitchOpenParSeen
);
2923 idlc
()->setParseState
(PS_SwitchTypeSeen
);
2927 idlc
()->setParseState
(PS_SwitchCloseParSeen
);
2929 AstScope
* pScope
= idlc
()->scopes
()->topNonNull
();
2930 AstUnion
* pUnion
= NULL
;
2933 * Create a node representing a union. Add it to its enclosing
2938 AstType
* pType
= (AstType
*)$9;
2941 idlc
()->error()->noTypeError
($9);
2944 pUnion
= new AstUnion
(*$3, pType
, pScope
);
2945 pScope
->addDeclaration
(pUnion
);
2950 * Push the scope of the union on the scopes stack
2952 idlc
()->scopes
()->push
(pUnion
);
2956 idlc
()->setParseState
(PS_UnionSqSeen
);
2958 at_least_one_case_branch
2960 idlc
()->setParseState
(PS_UnionBodySeen
);
2964 idlc
()->setParseState
(PS_UnionQsSeen
);
2965 /* this union is finished, pop its scope from the stack */
2966 idlc
()->scopes
()->pop
();
2973 $$
= idlc
()->scopes
()->bottom
()->lookupPrimitiveType
($1);
2977 $$
= idlc
()->scopes
()->bottom
()->lookupPrimitiveType
($1);
2981 $$
= idlc
()->scopes
()->bottom
()->lookupPrimitiveType
($1);
2986 AstScope
* pScope
= idlc
()->scopes
()->topNonNull
();
2987 AstBaseType
* pBaseType
= NULL
;
2988 AstDeclaration
const * pDecl
= NULL
;
2989 AstTypeDef
* pTypeDef
= NULL
;
2990 sal_Bool bFound
= sal_False
;
2992 * If the constant's type is a scoped name, it must resolve
2993 * to a scalar constant type
2995 if
( pScope
&& (pDecl
= pScope
->lookupByName
(*$1)) )
2998 * Look through typedefs
3002 switch
(pDecl
->getNodeType
())
3009 pBaseType
= (AstBaseType
*)pDecl
;
3012 switch
(pBaseType
->getExprType
())
3034 pTypeDef
= (AstTypeDef
*)pDecl
;
3036 pDecl
= pTypeDef
->getBaseType
();
3048 idlc
()->error()->lookupError
(*$1);
3052 at_least_one_case_branch
: case_branch case_branches
;
3055 case_branches case_branch
3060 at_least_one_case_label
3062 idlc
()->setParseState
(PS_UnionLabelSeen
);
3066 idlc
()->setParseState
(PS_UnionElemSeen
);
3068 AstScope
* pScope
= idlc
()->scopes
()->topNonNull
();
3069 AstUnionLabel
* pLabel
= NULL
;
3070 AstUnionBranch
* pBranch
= NULL
;
3071 AstMember
* pMember
= $3;
3074 * Create several nodes representing branches of a union.
3075 * Add them to the enclosing scope (the union scope)
3077 if
( pScope
&& $1 && $3 )
3079 LabelList
::iterator iter
= $1->begin
();
3080 LabelList
::iterator end
= $1->end
();
3081 for
(;iter
!= end
; iter
++)
3089 pBranch
= new AstUnionBranch
(pLabel
, pMember
->getType
(),
3090 pMember
->getLocalName
(), pScope
);
3091 pScope
->addDeclaration
(pBranch
);
3094 if
( $1 ) delete
($1);
3098 at_least_one_case_label
:
3099 case_label case_labels
3107 LabelList
* pLabels
= new LabelList
();
3108 pLabels
->push_back
($1);
3115 case_labels case_label
3123 LabelList
* pLabels
= new LabelList
();
3124 pLabels
->push_back
($2);
3137 idlc
()->setParseState
(PS_DefaultSeen
);
3141 idlc
()->setParseState
(PS_LabelColonSeen
);
3142 $$
= new AstUnionLabel
(UL_default
, NULL
);
3146 idlc
()->setParseState
(PS_CaseSeen
);
3150 idlc
()->setParseState
(PS_LabelExprSeen
);
3154 idlc
()->setParseState
(PS_LabelColonSeen
);
3155 $$
= new AstUnionLabel
(UL_label
, $3);
3162 idlc
()->setParseState
(PS_UnionElemTypeSeen
);
3166 idlc
()->setParseState
(PS_UnionElemDeclSeen
);
3170 idlc
()->setParseState
(PS_UnionElemCompleted
);
3172 AstScope
* pScope
= idlc
()->scopes
()->topNonNull
();
3174 * Check for illegal recursive use of type
3176 // if ( $1 && AST_illegal_recursive_type($1))
3177 // idlc()->error()->error1(EIDL_RECURSIVE_TYPE, $1);
3179 * Create a field in a union branch
3183 AstType
const * pType
= $3->compose
($1);
3187 $$
= new AstMember
(pType
, $3->getName
(), pScope
);
3191 if
( $3 ) delete
$3;
3202 | IDL_GET
{ $$
= new OString
("get"); }
3203 | IDL_SET
{ $$
= new OString
("set"); }
3204 | IDL_PUBLISHED
{ $$
= new OString
("published"); }
3210 * Report an error situation discovered in a production
3212 void yyerror(char const *errmsg
)
3214 idlc
()->error()->syntaxError
(idlc
()->getParseState
(), idlc
()->getLineNumber
(), errmsg
);
3215 idlc
()->setParseState
(PS_NoState
);