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"
58 #if !(defined MACOSX && defined PPC)
59 #define YYERROR_VERBOSE 1
62 using
::rtl
::OUString
;
64 using
::rtl
::OStringToOUString
;
65 using
::rtl
::OStringBuffer
;
67 extern
int yylex(void);
68 void yyerror(char const *);
70 void checkIdentifier
(::rtl
::OString
* id
)
72 static short check
= 0;
74 if
(idlc
()->getOptions
()->isValid
("-cid"))
80 if
( id
->indexOf
('_') >= 0 )
81 if
( (id
->pData
->buffer
[0] >= 97 && id
->pData
->buffer
[0] <= 122)
82 || id
->pData
->buffer
[0] == '_') {
84 ::rtl
::OStringBuffer msg
(25 + id
->getLength
());
85 msg.append
("mismatched identifier '");
88 idlc
()->error()->syntaxError
(idlc
()->getParseState
(),
89 idlc
()->getLineNumber
(),
93 idlc
()->error()->warning0
(WIDL_WRONG_NAMING_CONV
, id
->getStr
());
97 void reportDoubleMemberDeclarations
(
98 AstInterface
::DoubleMemberDeclarations
const & doubleMembers
)
100 for
(AstInterface
::DoubleMemberDeclarations
::const_iterator i
(
101 doubleMembers.begin
());
102 i
!= doubleMembers.end
(); ++i
)
104 idlc
()->error()->error2
(EIDL_DOUBLE_MEMBER
, i
->first
, i
->second
);
108 void addInheritedInterface
(
109 AstInterface
* ifc
, rtl
::OString
const & name
, bool optional
,
110 rtl
::OUString
const & documentation
)
112 AstDeclaration
* decl
= ifc
->lookupByName
(name
);
113 AstDeclaration
const * resolved
= resolveTypedefs
(decl
);
114 if
(resolved
!= 0 && resolved
->getNodeType
() == NT_interface
) {
115 if
(idlc
()->error()->checkPublished
(decl
)) {
116 if
(!static_cast
< AstInterface
const * >(resolved
)->isDefined
()) {
117 idlc
()->error()->inheritanceError
(
118 NT_interface
, &ifc
->getScopedName
(), decl
);
120 AstInterface
::DoubleDeclarations doubleDecls
(
121 ifc
->checkInheritedInterfaceClashes
(
122 static_cast
< AstInterface
const * >(resolved
),
124 if
(doubleDecls.interfaces.empty
()
125 && doubleDecls.members.empty
())
127 ifc
->addInheritedInterface
(
128 static_cast
< AstType
* >(decl
), optional
,
131 for
(AstInterface
::DoubleInterfaceDeclarations
::iterator i
(
132 doubleDecls.interfaces.begin
());
133 i
!= doubleDecls.interfaces.end
(); ++i
)
135 idlc
()->error()->error1
(
136 EIDL_DOUBLE_INHERITANCE
, *i
);
138 reportDoubleMemberDeclarations
(doubleDecls.members
);
143 idlc
()->error()->lookupError
(
144 EIDL_INTERFACEMEMBER_LOOKUP
, name
, scopeAsDecl
(ifc
));
148 AstDeclaration
const * createNamedType
(
149 rtl
::OString
const * scopedName
, DeclList
const * typeArgs
)
151 AstDeclaration
* decl
= idlc
()->scopes
()->topNonNull
()->lookupByName
(
153 AstDeclaration
const * resolved
= resolveTypedefs
(decl
);
155 idlc
()->error()->lookupError
(*scopedName
);
156 } else if
(!idlc
()->error()->checkPublished
(decl
)) {
158 } else if
(resolved
->getNodeType
() == NT_struct
) {
159 if
(static_cast
< AstStruct
const * >(resolved
)->getTypeParameterCount
()
160 != (typeArgs
== 0 ?
0 : typeArgs
->size
()))
162 idlc
()->error()->error0
(EIDL_WRONG_NUMBER_OF_TYPE_ARGUMENTS
);
164 } else if
(typeArgs
!= 0) {
165 AstScope
* global
= idlc
()->scopes
()->bottom
();
166 AstDeclaration
* inst
= new AstStructInstance
(
167 static_cast
< AstType
* >(decl
), typeArgs
, global
);
168 decl
= global
->addDeclaration
(inst
);
173 } else if
(decl
->isType
()) {
175 idlc
()->error()->error0
(EIDL_WRONG_NUMBER_OF_TYPE_ARGUMENTS
);
179 idlc
()->error()->noTypeError
(decl
);
187 bool includes
(AstDeclaration
const * type1
, AstDeclaration
const * type2
) {
188 OSL_ASSERT
(type2
!= 0);
190 if
(type1
->getNodeType
() == NT_instantiated_struct
) {
191 AstStructInstance
const * inst
192 = static_cast
< AstStructInstance
const * >(type1
);
193 if
(inst
->getTypeTemplate
() == type2
) {
196 for
(DeclList
::const_iterator i
(inst
->getTypeArgumentsBegin
());
197 i
!= inst
->getTypeArgumentsEnd
(); ++i
)
199 if
(includes
(*i
, type2
)) {
203 } else if
(type1
== type2
) {
210 // Suppress any warnings from generated code:
212 #pragma warning(push, 1)
213 #pragma warning(disable: 4273 4701 4702)
217 * Declare the type of values in the grammar
220 ExprType etval
; /* Expression type */
221 AstDeclaration
* dclval
; /* Declaration */
222 AstDeclaration
const * cdclval
;
224 AstExpression
* exval
; /* expression value */
225 FeDeclarator
* fdval
; /* declarator value */
226 FeDeclList
* dlval
; /* declarator list value */
227 FeInheritanceHeader
* ihval
; /* inheritance header value */
228 ::rtl
::OString
* sval
; /* OString value */
229 std
::vector
< rtl
::OString
> * svals
;
230 sal_Char
* strval
; /* sal_Char* value */
231 bool bval
; /* sal_Boolean* value */
232 sal_Int64 ival
; /* sal_Int64 value */
233 sal_uInt64 uval
; /* sal_uInt64 value */
234 sal_uInt32 ulval
; /* sal_uInt32 value */
235 double dval
; /* double value */
236 float fval
; /* float value */
237 StringList
* slval
; /* StringList value */
238 AttributeExceptions
::Part attexcpval
;
239 AttributeExceptions attexcval
;
243 * Token types: These are returned by the lexer
246 %token
<sval
> IDL_IDENTIFIER
251 %token IDL_CONSTRAINED
255 %token IDL_MAYBEAMBIGUOUS
256 %token IDL_MAYBEDEFAULT
301 %token
<strval
> IDL_LEFTSHIFT
302 %token
<strval
> IDL_RIGHTSHIFT
303 %token
<strval
> IDL_SCOPESEPARATOR
305 %token
<ival
> IDL_INTEGER_LITERAL
306 %token
<uval
> IDL_INTEGER_ULITERAL
307 %token
<dval
> IDL_FLOATING_PT_LITERAL
310 * These are production names:
312 %type
<dclval
> type_dcl
313 %type
<dclval
> exception_name
314 %type
<cdclval
> constructed_type_spec enum_type op_type_spec
315 %type
<cdclval
> sequence_type_spec simple_type_spec struct_type
316 %type
<cdclval
> type_spec
317 %type
<cdclval
> fundamental_type type_arg type_or_parameter
318 %type
<dclsval
> opt_raises raises exception_list
319 %type
<attexcpval
> opt_attribute_get_raises attribute_get_raises
320 %type
<attexcpval
> opt_attribute_set_raises attribute_set_raises
321 %type
<dclsval
> opt_type_args type_args
323 %type
<sval
> identifier
324 %type
<sval
> interface_decl
325 %type
<sval
> scoped_name inheritance_spec
326 %type
<slval
> scoped_names at_least_one_scoped_name
328 %type
<etval
> const_type integer_type char_type boolean_type
329 %type
<etval
> floating_pt_type any_type signed_int string_type
330 %type
<etval
> unsigned_int base_type_spec byte_type type_type
332 %type
<exval
> expression const_expr or_expr xor_expr and_expr
333 %type
<exval
> add_expr mult_expr unary_expr primary_expr shift_expr
334 %type
<exval
> literal positive_int_expr
336 %type
<fdval
> declarator
337 %type
<dlval
> declarators at_least_one_declarator
339 %type
<ihval
> exception_header structure_header interfaceheader
341 %type
<ulval
> flag_header opt_attrflags opt_attrflag
342 %type
<ulval
> direction service_interface_header service_service_header
344 %type
<bval
> optional_inherited_interface opt_rest opt_service_body
346 %type
<attexcval
> opt_attribute_block attribute_block_rest opt_attribute_raises
348 %type
<svals
> opt_type_params type_params
357 definition definitions
362 opt_published publishable_definition
365 idlc
()->setParseState
(PS_ModuleDeclSeen
);
369 idlc
()->setParseState
(PS_NoState
);
373 yyerror("definitions");
379 IDL_PUBLISHED
{ idlc
()->setPublished
(true
); }
380 |
/* empty */ { idlc
()->setPublished
(false
); }
383 publishable_definition:
386 idlc
()->setParseState
(PS_TypeDeclSeen
);
390 idlc
()->setParseState
(PS_NoState
);
394 idlc
()->setParseState
(PS_ExceptionDeclSeen
);
398 idlc
()->setParseState
(PS_NoState
);
402 idlc
()->setParseState
(PS_InterfaceDeclSeen
);
406 idlc
()->setParseState
(PS_NoState
);
410 idlc
()->setParseState
(PS_ServiceDeclSeen
);
414 idlc
()->setParseState
(PS_NoState
);
418 idlc
()->setParseState
(PS_SingletonDeclSeen
);
422 idlc
()->setParseState
(PS_NoState
);
426 idlc
()->setParseState
(PS_ConstantsDeclSeen
);
430 idlc
()->setParseState
(PS_NoState
);
437 idlc
()->setParseState
(PS_ModuleSeen
);
438 idlc
()->setPublished
(false
);
442 idlc
()->setParseState
(PS_ModuleIDSeen
);
445 AstScope
* pScope
= idlc
()->scopes
()->topNonNull
();
446 AstModule
* pModule
= NULL
;
447 AstDeclaration
* pExists
= NULL
;
451 pModule
= new AstModule
(*$3, pScope
);
452 if
( (pExists
= pScope
->lookupForAdd
(pModule
)) )
454 pExists
->setInMainfile
(idlc
()->isInMainFile
());
455 pExists
->setFileName
(pModule
->getFileName
());
456 if
(pExists
->isPredefined
())
458 pExists
->setPredefined
(false
);
459 if
(pExists
->getDocumentation
().getLength
() == 0 &&
460 pModule
->getDocumentation
().getLength
() > 0)
462 pExists
->setDocumentation
(pModule
->getDocumentation
());
466 pModule
= (AstModule
*)pExists
;
469 pScope
->addDeclaration
(pModule
);
471 idlc
()->scopes
()->push
(pModule
);
477 idlc
()->setParseState
(PS_ModuleSqSeen
);
481 idlc
()->setParseState
(PS_ModuleBodySeen
);
485 idlc
()->setParseState
(PS_ModuleQsSeen
);
487 * Finished with this module - pop it from the scope stack
489 idlc
()->scopes
()->pop
();
501 idlc
()->setParseState
(PS_InterfaceSeen
);
505 idlc
()->setParseState
(PS_InterfaceIDSeen
);
514 idlc
()->setParseState
(PS_ForwardDeclSeen
);
516 AstScope
* pScope
= idlc
()->scopes
()->topNonNull
();
517 AstInterface
* pForward
= NULL
;
518 AstDeclaration
* pDecl
= NULL
;
521 * Make a new forward interface node and add it to its enclosing scope
525 pForward
= new AstInterface
(*$1, NULL
, pScope
);
527 pDecl
= pScope
->lookupByName
(pForward
->getScopedName
());
530 if
( (pDecl
!= pForward
) &&
531 (pDecl
->getNodeType
() == NT_interface
) )
536 idlc
()->error()->error2
(EIDL_REDEF_SCOPE
, scopeAsDecl
(pScope
), pDecl
);
541 * Add the interface to its definition scope
543 pScope
->addDeclaration
(pForward
);
553 idlc
()->setParseState
(PS_InterfaceHeadSeen
);
555 AstScope
* pScope
= idlc
()->scopes
()->topNonNull
();
556 AstInterface
* pInterface
= NULL
;
557 AstInterface
* pForward
= NULL
;
558 AstDeclaration
* pDecl
= NULL
;
561 * Make a new interface node and add it to its enclosing scope
565 pInterface
= new AstInterface
(
567 static_cast
< AstInterface
const * >(resolveTypedefs
($1->getInherits
())), pScope
);
569 (pDecl
= pScope
->lookupByName
(pInterface
->getScopedName
())) )
572 * See if we're defining a forward declared interface.
574 if
(pDecl
->getNodeType
() == NT_interface
)
576 pForward
= (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 idlc
()->error()->error3
(EIDL_SCOPE_CONFLICT
,
587 pInterface
, pForward
, scopeAsDecl
(pScope
));
590 else if
( !pInterface
->isPublished
()
591 && pForward
->isPublished
() )
593 idlc
()->error()->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 idlc
()->error()->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 idlc
()->error()->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 idlc
()->error()->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
*pType
= (AstType
*)$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
= (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 idlc
()->error()->error0
(EIDL_CONSTRUCTOR_PARAMETER_NOT_IN
);
1062 if
(pScope
->isVariadic
()) {
1063 idlc
()->error()->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 idlc
()->error()->error0
(EIDL_REST_PARAMETER_NOT_ANY
);
1073 if
(pScope
->isConstructor
()) {
1074 if
(pScope
->getIteratorBegin
()
1075 != pScope
->getIteratorEnd
())
1077 idlc
()->error()->error0
(
1078 EIDL_CONSTRUCTOR_REST_PARAMETER_NOT_FIRST
);
1081 idlc
()->error()->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 idlc
()->error()->lookupError
(*$1);
1180 } else if
(!idlc
()->error()->checkPublished
(decl
)) {
1182 } else if
(decl
->getNodeType
() != NT_exception
) {
1183 idlc
()->error()->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 idlc
()->error()->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 idlc
()->error()->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
= (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
);
1440 $1->evaluate
(EK_const
);
1441 if
( !$1->coerce
(ET_ulong
) )
1443 idlc
()->error()->coercionError
($1, ET_ulong
);
1457 AstScope
* pScope
= idlc
()->scopes
()->topNonNull
();
1458 AstDeclaration
const * type
= 0;
1461 * If the constant's type is a scoped name, it must resolve
1462 * to a scalar constant type
1464 if
( pScope
&& (type
= pScope
->lookupByName
(*$1)) ) {
1465 if
(!idlc
()->error()->checkPublished
(type
))
1472 type
= resolveTypedefs
(type
);
1473 if
(type
->getNodeType
() == NT_predefined
)
1475 $$
= static_cast
< AstBaseType
const * >(type
)->
1488 idlc
()->setParseState
(PS_ExceptSeen
);
1492 idlc
()->setParseState
(PS_ExceptIDSeen
);
1493 checkIdentifier
($3);
1497 idlc
()->setParseState
(PS_InheritSpecSeen
);
1499 $$
= new FeInheritanceHeader
(NT_exception
, $3, $5, 0);
1507 idlc
()->setParseState
(PS_ExceptHeaderSeen
);
1509 AstScope
* pScope
= idlc
()->scopes
()->topNonNull
();
1510 AstException
* pExcept
= NULL
;
1514 AstException
* pBase
= static_cast
< AstException
* >(
1516 pExcept
= new AstException
(*$1->getName
(), pBase
, pScope
);
1517 pScope
->addDeclaration
(pExcept
);
1520 * Push the scope of the exception on the scopes stack
1522 idlc
()->scopes
()->push
(pExcept
);
1527 idlc
()->setParseState
(PS_ExceptSqSeen
);
1531 idlc
()->setParseState
(PS_ExceptBodySeen
);
1535 idlc
()->setParseState
(PS_ExceptQsSeen
);
1536 /* this exception is finished, pop its scope from the stack */
1537 idlc
()->scopes
()->pop
();
1545 idlc
()->setParseState
(PS_PropertyTypeSeen
);
1547 at_least_one_declarator
1549 idlc
()->setParseState
(PS_PropertyCompleted
);
1551 AstScope
* pScope
= idlc
()->scopes
()->topNonNull
();
1552 AstAttribute
* pAttr
= NULL
;
1553 FeDeclList
* pList
= $4;
1554 FeDeclarator
* pDecl
= NULL
;
1555 AstType
const * pType
= NULL
;
1557 if
( pScope
->getScopeNodeType
() == NT_singleton
)
1559 idlc
()->error()->error0
(EIDL_ILLEGAL_ADD
);
1562 if
( ($1 & AF_ATTRIBUTE
) == AF_ATTRIBUTE
)
1563 idlc
()->error()->flagError
(EIDL_WRONGATTRIBUTEKEYWORD
, AF_ATTRIBUTE
);
1565 if
( ($1 & AF_PROPERTY
) != AF_PROPERTY
)
1566 idlc
()->error()->flagError
(EIDL_MISSINGATTRIBUTEKEYWORD
, AF_PROPERTY
);
1569 * Create nodes representing attributes and add them to the
1572 if
( pScope
&& $2 && pList
)
1574 FeDeclList
::iterator iter
= pList
->begin
();
1575 FeDeclList
::iterator end
= pList
->end
();
1586 pType
= pDecl
->compose
($2);
1594 pAttr
= new AstAttribute
(NT_property
, $1, pType
, pDecl
->getName
(), pScope
);
1596 pScope
->addDeclaration
(pAttr
);
1608 yyerror("property");
1614 service_exports service_export
1619 service_interface_header
1620 at_least_one_scoped_name
1623 idlc
()->setParseState
(PS_ServiceMemberSeen
);
1625 AstScope
* pScope
= idlc
()->scopes
()->topNonNull
();
1626 AstDeclaration
* pDecl
= NULL
;
1627 AstInterfaceMember
* pIMember
= NULL
;
1629 if
( pScope
->getScopeNodeType
() == NT_singleton
)
1631 idlc
()->error()->error0
(EIDL_ILLEGAL_ADD
);
1635 * Create a node representing a class member.
1636 * Store it in the enclosing scope
1640 StringList
::iterator iter
= $2->begin
();
1641 StringList
::iterator end
= $2->end
();
1643 while
( iter
!= end
)
1645 pDecl
= pScope
->lookupByName
(*iter
);
1646 if
( pDecl
&& (pDecl
->getNodeType
() == NT_interface
) )
1648 /* we relax the strict published check and allow to add new
1649 * interfaces if they are optional
1651 bool bOptional
= (($1 & AF_OPTIONAL
) == AF_OPTIONAL
);
1652 if
( idlc
()->error()->checkPublished
(pDecl
, bOptional
) )
1654 pIMember
= new AstInterfaceMember
(
1655 $1, (AstInterface
*)pDecl
, *iter
, pScope
);
1656 pScope
->addDeclaration
(pIMember
);
1661 lookupError
(EIDL_INTERFACEMEMBER_LOOKUP
, *iter
, scopeAsDecl
(pScope
));
1669 | service_service_header
1670 at_least_one_scoped_name
1673 idlc
()->setParseState
(PS_ServiceMemberSeen
);
1675 AstScope
* pScope
= idlc
()->scopes
()->topNonNull
();
1676 AstDeclaration
* pDecl
= NULL
;
1677 AstServiceMember
* pSMember
= NULL
;
1680 * Create a node representing a class member.
1681 * Store it in the enclosing scope
1685 StringList
::iterator iter
= $2->begin
();
1686 StringList
::iterator end
= $2->end
();
1688 while
( iter
!= end
)
1690 pDecl
= pScope
->lookupByName
(*iter
);
1691 if
( pDecl
&& (pDecl
->getNodeType
() == NT_service
) )
1693 if
( static_cast
< AstService
* >(pDecl
)->isSingleInterfaceBasedService
() ||
(pScope
->getScopeNodeType
() == NT_singleton
&& pScope
->nMembers
() > 0) )
1694 idlc
()->error()->error0
(EIDL_ILLEGAL_ADD
);
1695 else if
( idlc
()->error()->checkPublished
(pDecl
) )
1697 pSMember
= new AstServiceMember
(
1698 $1, (AstService
*)pDecl
, *iter
, pScope
);
1699 pScope
->addDeclaration
(pSMember
);
1704 lookupError
(EIDL_SERVICEMEMBER_LOOKUP
, *iter
, scopeAsDecl
(pScope
));
1712 at_least_one_scoped_name
1715 idlc
()->setParseState
(PS_ServiceMemberSeen
);
1717 AstScope
* pScope
= idlc
()->scopes
()->topNonNull
();
1718 AstDeclaration
* pDecl
= NULL
;
1719 AstObserves
* pObserves
= NULL
;
1721 if
( pScope
->getScopeNodeType
() == NT_singleton
)
1723 idlc
()->error()->error0
(EIDL_ILLEGAL_ADD
);
1727 * Create a node representing a class member.
1728 * Store it in the enclosing scope
1732 StringList
::iterator iter
= $2->begin
();
1733 StringList
::iterator end
= $2->end
();
1735 while
( iter
!= end
)
1737 pDecl
= pScope
->lookupByName
(*iter
);
1738 if
( pDecl
&& (pDecl
->getNodeType
() == NT_interface
) )
1740 pObserves
= new AstObserves
((AstInterface
*)pDecl
, *iter
, pScope
);
1741 pScope
->addDeclaration
(pObserves
);
1745 lookupError
(EIDL_INTERFACEMEMBER_LOOKUP
, *iter
, scopeAsDecl
(pScope
));
1754 at_least_one_scoped_name
1757 idlc
()->setParseState
(PS_ServiceMemberSeen
);
1759 AstScope
* pScope
= idlc
()->scopes
()->topNonNull
();
1760 AstDeclaration
* pDecl
= NULL
;
1761 AstNeeds
* pNeeds
= NULL
;
1763 if
( pScope
->getScopeNodeType
() == NT_singleton
)
1765 idlc
()->error()->error0
(EIDL_ILLEGAL_ADD
);
1769 * Create a node representing a class member.
1770 * Store it in the enclosing scope
1774 StringList
::iterator iter
= $2->begin
();
1775 StringList
::iterator end
= $2->end
();
1777 while
( iter
!= end
)
1779 pDecl
= pScope
->lookupByName
(*iter
);
1780 if
( pDecl
&& (pDecl
->getNodeType
() == NT_service
) )
1782 pNeeds
= new AstNeeds
((AstService
*)pDecl
, *iter
, pScope
);
1783 pScope
->addDeclaration
(pNeeds
);
1787 lookupError
(EIDL_SERVICEMEMBER_LOOKUP
, *iter
, scopeAsDecl
(pScope
));
1798 idlc
()->setParseState
(PS_PropertyDeclSeen
);
1802 service_interface_header
:
1805 idlc
()->setParseState
(PS_ServiceIFHeadSeen
);
1811 idlc
()->setParseState
(PS_ServiceIFHeadSeen
);
1812 if
( (AF_OPTIONAL
!= $1) && ( AF_INVALID
!= $1) )
1813 idlc
()->error()->flagError
(EIDL_OPTIONALEXPECTED
, $1);
1818 service_service_header
:
1821 idlc
()->setParseState
(PS_ServiceSHeadSeen
);
1827 idlc
()->setParseState
(PS_ServiceSHeadSeen
);
1828 if
( (AF_OPTIONAL
!= $1) && ( AF_INVALID
!= $1) )
1829 idlc
()->error()->flagError
(EIDL_OPTIONALEXPECTED
, $1);
1837 idlc
()->setParseState
(PS_ServiceSeen
);
1841 idlc
()->setParseState
(PS_ServiceIDSeen
);
1842 checkIdentifier
($3);
1844 AstScope
* pScope
= idlc
()->scopes
()->topNonNull
();
1845 AstService
* pService
= NULL
;
1848 * Make a new service and add it to the enclosing scope
1852 pService
= new AstService
(*$3, pScope
);
1853 pScope
->addDeclaration
(pService
);
1857 * Push it on the stack
1859 idlc
()->scopes
()->push
(pService
);
1863 /* this service is finished, pop its scope from the stack */
1864 idlc
()->scopes
()->pop
();
1869 service_interface_dfn
1870 | service_obsolete_dfn
1873 service_interface_dfn:
1876 AstScope
* scope
= idlc
()->scopes
()->nextToTop
();
1877 // skip the scope pushed by service_dcl
1878 AstDeclaration
* decl
= scope
->lookupByName
(*$2);
1879 if
(decl
!= 0 && resolveTypedefs
(decl
)->getNodeType
() == NT_interface
) {
1880 if
(idlc
()->error()->checkPublished
(decl
)) {
1881 idlc
()->scopes
()->top
()->addDeclaration
(decl
);
1884 idlc
()->error()->lookupError
(
1885 EIDL_INTERFACEMEMBER_LOOKUP
, *$2, scopeAsDecl
(scope
));
1891 AstService
* s
= static_cast
< AstService
* >(idlc
()->scopes
()->top
());
1893 s
->setSingleInterfaceBasedService
();
1894 s
->setDefaultConstructor
(!$4);
1900 service_body
{ $$
= true
; }
1901 |
/* empty */ { $$
= false
; }
1911 constructors constructor
1918 checkIdentifier
($1);
1919 AstScope
* scope
= idlc
()->scopes
()->top
();
1920 AstOperation
* ctor
= new AstOperation
(0, *$1, scope
);
1922 scope
->addDeclaration
(ctor
);
1923 idlc
()->scopes
()->push
(ctor
);
1930 static_cast
< AstOperation
* >(idlc
()->scopes
()->top
())->setExceptions
(
1933 idlc
()->scopes
()->pop
();
1934 if
(static_cast
< AstService
* >(idlc
()->scopes
()->top
())->
1935 checkLastConstructor
())
1937 idlc
()->error()->error0
(EIDL_SIMILAR_CONSTRUCTORS
);
1946 idlc
()->setParseState
(PS_SingletonSeen
);
1950 idlc
()->setParseState
(PS_SingletonIDSeen
);
1951 checkIdentifier
($3);
1953 AstScope
* pScope
= idlc
()->scopes
()->topNonNull
();
1954 AstService
* pService
= NULL
;
1957 * Make a new service and add it to the enclosing scope
1961 pService
= new AstService
(NT_singleton
, *$3, pScope
);
1962 pScope
->addDeclaration
(pService
);
1966 * Push it on the stack
1968 idlc
()->scopes
()->push
(pService
);
1972 /* this singelton is finished, pop its scope from the stack */
1973 idlc
()->scopes
()->pop
();
1978 singleton_interface_dfn
1979 | service_obsolete_dfn
1982 singleton_interface_dfn:
1985 AstScope
* scope
= idlc
()->scopes
()->nextToTop
();
1986 // skip the scope (needlessly) pushed by singleton_dcl
1987 AstDeclaration
* decl
= scope
->lookupByName
(*$2);
1988 if
(decl
!= 0 && resolveTypedefs
(decl
)->getNodeType
() == NT_interface
) {
1989 if
(idlc
()->error()->checkPublished
(decl
)) {
1990 idlc
()->scopes
()->top
()->addDeclaration
(decl
);
1993 idlc
()->error()->lookupError
(
1994 EIDL_INTERFACEMEMBER_LOOKUP
, *$2, scopeAsDecl
(scope
));
2000 service_obsolete_dfn:
2003 idlc
()->setParseState
(
2004 idlc
()->scopes
()->top
()->getScopeNodeType
() == NT_service
2005 ? PS_ServiceSqSeen
: PS_SingletonSqSeen
);
2009 idlc
()->setParseState
(
2010 idlc
()->scopes
()->top
()->getScopeNodeType
() == NT_service
2011 ? PS_ServiceBodySeen
: PS_SingletonBodySeen
);
2015 idlc
()->setParseState
(
2016 idlc
()->scopes
()->top
()->getScopeNodeType
() == NT_service
2017 ? PS_ServiceQsSeen
: PS_SingletonQsSeen
);
2024 idlc
()->setParseState
(PS_TypedefSeen
);
2034 idlc
()->setParseState
(PS_TypeSpecSeen
);
2035 if
($1 != 0 && $1->getNodeType
() == NT_instantiated_struct
) {
2036 idlc
()->error()->error0
(EIDL_INSTANTIATED_STRUCT_TYPE_TYPEDEF
);
2039 at_least_one_declarator
2041 idlc
()->setParseState
(PS_DeclaratorsSeen
);
2043 AstScope
* pScope
= idlc
()->scopes
()->topNonNull
();
2044 AstTypeDef
* pTypeDef
= NULL
;
2045 FeDeclList
* pList
= $3;
2046 FeDeclarator
* pDecl
= NULL
;
2047 AstType
const * pType
= NULL
;
2050 * Create nodes representing typedefs and add them to the
2053 if
( pScope
&& $1 && pList
)
2055 FeDeclList
::iterator iter
= pList
->begin
();
2056 FeDeclList
::iterator end
= pList
->end
();
2067 pType
= pDecl
->compose
($1);
2075 pTypeDef
= new AstTypeDef
(pType
, pDecl
->getName
(), pScope
);
2077 pScope
->addDeclaration
(pTypeDef
);
2086 at_least_one_declarator
:
2087 declarator declarators
2095 FeDeclList
* pList
= new FeDeclList
();
2096 pList
->push_back
($1);
2106 idlc
()->setParseState
(PS_DeclsCommaSeen
);
2110 idlc
()->setParseState
(PS_DeclsDeclSeen
);
2117 FeDeclList
* pList
= new FeDeclList
();
2118 pList
->push_back
($4);
2131 // For historic reasons, the struct com.sun.star.uno.Uik contains
2132 // members with illegal names (of the form "m_DataN"); avoid useless
2133 // warnings about them:
2134 AstScope
* scope
= idlc
()->scopes
()->top
();
2135 if
(scope
== 0 || scope
->getScopeNodeType
() != NT_struct
2136 ||
(scopeAsDecl
(scope
)->getScopedName
()
2137 != "com::sun::star::uno::Uik"))
2139 checkIdentifier
($1);
2142 $$
= new FeDeclarator
(*$1, FeDeclarator
::FD_simple
, NULL
);
2147 at_least_one_scoped_name
:
2148 scoped_name scoped_names
2152 $2->push_front
(*$1);
2156 StringList
* pNames
= new StringList
();
2157 pNames
->push_back
(*$1);
2168 idlc
()->setParseState
(PS_SNListCommaSeen
);
2172 idlc
()->setParseState
(PS_ScopedNameSeen
);
2179 StringList
* pNames
= new StringList
();
2180 pNames
->push_back
(*$4);
2194 idlc
()->setParseState
(PS_SN_IDSeen
);
2195 checkIdentifier
($1);
2198 | IDL_SCOPESEPARATOR
2200 idlc
()->setParseState
(PS_ScopeDelimSeen
);
2204 checkIdentifier
($3);
2205 OString
* pName
= new OString
("::");
2216 checkIdentifier
($4);
2217 *$1 += ::rtl
::OString
("::");
2226 | constructed_type_spec
2231 | scoped_name opt_type_args
2233 $$
= createNamedType
($1, $2);
2240 $$
= idlc
()->scopes
()->bottom
()->lookupPrimitiveType
($1);
2242 | sequence_type_spec
2246 '<' type_args
'>' { $$
= $2; }
2247 |
/* empty */ { $$
= 0; }
2254 $$
->push_back
(const_cast
< AstDeclaration
* >($1)); //TODO: const_cast
2256 | type_args
',' type_arg
2258 $1->push_back
(const_cast
< AstDeclaration
* >($3)); //TODO: const_cast
2266 if
($1 != 0 && static_cast
< AstType
const * >($1)->isUnsigned
()) {
2267 idlc
()->error()->error0
(EIDL_UNSIGNED_TYPE_ARGUMENT
);
2305 IDL_UNSIGNED IDL_LONG
2309 | IDL_UNSIGNED IDL_HYPER
2313 | IDL_UNSIGNED IDL_SHORT
2372 constructed_type_spec
:
2377 sequence_type_spec
:
2380 idlc
()->setParseState
(PS_SequenceSeen
);
2382 * Push a sequence marker on scopes stack
2384 idlc
()->scopes
()->push
(NULL
);
2388 idlc
()->setParseState
(PS_SequenceSqSeen
);
2392 idlc
()->setParseState
(PS_SequenceTypeSeen
);
2396 idlc
()->setParseState
(PS_SequenceQsSeen
);
2398 * Remove sequence marker from scopes stack
2400 if
(idlc
()->scopes
()->top
() == NULL
)
2401 idlc
()->scopes
()->pop
();
2403 * Create a node representing a sequence
2405 AstScope
* pScope
= idlc
()->scopes
()->bottom
();
2406 AstDeclaration
* pDecl
= NULL
;
2407 AstDeclaration
* pSeq
= NULL
;
2411 AstType
*pType
= (AstType
*)$5;
2414 pSeq
= new AstSequence
(pType
, pScope
);
2416 * Add this AstSequence to the types defined in the global scope
2418 pDecl
= pScope
->addDeclaration
(pSeq
);
2419 if
( pSeq
!= pDecl
)
2421 // if sequence type already defined then use it
2431 yyerror("sequence declaration");
2440 idlc
()->setParseState
(PS_StructHeaderSeen
);
2442 AstScope
* pScope
= idlc
()->scopes
()->topNonNull
();
2443 AstStruct
* pStruct
= NULL
;
2447 AstStruct
const* pBase
= static_cast
< AstStruct
const* >(resolveTypedefs
($1->getInherits
()));
2448 pStruct
= new AstStruct
(
2449 *$1->getName
(), $1->getTypeParameters
(), pBase
, pScope
);
2450 pScope
->addDeclaration
(pStruct
);
2453 * Push the scope of the struct on the scopes stack
2455 idlc
()->scopes
()->push
(pStruct
);
2460 idlc
()->setParseState
(PS_StructSqSeen
);
2464 idlc
()->setParseState
(PS_StructBodySeen
);
2468 idlc
()->setParseState
(PS_StructQsSeen
);
2469 /* this exception is finished, pop its scope from the stack */
2470 idlc
()->scopes
()->pop
();
2477 idlc
()->setParseState
(PS_StructSeen
);
2481 idlc
()->setParseState
(PS_StructIDSeen
);
2482 checkIdentifier
($3);
2487 idlc
()->setParseState
(PS_InheritSpecSeen
);
2489 // Polymorphic struct type templates with base types would cause various
2490 // problems in language bindings, so forbid them here. For example,
2491 // GCC prior to version 3.4 fails with code like
2493 // struct Base { ... };
2494 // template< typename typeparam_T > struct Derived: public Base {
2495 // int member1 CPPU_GCC3_ALIGN(Base);
2498 // (Note that plain struct types with instantiated polymorphic struct
2499 // type bases, which might also cause problems in language bindings, are
2500 // already rejected on a syntactic level.)
2501 if
($5 != 0 && $6 != 0) {
2502 idlc
()->error()->error0
(EIDL_STRUCT_TYPE_TEMPLATE_WITH_BASE
);
2505 $$
= new FeInheritanceHeader
(NT_struct
, $3, $6, $5);
2512 '<' type_params
'>' { $$
= $2; }
2513 |
/* empty */ { $$
= 0; }
2519 $$
= new std
::vector
< rtl
::OString
>;
2523 | type_params
',' identifier
2525 if
(std
::find
($1->begin
(), $1->end
(), *$3) != $1->end
()) {
2526 idlc
()->error()->error0
(EIDL_IDENTICAL_TYPE_PARAMETERS
);
2534 at_least_one_member
: member members
;
2544 idlc
()->setParseState
(PS_MemberTypeSeen
);
2546 at_least_one_declarator
2548 idlc
()->setParseState
(PS_MemberDeclsSeen
);
2552 idlc
()->setParseState
(PS_MemberDeclsCompleted
);
2554 AstScope
* pScope
= idlc
()->scopes
()->topNonNull
();
2555 AstMember
* pMember
= NULL
;
2556 FeDeclList
* pList
= $3;
2557 FeDeclarator
* pDecl
= NULL
;
2558 AstType
const * pType
= NULL
;
2560 // !!! check recursive type
2562 if
( pScope
&& pList
&& $1 )
2564 FeDeclList
::iterator iter
= pList
->begin
();
2565 FeDeclList
::iterator end
= pList
->end
();
2575 pType
= pDecl
->compose
($1);
2583 pMember
= new AstMember
(pType
, pDecl
->getName
(), pScope
);
2585 if
( !pDecl
->checkType
($1) )
2590 pScope
->addDeclaration
(pMember
);
2599 yyerror("member definition");
2606 | scoped_name opt_type_args
2608 AstDeclaration
const * decl
= 0;
2609 AstStruct
* scope
= static_cast
< AstStruct
* >(idlc
()->scopes
()->top
());
2610 if
(scope
!= 0 && $2 == 0) {
2611 decl
= scope
->findTypeParameter
(*$1);
2617 decl
= createNamedType
($1, $2);
2618 if
(scope
!= 0 && includes
(decl
, scopeAsDecl
(scope
))) {
2619 idlc
()->error()->error1
(
2620 EIDL_RECURSIVE_TYPE
, scopeAsDecl
(scope
));
2631 idlc
()->setParseState
(PS_EnumSeen
);
2635 idlc
()->setParseState
(PS_EnumIDSeen
);
2636 checkIdentifier
($3);
2638 AstScope
* pScope
= idlc
()->scopes
()->topNonNull
();
2639 AstEnum
* pEnum
= NULL
;
2642 * Create a node representing an enum and add it to its
2647 pEnum
= new AstEnum
(*$3, pScope
);
2649 * Add it to its defining scope
2651 pScope
->addDeclaration
(pEnum
);
2655 * Push the enum scope on the scopes stack
2657 idlc
()->scopes
()->push
(pEnum
);
2662 idlc
()->setParseState
(PS_EnumSqSeen
);
2664 at_least_one_enumerator
2666 idlc
()->setParseState
(PS_EnumBodySeen
);
2670 idlc
()->setParseState
(PS_EnumQsSeen
);
2672 * Done with this enum. Pop its scope from the scopes stack
2674 if
(idlc
()->scopes
()->top
() == NULL
)
2678 $$
= (AstEnum
*)idlc
()->scopes
()->topNonNull
();
2679 idlc
()->scopes
()->pop
();
2684 at_least_one_enumerator
: enumerator enumerators
;
2690 idlc
()->setParseState
(PS_EnumCommaSeen
);
2696 yyerror("enumerator definition");
2704 checkIdentifier
($1);
2706 AstScope
* pScope
= idlc
()->scopes
()->topNonNull
();
2707 AstEnum
* pEnum
= NULL
;
2708 AstConstant
* pEnumVal
= NULL
;
2710 if
( pScope
&& pScope
->getScopeNodeType
() == NT_enum
)
2712 pEnum
= (AstEnum
*)pScope
;
2715 AstExpression
* pExpr
= new AstExpression
(pEnum
->getEnumValueCount
());
2716 pEnumVal
= new AstConstant
(ET_long
, NT_enum_val
,
2717 pExpr
, *$1, pScope
);
2719 if
( pEnum
->checkValue
(pEnumVal
->getConstValue
()) )
2720 idlc
()->error()->error1
(EIDL_EVAL_ERROR
, pEnum
);
2722 pScope
->addDeclaration
(pEnumVal
);
2730 checkIdentifier
($1);
2732 AstScope
* pScope
= idlc
()->scopes
()->topNonNull
();
2733 AstEnum
* pEnum
= NULL
;
2734 AstConstant
* pEnumVal
= NULL
;
2736 if
( $3 && pScope
&& pScope
->getScopeNodeType
() == NT_enum
)
2738 $3->evaluate
(EK_const
);
2739 if
( $3->coerce
(ET_long
) )
2741 pEnum
= (AstEnum
*)pScope
;
2744 pEnumVal
= new AstConstant
(ET_long
, NT_enum_val
,
2747 if
( pEnum
->checkValue
(pEnumVal
->getConstValue
()) )
2748 idlc
()->error()->error1
(EIDL_EVAL_ERROR
, pEnum
);
2750 pScope
->addDeclaration
(pEnumVal
);
2753 idlc
()->error()->coercionError
($3, ET_long
);
2763 | IDL_GET
{ $$
= new OString
("get"); }
2764 | IDL_SET
{ $$
= new OString
("set"); }
2765 | IDL_PUBLISHED
{ $$
= new OString
("published"); }
2771 * Report an error situation discovered in a production
2773 void yyerror(char const *errmsg
)
2775 idlc
()->error()->syntaxError
(idlc
()->getParseState
(), idlc
()->getLineNumber
(), errmsg
);
2776 idlc
()->setParseState
(PS_NoState
);
2779 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */