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
27 #include <idlc/idlc.hxx>
28 #include <idlc/errorhandler.hxx>
29 #include <idlc/fehelper.hxx>
30 #include <idlc/astexpression.hxx>
31 #include <idlc/astconstants.hxx>
32 #include <idlc/astconstant.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>
47 #include "idlc/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
!= 0 && 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
);
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
== 0 ?
0 : typeArgs
->size
()))
163 ErrorHandler
::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 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
!= 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:
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 StringList
* 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
= NULL
;
448 AstDeclaration
* pExists
= NULL
;
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
= NULL
;
519 AstDeclaration
* pDecl
= NULL
;
522 * Make a new forward interface node and add it to its enclosing scope
526 pForward
= new AstInterface
(*$1, NULL
, 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
= NULL
;
558 AstInterface
* pForward
= NULL
;
559 AstDeclaration
* pDecl
= NULL
;
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, 0);
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, $4->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
= 0;
850 $$.get.exceptions
= 0;
851 $$.set.documentation
= 0;
852 $$.set.exceptions
= 0;
856 attribute_block_rest:
857 opt_attribute_raises
'}'
860 yyerror("bad attribute raises block");
862 $$.get.documentation
= 0;
863 $$.get.exceptions
= 0;
864 $$.set.documentation
= 0;
865 $$.set.exceptions
= 0;
869 opt_attribute_raises:
871 opt_attribute_set_raises
876 | attribute_set_raises
877 opt_attribute_get_raises
884 $$.get.documentation
= 0;
885 $$.get.exceptions
= 0;
886 $$.set.documentation
= 0;
887 $$.set.exceptions
= 0;
891 opt_attribute_get_raises:
893 |
/* empty */ { $$.documentation
= 0; $$.exceptions
= 0; }
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
= 0; $$.exceptions
= 0; }
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
= NULL
;
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
= NULL
;
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
= NULL
;
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
= $8->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
(
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
= NULL
;
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
= NULL
;
1282 AstDeclaration
* pExists
= NULL
;
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, NULL
);
1390 $$
= new AstExpression
(EC_u_minus
, $2, NULL
);
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
= 0;
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, 0);
1494 idlc
()->setParseState
(PS_ExceptHeaderSeen
);
1496 AstScope
* pScope
= idlc
()->scopes
()->topNonNull
();
1497 AstException
* pExcept
= NULL
;
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
= NULL
;
1540 FeDeclList
* pList
= $4;
1541 FeDeclarator
* pDecl
= NULL
;
1542 AstType
const * pType
= NULL
;
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
= pDecl
->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
= NULL
;
1614 AstInterfaceMember
* pIMember
= NULL
;
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 StringList
::iterator iter
= $2->begin
();
1628 StringList
::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
= NULL
;
1663 AstServiceMember
* pSMember
= NULL
;
1666 * Create a node representing a class member.
1667 * Store it in the enclosing scope
1671 StringList
::iterator iter
= $2->begin
();
1672 StringList
::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
= NULL
;
1704 AstObserves
* pObserves
= NULL
;
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 StringList
::iterator iter
= $2->begin
();
1718 StringList
::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
= NULL
;
1745 AstNeeds
* pNeeds
= NULL
;
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 StringList
::iterator iter
= $2->begin
();
1759 StringList
::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
= NULL
;
1831 * Make a new service and add it to the enclosing scope
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);
1862 if
(decl
!= 0 && resolveTypedefs
(decl
)->getNodeType
() == NT_interface
) {
1863 if
(ErrorHandler
::checkPublished
(decl
)) {
1864 idlc
()->scopes
()->top
()->addDeclaration
(decl
);
1867 ErrorHandler
::lookupError
(
1868 EIDL_INTERFACEMEMBER_LOOKUP
, *$2, scopeAsDecl
(scope
));
1874 AstService
* s
= static_cast
< AstService
* >(idlc
()->scopes
()->top
());
1876 s
->setSingleInterfaceBasedService
();
1877 s
->setDefaultConstructor
(!$4);
1883 service_body
{ $$
= true
; }
1884 |
/* empty */ { $$
= false
; }
1894 constructors constructor
1901 checkIdentifier
($1);
1902 AstScope
* scope
= idlc
()->scopes
()->top
();
1903 AstOperation
* ctor
= new AstOperation
(0, *$1, scope
);
1905 scope
->addDeclaration
(ctor
);
1906 idlc
()->scopes
()->push
(ctor
);
1913 static_cast
< AstOperation
* >(idlc
()->scopes
()->top
())->setExceptions
(
1916 idlc
()->scopes
()->pop
();
1917 if
(static_cast
< AstService
* >(idlc
()->scopes
()->top
())->
1918 checkLastConstructor
())
1920 ErrorHandler
::error0
(EIDL_SIMILAR_CONSTRUCTORS
);
1929 idlc
()->setParseState
(PS_SingletonSeen
);
1933 idlc
()->setParseState
(PS_SingletonIDSeen
);
1934 checkIdentifier
($3);
1936 AstScope
* pScope
= idlc
()->scopes
()->topNonNull
();
1937 AstService
* pService
= NULL
;
1940 * Make a new service and add it to the enclosing scope
1944 pService
= new AstService
(NT_singleton
, *$3, pScope
);
1945 pScope
->addDeclaration
(pService
);
1949 * Push it on the stack
1951 idlc
()->scopes
()->push
(pService
);
1955 /* this singelton is finished, pop its scope from the stack */
1956 idlc
()->scopes
()->pop
();
1961 singleton_interface_dfn
1962 | service_obsolete_dfn
1965 singleton_interface_dfn:
1968 AstScope
* scope
= idlc
()->scopes
()->nextToTop
();
1969 // skip the scope (needlessly) pushed by singleton_dcl
1970 AstDeclaration
* decl
= scope
->lookupByName
(*$2);
1971 if
(decl
!= 0 && resolveTypedefs
(decl
)->getNodeType
() == NT_interface
) {
1972 if
(ErrorHandler
::checkPublished
(decl
)) {
1973 idlc
()->scopes
()->top
()->addDeclaration
(decl
);
1976 ErrorHandler
::lookupError
(
1977 EIDL_INTERFACEMEMBER_LOOKUP
, *$2, scopeAsDecl
(scope
));
1983 service_obsolete_dfn:
1986 idlc
()->setParseState
(
1987 idlc
()->scopes
()->top
()->getScopeNodeType
() == NT_service
1988 ? PS_ServiceSqSeen
: PS_SingletonSqSeen
);
1992 idlc
()->setParseState
(
1993 idlc
()->scopes
()->top
()->getScopeNodeType
() == NT_service
1994 ? PS_ServiceBodySeen
: PS_SingletonBodySeen
);
1998 idlc
()->setParseState
(
1999 idlc
()->scopes
()->top
()->getScopeNodeType
() == NT_service
2000 ? PS_ServiceQsSeen
: PS_SingletonQsSeen
);
2007 idlc
()->setParseState
(PS_TypedefSeen
);
2017 idlc
()->setParseState
(PS_TypeSpecSeen
);
2018 if
($1 != 0 && $1->getNodeType
() == NT_instantiated_struct
) {
2019 ErrorHandler
::error0
(EIDL_INSTANTIATED_STRUCT_TYPE_TYPEDEF
);
2022 at_least_one_declarator
2024 idlc
()->setParseState
(PS_DeclaratorsSeen
);
2026 AstScope
* pScope
= idlc
()->scopes
()->topNonNull
();
2027 AstTypeDef
* pTypeDef
= NULL
;
2028 FeDeclList
* pList
= $3;
2029 FeDeclarator
* pDecl
= NULL
;
2030 AstType
const * pType
= NULL
;
2033 * Create nodes representing typedefs and add them to the
2036 if
( pScope
&& $1 && pList
)
2038 FeDeclList
::iterator iter
= pList
->begin
();
2039 FeDeclList
::iterator end
= pList
->end
();
2050 pType
= pDecl
->compose
($1);
2058 pTypeDef
= new AstTypeDef
(pType
, pDecl
->getName
(), pScope
);
2060 pScope
->addDeclaration
(pTypeDef
);
2069 at_least_one_declarator
:
2070 declarator declarators
2078 FeDeclList
* pList
= new FeDeclList
();
2079 pList
->push_back
($1);
2089 idlc
()->setParseState
(PS_DeclsCommaSeen
);
2093 idlc
()->setParseState
(PS_DeclsDeclSeen
);
2100 FeDeclList
* pList
= new FeDeclList
();
2101 pList
->push_back
($4);
2114 // For historic reasons, the struct com.sun.star.uno.Uik contains
2115 // members with illegal names (of the form "m_DataN"); avoid useless
2116 // warnings about them:
2117 AstScope
* scope
= idlc
()->scopes
()->top
();
2118 if
(scope
== 0 || scope
->getScopeNodeType
() != NT_struct
2119 ||
(scopeAsDecl
(scope
)->getScopedName
()
2120 != "com::sun::star::uno::Uik"))
2122 checkIdentifier
($1);
2125 $$
= new FeDeclarator
(*$1, FeDeclarator
::FD_simple
, NULL
);
2130 at_least_one_scoped_name
:
2131 scoped_name scoped_names
2135 $2->push_front
(*$1);
2139 StringList
* pScopedNames
= new StringList
();
2140 // coverity [copy_paste_error]
2141 pScopedNames
->push_back
(*$1);
2152 idlc
()->setParseState
(PS_SNListCommaSeen
);
2156 idlc
()->setParseState
(PS_ScopedNameSeen
);
2163 StringList
* pNames
= new StringList
();
2164 pNames
->push_back
(*$4);
2178 idlc
()->setParseState
(PS_SN_IDSeen
);
2179 checkIdentifier
($1);
2182 | IDL_SCOPESEPARATOR
2184 idlc
()->setParseState
(PS_ScopeDelimSeen
);
2188 checkIdentifier
($3);
2189 OString
* pName
= new OString
("::");
2200 checkIdentifier
($4);
2201 *$1 += ::rtl
::OString
("::");
2210 | constructed_type_spec
2215 | scoped_name opt_type_args
2217 $$
= createNamedType
($1, $2);
2224 $$
= idlc
()->scopes
()->bottom
()->lookupPrimitiveType
($1);
2226 | sequence_type_spec
2230 '<' type_args
'>' { $$
= $2; }
2231 |
/* empty */ { $$
= 0; }
2238 $$
->push_back
(const_cast
< AstDeclaration
* >($1)); //TODO: const_cast
2240 | type_args
',' type_arg
2242 $1->push_back
(const_cast
< AstDeclaration
* >($3)); //TODO: const_cast
2250 if
($1 != 0 && static_cast
< AstType
const * >($1)->isUnsigned
()) {
2251 ErrorHandler
::error0
(EIDL_UNSIGNED_TYPE_ARGUMENT
);
2289 IDL_UNSIGNED IDL_LONG
2293 | IDL_UNSIGNED IDL_HYPER
2297 | IDL_UNSIGNED IDL_SHORT
2356 constructed_type_spec
:
2361 sequence_type_spec
:
2364 idlc
()->setParseState
(PS_SequenceSeen
);
2366 * Push a sequence marker on scopes stack
2368 idlc
()->scopes
()->push
(NULL
);
2372 idlc
()->setParseState
(PS_SequenceSqSeen
);
2376 idlc
()->setParseState
(PS_SequenceTypeSeen
);
2380 idlc
()->setParseState
(PS_SequenceQsSeen
);
2382 * Remove sequence marker from scopes stack
2384 if
(idlc
()->scopes
()->top
() == NULL
)
2385 idlc
()->scopes
()->pop
();
2387 * Create a node representing a sequence
2389 AstScope
* pScope
= idlc
()->scopes
()->bottom
();
2390 AstDeclaration
* pDecl
= NULL
;
2391 AstDeclaration
* pSeq
= NULL
;
2395 AstType
const *pType
= static_cast
<AstType
const *>($5);
2398 pSeq
= new AstSequence
(pType
, pScope
);
2400 * Add this AstSequence to the types defined in the global scope
2402 pDecl
= pScope
->addDeclaration
(pSeq
);
2403 if
( pSeq
!= pDecl
)
2405 // if sequence type already defined then use it
2415 yyerror("sequence declaration");
2424 idlc
()->setParseState
(PS_StructHeaderSeen
);
2426 AstScope
* pScope
= idlc
()->scopes
()->topNonNull
();
2427 AstStruct
* pStruct
= NULL
;
2431 AstStruct
const* pBase
= static_cast
< AstStruct
const* >(resolveTypedefs
($1->getInherits
()));
2432 pStruct
= new AstStruct
(
2433 *$1->getName
(), $1->getTypeParameters
(), pBase
, pScope
);
2434 pScope
->addDeclaration
(pStruct
);
2437 * Push the scope of the struct on the scopes stack
2439 idlc
()->scopes
()->push
(pStruct
);
2444 idlc
()->setParseState
(PS_StructSqSeen
);
2448 idlc
()->setParseState
(PS_StructBodySeen
);
2452 idlc
()->setParseState
(PS_StructQsSeen
);
2453 /* this exception is finished, pop its scope from the stack */
2454 idlc
()->scopes
()->pop
();
2461 idlc
()->setParseState
(PS_StructSeen
);
2465 idlc
()->setParseState
(PS_StructIDSeen
);
2466 checkIdentifier
($3);
2471 idlc
()->setParseState
(PS_InheritSpecSeen
);
2473 // Polymorphic struct type templates with base types would cause various
2474 // problems in language bindings, so forbid them here. For example,
2475 // GCC prior to version 3.4 fails with code like
2477 // struct Base { ... };
2478 // template< typename typeparam_T > struct Derived: public Base {
2479 // int member1 CPPU_GCC3_ALIGN(Base);
2482 // (Note that plain struct types with instantiated polymorphic struct
2483 // type bases, which might also cause problems in language bindings, are
2484 // already rejected on a syntactic level.)
2485 if
($5 != 0 && $6 != 0) {
2486 ErrorHandler
::error0
(EIDL_STRUCT_TYPE_TEMPLATE_WITH_BASE
);
2489 $$
= new FeInheritanceHeader
(NT_struct
, $3, $6, $5);
2496 '<' type_params
'>' { $$
= $2; }
2497 |
/* empty */ { $$
= 0; }
2503 $$
= new std
::vector
< rtl
::OString
>;
2507 | type_params
',' identifier
2509 if
(std
::find
($1->begin
(), $1->end
(), *$3) != $1->end
()) {
2510 ErrorHandler
::error0
(EIDL_IDENTICAL_TYPE_PARAMETERS
);
2518 at_least_one_member
: member members
;
2528 idlc
()->setParseState
(PS_MemberTypeSeen
);
2530 at_least_one_declarator
2532 idlc
()->setParseState
(PS_MemberDeclsSeen
);
2536 idlc
()->setParseState
(PS_MemberDeclsCompleted
);
2538 AstScope
* pScope
= idlc
()->scopes
()->topNonNull
();
2539 AstMember
* pMember
= NULL
;
2540 FeDeclList
* pList
= $3;
2541 FeDeclarator
* pDecl
= NULL
;
2542 AstType
const * pType
= NULL
;
2544 // !!! check recursive type
2546 if
( pScope
&& pList
&& $1 )
2548 FeDeclList
::iterator iter
= pList
->begin
();
2549 FeDeclList
::iterator end
= pList
->end
();
2559 pType
= pDecl
->compose
($1);
2567 pMember
= new AstMember
(pType
, pDecl
->getName
(), pScope
);
2569 if
( !pDecl
->checkType
($1) )
2574 pScope
->addDeclaration
(pMember
);
2583 yyerror("member definition");
2590 | scoped_name opt_type_args
2592 AstDeclaration
const * decl
= 0;
2593 AstStruct
* scope
= static_cast
< AstStruct
* >(idlc
()->scopes
()->top
());
2594 if
(scope
!= 0 && $2 == 0) {
2595 decl
= scope
->findTypeParameter
(*$1);
2601 decl
= createNamedType
($1, $2);
2602 if
(scope
!= 0 && includes
(decl
, scopeAsDecl
(scope
))) {
2603 ErrorHandler
::error1
(
2604 EIDL_RECURSIVE_TYPE
, scopeAsDecl
(scope
));
2615 idlc
()->setParseState
(PS_EnumSeen
);
2619 idlc
()->setParseState
(PS_EnumIDSeen
);
2620 checkIdentifier
($3);
2622 AstScope
* pScope
= idlc
()->scopes
()->topNonNull
();
2623 AstEnum
* pEnum
= NULL
;
2626 * Create a node representing an enum and add it to its
2631 pEnum
= new AstEnum
(*$3, pScope
);
2633 * Add it to its defining scope
2635 pScope
->addDeclaration
(pEnum
);
2639 * Push the enum scope on the scopes stack
2641 idlc
()->scopes
()->push
(pEnum
);
2646 idlc
()->setParseState
(PS_EnumSqSeen
);
2648 at_least_one_enumerator
2650 idlc
()->setParseState
(PS_EnumBodySeen
);
2654 idlc
()->setParseState
(PS_EnumQsSeen
);
2656 * Done with this enum. Pop its scope from the scopes stack
2658 if
(idlc
()->scopes
()->top
() == NULL
)
2662 $$
= static_cast
<AstEnum
*>(idlc
()->scopes
()->topNonNull
());
2663 idlc
()->scopes
()->pop
();
2668 at_least_one_enumerator
: enumerator enumerators
;
2674 idlc
()->setParseState
(PS_EnumCommaSeen
);
2680 yyerror("enumerator definition");
2688 checkIdentifier
($1);
2690 AstScope
* pScope
= idlc
()->scopes
()->topNonNull
();
2691 AstEnum
* pEnum
= NULL
;
2692 AstConstant
* pEnumVal
= NULL
;
2694 if
( pScope
&& pScope
->getScopeNodeType
() == NT_enum
)
2696 pEnum
= static_cast
<AstEnum
*>(pScope
);
2699 AstExpression
* pExpr
= new AstExpression
(pEnum
->getEnumValueCount
());
2700 pEnumVal
= new AstConstant
(ET_long
, NT_enum_val
,
2701 pExpr
, *$1, pScope
);
2703 if
( pEnum
->checkValue
(pEnumVal
->getConstValue
()) )
2704 ErrorHandler
::error1
(EIDL_EVAL_ERROR
, pEnum
);
2706 pScope
->addDeclaration
(pEnumVal
);
2714 checkIdentifier
($1);
2716 AstScope
* pScope
= idlc
()->scopes
()->topNonNull
();
2717 AstEnum
* pEnum
= NULL
;
2718 AstConstant
* pEnumVal
= NULL
;
2720 if
( $3 && pScope
&& pScope
->getScopeNodeType
() == NT_enum
)
2722 $3->evaluate
(EK_const
);
2723 if
( $3->coerce
(ET_long
) )
2725 pEnum
= static_cast
<AstEnum
*>(pScope
);
2728 pEnumVal
= new AstConstant
(ET_long
, NT_enum_val
,
2731 if
( pEnum
->checkValue
(pEnumVal
->getConstValue
()) )
2732 ErrorHandler
::error1
(EIDL_EVAL_ERROR
, pEnum
);
2734 pScope
->addDeclaration
(pEnumVal
);
2737 ErrorHandler
::coercionError
($3, ET_long
);
2747 | IDL_GET
{ $$
= new OString
("get"); }
2748 | IDL_SET
{ $$
= new OString
("set"); }
2749 | IDL_PUBLISHED
{ $$
= new OString
("published"); }
2755 * Report an error situation discovered in a production
2757 void yyerror(char const *errmsg
)
2759 ErrorHandler
::syntaxError
(idlc
()->getParseState
(), idlc
()->getLineNumber
(), errmsg
);
2760 idlc
()->setParseState
(PS_NoState
);
2763 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */