1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
21 * parser.yy - BISON grammar for IDLC 1.0
28 #include <errorhandler.hxx>
29 #include <fehelper.hxx>
30 #include <astexpression.hxx>
31 #include <astconstants.hxx>
32 #include <astconstant.hxx>
33 #include <astbasetype.hxx>
34 #include <asttypedef.hxx>
35 #include <astexception.hxx>
36 #include <astmember.hxx>
37 #include <astenum.hxx>
38 #include <astsequence.hxx>
39 #include <astattribute.hxx>
40 #include <astoperation.hxx>
41 #include <astparameter.hxx>
42 #include <astinterfacemember.hxx>
43 #include <astservicemember.hxx>
44 #include <astobserves.hxx>
45 #include <astneeds.hxx>
47 #include "aststructinstance.hxx"
49 #include "attributeexceptions.hxx"
51 #include "rtl/strbuf.hxx"
52 #include <osl/diagnose.h>
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 ErrorHandler
::syntaxError
(idlc
()->getParseState
(),
90 idlc
()->getLineNumber
(),
94 ErrorHandler
::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 ErrorHandler
::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
!= nullptr
&& resolved
->getNodeType
() == NT_interface
) {
116 if
(ErrorHandler
::checkPublished
(decl
)) {
117 if
(!static_cast
< AstInterface
const * >(resolved
)->isDefined
()) {
118 ErrorHandler
::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 ErrorHandler
::error1
(
137 EIDL_DOUBLE_INHERITANCE
, *i
);
139 reportDoubleMemberDeclarations
(doubleDecls.members
);
144 ErrorHandler
::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
);
155 if
(decl
== nullptr
) {
156 ErrorHandler
::lookupError
(*scopedName
);
157 } else if
(!ErrorHandler
::checkPublished
(decl
)) {
159 } else if
(resolved
->getNodeType
() == NT_struct
) {
160 if
(static_cast
< AstStruct
const * >(resolved
)->getTypeParameterCount
()
161 != (typeArgs
== nullptr ?
0 : typeArgs
->size
()))
163 ErrorHandler
::error0
(EIDL_WRONG_NUMBER_OF_TYPE_ARGUMENTS
);
165 } else if
(typeArgs
!= nullptr
) {
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
()) {
175 if
(typeArgs
!= nullptr
) {
176 ErrorHandler
::error0
(EIDL_WRONG_NUMBER_OF_TYPE_ARGUMENTS
);
180 ErrorHandler
::noTypeError
(decl
);
188 bool includes
(AstDeclaration
const * type1
, AstDeclaration
const * type2
) {
189 OSL_ASSERT
(type2
!= nullptr
);
190 if
(type1
!= nullptr
) {
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:
213 #pragma warning(push, 1)
214 #pragma warning(disable: 4273 4701 4702)
218 * Declare the type of values in the grammar
221 ExprType etval
; /* Expression type */
222 AstDeclaration
* dclval
; /* Declaration */
223 AstDeclaration
const * cdclval
;
225 AstExpression
* exval
; /* expression value */
226 FeDeclarator
* fdval
; /* declarator value */
227 FeDeclList
* dlval
; /* declarator list value */
228 FeInheritanceHeader
* ihval
; /* inheritance header value */
229 ::rtl
::OString
* sval
; /* OString value */
230 std
::vector
< rtl
::OString
> * svals
;
231 sal_Char
* strval
; /* sal_Char* value */
232 bool bval
; /* sal_Boolean* value */
233 sal_Int64 ival
; /* sal_Int64 value */
234 sal_uInt64 uval
; /* sal_uInt64 value */
235 sal_uInt32 ulval
; /* sal_uInt32 value */
236 double dval
; /* double value */
237 float fval
; /* float value */
238 std
::list
< OString
>* slval
; /* StringList value */
239 AttributeExceptions
::Part attexcpval
;
240 AttributeExceptions attexcval
;
244 * Token types: These are returned by the lexer
247 %token
<sval
> IDL_IDENTIFIER
252 %token IDL_CONSTRAINED
256 %token IDL_MAYBEAMBIGUOUS
257 %token IDL_MAYBEDEFAULT
302 %token
<strval
> IDL_LEFTSHIFT
303 %token
<strval
> IDL_RIGHTSHIFT
304 %token
<strval
> IDL_SCOPESEPARATOR
306 %token
<ival
> IDL_INTEGER_LITERAL
307 %token
<uval
> IDL_INTEGER_ULITERAL
308 %token
<dval
> IDL_FLOATING_PT_LITERAL
311 * These are production names:
313 %type
<dclval
> type_dcl
314 %type
<dclval
> exception_name
315 %type
<cdclval
> constructed_type_spec enum_type op_type_spec
316 %type
<cdclval
> sequence_type_spec simple_type_spec struct_type
317 %type
<cdclval
> type_spec
318 %type
<cdclval
> fundamental_type type_arg type_or_parameter
319 %type
<dclsval
> opt_raises raises exception_list
320 %type
<attexcpval
> opt_attribute_get_raises attribute_get_raises
321 %type
<attexcpval
> opt_attribute_set_raises attribute_set_raises
322 %type
<dclsval
> opt_type_args type_args
324 %type
<sval
> identifier
325 %type
<sval
> interface_decl
326 %type
<sval
> scoped_name inheritance_spec
327 %type
<slval
> scoped_names at_least_one_scoped_name
329 %type
<etval
> const_type integer_type char_type boolean_type
330 %type
<etval
> floating_pt_type any_type signed_int string_type
331 %type
<etval
> unsigned_int base_type_spec byte_type type_type
333 %type
<exval
> expression const_expr or_expr xor_expr and_expr
334 %type
<exval
> add_expr mult_expr unary_expr primary_expr shift_expr
335 %type
<exval
> literal
337 %type
<fdval
> declarator
338 %type
<dlval
> declarators at_least_one_declarator
340 %type
<ihval
> exception_header structure_header interfaceheader
342 %type
<ulval
> flag_header opt_attrflags opt_attrflag
343 %type
<ulval
> direction service_interface_header service_service_header
345 %type
<bval
> optional_inherited_interface opt_rest opt_service_body
347 %type
<attexcval
> opt_attribute_block attribute_block_rest opt_attribute_raises
349 %type
<svals
> opt_type_params type_params
358 definition definitions
363 opt_published publishable_definition
366 idlc
()->setParseState
(PS_ModuleDeclSeen
);
370 idlc
()->setParseState
(PS_NoState
);
374 yyerror("definitions");
380 IDL_PUBLISHED
{ idlc
()->setPublished
(true
); }
381 |
/* empty */ { idlc
()->setPublished
(false
); }
384 publishable_definition:
387 idlc
()->setParseState
(PS_TypeDeclSeen
);
391 idlc
()->setParseState
(PS_NoState
);
395 idlc
()->setParseState
(PS_ExceptionDeclSeen
);
399 idlc
()->setParseState
(PS_NoState
);
403 idlc
()->setParseState
(PS_InterfaceDeclSeen
);
407 idlc
()->setParseState
(PS_NoState
);
411 idlc
()->setParseState
(PS_ServiceDeclSeen
);
415 idlc
()->setParseState
(PS_NoState
);
419 idlc
()->setParseState
(PS_SingletonDeclSeen
);
423 idlc
()->setParseState
(PS_NoState
);
427 idlc
()->setParseState
(PS_ConstantsDeclSeen
);
431 idlc
()->setParseState
(PS_NoState
);
438 idlc
()->setParseState
(PS_ModuleSeen
);
439 idlc
()->setPublished
(false
);
443 idlc
()->setParseState
(PS_ModuleIDSeen
);
446 AstScope
* pScope
= idlc
()->scopes
()->topNonNull
();
447 AstModule
* pModule
= nullptr
;
448 AstDeclaration
* pExists
= nullptr
;
452 pModule
= new AstModule
(*$3, pScope
);
453 if
( (pExists
= pScope
->lookupForAdd
(pModule
)) )
455 pExists
->setInMainfile
(idlc
()->isInMainFile
());
456 pExists
->setFileName
(pModule
->getFileName
());
457 if
(pExists
->isPredefined
())
459 pExists
->setPredefined
(false
);
460 if
(pExists
->getDocumentation
().getLength
() == 0 &&
461 pModule
->getDocumentation
().getLength
() > 0)
463 pExists
->setDocumentation
(pModule
->getDocumentation
());
467 pModule
= static_cast
<AstModule
*>(pExists
);
470 pScope
->addDeclaration
(pModule
);
472 idlc
()->scopes
()->push
(pModule
);
478 idlc
()->setParseState
(PS_ModuleSqSeen
);
482 idlc
()->setParseState
(PS_ModuleBodySeen
);
486 idlc
()->setParseState
(PS_ModuleQsSeen
);
488 * Finished with this module - pop it from the scope stack
490 idlc
()->scopes
()->pop
();
502 idlc
()->setParseState
(PS_InterfaceSeen
);
506 idlc
()->setParseState
(PS_InterfaceIDSeen
);
515 idlc
()->setParseState
(PS_ForwardDeclSeen
);
517 AstScope
* pScope
= idlc
()->scopes
()->topNonNull
();
518 AstInterface
* pForward
= nullptr
;
519 AstDeclaration
* pDecl
= nullptr
;
522 * Make a new forward interface node and add it to its enclosing scope
526 pForward
= new AstInterface
(*$1, nullptr
, pScope
);
528 pDecl
= pScope
->lookupByName
(pForward
->getScopedName
());
531 if
( (pDecl
!= pForward
) &&
532 (pDecl
->getNodeType
() == NT_interface
) )
537 ErrorHandler
::error2
(EIDL_REDEF_SCOPE
, scopeAsDecl
(pScope
), pDecl
);
542 * Add the interface to its definition scope
544 pScope
->addDeclaration
(pForward
);
554 idlc
()->setParseState
(PS_InterfaceHeadSeen
);
556 AstScope
* pScope
= idlc
()->scopes
()->topNonNull
();
557 AstInterface
* pInterface
= nullptr
;
558 AstInterface
* pForward
= nullptr
;
559 AstDeclaration
* pDecl
= nullptr
;
562 * Make a new interface node and add it to its enclosing scope
566 pInterface
= new AstInterface
(
568 static_cast
< AstInterface
const * >(resolveTypedefs
($1->getInherits
())), pScope
);
569 if
( (pDecl
= pScope
->lookupByName
(pInterface
->getScopedName
())) )
572 * See if we're defining a forward declared interface.
574 if
(pDecl
->getNodeType
() == NT_interface
)
576 pForward
= static_cast
<AstInterface
*>(pDecl
);
577 if
( !pForward
->isDefined
() )
580 * Check if redefining in same scope
582 if
( pForward
->getScope
() != pScope
)
584 if
( pForward
->getScopedName
() != pInterface
->getScopedName
() )
586 ErrorHandler
::error3
(EIDL_SCOPE_CONFLICT
,
587 pInterface
, pForward
, scopeAsDecl
(pScope
));
590 else if
( !pInterface
->isPublished
()
591 && pForward
->isPublished
() )
593 ErrorHandler
::error0
(EIDL_PUBLISHED_FORWARD
);
596 * All OK, set full definition
600 pForward
->forwardDefined
(*pInterface
);
602 pInterface
= pForward
;
605 // special handling for XInterface because it is predefined
606 if
( pForward
->isPredefined
() &&
607 pForward
->getScopedName
() == "com::sun::star::uno::XInterface")
609 /* replace the predefined XInterface */
610 *pForward
= *pInterface
;
612 pInterface
= pForward
;
620 * Add the interface to its definition scope
622 pScope
->addDeclaration
(pInterface
);
626 * Push it on the scope stack
628 idlc
()->scopes
()->push
(pInterface
);
633 idlc
()->setParseState
(PS_InterfaceSqSeen
);
637 AstInterface
* ifc
= static_cast
< AstInterface
* >(
638 idlc
()->scopes
()->topNonNull
());
639 if
(!ifc
->hasMandatoryInheritedInterfaces
()
640 && ifc
->getScopedName
() != "com::sun::star::uno::XInterface")
642 addInheritedInterface
(
643 ifc
, rtl
::OString
("::com::sun::star::uno::XInterface"), false
,
647 idlc
()->setParseState
(PS_InterfaceBodySeen
);
651 idlc
()->setParseState
(PS_InterfaceQsSeen
);
653 * Done with this interface - pop it off the scopes stack
655 idlc
()->scopes
()->pop
();
659 yyerror("interface definition");
665 interface_decl inheritance_spec
667 idlc
()->setParseState
(PS_InheritSpecSeen
);
669 $$
= new FeInheritanceHeader
(NT_interface
, $1, $2, nullptr
);
677 idlc
()->setParseState
(PS_InheritColonSeen
);
697 idlc
()->setParseState
(PS_AttributeDeclSeen
);
701 idlc
()->setParseState
(PS_NoState
);
705 idlc
()->setParseState
(PS_OperationDeclSeen
);
709 idlc
()->setParseState
(PS_NoState
);
711 | interface_inheritance_decl
713 idlc
()->setParseState
(PS_InterfaceInheritanceDeclSeen
);
717 idlc
()->setParseState
(PS_NoState
);
725 idlc
()->setParseState
(PS_AttrTypeSeen
);
729 idlc
()->setParseState
(PS_AttrCompleted
);
730 if
(($1 & ~
(AF_BOUND | AF_READONLY
)) != AF_ATTRIBUTE
) {
731 ErrorHandler
::flagError
(EIDL_BAD_ATTRIBUTE_FLAGS
, $1);
733 AstInterface
* scope
= static_cast
< AstInterface
* >(
734 idlc
()->scopes
()->top
());
735 AstAttribute
* attr
= new AstAttribute
(
736 $1, FeDeclarator
::compose
($2), $4->getName
(), scope
);
738 AstInterface
::DoubleMemberDeclarations doubleMembers
(
739 scope
->checkMemberClashes
(attr
));
740 if
(doubleMembers.empty
()) {
741 scope
->addMember
(attr
);
743 reportDoubleMemberDeclarations
(doubleMembers
);
745 idlc
()->scopes
()->push
(attr
);
749 static_cast
< AstAttribute
* >(idlc
()->scopes
()->top
())->setExceptions
(
750 $6.get.documentation
, $6.get.exceptions
, $6.set.documentation
,
752 delete
$6.get.documentation
;
753 delete
$6.get.exceptions
;
754 delete
$6.set.documentation
;
755 delete
$6.set.exceptions
;
756 idlc
()->scopes
()->pop
();
761 '[' opt_attrflags
']'
763 idlc
()->setParseState
(PS_FlagHeaderSeen
);
769 opt_attrflags
',' opt_attrflag
771 if
( ($1 & $3) == $3 )
772 ErrorHandler
::flagError
(EIDL_DEFINED_ATTRIBUTEFLAG
, $3);
785 idlc
()->setParseState
(PS_AttrSeen
);
790 idlc
()->setParseState
(PS_PropertySeen
);
795 idlc
()->setParseState
(PS_ReadOnlySeen
);
800 idlc
()->setParseState
(PS_OptionalSeen
);
805 idlc
()->setParseState
(PS_MayBeVoidSeen
);
810 idlc
()->setParseState
(PS_BoundSeen
);
815 idlc
()->setParseState
(PS_ConstrainedSeen
);
820 idlc
()->setParseState
(PS_TransientSeen
);
825 idlc
()->setParseState
(PS_MayBeAmbigiousSeen
);
826 $$
= AF_MAYBEAMBIGUOUS
;
830 idlc
()->setParseState
(PS_MayBeDefaultSeen
);
831 $$
= AF_MAYBEDEFAULT
;
835 idlc
()->setParseState
(PS_RemoveableSeen
);
840 yyerror("unknown property|attribute flag");
846 '{' attribute_block_rest
{ $$
= $2; }
849 $$.get.documentation
= nullptr
;
850 $$.get.exceptions
= nullptr
;
851 $$.set.documentation
= nullptr
;
852 $$.set.exceptions
= nullptr
;
856 attribute_block_rest:
857 opt_attribute_raises
'}'
860 yyerror("bad attribute raises block");
862 $$.get.documentation
= nullptr
;
863 $$.get.exceptions
= nullptr
;
864 $$.set.documentation
= nullptr
;
865 $$.set.exceptions
= nullptr
;
869 opt_attribute_raises:
871 opt_attribute_set_raises
876 | attribute_set_raises
877 opt_attribute_get_raises
884 $$.get.documentation
= nullptr
;
885 $$.get.exceptions
= nullptr
;
886 $$.set.documentation
= nullptr
;
887 $$.set.exceptions
= nullptr
;
891 opt_attribute_get_raises:
893 |
/* empty */ { $$.documentation
= nullptr
; $$.exceptions
= nullptr
; }
896 attribute_get_raises:
899 $$.documentation
= new rtl
::OUString
(
900 rtl
::OStringToOUString
(
901 idlc
()->getDocumentation
(), RTL_TEXTENCODING_UTF8
));
906 opt_attribute_set_raises:
908 |
/* empty */ { $$.documentation
= nullptr
; $$.exceptions
= nullptr
; }
911 attribute_set_raises:
914 if
(static_cast
< AstAttribute
* >(idlc
()->scopes
()->top
())->
917 ErrorHandler
::error0
(EIDL_READONLY_ATTRIBUTE_SET_EXCEPTIONS
);
922 $$.documentation
= new rtl
::OUString
(
923 rtl
::OStringToOUString
(
924 idlc
()->getDocumentation
(), RTL_TEXTENCODING_UTF8
));
932 idlc
()->setParseState
(PS_OpTypeSeen
);
936 idlc
()->setParseState
(PS_OpIDSeen
);
939 AstInterface
* pScope
= static_cast
< AstInterface
* >(
940 idlc
()->scopes
()->top
());
941 AstOperation
* pOp
= nullptr
;
944 * Create a node representing an operation on an interface
945 * and add it to its enclosing scope
949 AstType
const *pType
= static_cast
<AstType
const *>($1);
950 if
( !pType ||
(pType
->getNodeType
() == NT_exception
) )
955 pOp
= new AstOperation
(pType
, *$3, pScope
);
957 AstInterface
::DoubleMemberDeclarations doubleMembers
(
958 pScope
->checkMemberClashes
(pOp
));
959 if
(doubleMembers.empty
()) {
960 pScope
->addMember
(pOp
);
962 reportDoubleMemberDeclarations
(doubleMembers
);
968 * Push the operation scope onto the scopes stack
970 idlc
()->scopes
()->push
(pOp
);
974 idlc
()->setParseState
(PS_OpSqSeen
);
978 idlc
()->setParseState
(PS_OpParsCompleted
);
982 idlc
()->setParseState
(PS_OpQsSeen
);
986 AstScope
* pScope
= idlc
()->scopes
()->topNonNull
();
987 AstOperation
* pOp
= nullptr
;
989 * Add exceptions and context to the operation
991 if
( pScope
&& pScope
->getScopeNodeType
() == NT_operation
)
993 pOp
= static_cast
<AstOperation
*>(pScope
);
996 pOp
->setExceptions
($11);
1000 * Done with this operation. Pop its scope from the scopes stack
1002 idlc
()->scopes
()->pop
();
1010 $$
= idlc
()->scopes
()->bottom
()->lookupPrimitiveType
(ET_void
);
1019 idlc
()->setParseState
(PS_OpParCommaSeen
);
1025 yyerror("parameter definition");
1035 idlc
()->setParseState
(PS_OpParDirSeen
);
1039 idlc
()->setParseState
(PS_OpParTypeSeen
);
1044 idlc
()->setParseState
(PS_OpParDeclSeen
);
1046 AstOperation
* pScope
= static_cast
< AstOperation
* >(
1047 idlc
()->scopes
()->top
());
1048 AstParameter
* pParam
= nullptr
;
1051 * Create a node representing an argument to an operation
1052 * Add it to the enclosing scope (the operation scope)
1054 if
( pScope
&& $5 && $8 )
1056 AstType
const * pType
= FeDeclarator
::compose
($5);
1059 if
(pScope
->isConstructor
() && $2 != DIR_IN
) {
1060 ErrorHandler
::error0
(EIDL_CONSTRUCTOR_PARAMETER_NOT_IN
);
1062 if
(pScope
->isVariadic
()) {
1063 ErrorHandler
::error0
(EIDL_REST_PARAMETER_NOT_LAST
);
1066 AstDeclaration
const * type
= resolveTypedefs
(pType
);
1067 if
(type
->getNodeType
() != NT_predefined
1068 ||
(static_cast
< AstBaseType
const * >(type
)->
1069 getExprType
() != ET_any
))
1071 ErrorHandler
::error0
(EIDL_REST_PARAMETER_NOT_ANY
);
1073 if
(pScope
->isConstructor
()) {
1074 if
(pScope
->getIteratorBegin
()
1075 != pScope
->getIteratorEnd
())
1077 ErrorHandler
::error0
(
1078 EIDL_CONSTRUCTOR_REST_PARAMETER_NOT_FIRST
);
1081 ErrorHandler
::error0
(EIDL_METHOD_HAS_REST_PARAMETER
);
1085 pParam
= new AstParameter
(
1086 static_cast
< Direction
>($2), $7, pType
, $8->getName
(),
1089 if
( !$8->checkType
($5) )
1094 pScope
->addDeclaration
(pParam
);
1101 idlc
()->setParseState
(PS_NoState
);
1143 idlc
()->setParseState
(PS_RaiseSeen
);
1147 idlc
()->setParseState
(PS_RaiseSqSeen
);
1152 idlc
()->setParseState
(PS_RaiseQsSeen
);
1163 | exception_list
',' exception_name
1173 // The topmost scope is either an AstOperation (for interface methods
1174 // and service constructors) or an AstAttribute (for interface
1175 // attributes), so look up exception names in the next-to-topmost scope:
1176 AstDeclaration
* decl
= idlc
()->scopes
()->nextToTop
()->lookupByName
(
1178 if
(decl
== nullptr
) {
1179 ErrorHandler
::lookupError
(*$1);
1180 } else if
(!ErrorHandler
::checkPublished
(decl
)) {
1182 } else if
(decl
->getNodeType
() != NT_exception
) {
1183 ErrorHandler
::error1
(EIDL_ILLEGAL_RAISES
, decl
);
1191 interface_inheritance_decl:
1192 optional_inherited_interface
1195 idlc
()->setParseState
(PS_ServiceIFHeadSeen
);
1199 AstInterface
* ifc
= static_cast
< AstInterface
* >(
1200 idlc
()->scopes
()->top
());
1201 if
(ifc
->usesSingleInheritance
()) {
1202 ErrorHandler
::error0
(EIDL_MIXED_INHERITANCE
);
1204 addInheritedInterface
(
1206 rtl
::OStringToOUString
(
1207 idlc
()->getDocumentation
(), RTL_TEXTENCODING_UTF8
));
1213 optional_inherited_interface:
1214 '[' IDL_OPTIONAL
']' { $$
= true
; }
1215 |
/* EMPTY */ { $$
= false
; }
1219 constants_export constants_exports
1226 idlc
()->setParseState
(PS_ConstSeen
);
1230 idlc
()->setParseState
(PS_ConstTypeSeen
);
1234 idlc
()->setParseState
(PS_ConstIDSeen
);
1235 checkIdentifier
($5);
1239 idlc
()->setParseState
(PS_ConstAssignSeen
);
1243 idlc
()->setParseState
(PS_ConstExprSeen
);
1245 AstScope
* pScope
= idlc
()->scopes
()->topNonNull
();
1246 AstConstant
* pConstant
= nullptr
;
1250 if
( !$9->coerce
($3) )
1252 ErrorHandler
::coercionError
($9, $3);
1255 pConstant
= new AstConstant
($3, $9, *$5, pScope
);
1256 pScope
->addDeclaration
(pConstant
);
1261 idlc
()->setParseState
(PS_ConstantDeclSeen
);
1269 idlc
()->setParseState
(PS_ConstantsSeen
);
1273 idlc
()->setParseState
(PS_ConstantsIDSeen
);
1274 checkIdentifier
($3);
1278 idlc
()->setParseState
(PS_ConstantsSqSeen
);
1280 AstScope
* pScope
= idlc
()->scopes
()->topNonNull
();
1281 AstConstants
* pConstants
= nullptr
;
1282 AstDeclaration
* pExists
= nullptr
;
1286 pConstants
= new AstConstants
(*$3, pScope
);
1287 if
( (pExists
= pScope
->lookupForAdd
(pConstants
)) )
1289 pExists
->setInMainfile
(idlc
()->isInMainFile
());
1291 pConstants
= static_cast
<AstConstants
*>(pExists
);
1294 pScope
->addDeclaration
(pConstants
);
1296 idlc
()->scopes
()->push
(pConstants
);
1302 idlc
()->setParseState
(PS_ConstantsBodySeen
);
1306 idlc
()->setParseState
(PS_ConstantsQsSeen
);
1308 * Finished with this constants - pop it from the scope stack
1310 idlc
()->scopes
()->pop
();
1314 expression
: const_expr
;
1316 const_expr
: or_expr
;
1320 | or_expr
'|' xor_expr
1322 $$
= new AstExpression
(EC_or
, $1, $3);
1328 | xor_expr
'^' and_expr
1330 $$
= new AstExpression
(EC_xor
, $1, $3);
1336 | and_expr
'&' shift_expr
1338 $$
= new AstExpression
(EC_and
, $1, $3);
1344 | shift_expr IDL_LEFTSHIFT add_expr
1346 $$
= new AstExpression
(EC_left
, $1, $3);
1348 | shift_expr IDL_RIGHTSHIFT add_expr
1350 $$
= new AstExpression
(EC_right
, $1, $3);
1356 | add_expr
'+' mult_expr
1358 $$
= new AstExpression
(EC_add
, $1, $3);
1360 | add_expr
'-' mult_expr
1362 $$
= new AstExpression
(EC_minus
, $1, $3);
1368 | mult_expr
'*' unary_expr
1370 $$
= new AstExpression
(EC_mul
, $1, $3);
1372 | mult_expr
'/' unary_expr
1374 $$
= new AstExpression
(EC_div
, $1, $3);
1376 | mult_expr
'%' unary_expr
1378 $$
= new AstExpression
(EC_mod
, $1, $3);
1386 $$
= new AstExpression
(EC_u_plus
, $2, nullptr
);
1390 $$
= new AstExpression
(EC_u_minus
, $2, nullptr
);
1401 * An expression which is a scoped name is not resolved now,
1402 * but only when it is evaluated (such as when it is assigned
1403 * as a constant value)
1405 $$
= new AstExpression
($1);
1408 |
'(' const_expr
')'
1417 $$
= new AstExpression
($1);
1419 | IDL_INTEGER_ULITERAL
1421 $$
= new AstExpression
($1);
1423 | IDL_FLOATING_PT_LITERAL
1425 $$
= new AstExpression
($1);
1429 $$
= new AstExpression
((sal_Int32
)1, ET_boolean
);
1433 $$
= new AstExpression
((sal_Int32
)0, ET_boolean
);
1444 AstScope
* pScope
= idlc
()->scopes
()->topNonNull
();
1445 AstDeclaration
const * type
= nullptr
;
1448 * If the constant's type is a scoped name, it must resolve
1449 * to a scalar constant type
1451 if
( pScope
&& (type
= pScope
->lookupByName
(*$1)) ) {
1452 if
(!ErrorHandler
::checkPublished
(type
))
1459 type
= resolveTypedefs
(type
);
1460 if
(type
->getNodeType
() == NT_predefined
)
1462 $$
= static_cast
< AstBaseType
const * >(type
)->
1475 idlc
()->setParseState
(PS_ExceptSeen
);
1479 idlc
()->setParseState
(PS_ExceptIDSeen
);
1480 checkIdentifier
($3);
1484 idlc
()->setParseState
(PS_InheritSpecSeen
);
1486 $$
= new FeInheritanceHeader
(NT_exception
, $3, $5, nullptr
);
1494 idlc
()->setParseState
(PS_ExceptHeaderSeen
);
1496 AstScope
* pScope
= idlc
()->scopes
()->topNonNull
();
1497 AstException
* pExcept
= nullptr
;
1501 AstException
* pBase
= static_cast
< AstException
* >(
1503 pExcept
= new AstException
(*$1->getName
(), pBase
, pScope
);
1504 pScope
->addDeclaration
(pExcept
);
1507 * Push the scope of the exception on the scopes stack
1509 idlc
()->scopes
()->push
(pExcept
);
1514 idlc
()->setParseState
(PS_ExceptSqSeen
);
1518 idlc
()->setParseState
(PS_ExceptBodySeen
);
1522 idlc
()->setParseState
(PS_ExceptQsSeen
);
1523 /* this exception is finished, pop its scope from the stack */
1524 idlc
()->scopes
()->pop
();
1532 idlc
()->setParseState
(PS_PropertyTypeSeen
);
1534 at_least_one_declarator
1536 idlc
()->setParseState
(PS_PropertyCompleted
);
1538 AstScope
* pScope
= idlc
()->scopes
()->topNonNull
();
1539 AstAttribute
* pAttr
= nullptr
;
1540 FeDeclList
* pList
= $4;
1541 FeDeclarator
* pDecl
= nullptr
;
1542 AstType
const * pType
= nullptr
;
1544 if
( pScope
->getScopeNodeType
() == NT_singleton
)
1546 ErrorHandler
::error0
(EIDL_ILLEGAL_ADD
);
1549 if
( ($1 & AF_ATTRIBUTE
) == AF_ATTRIBUTE
)
1550 ErrorHandler
::flagError
(EIDL_WRONGATTRIBUTEKEYWORD
, AF_ATTRIBUTE
);
1552 if
( ($1 & AF_PROPERTY
) != AF_PROPERTY
)
1553 ErrorHandler
::flagError
(EIDL_MISSINGATTRIBUTEKEYWORD
, AF_PROPERTY
);
1556 * Create nodes representing attributes and add them to the
1559 if
( pScope
&& $2 && pList
)
1561 FeDeclList
::iterator iter
= pList
->begin
();
1562 FeDeclList
::iterator end
= pList
->end
();
1573 pType
= FeDeclarator
::compose
($2);
1581 pAttr
= new AstAttribute
(NT_property
, $1, pType
, pDecl
->getName
(), pScope
);
1583 pScope
->addDeclaration
(pAttr
);
1595 yyerror("property");
1601 service_exports service_export
1606 service_interface_header
1607 at_least_one_scoped_name
1610 idlc
()->setParseState
(PS_ServiceMemberSeen
);
1612 AstScope
* pScope
= idlc
()->scopes
()->topNonNull
();
1613 AstDeclaration
* pDecl
= nullptr
;
1614 AstInterfaceMember
* pIMember
= nullptr
;
1616 if
( pScope
->getScopeNodeType
() == NT_singleton
)
1618 ErrorHandler
::error0
(EIDL_ILLEGAL_ADD
);
1622 * Create a node representing a class member.
1623 * Store it in the enclosing scope
1627 std
::list
< OString
>::iterator iter
= $2->begin
();
1628 std
::list
< OString
>::iterator end
= $2->end
();
1630 while
( iter
!= end
)
1632 pDecl
= pScope
->lookupByName
(*iter
);
1633 if
( pDecl
&& (pDecl
->getNodeType
() == NT_interface
) )
1635 /* we relax the strict published check and allow to add new
1636 * interfaces if they are optional
1638 bool bOptional
= (($1 & AF_OPTIONAL
) == AF_OPTIONAL
);
1639 if
( ErrorHandler
::checkPublished
(pDecl
, bOptional
) )
1641 pIMember
= new AstInterfaceMember
(
1642 $1, static_cast
<AstInterface
*>(pDecl
), *iter
, pScope
);
1643 pScope
->addDeclaration
(pIMember
);
1647 ErrorHandler
::lookupError
(EIDL_INTERFACEMEMBER_LOOKUP
, *iter
, scopeAsDecl
(pScope
));
1655 | service_service_header
1656 at_least_one_scoped_name
1659 idlc
()->setParseState
(PS_ServiceMemberSeen
);
1661 AstScope
* pScope
= idlc
()->scopes
()->topNonNull
();
1662 AstDeclaration
* pDecl
= nullptr
;
1663 AstServiceMember
* pSMember
= nullptr
;
1666 * Create a node representing a class member.
1667 * Store it in the enclosing scope
1671 std
::list
< OString
>::iterator iter
= $2->begin
();
1672 std
::list
< OString
>::iterator end
= $2->end
();
1674 while
( iter
!= end
)
1676 pDecl
= pScope
->lookupByName
(*iter
);
1677 if
( pDecl
&& (pDecl
->getNodeType
() == NT_service
) )
1679 if
( static_cast
< AstService
* >(pDecl
)->isSingleInterfaceBasedService
() ||
(pScope
->getScopeNodeType
() == NT_singleton
&& pScope
->nMembers
() > 0) )
1680 ErrorHandler
::error0
(EIDL_ILLEGAL_ADD
);
1681 else if
( ErrorHandler
::checkPublished
(pDecl
) )
1683 pSMember
= new AstServiceMember
(
1684 $1, static_cast
<AstService
*>(pDecl
), *iter
, pScope
);
1685 pScope
->addDeclaration
(pSMember
);
1689 ErrorHandler
::lookupError
(EIDL_SERVICEMEMBER_LOOKUP
, *iter
, scopeAsDecl
(pScope
));
1697 at_least_one_scoped_name
1700 idlc
()->setParseState
(PS_ServiceMemberSeen
);
1702 AstScope
* pScope
= idlc
()->scopes
()->topNonNull
();
1703 AstDeclaration
* pDecl
= nullptr
;
1704 AstObserves
* pObserves
= nullptr
;
1706 if
( pScope
->getScopeNodeType
() == NT_singleton
)
1708 ErrorHandler
::error0
(EIDL_ILLEGAL_ADD
);
1712 * Create a node representing a class member.
1713 * Store it in the enclosing scope
1717 std
::list
< OString
>::iterator iter
= $2->begin
();
1718 std
::list
< OString
>::iterator end
= $2->end
();
1720 while
( iter
!= end
)
1722 pDecl
= pScope
->lookupByName
(*iter
);
1723 if
( pDecl
&& (pDecl
->getNodeType
() == NT_interface
) )
1725 pObserves
= new AstObserves
(static_cast
<AstInterface
*>(pDecl
), *iter
, pScope
);
1726 pScope
->addDeclaration
(pObserves
);
1729 ErrorHandler
::lookupError
(EIDL_INTERFACEMEMBER_LOOKUP
, *iter
, scopeAsDecl
(pScope
));
1738 at_least_one_scoped_name
1741 idlc
()->setParseState
(PS_ServiceMemberSeen
);
1743 AstScope
* pScope
= idlc
()->scopes
()->topNonNull
();
1744 AstDeclaration
* pDecl
= nullptr
;
1745 AstNeeds
* pNeeds
= nullptr
;
1747 if
( pScope
->getScopeNodeType
() == NT_singleton
)
1749 ErrorHandler
::error0
(EIDL_ILLEGAL_ADD
);
1753 * Create a node representing a class member.
1754 * Store it in the enclosing scope
1758 std
::list
< OString
>::iterator iter
= $2->begin
();
1759 std
::list
< OString
>::iterator end
= $2->end
();
1761 while
( iter
!= end
)
1763 pDecl
= pScope
->lookupByName
(*iter
);
1764 if
( pDecl
&& (pDecl
->getNodeType
() == NT_service
) )
1766 pNeeds
= new AstNeeds
(static_cast
<AstService
*>(pDecl
), *iter
, pScope
);
1767 pScope
->addDeclaration
(pNeeds
);
1770 ErrorHandler
::lookupError
(EIDL_SERVICEMEMBER_LOOKUP
, *iter
, scopeAsDecl
(pScope
));
1781 idlc
()->setParseState
(PS_PropertyDeclSeen
);
1785 service_interface_header
:
1788 idlc
()->setParseState
(PS_ServiceIFHeadSeen
);
1794 idlc
()->setParseState
(PS_ServiceIFHeadSeen
);
1795 if
( (AF_OPTIONAL
!= $1) && ( AF_INVALID
!= $1) )
1796 ErrorHandler
::flagError
(EIDL_OPTIONALEXPECTED
, $1);
1801 service_service_header
:
1804 idlc
()->setParseState
(PS_ServiceSHeadSeen
);
1810 idlc
()->setParseState
(PS_ServiceSHeadSeen
);
1811 if
( (AF_OPTIONAL
!= $1) && ( AF_INVALID
!= $1) )
1812 ErrorHandler
::flagError
(EIDL_OPTIONALEXPECTED
, $1);
1820 idlc
()->setParseState
(PS_ServiceSeen
);
1824 idlc
()->setParseState
(PS_ServiceIDSeen
);
1825 checkIdentifier
($3);
1827 AstScope
* pScope
= idlc
()->scopes
()->topNonNull
();
1828 AstService
* pService
= nullptr
;
1831 * Make a new service and add it to the enclosing scope
1833 if
(pScope
!= nullptr
)
1835 pService
= new AstService
(*$3, pScope
);
1836 pScope
->addDeclaration
(pService
);
1840 * Push it on the stack
1842 idlc
()->scopes
()->push
(pService
);
1846 /* this service is finished, pop its scope from the stack */
1847 idlc
()->scopes
()->pop
();
1852 service_interface_dfn
1853 | service_obsolete_dfn
1856 service_interface_dfn:
1859 AstScope
* scope
= idlc
()->scopes
()->nextToTop
();
1860 // skip the scope pushed by service_dcl
1861 AstDeclaration
* decl
= scope
->lookupByName
(*$2);
1863 && resolveTypedefs
(decl
)->getNodeType
() == NT_interface
)
1865 if
(ErrorHandler
::checkPublished
(decl
)) {
1866 idlc
()->scopes
()->top
()->addDeclaration
(decl
);
1869 ErrorHandler
::lookupError
(
1870 EIDL_INTERFACEMEMBER_LOOKUP
, *$2, scopeAsDecl
(scope
));
1876 AstService
* s
= static_cast
< AstService
* >(idlc
()->scopes
()->top
());
1878 s
->setSingleInterfaceBasedService
();
1879 s
->setDefaultConstructor
(!$4);
1885 service_body
{ $$
= true
; }
1886 |
/* empty */ { $$
= false
; }
1896 constructors constructor
1903 checkIdentifier
($1);
1904 AstScope
* scope
= idlc
()->scopes
()->top
();
1905 AstOperation
* ctor
= new AstOperation
(nullptr
, *$1, scope
);
1907 scope
->addDeclaration
(ctor
);
1908 idlc
()->scopes
()->push
(ctor
);
1915 static_cast
< AstOperation
* >(idlc
()->scopes
()->top
())->setExceptions
(
1918 idlc
()->scopes
()->pop
();
1919 if
(static_cast
< AstService
* >(idlc
()->scopes
()->top
())->
1920 checkLastConstructor
())
1922 ErrorHandler
::error0
(EIDL_SIMILAR_CONSTRUCTORS
);
1931 idlc
()->setParseState
(PS_SingletonSeen
);
1935 idlc
()->setParseState
(PS_SingletonIDSeen
);
1936 checkIdentifier
($3);
1938 AstScope
* pScope
= idlc
()->scopes
()->topNonNull
();
1939 AstService
* pService
= nullptr
;
1942 * Make a new service and add it to the enclosing scope
1944 if
(pScope
!= nullptr
)
1946 pService
= new AstService
(NT_singleton
, *$3, pScope
);
1947 pScope
->addDeclaration
(pService
);
1951 * Push it on the stack
1953 idlc
()->scopes
()->push
(pService
);
1957 /* this singelton is finished, pop its scope from the stack */
1958 idlc
()->scopes
()->pop
();
1963 singleton_interface_dfn
1964 | service_obsolete_dfn
1967 singleton_interface_dfn:
1970 AstScope
* scope
= idlc
()->scopes
()->nextToTop
();
1971 // skip the scope (needlessly) pushed by singleton_dcl
1972 AstDeclaration
* decl
= scope
->lookupByName
(*$2);
1974 && resolveTypedefs
(decl
)->getNodeType
() == NT_interface
)
1976 if
(ErrorHandler
::checkPublished
(decl
)) {
1977 idlc
()->scopes
()->top
()->addDeclaration
(decl
);
1980 ErrorHandler
::lookupError
(
1981 EIDL_INTERFACEMEMBER_LOOKUP
, *$2, scopeAsDecl
(scope
));
1987 service_obsolete_dfn:
1990 idlc
()->setParseState
(
1991 idlc
()->scopes
()->top
()->getScopeNodeType
() == NT_service
1992 ? PS_ServiceSqSeen
: PS_SingletonSqSeen
);
1996 idlc
()->setParseState
(
1997 idlc
()->scopes
()->top
()->getScopeNodeType
() == NT_service
1998 ? PS_ServiceBodySeen
: PS_SingletonBodySeen
);
2002 idlc
()->setParseState
(
2003 idlc
()->scopes
()->top
()->getScopeNodeType
() == NT_service
2004 ? PS_ServiceQsSeen
: PS_SingletonQsSeen
);
2011 idlc
()->setParseState
(PS_TypedefSeen
);
2021 idlc
()->setParseState
(PS_TypeSpecSeen
);
2022 if
($1 != nullptr
&& $1->getNodeType
() == NT_instantiated_struct
) {
2023 ErrorHandler
::error0
(EIDL_INSTANTIATED_STRUCT_TYPE_TYPEDEF
);
2026 at_least_one_declarator
2028 idlc
()->setParseState
(PS_DeclaratorsSeen
);
2030 AstScope
* pScope
= idlc
()->scopes
()->topNonNull
();
2031 AstTypeDef
* pTypeDef
= nullptr
;
2032 FeDeclList
* pList
= $3;
2033 FeDeclarator
* pDecl
= nullptr
;
2034 AstType
const * pType
= nullptr
;
2037 * Create nodes representing typedefs and add them to the
2040 if
( pScope
&& $1 && pList
)
2042 FeDeclList
::iterator iter
= pList
->begin
();
2043 FeDeclList
::iterator end
= pList
->end
();
2054 pType
= FeDeclarator
::compose
($1);
2062 pTypeDef
= new AstTypeDef
(pType
, pDecl
->getName
(), pScope
);
2064 pScope
->addDeclaration
(pTypeDef
);
2073 at_least_one_declarator
:
2074 declarator declarators
2082 FeDeclList
* pList
= new FeDeclList
();
2083 pList
->push_back
($1);
2093 idlc
()->setParseState
(PS_DeclsCommaSeen
);
2097 idlc
()->setParseState
(PS_DeclsDeclSeen
);
2104 FeDeclList
* pList
= new FeDeclList
();
2105 pList
->push_back
($4);
2118 // For historic reasons, the struct com.sun.star.uno.Uik contains
2119 // members with illegal names (of the form "m_DataN"); avoid useless
2120 // warnings about them:
2121 AstScope
* scope
= idlc
()->scopes
()->top
();
2122 if
(scope
== nullptr || scope
->getScopeNodeType
() != NT_struct
2123 ||
(scopeAsDecl
(scope
)->getScopedName
()
2124 != "com::sun::star::uno::Uik"))
2126 checkIdentifier
($1);
2129 $$
= new FeDeclarator
(*$1);
2134 at_least_one_scoped_name
:
2135 scoped_name scoped_names
2139 $2->push_front
(*$1);
2143 std
::list
< OString
>* pScopedNames
= new std
::list
< OString
>();
2144 // coverity [copy_paste_error]
2145 pScopedNames
->push_back
(*$1);
2156 idlc
()->setParseState
(PS_SNListCommaSeen
);
2160 idlc
()->setParseState
(PS_ScopedNameSeen
);
2167 std
::list
< OString
>* pNames
= new std
::list
< OString
>();
2168 pNames
->push_back
(*$4);
2182 idlc
()->setParseState
(PS_SN_IDSeen
);
2183 checkIdentifier
($1);
2186 | IDL_SCOPESEPARATOR
2188 idlc
()->setParseState
(PS_ScopeDelimSeen
);
2192 checkIdentifier
($3);
2193 OString
* pName
= new OString
("::");
2204 checkIdentifier
($4);
2205 *$1 += ::rtl
::OString
("::");
2214 | constructed_type_spec
2219 | scoped_name opt_type_args
2221 $$
= createNamedType
($1, $2);
2228 $$
= idlc
()->scopes
()->bottom
()->lookupPrimitiveType
($1);
2230 | sequence_type_spec
2234 '<' type_args
'>' { $$
= $2; }
2235 |
/* empty */ { $$
= nullptr
; }
2242 $$
->push_back
(const_cast
< AstDeclaration
* >($1)); //TODO: const_cast
2244 | type_args
',' type_arg
2246 $1->push_back
(const_cast
< AstDeclaration
* >($3)); //TODO: const_cast
2254 if
($1 != nullptr
&& static_cast
< AstType
const * >($1)->isUnsigned
()) {
2255 ErrorHandler
::error0
(EIDL_UNSIGNED_TYPE_ARGUMENT
);
2293 IDL_UNSIGNED IDL_LONG
2297 | IDL_UNSIGNED IDL_HYPER
2301 | IDL_UNSIGNED IDL_SHORT
2360 constructed_type_spec
:
2365 sequence_type_spec
:
2368 idlc
()->setParseState
(PS_SequenceSeen
);
2370 * Push a sequence marker on scopes stack
2372 idlc
()->scopes
()->push
(nullptr
);
2376 idlc
()->setParseState
(PS_SequenceSqSeen
);
2380 idlc
()->setParseState
(PS_SequenceTypeSeen
);
2384 idlc
()->setParseState
(PS_SequenceQsSeen
);
2386 * Remove sequence marker from scopes stack
2388 if
(idlc
()->scopes
()->top
() == nullptr
)
2389 idlc
()->scopes
()->pop
();
2391 * Create a node representing a sequence
2393 AstScope
* pScope
= idlc
()->scopes
()->bottom
();
2394 AstDeclaration
* pDecl
= nullptr
;
2395 AstDeclaration
* pSeq
= nullptr
;
2399 AstType
const *pType
= static_cast
<AstType
const *>($5);
2402 pSeq
= new AstSequence
(pType
, pScope
);
2404 * Add this AstSequence to the types defined in the global scope
2406 pDecl
= pScope
->addDeclaration
(pSeq
);
2407 if
( pSeq
!= pDecl
)
2409 // if sequence type already defined then use it
2419 yyerror("sequence declaration");
2428 idlc
()->setParseState
(PS_StructHeaderSeen
);
2430 AstScope
* pScope
= idlc
()->scopes
()->topNonNull
();
2431 AstStruct
* pStruct
= nullptr
;
2435 AstStruct
const* pBase
= static_cast
< AstStruct
const* >(resolveTypedefs
($1->getInherits
()));
2436 pStruct
= new AstStruct
(
2437 *$1->getName
(), $1->getTypeParameters
(), pBase
, pScope
);
2438 pScope
->addDeclaration
(pStruct
);
2441 * Push the scope of the struct on the scopes stack
2443 idlc
()->scopes
()->push
(pStruct
);
2448 idlc
()->setParseState
(PS_StructSqSeen
);
2452 idlc
()->setParseState
(PS_StructBodySeen
);
2456 idlc
()->setParseState
(PS_StructQsSeen
);
2457 /* this exception is finished, pop its scope from the stack */
2458 idlc
()->scopes
()->pop
();
2465 idlc
()->setParseState
(PS_StructSeen
);
2469 idlc
()->setParseState
(PS_StructIDSeen
);
2470 checkIdentifier
($3);
2475 idlc
()->setParseState
(PS_InheritSpecSeen
);
2477 // Polymorphic struct type templates with base types would cause various
2478 // problems in language bindings, so forbid them here. For example,
2479 // GCC prior to version 3.4 fails with code like
2481 // struct Base { ... };
2482 // template< typename typeparam_T > struct Derived: public Base {
2483 // int member1 CPPU_GCC3_ALIGN(Base);
2486 // (Note that plain struct types with instantiated polymorphic struct
2487 // type bases, which might also cause problems in language bindings, are
2488 // already rejected on a syntactic level.)
2489 if
($5 != nullptr
&& $6 != nullptr
) {
2490 ErrorHandler
::error0
(EIDL_STRUCT_TYPE_TEMPLATE_WITH_BASE
);
2493 $$
= new FeInheritanceHeader
(NT_struct
, $3, $6, $5);
2500 '<' type_params
'>' { $$
= $2; }
2501 |
/* empty */ { $$
= nullptr
; }
2507 $$
= new std
::vector
< rtl
::OString
>;
2511 | type_params
',' identifier
2513 if
(std
::find
($1->begin
(), $1->end
(), *$3) != $1->end
()) {
2514 ErrorHandler
::error0
(EIDL_IDENTICAL_TYPE_PARAMETERS
);
2522 at_least_one_member
: member members
;
2532 idlc
()->setParseState
(PS_MemberTypeSeen
);
2534 at_least_one_declarator
2536 idlc
()->setParseState
(PS_MemberDeclsSeen
);
2540 idlc
()->setParseState
(PS_MemberDeclsCompleted
);
2542 AstScope
* pScope
= idlc
()->scopes
()->topNonNull
();
2543 AstMember
* pMember
= nullptr
;
2544 FeDeclList
* pList
= $3;
2545 FeDeclarator
* pDecl
= nullptr
;
2546 AstType
const * pType
= nullptr
;
2548 // !!! check recursive type
2550 if
( pScope
&& pList
&& $1 )
2552 FeDeclList
::iterator iter
= pList
->begin
();
2553 FeDeclList
::iterator end
= pList
->end
();
2563 pType
= FeDeclarator
::compose
($1);
2571 pMember
= new AstMember
(pType
, pDecl
->getName
(), pScope
);
2573 if
( !pDecl
->checkType
($1) )
2578 pScope
->addDeclaration
(pMember
);
2587 yyerror("member definition");
2594 | scoped_name opt_type_args
2596 AstDeclaration
const * decl
= nullptr
;
2597 AstStruct
* scope
= static_cast
< AstStruct
* >(idlc
()->scopes
()->top
());
2598 if
(scope
!= nullptr
&& $2 == nullptr
) {
2599 decl
= scope
->findTypeParameter
(*$1);
2601 if
(decl
!= nullptr
) {
2605 decl
= createNamedType
($1, $2);
2606 if
(scope
!= nullptr
&& includes
(decl
, scopeAsDecl
(scope
))) {
2607 ErrorHandler
::error1
(
2608 EIDL_RECURSIVE_TYPE
, scopeAsDecl
(scope
));
2619 idlc
()->setParseState
(PS_EnumSeen
);
2623 idlc
()->setParseState
(PS_EnumIDSeen
);
2624 checkIdentifier
($3);
2626 AstScope
* pScope
= idlc
()->scopes
()->topNonNull
();
2627 AstEnum
* pEnum
= nullptr
;
2630 * Create a node representing an enum and add it to its
2633 if
(pScope
!= nullptr
)
2635 pEnum
= new AstEnum
(*$3, pScope
);
2637 * Add it to its defining scope
2639 pScope
->addDeclaration
(pEnum
);
2643 * Push the enum scope on the scopes stack
2645 idlc
()->scopes
()->push
(pEnum
);
2650 idlc
()->setParseState
(PS_EnumSqSeen
);
2652 at_least_one_enumerator
2654 idlc
()->setParseState
(PS_EnumBodySeen
);
2658 idlc
()->setParseState
(PS_EnumQsSeen
);
2660 * Done with this enum. Pop its scope from the scopes stack
2662 if
(idlc
()->scopes
()->top
() == nullptr
)
2666 $$
= static_cast
<AstEnum
*>(idlc
()->scopes
()->topNonNull
());
2667 idlc
()->scopes
()->pop
();
2672 at_least_one_enumerator
: enumerator enumerators
;
2678 idlc
()->setParseState
(PS_EnumCommaSeen
);
2684 yyerror("enumerator definition");
2692 checkIdentifier
($1);
2694 AstScope
* pScope
= idlc
()->scopes
()->topNonNull
();
2695 AstEnum
* pEnum
= nullptr
;
2696 AstConstant
* pEnumVal
= nullptr
;
2698 if
( pScope
&& pScope
->getScopeNodeType
() == NT_enum
)
2700 pEnum
= static_cast
<AstEnum
*>(pScope
);
2703 AstExpression
* pExpr
= new AstExpression
(pEnum
->getEnumValueCount
());
2704 pEnumVal
= new AstConstant
(ET_long
, NT_enum_val
,
2705 pExpr
, *$1, pScope
);
2707 if
( pEnum
->checkValue
(pEnumVal
->getConstValue
()) )
2708 ErrorHandler
::error1
(EIDL_EVAL_ERROR
, pEnum
);
2710 pScope
->addDeclaration
(pEnumVal
);
2718 checkIdentifier
($1);
2720 AstScope
* pScope
= idlc
()->scopes
()->topNonNull
();
2721 AstEnum
* pEnum
= nullptr
;
2722 AstConstant
* pEnumVal
= nullptr
;
2724 if
( $3 && pScope
&& pScope
->getScopeNodeType
() == NT_enum
)
2727 if
( $3->coerce
(ET_long
) )
2729 pEnum
= static_cast
<AstEnum
*>(pScope
);
2732 pEnumVal
= new AstConstant
(ET_long
, NT_enum_val
,
2735 if
( pEnum
->checkValue
(pEnumVal
->getConstValue
()) )
2736 ErrorHandler
::error1
(EIDL_EVAL_ERROR
, pEnum
);
2738 pScope
->addDeclaration
(pEnumVal
);
2741 ErrorHandler
::coercionError
($3, ET_long
);
2751 | IDL_GET
{ $$
= new OString
("get"); }
2752 | IDL_SET
{ $$
= new OString
("set"); }
2753 | IDL_PUBLISHED
{ $$
= new OString
("published"); }
2759 * Report an error situation discovered in a production
2761 void yyerror(char const *errmsg
)
2763 ErrorHandler
::syntaxError
(idlc
()->getParseState
(), idlc
()->getLineNumber
(), errmsg
);
2764 idlc
()->setParseState
(PS_NoState
);
2767 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */