Branch data Line data Source code
1 : : /*
2 : : * This file is part of the LibreOffice project.
3 : : *
4 : : * This Source Code Form is subject to the terms of the Mozilla Public
5 : : * License, v. 2.0. If a copy of the MPL was not distributed with this
6 : : * file, You can obtain one at http://mozilla.org/MPL/2.0/.
7 : : *
8 : : * This file incorporates work covered by the following license notice:
9 : : *
10 : : * Licensed to the Apache Software Foundation (ASF) under one or more
11 : : * contributor license agreements. See the NOTICE file distributed
12 : : * with this work for additional information regarding copyright
13 : : * ownership. The ASF licenses this file to you under the Apache
14 : : * License, Version 2.0 (the "License"); you may not use this file
15 : : * except in compliance with the License. You may obtain a copy of
16 : : * the License at http://www.apache.org/licenses/LICENSE-2.0 .
17 : : */
18 : :
19 : : /*
20 : : * parser.yy - BISON grammar for IDLC 1.0
21 : : */
22 : :
23 : : %{
24 : : #include <string.h>
25 : :
26 : : #ifndef _IDLC_IDLC_HXX_
27 : : #include <idlc/idlc.hxx>
28 : : #endif
29 : : #ifndef _IDLC_ERRORHANDLER_HXX_
30 : : #include <idlc/errorhandler.hxx>
31 : : #endif
32 : : #ifndef _IDLC_FEHELPER_HXX_
33 : : #include <idlc/fehelper.hxx>
34 : : #endif
35 : : #ifndef _IDLC_EXPRESSION_HXX_
36 : : #include <idlc/astexpression.hxx>
37 : : #endif
38 : : #ifndef _IDLC_ASTCONSTANTS_HXX_
39 : : #include <idlc/astconstants.hxx>
40 : : #endif
41 : : #ifndef _IDLC_ASTCONSTANT_HXX_
42 : : #include <idlc/astconstant.hxx>
43 : : #endif
44 : : #ifndef _IDLC_ASTARRAY_HXX_
45 : : #include <idlc/astarray.hxx>
46 : : #endif
47 : : #ifndef _IDLC_ASTBASETYPE_HXX_
48 : : #include <idlc/astbasetype.hxx>
49 : : #endif
50 : : #ifndef _IDLC_ASTTYPEDEF_HXX_
51 : : #include <idlc/asttypedef.hxx>
52 : : #endif
53 : : #ifndef _IDLC_ASTEXCEPTION_HXX_
54 : : #include <idlc/astexception.hxx>
55 : : #endif
56 : : #ifndef _IDLC_ASTMEMBER_HXX_
57 : : #include <idlc/astmember.hxx>
58 : : #endif
59 : : #ifndef _IDLC_ASTENUM_HXX_
60 : : #include <idlc/astenum.hxx>
61 : : #endif
62 : : #ifndef _IDLC_ASTSEQUENCE_HXX_
63 : : #include <idlc/astsequence.hxx>
64 : : #endif
65 : : #ifndef _IDLC_ASTATTRIBUTE_HXX_
66 : : #include <idlc/astattribute.hxx>
67 : : #endif
68 : : #ifndef _IDLC_ASTOPERATION_HXX_
69 : : #include <idlc/astoperation.hxx>
70 : : #endif
71 : : #ifndef _IDLC_ASTPARAMETER_HXX_
72 : : #include <idlc/astparameter.hxx>
73 : : #endif
74 : : #ifndef _IDLC_ASTINTERFACEMEMBER_HXX_
75 : : #include <idlc/astinterfacemember.hxx>
76 : : #endif
77 : : #ifndef _IDLC_ASTSERVICEMEMBER_HXX_
78 : : #include <idlc/astservicemember.hxx>
79 : : #endif
80 : : #ifndef _IDLC_ASTOBSERVES_HXX_
81 : : #include <idlc/astobserves.hxx>
82 : : #endif
83 : : #ifndef _IDLC_ASTNEEDS_HXX_
84 : : #include <idlc/astneeds.hxx>
85 : : #endif
86 : : #ifndef _IDLC_ASTUNION_HXX_
87 : : #include <idlc/astunion.hxx>
88 : : #endif
89 : : #include "idlc/aststructinstance.hxx"
90 : :
91 : : #include "attributeexceptions.hxx"
92 : :
93 : : #include "rtl/strbuf.hxx"
94 : :
95 : : #include <algorithm>
96 : : #include <vector>
97 : :
98 : :
99 : : #define YYDEBUG 1
100 : : #if !(defined MACOSX && defined PPC)
101 : : #define YYERROR_VERBOSE 1
102 : : #endif
103 : :
104 : : using ::rtl::OUString;
105 : : using ::rtl::OString;
106 : : using ::rtl::OStringToOUString;
107 : : using ::rtl::OStringBuffer;
108 : :
109 : : extern int yylex(void);
110 : : void yyerror(char const *);
111 : :
112 : 1505139 : void checkIdentifier(::rtl::OString* id)
113 : : {
114 : : static short check = 0;
115 [ + + ]: 1505139 : if (check == 0) {
116 [ + - ][ + - ]: 166 : if (idlc()->getOptions()->isValid("-cid"))
[ + + ]
117 : 1 : check = 1;
118 : : else
119 : 165 : check = 2;
120 : : }
121 : :
122 [ + + ]: 1505139 : if ( id->indexOf('_') >= 0 )
123 [ + + ][ - + ]: 24720 : if ( (id->pData->buffer[0] >= 97 && id->pData->buffer[0] <= 122)
[ + + ]
124 : 24121 : || id->pData->buffer[0] == '_') {
125 [ - + ]: 762 : if (check == 1) {
126 : 0 : ::rtl::OStringBuffer msg(25 + id->getLength());
127 [ # # ]: 0 : msg.append("mismatched identifier '");
128 [ # # ]: 0 : msg.append(*id);
129 [ # # ]: 0 : msg.append("'");
130 : : idlc()->error()->syntaxError(idlc()->getParseState(),
131 [ # # ]: 0 : idlc()->getLineNumber(),
132 [ # # ][ # # ]: 0 : msg.getStr());
[ # # ]
133 : : }
134 : : else
135 : 762 : idlc()->error()->warning0(WIDL_WRONG_NAMING_CONV, id->getStr());
136 : : }
137 : 1505139 : }
138 : :
139 : 0 : void reportDoubleMemberDeclarations(
140 : : AstInterface::DoubleMemberDeclarations const & doubleMembers)
141 : : {
142 [ # # ][ # # ]: 0 : for (AstInterface::DoubleMemberDeclarations::const_iterator i(
143 : 0 : doubleMembers.begin());
144 : 0 : i != doubleMembers.end(); ++i)
145 : : {
146 [ # # ][ # # ]: 0 : idlc()->error()->error2(EIDL_DOUBLE_MEMBER, i->first, i->second);
147 : : }
148 : 0 : }
149 : :
150 : 2117 : void addInheritedInterface(
151 : : AstInterface * ifc, rtl::OString const & name, bool optional,
152 : : rtl::OUString const & documentation)
153 : : {
154 : 2117 : AstDeclaration * decl = ifc->lookupByName(name);
155 : 2117 : AstDeclaration const * resolved = resolveTypedefs(decl);
156 [ + - ][ + - ]: 2117 : if (resolved != 0 && resolved->getNodeType() == NT_interface) {
[ + - ]
157 [ + - ]: 2117 : if (idlc()->error()->checkPublished(decl)) {
158 [ - + ]: 2117 : if (!static_cast< AstInterface const * >(resolved)->isDefined()) {
159 : : idlc()->error()->inheritanceError(
160 : 0 : NT_interface, &ifc->getScopedName(), decl);
161 : : } else {
162 : : AstInterface::DoubleDeclarations doubleDecls(
163 : : ifc->checkInheritedInterfaceClashes(
164 : : static_cast< AstInterface const * >(resolved),
165 [ + - ]: 2117 : optional));
166 [ + - + - ]: 4234 : if (doubleDecls.interfaces.empty()
[ + - ]
167 : 2117 : && doubleDecls.members.empty())
168 : : {
169 : : ifc->addInheritedInterface(
170 : : static_cast< AstType * >(decl), optional,
171 [ + - ]: 2117 : documentation);
172 : : } else {
173 [ # # ][ # # ]: 0 : for (AstInterface::DoubleInterfaceDeclarations::iterator i(
174 : 0 : doubleDecls.interfaces.begin());
175 : 0 : i != doubleDecls.interfaces.end(); ++i)
176 : : {
177 : : idlc()->error()->error1(
178 [ # # ][ # # ]: 0 : EIDL_DOUBLE_INHERITANCE, *i);
179 : : }
180 [ # # ]: 0 : reportDoubleMemberDeclarations(doubleDecls.members);
181 : 2117 : }
182 : : }
183 : : }
184 : : } else {
185 : : idlc()->error()->lookupError(
186 [ # # ]: 0 : EIDL_INTERFACEMEMBER_LOOKUP, name, scopeAsDecl(ifc));
187 : : }
188 : 2117 : }
189 : :
190 : 90942 : AstDeclaration const * createNamedType(
191 : : rtl::OString const * scopedName, DeclList const * typeArgs)
192 : : {
193 : : AstDeclaration * decl = idlc()->scopes()->topNonNull()->lookupByName(
194 : 90942 : *scopedName);
195 : 90942 : AstDeclaration const * resolved = resolveTypedefs(decl);
196 [ - + ]: 90942 : if (decl == 0) {
197 : 0 : idlc()->error()->lookupError(*scopedName);
198 [ - + ]: 90942 : } else if (!idlc()->error()->checkPublished(decl)) {
199 : 0 : decl = 0;
200 [ + + ]: 90942 : } else if (resolved->getNodeType() == NT_struct) {
201 [ + + ][ - + ]: 25234 : if (static_cast< AstStruct const * >(resolved)->getTypeParameterCount()
202 : : != (typeArgs == 0 ? 0 : typeArgs->size()))
203 : : {
204 : 0 : idlc()->error()->error0(EIDL_WRONG_NUMBER_OF_TYPE_ARGUMENTS);
205 : 0 : decl = 0;
206 [ + + ]: 25234 : } else if (typeArgs != 0) {
207 : 159 : AstScope * global = idlc()->scopes()->bottom();
208 : : AstDeclaration * inst = new AstStructInstance(
209 [ + - ]: 159 : static_cast< AstType * >(decl), typeArgs, global);
210 : 159 : decl = global->addDeclaration(inst);
211 [ + + ]: 159 : if (decl != inst) {
212 [ + - ]: 64 : delete inst;
213 : : }
214 : : }
215 [ + - ]: 65708 : } else if (decl->isType()) {
216 [ - + ]: 65708 : if (typeArgs != 0) {
217 : 0 : idlc()->error()->error0(EIDL_WRONG_NUMBER_OF_TYPE_ARGUMENTS);
218 : 0 : decl = 0;
219 : : }
220 : : } else {
221 : 0 : idlc()->error()->noTypeError(decl);
222 : 0 : decl = 0;
223 : : }
224 [ + - ]: 90942 : delete scopedName;
225 [ + + ]: 90942 : delete typeArgs;
226 : 90942 : return decl;
227 : : }
228 : :
229 : 9864 : bool includes(AstDeclaration const * type1, AstDeclaration const * type2) {
230 : : OSL_ASSERT(type2 != 0);
231 [ + - ]: 9864 : if (type1 != 0) {
232 [ + + ]: 9864 : if (type1->getNodeType() == NT_instantiated_struct) {
233 : : AstStructInstance const * inst
234 : 6 : = static_cast< AstStructInstance const * >(type1);
235 [ - + ]: 6 : if (inst->getTypeTemplate() == type2) {
236 : 0 : return true;
237 : : }
238 [ + + ]: 28 : for (DeclList::const_iterator i(inst->getTypeArgumentsBegin());
239 : 14 : i != inst->getTypeArgumentsEnd(); ++i)
240 : : {
241 [ + - ][ - + ]: 8 : if (includes(*i, type2)) {
242 : 0 : return true;
243 : : }
244 : : }
245 [ - + ]: 9858 : } else if (type1 == type2) {
246 : 0 : return true;
247 : : }
248 : : }
249 : 9864 : return false;
250 : : }
251 : :
252 : : // Suppress any warnings from generated code:
253 : : #if defined __SUNPRO_CC
254 : : #pragma disable_warn
255 : : #elif defined _MSC_VER
256 : : #pragma warning(push, 1)
257 : : #pragma warning(disable: 4273 4701 4702 4706)
258 : : #endif
259 : : %}
260 : : /*
261 : : * Declare the type of values in the grammar
262 : : */
263 : : %union {
264 : : ExprType etval; /* Expression type */
265 : : AstDeclaration* dclval; /* Declaration */
266 : : AstDeclaration const * cdclval;
267 : : DeclList * dclsval;
268 : : AstExpression* exval; /* expression value */
269 : : ExprList* exlval; /* expression list value */
270 : : FeDeclarator* fdval; /* declarator value */
271 : : FeDeclList* dlval; /* declarator list value */
272 : : FeInheritanceHeader* ihval; /* inheritance header value */
273 : : ::rtl::OString* sval; /* OString value */
274 : : std::vector< rtl::OString > * svals;
275 : : sal_Char* strval; /* sal_Char* value */
276 : : sal_Bool bval; /* sal_Boolean* value */
277 : : sal_Int64 ival; /* sal_Int64 value */
278 : : sal_uInt64 uval; /* sal_uInt64 value */
279 : : sal_uInt32 ulval; /* sal_uInt32 value */
280 : : double dval; /* double value */
281 : : float fval; /* float value */
282 : : StringList* slval; /* StringList value */
283 : : LabelList* llval; /* LabelList value */
284 : : AstUnionLabel* lbval; /* union label value */
285 : : AstMember* mval; /* member value */
286 : : AttributeExceptions::Part attexcpval;
287 : : AttributeExceptions attexcval;
288 : : }
289 : :
290 : : /*
291 : : * Token types: These are returned by the lexer
292 : : */
293 : :
294 : : %token <sval> IDL_IDENTIFIER
295 : : %token IDL_ATTRIBUTE
296 : : %token IDL_BOUND
297 : : %token IDL_CASE
298 : : %token IDL_CONST
299 : : %token IDL_CONSTANTS
300 : : %token IDL_CONSTRAINED
301 : : %token IDL_DEFAULT
302 : : %token IDL_ENUM
303 : : %token IDL_EXCEPTION
304 : : %token IDL_INTERFACE
305 : : %token IDL_MAYBEAMBIGUOUS
306 : : %token IDL_MAYBEDEFAULT
307 : : %token IDL_MAYBEVOID
308 : : %token IDL_MODULE
309 : : %token IDL_NEEDS
310 : : %token IDL_OBSERVES
311 : : %token IDL_OPTIONAL
312 : : %token IDL_PROPERTY
313 : : %token IDL_RAISES
314 : : %token IDL_READONLY
315 : : %token IDL_REMOVEABLE
316 : : %token IDL_SERVICE
317 : : %token IDL_SEQUENCE
318 : : %token IDL_SINGLETON
319 : : %token IDL_STRUCT
320 : : %token IDL_SWITCH
321 : : %token IDL_TYPEDEF
322 : : %token IDL_TRANSIENT
323 : : %token IDL_UNION
324 : :
325 : : %token IDL_ANY
326 : : %token IDL_CHAR
327 : : %token IDL_BOOLEAN
328 : : %token IDL_BYTE
329 : : %token IDL_DOUBLE
330 : : %token IDL_FLOAT
331 : : %token IDL_HYPER
332 : : %token IDL_LONG
333 : : %token IDL_SHORT
334 : : %token IDL_VOID
335 : : %token IDL_STRING
336 : : %token IDL_TYPE
337 : : %token IDL_UNSIGNED
338 : :
339 : : %token IDL_TRUE
340 : : %token IDL_FALSE
341 : :
342 : : %token IDL_IN
343 : : %token IDL_OUT
344 : : %token IDL_INOUT
345 : : %token IDL_ONEWAY
346 : :
347 : : %token IDL_GET
348 : : %token IDL_SET
349 : :
350 : : %token IDL_PUBLISHED
351 : :
352 : : %token IDL_ELLIPSIS
353 : :
354 : : %token <strval> IDL_LEFTSHIFT
355 : : %token <strval> IDL_RIGHTSHIFT
356 : : %token <strval> IDL_SCOPESEPARATOR
357 : :
358 : : %token <ival> IDL_INTEGER_LITERAL
359 : : %token <uval> IDL_INTEGER_ULITERAL
360 : : %token <dval> IDL_FLOATING_PT_LITERAL
361 : :
362 : : /*
363 : : * These are production names:
364 : : */
365 : : %type <dclval> type_dcl const_dcl
366 : : %type <dclval> array_declarator
367 : : %type <dclval> exception_name
368 : : %type <cdclval> array_type constructed_type_spec enum_type op_type_spec
369 : : %type <cdclval> sequence_type_spec simple_type_spec struct_type switch_type_spec
370 : : %type <cdclval> template_type_spec type_spec union_type
371 : : %type <cdclval> fundamental_type type_arg type_or_parameter
372 : : %type <dclsval> opt_raises raises exception_list
373 : : %type <attexcpval> opt_attribute_get_raises attribute_get_raises
374 : : %type <attexcpval> opt_attribute_set_raises attribute_set_raises
375 : : %type <dclsval> opt_type_args type_args
376 : :
377 : : %type <sval> identifier
378 : : %type <sval> interface_decl
379 : : %type <sval> scoped_name inheritance_spec
380 : : %type <slval> scoped_names at_least_one_scoped_name
381 : :
382 : : %type <etval> const_type integer_type char_type boolean_type
383 : : %type <etval> floating_pt_type any_type signed_int string_type
384 : : %type <etval> unsigned_int base_type_spec byte_type type_type
385 : :
386 : : %type <exval> expression const_expr or_expr xor_expr and_expr
387 : : %type <exval> add_expr mult_expr unary_expr primary_expr shift_expr
388 : : %type <exval> literal positive_int_expr array_dim
389 : :
390 : : %type <exlval> at_least_one_array_dim array_dims
391 : :
392 : : %type <fdval> declarator simple_declarator complex_declarator
393 : : %type <dlval> declarators at_least_one_declarator
394 : :
395 : : %type <ihval> exception_header structure_header interfaceheader
396 : :
397 : : %type <ulval> flag_header opt_attrflags opt_attrflag operation_head
398 : : %type <ulval> direction service_interface_header service_service_header
399 : :
400 : : %type <llval> case_labels at_least_one_case_label
401 : : %type <lbval> case_label
402 : : %type <mval> element_spec
403 : :
404 : : %type <bval> optional_inherited_interface opt_rest opt_service_body
405 : :
406 : : %type <attexcval> opt_attribute_block attribute_block_rest opt_attribute_raises
407 : :
408 : : %type <svals> opt_type_params type_params
409 : :
410 : : %%
411 : : /*
412 : : * Grammar start here
413 : : */
414 : : start : definitions;
415 : :
416 : : definitions :
417 : : definition definitions
418 : : | /* EMPTY */
419 : : ;
420 : :
421 : : definition :
422 : : opt_published publishable_definition
423 : : | module_dcl
424 : : {
425 [ + - ]: 277946 : idlc()->setParseState(PS_ModuleDeclSeen);
426 : : }
427 : 277946 : ';'
428 : : {
429 [ + - ]: 277946 : idlc()->setParseState(PS_NoState);
430 : : }
431 : 277946 : | error ';'
432 : : {
433 [ # # ]: 0 : yyerror("definitions");
434 : 0 : yyerrok;
435 : : }
436 : 0 : ;
437 : :
438 : : opt_published:
439 [ + - ]: 70947 : IDL_PUBLISHED { idlc()->setPublished(true); }
440 [ + - ]: 79599 : | /* empty */ { idlc()->setPublished(false); }
441 : 8652 : ;
442 : :
443 : : publishable_definition:
444 : : type_dcl
445 : : {
446 [ + - ]: 20374 : idlc()->setParseState(PS_TypeDeclSeen);
447 : : }
448 : 20374 : ';'
449 : : {
450 [ + - ]: 20374 : idlc()->setParseState(PS_NoState);
451 : : }
452 : 20374 : | const_dcl
453 : : {
454 [ # # ]: 0 : idlc()->setParseState(PS_ConstantDeclSeen);
455 : : }
456 : 0 : ';'
457 : : {
458 [ # # ]: 0 : idlc()->setParseState(PS_NoState);
459 : : }
460 : 0 : | exception_dcl
461 : : {
462 [ + - ]: 13137 : idlc()->setParseState(PS_ExceptionDeclSeen);
463 : : }
464 : 13137 : ';'
465 : : {
466 [ + - ]: 13137 : idlc()->setParseState(PS_NoState);
467 : : }
468 : 13137 : | interface
469 : : {
470 [ + - ]: 40496 : idlc()->setParseState(PS_InterfaceDeclSeen);
471 : : }
472 : 40496 : ';'
473 : : {
474 [ + - ]: 40496 : idlc()->setParseState(PS_NoState);
475 : : }
476 : 40496 : | service_dcl
477 : : {
478 [ + - ]: 3797 : idlc()->setParseState(PS_ServiceDeclSeen);
479 : : }
480 : 3797 : ';'
481 : : {
482 [ + - ]: 3797 : idlc()->setParseState(PS_NoState);
483 : : }
484 : 3797 : | singleton_dcl
485 : : {
486 [ + - ]: 163 : idlc()->setParseState(PS_SingletonDeclSeen);
487 : : }
488 : 163 : ';'
489 : : {
490 [ + - ]: 163 : idlc()->setParseState(PS_NoState);
491 : : }
492 : 163 : | constants_dcl
493 : : {
494 [ + - ]: 1632 : idlc()->setParseState(PS_ConstantsDeclSeen);
495 : : }
496 : 1632 : ';'
497 : : {
498 [ + - ]: 1632 : idlc()->setParseState(PS_NoState);
499 : : }
500 : 1632 : ;
501 : :
502 : : module_dcl :
503 : : IDL_MODULE
504 : : {
505 [ + - ]: 277946 : idlc()->setParseState(PS_ModuleSeen);
506 [ + - ]: 277946 : idlc()->setPublished(false);
507 : : }
508 : 277946 : identifier
509 : : {
510 [ + - ]: 277946 : idlc()->setParseState(PS_ModuleIDSeen);
511 [ + - ]: 277946 : checkIdentifier($3);
512 : :
513 [ + - ][ + - ]: 277946 : AstScope* pScope = idlc()->scopes()->topNonNull();
514 : 277946 : AstModule* pModule = NULL;
515 : 277946 : AstDeclaration* pExists = NULL;
516 : :
517 [ + - ]: 277946 : if ( pScope )
518 : : {
519 [ + - ][ + - ]: 277946 : pModule = new AstModule(*$3, pScope);
520 [ + - ][ + + ]: 277946 : if( (pExists = pScope->lookupForAdd(pModule)) )
521 : : {
522 [ + - ]: 239003 : pExists->setInMainfile(idlc()->isInMainFile());
523 : 239003 : pExists->setFileName(pModule->getFileName());
524 [ + + ]: 239003 : if (pExists->isPredefined())
525 : : {
526 [ + - ]: 591 : pExists->setPredefined(false);
527 [ + - - + ]: 1182 : if (pExists->getDocumentation().getLength() == 0 &&
[ - + ]
528 : 591 : pModule->getDocumentation().getLength() > 0)
529 : : {
530 : 0 : pExists->setDocumentation(pModule->getDocumentation());
531 : : }
532 : : }
533 [ + - ][ + - ]: 239003 : delete(pModule);
534 : 239003 : pModule = (AstModule*)pExists;
535 : : } else
536 : : {
537 [ + - ]: 38943 : pScope->addDeclaration(pModule);
538 : : }
539 [ + - ][ + - ]: 277946 : idlc()->scopes()->push(pModule);
[ + - ]
540 : : }
541 [ + - ]: 277946 : delete $3;
542 : : }
543 : 277946 : '{'
544 : : {
545 [ + - ]: 277946 : idlc()->setParseState(PS_ModuleSqSeen);
546 : : }
547 : 277946 : definitions
548 : : {
549 [ + - ]: 277946 : idlc()->setParseState(PS_ModuleBodySeen);
550 : : }
551 : 277946 : '}'
552 : : {
553 [ + - ]: 277946 : idlc()->setParseState(PS_ModuleQsSeen);
554 : : /*
555 : : * Finished with this module - pop it from the scope stack
556 : : */
557 [ + - ][ + - ]: 277946 : idlc()->scopes()->pop();
558 : : }
559 : 277946 : ;
560 : :
561 : : interface :
562 : : interface_dcl
563 : : | forward_dcl
564 : : ;
565 : :
566 : : interface_decl :
567 : : IDL_INTERFACE
568 : : {
569 [ + - ]: 40496 : idlc()->setParseState(PS_InterfaceSeen);
570 : : }
571 : 40496 : identifier
572 : : {
573 [ + - ]: 40496 : idlc()->setParseState(PS_InterfaceIDSeen);
574 [ + - ]: 40496 : checkIdentifier($3);
575 : 40496 : $$ = $3;
576 : : }
577 : 40496 : ;
578 : :
579 : : forward_dcl :
580 : : interface_decl
581 : : {
582 [ + - ]: 10121 : idlc()->setParseState(PS_ForwardDeclSeen);
583 : :
584 [ + - ][ + - ]: 10121 : AstScope* pScope = idlc()->scopes()->topNonNull();
585 : 10121 : AstInterface* pForward = NULL;
586 : 10121 : AstDeclaration* pDecl = NULL;
587 : :
588 : : /*
589 : : * Make a new forward interface node and add it to its enclosing scope
590 : : */
591 [ + - ][ + - ]: 10121 : if ( pScope && $1 )
592 : : {
593 [ + - ][ + - ]: 10121 : pForward = new AstInterface(*$1, NULL, pScope);
594 : :
595 [ + - ]: 10121 : pDecl = pScope->lookupByName(pForward->getScopedName());
596 [ + + ]: 10121 : if ( pDecl )
597 : : {
598 [ + - + - ]: 2112 : if ( (pDecl != pForward) &&
[ + - ]
599 : 1056 : (pDecl->getNodeType() == NT_interface) )
600 : : {
601 [ + - ][ + - ]: 1056 : delete pForward;
602 : : } else
603 : : {
604 [ # # ][ # # ]: 0 : idlc()->error()->error2(EIDL_REDEF_SCOPE, scopeAsDecl(pScope), pDecl);
[ # # ]
605 : : }
606 : : } else
607 : : {
608 : : /*
609 : : * Add the interface to its definition scope
610 : : */
611 [ + - ]: 9065 : pScope->addDeclaration(pForward);
612 : : }
613 : : }
614 [ + - ]: 10121 : delete $1;
615 : : }
616 : 10121 : ;
617 : :
618 : : interface_dcl :
619 : : interfaceheader
620 : : {
621 [ + - ]: 30375 : idlc()->setParseState(PS_InterfaceHeadSeen);
622 : :
623 [ + - ][ + - ]: 30375 : AstScope* pScope = idlc()->scopes()->topNonNull();
624 : 30375 : AstInterface* pInterface = NULL;
625 : 30375 : AstInterface* pForward = NULL;
626 : 30375 : AstDeclaration* pDecl = NULL;
627 : :
628 : : /*
629 : : * Make a new interface node and add it to its enclosing scope
630 : : */
631 [ + - ][ + - ]: 30375 : if ( pScope && $1 )
632 : : {
633 : : pInterface = new AstInterface(
634 : 30375 : *$1->getName(),
635 [ + - ][ + - ]: 30375 : static_cast< AstInterface * >($1->getInherits()), pScope);
636 [ + - + - ]: 60750 : if ( pInterface &&
[ + + ][ + + ]
637 : 30375 : (pDecl = pScope->lookupByName(pInterface->getScopedName())) )
638 : : {
639 : : /*
640 : : * See if we're defining a forward declared interface.
641 : : */
642 [ + - ]: 1054 : if (pDecl->getNodeType() == NT_interface)
643 : : {
644 : 1054 : pForward = (AstInterface*)pDecl;
645 [ + + ]: 1054 : if ( !pForward->isDefined() )
646 : : {
647 : : /*
648 : : * Check if redefining in same scope
649 : : */
650 [ - + ]: 938 : if ( pForward->getScope() != pScope )
651 : : {
652 [ # # ]: 0 : if ( pForward->getScopedName() != pInterface->getScopedName() )
653 : : {
654 : : idlc()->error()->error3(EIDL_SCOPE_CONFLICT,
655 [ # # ][ # # ]: 0 : pInterface, pForward, scopeAsDecl(pScope));
[ # # ]
656 : : }
657 : : }
658 [ + + - + ]: 1010 : else if ( !pInterface->isPublished()
[ - + ]
659 : 72 : && pForward->isPublished() )
660 : : {
661 [ # # ][ # # ]: 0 : idlc()->error()->error0(EIDL_PUBLISHED_FORWARD);
662 : : }
663 : : /*
664 : : * All OK, set full definition
665 : : */
666 : : else
667 : : {
668 [ + - ]: 938 : pForward->forwardDefined(*pInterface);
669 [ + - ][ + - ]: 938 : delete pInterface;
670 : 938 : pInterface = pForward;
671 : : }
672 : : } else {
673 : : // special handling for XInterface because it is predefined
674 [ + - + - ]: 232 : if ( pForward->isPredefined() &&
[ + - ]
675 : 116 : pForward->getScopedName() == "com::sun::star::uno::XInterface")
676 : : {
677 : : /* replace the predefined XInterface */
678 [ + - ]: 116 : *pForward = *pInterface;
679 [ + - ][ + - ]: 116 : delete pInterface;
680 : 116 : pInterface = pForward;
681 : : }
682 : :
683 : : }
684 : : }
685 : : } else
686 : : {
687 : : /*
688 : : * Add the interface to its definition scope
689 : : */
690 [ + - ]: 29321 : pScope->addDeclaration(pInterface);
691 : : }
692 : : }
693 : : /*
694 : : * Push it on the scope stack
695 : : */
696 [ + - ][ + - ]: 30375 : idlc()->scopes()->push(pInterface);
[ + - ]
697 [ + - ][ + - ]: 30375 : delete($1);
698 : : }
699 : 30375 : '{'
700 : : {
701 [ + - ]: 30375 : idlc()->setParseState(PS_InterfaceSqSeen);
702 : : }
703 : 30375 : exports
704 : : {
705 : : AstInterface * ifc = static_cast< AstInterface * >(
706 [ + - ][ + - ]: 30375 : idlc()->scopes()->topNonNull());
[ + - ]
707 [ + + + + ]: 34955 : if (!ifc->hasMandatoryInheritedInterfaces()
[ + + ]
708 : 4580 : && ifc->getScopedName() != "com::sun::star::uno::XInterface")
709 : : {
710 : : addInheritedInterface(
711 : : ifc, rtl::OString("::com::sun::star::uno::XInterface"), false,
712 [ + - ]: 538 : rtl::OUString());
713 : : }
714 : 30375 : ifc->setDefined();
715 [ + - ]: 30375 : idlc()->setParseState(PS_InterfaceBodySeen);
716 : : }
717 : 30375 : '}'
718 : : {
719 [ + - ]: 30375 : idlc()->setParseState(PS_InterfaceQsSeen);
720 : : /*
721 : : * Done with this interface - pop it off the scopes stack
722 : : */
723 [ + - ][ + - ]: 30375 : idlc()->scopes()->pop();
724 : : }
725 : 30375 : | error '}'
726 : : {
727 [ # # ]: 0 : yyerror("interface definition");
728 : 0 : yyerrok;
729 : : }
730 : 0 : ;
731 : :
732 : : interfaceheader :
733 : : interface_decl inheritance_spec
734 : : {
735 [ + - ]: 30375 : idlc()->setParseState(PS_InheritSpecSeen);
736 : :
737 [ + - ][ + - ]: 30375 : $$ = new FeInheritanceHeader(NT_interface, $1, $2, 0);
738 [ + + ]: 30375 : delete $2;
739 : : }
740 : 30375 : ;
741 : :
742 : : inheritance_spec :
743 : : ':'
744 : : {
745 [ + - ]: 38214 : idlc()->setParseState(PS_InheritColonSeen);
746 : : }
747 : 38214 : scoped_name
748 : : {
749 : 38214 : $$ = $3;
750 : : }
751 : 38214 : | /* EMPTY */
752 : : {
753 : 18984 : $$ = NULL;
754 : : }
755 : 18984 : ;
756 : :
757 : : exports :
758 : : exports export
759 : : | /* EMPTY */
760 : : ;
761 : :
762 : : export :
763 : : attribute
764 : : {
765 [ + - ]: 4980 : idlc()->setParseState(PS_AttributeDeclSeen);
766 : : }
767 : 4980 : ';'
768 : : {
769 [ + - ]: 4980 : idlc()->setParseState(PS_NoState);
770 : : }
771 : 4980 : | operation
772 : : {
773 [ + - ]: 118366 : idlc()->setParseState(PS_OperationDeclSeen);
774 : : }
775 : 118366 : ';'
776 : : {
777 [ + - ]: 118366 : idlc()->setParseState(PS_NoState);
778 : : }
779 : 118366 : | interface_inheritance_decl
780 : : {
781 [ + - ]: 1579 : idlc()->setParseState(PS_InterfaceInheritanceDeclSeen);
782 : : }
783 : 1579 : ';'
784 : : {
785 [ + - ]: 1579 : idlc()->setParseState(PS_NoState);
786 : : }
787 : 1579 : ;
788 : :
789 : : attribute :
790 : : flag_header
791 : : simple_type_spec
792 : : {
793 [ + - ]: 4980 : idlc()->setParseState(PS_AttrTypeSeen);
794 : : }
795 : 4980 : simple_declarator
796 : : {
797 [ + - ]: 4980 : idlc()->setParseState(PS_AttrCompleted);
798 [ - + ]: 4980 : if (($1 & ~(AF_BOUND | AF_READONLY)) != AF_ATTRIBUTE) {
799 [ # # ][ # # ]: 0 : idlc()->error()->flagError(EIDL_BAD_ATTRIBUTE_FLAGS, $1);
800 : : }
801 : : AstInterface * scope = static_cast< AstInterface * >(
802 [ + - ][ + - ]: 4980 : idlc()->scopes()->top());
[ + - ]
803 : : AstAttribute * attr = new AstAttribute(
804 [ + - ][ + - ]: 4980 : $1, $4->compose($2), $4->getName(), scope);
[ + - ][ + - ]
805 [ + - ][ + - ]: 4980 : delete $4;
806 : : AstInterface::DoubleMemberDeclarations doubleMembers(
807 [ + - ]: 4980 : scope->checkMemberClashes(attr));
808 [ + - ]: 4980 : if (doubleMembers.empty()) {
809 [ + - ]: 4980 : scope->addMember(attr);
810 : : } else {
811 [ # # ]: 0 : reportDoubleMemberDeclarations(doubleMembers);
812 : : }
813 [ + - ][ + - ]: 4980 : idlc()->scopes()->push(attr);
[ + - ]
814 : : }
815 : 4980 : opt_attribute_block
816 : : {
817 [ + - ][ + - ]: 4980 : static_cast< AstAttribute * >(idlc()->scopes()->top())->setExceptions(
818 : : $6.get.documentation, $6.get.exceptions, $6.set.documentation,
819 [ + - ][ + - ]: 4980 : $6.set.exceptions);
820 [ + + ]: 4980 : delete $6.get.documentation;
821 [ + + ]: 4980 : delete $6.get.exceptions;
822 [ + + ]: 4980 : delete $6.set.documentation;
823 [ + + ]: 4980 : delete $6.set.exceptions;
824 [ + - ][ + - ]: 4980 : idlc()->scopes()->pop();
825 : : }
826 : 4980 : ;
827 : :
828 : : flag_header :
829 : : '[' opt_attrflags ']'
830 : : {
831 [ + - ]: 30292 : idlc()->setParseState(PS_FlagHeaderSeen);
832 : 30292 : $$ = $2;
833 : : }
834 : 30292 : ;
835 : :
836 : : opt_attrflags :
837 : : opt_attrflags ',' opt_attrflag
838 : : {
839 [ - + ]: 15766 : if ( ($1 & $3) == $3 )
840 [ # # ][ # # ]: 0 : idlc()->error()->flagError(EIDL_DEFINED_ATTRIBUTEFLAG, $3);
841 : :
842 : 15766 : $$ = $1 | $3;
843 : : }
844 : 15766 : | opt_attrflag
845 : : {
846 : 30292 : $$ = $1;
847 : : }
848 : 30292 : ;
849 : :
850 : : opt_attrflag :
851 : : IDL_ATTRIBUTE
852 : : {
853 [ + - ]: 4980 : idlc()->setParseState(PS_AttrSeen);
854 : 4980 : $$ = AF_ATTRIBUTE;
855 : : }
856 : 4980 : | IDL_PROPERTY
857 : : {
858 [ + - ]: 23273 : idlc()->setParseState(PS_PropertySeen);
859 : 23273 : $$ = AF_PROPERTY;
860 : : }
861 : 23273 : | IDL_READONLY
862 : : {
863 [ + - ]: 2299 : idlc()->setParseState(PS_ReadOnlySeen);
864 : 2299 : $$ = AF_READONLY;
865 : : }
866 : 2299 : | IDL_OPTIONAL
867 : : {
868 [ + - ]: 13436 : idlc()->setParseState(PS_OptionalSeen);
869 : 13436 : $$ = AF_OPTIONAL;
870 : : }
871 : 13436 : | IDL_MAYBEVOID
872 : : {
873 [ + - ]: 550 : idlc()->setParseState(PS_MayBeVoidSeen);
874 : 550 : $$ = AF_MAYBEVOID;
875 : : }
876 : 550 : | IDL_BOUND
877 : : {
878 [ + - ]: 1501 : idlc()->setParseState(PS_BoundSeen);
879 : 1501 : $$ = AF_BOUND;
880 : : }
881 : 1501 : | IDL_CONSTRAINED
882 : : {
883 [ # # ]: 0 : idlc()->setParseState(PS_ConstrainedSeen);
884 : 0 : $$ = AF_CONSTRAINED;
885 : : }
886 : 0 : | IDL_TRANSIENT
887 : : {
888 [ + - ]: 16 : idlc()->setParseState(PS_TransientSeen);
889 : 16 : $$ = AF_TRANSIENT;
890 : : }
891 : 16 : | IDL_MAYBEAMBIGUOUS
892 : : {
893 [ # # ]: 0 : idlc()->setParseState(PS_MayBeAmbigiousSeen);
894 : 0 : $$ = AF_MAYBEAMBIGUOUS;
895 : : }
896 : 0 : | IDL_MAYBEDEFAULT
897 : : {
898 [ + - ]: 3 : idlc()->setParseState(PS_MayBeDefaultSeen);
899 : 3 : $$ = AF_MAYBEDEFAULT;
900 : : }
901 : 3 : | IDL_REMOVEABLE
902 : : {
903 [ # # ]: 0 : idlc()->setParseState(PS_RemoveableSeen);
904 : 0 : $$ = AF_REMOVEABLE;
905 : : }
906 : 0 : | error ']'
907 : : {
908 [ # # ]: 0 : yyerror("unknown property|attribute flag");
909 : 0 : yyerrok;
910 : : }
911 : 0 : ;
912 : :
913 : : opt_attribute_block:
914 : 1368 : '{' attribute_block_rest { $$ = $2; }
915 : 1368 : | /* empty */
916 : : {
917 : 3612 : $$.get.documentation = 0;
918 : 3612 : $$.get.exceptions = 0;
919 : 3612 : $$.set.documentation = 0;
920 : 3612 : $$.set.exceptions = 0;
921 : : }
922 : 3612 : ;
923 : :
924 : : attribute_block_rest:
925 : : opt_attribute_raises '}'
926 : : | error '}'
927 : : {
928 [ # # ]: 0 : yyerror("bad attribute raises block");
929 : 0 : yyerrok;
930 : 0 : $$.get.documentation = 0;
931 : 0 : $$.get.exceptions = 0;
932 : 0 : $$.set.documentation = 0;
933 : 0 : $$.set.exceptions = 0;
934 : : }
935 : 0 : ;
936 : :
937 : : opt_attribute_raises:
938 : : attribute_get_raises
939 : : opt_attribute_set_raises
940 : : {
941 : 36 : $$.get = $1;
942 : 36 : $$.set = $2;
943 : : }
944 : 36 : | attribute_set_raises
945 : : opt_attribute_get_raises
946 : : {
947 : 1332 : $$.get = $2;
948 : 1332 : $$.set = $1;
949 : : }
950 : 1332 : | /* empty */
951 : : {
952 : 0 : $$.get.documentation = 0;
953 : 0 : $$.get.exceptions = 0;
954 : 0 : $$.set.documentation = 0;
955 : 0 : $$.set.exceptions = 0;
956 : : }
957 : 0 : ;
958 : :
959 : : opt_attribute_get_raises:
960 : : attribute_get_raises
961 : 194 : | /* empty */ { $$.documentation = 0; $$.exceptions = 0; }
962 : 194 : ;
963 : :
964 : : attribute_get_raises:
965 : : IDL_GET raises ';'
966 : : {
967 : : $$.documentation = new rtl::OUString(
968 : : rtl::OStringToOUString(
969 [ + - ][ + - ]: 1174 : idlc()->getDocumentation(), RTL_TEXTENCODING_UTF8));
[ + - ]
970 : 1174 : $$.exceptions = $2;
971 : : }
972 : 1174 : ;
973 : :
974 : : opt_attribute_set_raises:
975 : : attribute_set_raises
976 : 34 : | /* empty */ { $$.documentation = 0; $$.exceptions = 0; }
977 : 34 : ;
978 : :
979 : : attribute_set_raises:
980 : : IDL_SET
981 : : {
982 [ + - ]: 2668 : if (static_cast< AstAttribute * >(idlc()->scopes()->top())->
[ + - - + ]
983 [ + - ]: 1334 : isReadonly())
984 : : {
985 [ # # ][ # # ]: 0 : idlc()->error()->error0(EIDL_READONLY_ATTRIBUTE_SET_EXCEPTIONS);
986 : : }
987 : : }
988 : 1334 : raises ';'
989 : : {
990 : : $$.documentation = new rtl::OUString(
991 : : rtl::OStringToOUString(
992 [ + - ][ + - ]: 1334 : idlc()->getDocumentation(), RTL_TEXTENCODING_UTF8));
[ + - ]
993 : 1334 : $$.exceptions = $3;
994 : : }
995 : 1334 : ;
996 : :
997 : : operation :
998 : : operation_head
999 : : op_type_spec
1000 : : {
1001 [ + - ]: 118366 : idlc()->setParseState(PS_OpTypeSeen);
1002 : : }
1003 : 118366 : identifier
1004 : : {
1005 [ + - ]: 118366 : idlc()->setParseState(PS_OpIDSeen);
1006 [ + - ]: 118366 : checkIdentifier($4);
1007 : :
1008 : : AstInterface * pScope = static_cast< AstInterface * >(
1009 [ + - ][ + - ]: 118366 : idlc()->scopes()->top());
[ + - ]
1010 : 118366 : AstOperation* pOp = NULL;
1011 : :
1012 : : /*
1013 : : * Create a node representing an operation on an interface
1014 : : * and add it to its enclosing scope
1015 : : */
1016 [ + - ][ + - ]: 118366 : if ( pScope && $2 )
1017 : : {
1018 : 118366 : AstType *pType = (AstType*)$2;
1019 [ + - ][ - + ]: 118366 : if ( !pType || (pType->getNodeType() == NT_exception) )
[ + - ]
1020 : : {
1021 : : // type ERROR
1022 : : } else
1023 : : {
1024 [ + - ][ + - ]: 118366 : pOp = new AstOperation($1, pType, *$4, pScope);
[ + - ]
1025 : :
1026 : : AstInterface::DoubleMemberDeclarations doubleMembers(
1027 [ + - ]: 118366 : pScope->checkMemberClashes(pOp));
1028 [ + - ]: 118366 : if (doubleMembers.empty()) {
1029 [ + - ]: 118366 : pScope->addMember(pOp);
1030 : : } else {
1031 [ # # ]: 0 : reportDoubleMemberDeclarations(doubleMembers);
1032 : 118366 : }
1033 : : }
1034 : : }
1035 [ + - ]: 118366 : delete $4;
1036 : : /*
1037 : : * Push the operation scope onto the scopes stack
1038 : : */
1039 [ + - ][ + - ]: 118366 : idlc()->scopes()->push(pOp);
[ + - ]
1040 : : }
1041 : 118366 : '('
1042 : : {
1043 [ + - ]: 118366 : idlc()->setParseState(PS_OpSqSeen);
1044 : : }
1045 : 118366 : parameters
1046 : : {
1047 [ + - ]: 118366 : idlc()->setParseState(PS_OpParsCompleted);
1048 : : }
1049 : 118366 : ')'
1050 : : {
1051 [ + - ]: 118366 : idlc()->setParseState(PS_OpQsSeen);
1052 : : }
1053 : 118366 : opt_raises
1054 : : {
1055 [ + - ][ + - ]: 118366 : AstScope* pScope = idlc()->scopes()->topNonNull();
1056 : 118366 : AstOperation* pOp = NULL;
1057 : : /*
1058 : : * Add exceptions and context to the operation
1059 : : */
1060 [ + - ][ + - ]: 118366 : if ( pScope && pScope->getScopeNodeType() == NT_operation)
[ + - ]
1061 : : {
1062 [ + - ]: 118366 : pOp = (AstOperation*)pScope;
1063 : :
1064 [ + - ]: 118366 : if ( pOp )
1065 [ + - ]: 118366 : pOp->setExceptions($12);
1066 : : }
1067 [ + + ]: 118366 : delete $12;
1068 : : /*
1069 : : * Done with this operation. Pop its scope from the scopes stack
1070 : : */
1071 [ + - ][ + - ]: 118366 : idlc()->scopes()->pop();
1072 : : }
1073 : 118366 : ;
1074 : :
1075 : : operation_head :
1076 : : '['
1077 : : IDL_ONEWAY
1078 : : {
1079 [ + - ]: 22299 : idlc()->setParseState(PS_OpOnewaySeen);
1080 : : }
1081 : 22299 : ']'
1082 : : {
1083 [ + - ]: 22299 : idlc()->setParseState(PS_OpHeadSeen);
1084 : 22299 : $$ = OP_ONEWAY;
1085 : : }
1086 : 22299 : | /* EMPTY */
1087 : : {
1088 : 96067 : $$ = OP_NONE;
1089 : : }
1090 : 96067 : ;
1091 : :
1092 : : op_type_spec :
1093 : : simple_type_spec
1094 : : | IDL_VOID
1095 : : {
1096 [ + - ][ + - ]: 49167 : $$ = idlc()->scopes()->bottom()->lookupPrimitiveType(ET_void);
[ + - ]
1097 : : }
1098 : 49167 : ;
1099 : :
1100 : : parameters :
1101 : : parameter
1102 : : | parameters
1103 : : ','
1104 : : {
1105 [ + - ]: 27163 : idlc()->setParseState(PS_OpParCommaSeen);
1106 : : }
1107 : 27163 : parameter
1108 : : | /* EMPTY */
1109 : : | error ','
1110 : : {
1111 [ # # ]: 0 : yyerror("parameter definition");
1112 : 0 : yyerrok;
1113 : : }
1114 : 0 : ;
1115 : :
1116 : : parameter :
1117 : : '['
1118 : : direction
1119 : : ']'
1120 : : {
1121 [ + - ]: 92948 : idlc()->setParseState(PS_OpParDirSeen);
1122 : : }
1123 : 92948 : simple_type_spec
1124 : : {
1125 [ + - ]: 92948 : idlc()->setParseState(PS_OpParTypeSeen);
1126 : : }
1127 : 92948 : opt_rest
1128 : : declarator
1129 : : {
1130 [ + - ]: 92948 : idlc()->setParseState(PS_OpParDeclSeen);
1131 : :
1132 : : AstOperation * pScope = static_cast< AstOperation * >(
1133 [ + - ][ + - ]: 92948 : idlc()->scopes()->top());
[ + - ]
1134 : 92948 : AstParameter* pParam = NULL;
1135 : :
1136 : : /*
1137 : : * Create a node representing an argument to an operation
1138 : : * Add it to the enclosing scope (the operation scope)
1139 : : */
1140 [ + - ][ + - ]: 92948 : if ( pScope && $5 && $8 )
[ + - ]
1141 : : {
1142 [ + - ]: 92948 : AstType const * pType = $8->compose($5);
1143 [ + - ]: 92948 : if ( pType )
1144 : : {
1145 [ + + ][ - + ]: 92948 : if (pScope->isConstructor() && $2 != DIR_IN) {
[ - + ]
1146 [ # # ][ # # ]: 0 : idlc()->error()->error0(EIDL_CONSTRUCTOR_PARAMETER_NOT_IN);
1147 : : }
1148 [ + - ][ - + ]: 92948 : if (pScope->isVariadic()) {
1149 [ # # ][ # # ]: 0 : idlc()->error()->error0(EIDL_REST_PARAMETER_NOT_LAST);
1150 : : }
1151 [ + + ]: 92948 : if ($7) {
1152 [ + - ]: 2 : AstDeclaration const * type = resolveTypedefs(pType);
1153 [ + - - + ]: 4 : if (type->getNodeType() != NT_predefined
[ - + ]
1154 : : || (static_cast< AstBaseType const * >(type)->
1155 : 2 : getExprType() != ET_any))
1156 : : {
1157 [ # # ][ # # ]: 0 : idlc()->error()->error0(EIDL_REST_PARAMETER_NOT_ANY);
1158 : : }
1159 [ + - ]: 2 : if (pScope->isConstructor()) {
1160 [ - + ]: 2 : if (pScope->getIteratorBegin()
1161 : 2 : != pScope->getIteratorEnd())
1162 : : {
1163 : : idlc()->error()->error0(
1164 [ # # ][ # # ]: 0 : EIDL_CONSTRUCTOR_REST_PARAMETER_NOT_FIRST);
1165 : : }
1166 : : } else {
1167 [ # # ][ # # ]: 0 : idlc()->error()->error0(EIDL_METHOD_HAS_REST_PARAMETER);
1168 : : }
1169 : : }
1170 : :
1171 : : pParam = new AstParameter(
1172 : 278844 : static_cast< Direction >($2), $7, pType, $8->getName(),
1173 [ + - ][ + - ]: 92948 : pScope);
[ + - ]
1174 : :
1175 [ + - ]: 92948 : if ( !$8->checkType($5) )
1176 : : {
1177 : : // WARNING
1178 : : }
1179 : :
1180 [ + - ]: 92948 : pScope->addDeclaration(pParam);
1181 : : }
1182 : : }
1183 : : }
1184 : 92948 : | error
1185 : : simple_type_spec
1186 : : {
1187 [ # # ]: 0 : idlc()->setParseState(PS_NoState);
1188 : 0 : yyerrok;
1189 : : }
1190 : 0 : ;
1191 : :
1192 : : direction :
1193 : : IDL_IN
1194 : : {
1195 : 90260 : $$ = DIR_IN;
1196 : : }
1197 : 90260 : | IDL_OUT
1198 : : {
1199 : 2554 : $$ = DIR_OUT;
1200 : : }
1201 : 2554 : | IDL_INOUT
1202 : : {
1203 : 134 : $$ = DIR_INOUT;
1204 : : }
1205 : 134 : ;
1206 : :
1207 : : opt_rest:
1208 : : IDL_ELLIPSIS
1209 : : {
1210 : 2 : $$ = true;
1211 : : }
1212 : 2 : | /* empty */
1213 : : {
1214 : 92946 : $$ = false;
1215 : : }
1216 : 92946 : ;
1217 : :
1218 : : opt_raises:
1219 : : raises
1220 : : | /* empty */
1221 : : {
1222 : 94016 : $$ = 0;
1223 : : }
1224 : 94016 : ;
1225 : :
1226 : : raises:
1227 : : IDL_RAISES
1228 : : {
1229 [ + - ]: 27108 : idlc()->setParseState(PS_RaiseSeen);
1230 : : }
1231 : 27108 : '('
1232 : : {
1233 [ + - ]: 27108 : idlc()->setParseState(PS_RaiseSqSeen);
1234 : : }
1235 : 27108 : exception_list
1236 : : ')'
1237 : : {
1238 [ + - ]: 27108 : idlc()->setParseState(PS_RaiseQsSeen);
1239 : 27108 : $$ = $5;
1240 : : }
1241 : 27108 : ;
1242 : :
1243 : : exception_list:
1244 : : exception_name
1245 : : {
1246 [ + - ][ + - ]: 27108 : $$ = new DeclList;
1247 [ + - ]: 27108 : $$->push_back($1);
1248 : : }
1249 : 27108 : | exception_list ',' exception_name
1250 : : {
1251 [ + - ]: 20402 : $1->push_back($3);
1252 : 20402 : $$ = $1;
1253 : : }
1254 : 20402 : ;
1255 : :
1256 : : exception_name:
1257 : : scoped_name
1258 : : {
1259 : : // The topmost scope is either an AstOperation (for interface methods
1260 : : // and service constructors) or an AstAttribute (for interface
1261 : : // attributes), so look up exception names in the next-to-topmost scope:
1262 : : AstDeclaration * decl = idlc()->scopes()->nextToTop()->lookupByName(
1263 [ + - ][ + - ]: 47510 : *$1);
[ + - ]
1264 [ - + ]: 47510 : if (decl == 0) {
1265 [ # # ][ # # ]: 0 : idlc()->error()->lookupError(*$1);
1266 [ + - ][ + - ]: 47510 : } else if (!idlc()->error()->checkPublished(decl)) {
[ - + ]
1267 : 0 : decl = 0;
1268 [ - + ]: 47510 : } else if (decl->getNodeType() != NT_exception) {
1269 [ # # ][ # # ]: 0 : idlc()->error()->error1(EIDL_ILLEGAL_RAISES, decl);
1270 : 0 : decl = 0;
1271 : : }
1272 [ + - ]: 47510 : delete $1;
1273 : 47510 : $$ = decl;
1274 : : }
1275 : 47510 : ;
1276 : :
1277 : : interface_inheritance_decl:
1278 : : optional_inherited_interface
1279 : : IDL_INTERFACE
1280 : : {
1281 [ + - ]: 1579 : idlc()->setParseState(PS_ServiceIFHeadSeen);
1282 : : }
1283 : 1579 : scoped_name
1284 : : {
1285 : : AstInterface * ifc = static_cast< AstInterface * >(
1286 [ + - ][ + - ]: 1579 : idlc()->scopes()->top());
[ + - ]
1287 [ - + ]: 1579 : if (ifc->usesSingleInheritance()) {
1288 [ # # ][ # # ]: 0 : idlc()->error()->error0(EIDL_MIXED_INHERITANCE);
1289 : : } else {
1290 : : addInheritedInterface(
1291 : 1579 : ifc, *$4, $1,
1292 : : rtl::OStringToOUString(
1293 [ + - ][ + - ]: 1579 : idlc()->getDocumentation(), RTL_TEXTENCODING_UTF8));
[ + - ]
1294 : : }
1295 [ + - ]: 1579 : delete $4;
1296 : : }
1297 : 1579 : ;
1298 : :
1299 : : optional_inherited_interface:
1300 : 20 : '[' IDL_OPTIONAL ']' { $$ = true; }
1301 : 20 : | /* EMPTY */ { $$ = false; }
1302 : 1559 : ;
1303 : :
1304 : : constants_exports :
1305 : : constants_export constants_exports
1306 : : | /* EMPTY */
1307 : : ;
1308 : :
1309 : : constants_export :
1310 : : const_dcl
1311 : : {
1312 [ + - ]: 14719 : idlc()->setParseState(PS_ConstantDeclSeen);
1313 : : }
1314 : 14719 : ';' {};
1315 : 14719 :
1316 : : const_dcl :
1317 : : IDL_CONST
1318 : : {
1319 [ + - ]: 14719 : idlc()->setParseState(PS_ConstSeen);
1320 : : }
1321 : 14719 : const_type
1322 : : {
1323 [ + - ]: 14719 : idlc()->setParseState(PS_ConstTypeSeen);
1324 : : }
1325 : 14719 : identifier
1326 : : {
1327 [ + - ]: 14719 : idlc()->setParseState(PS_ConstIDSeen);
1328 [ + - ]: 14719 : checkIdentifier($5);
1329 : : }
1330 : 14719 : '='
1331 : : {
1332 [ + - ]: 14719 : idlc()->setParseState(PS_ConstAssignSeen);
1333 : : }
1334 : 14719 : expression
1335 : : {
1336 [ + - ]: 14719 : idlc()->setParseState(PS_ConstExprSeen);
1337 : :
1338 [ + - ][ + - ]: 14719 : AstScope* pScope = idlc()->scopes()->topNonNull();
1339 : 14719 : AstConstant* pConstant = NULL;
1340 : :
1341 [ + - ][ + - ]: 14719 : if ( $9 && pScope )
1342 : : {
1343 [ + - ][ - + ]: 14719 : if ( !$9->coerce($3) )
1344 : : {
1345 [ # # ][ # # ]: 0 : idlc()->error()->coercionError($9, $3);
1346 : : } else
1347 : : {
1348 [ + - ][ + - ]: 14719 : pConstant = new AstConstant($3, $9, *$5, pScope);
1349 [ + - ]: 14719 : pScope->addDeclaration(pConstant);
1350 : : }
1351 : : }
1352 [ + - ]: 14719 : delete $5;
1353 : : }
1354 : 14719 : ;
1355 : :
1356 : : constants_dcl :
1357 : : IDL_CONSTANTS
1358 : : {
1359 [ + - ]: 1632 : idlc()->setParseState(PS_ConstantsSeen);
1360 : : }
1361 : 1632 : identifier
1362 : : {
1363 [ + - ]: 1632 : idlc()->setParseState(PS_ConstantsIDSeen);
1364 [ + - ]: 1632 : checkIdentifier($3);
1365 : : }
1366 : 1632 : '{'
1367 : : {
1368 [ + - ]: 1632 : idlc()->setParseState(PS_ConstantsSqSeen);
1369 : :
1370 [ + - ][ + - ]: 1632 : AstScope* pScope = idlc()->scopes()->topNonNull();
1371 : 1632 : AstConstants* pConstants = NULL;
1372 : 1632 : AstDeclaration* pExists = NULL;
1373 : :
1374 [ + - ]: 1632 : if ( pScope )
1375 : : {
1376 [ + - ][ + - ]: 1632 : pConstants = new AstConstants(*$3, pScope);
1377 [ + - ][ - + ]: 1632 : if( (pExists = pScope->lookupForAdd(pConstants)) )
1378 : : {
1379 [ # # ]: 0 : pExists->setInMainfile(idlc()->isInMainFile());
1380 [ # # ][ # # ]: 0 : delete(pConstants);
1381 : 0 : pConstants = (AstConstants*)pExists;
1382 : : } else
1383 : : {
1384 [ + - ]: 1632 : pScope->addDeclaration(pConstants);
1385 : : }
1386 [ + - ][ + - ]: 1632 : idlc()->scopes()->push(pConstants);
[ + - ]
1387 : : }
1388 [ + - ]: 1632 : delete $3;
1389 : : }
1390 : 1632 : constants_exports
1391 : : {
1392 [ + - ]: 1632 : idlc()->setParseState(PS_ConstantsBodySeen);
1393 : : }
1394 : 1632 : '}'
1395 : : {
1396 [ + - ]: 1632 : idlc()->setParseState(PS_ConstantsQsSeen);
1397 : : /*
1398 : : * Finished with this constants - pop it from the scope stack
1399 : : */
1400 [ + - ][ + - ]: 1632 : idlc()->scopes()->pop();
1401 : : }
1402 : 1632 : ;
1403 : :
1404 : : expression : const_expr ;
1405 : :
1406 : : const_expr : or_expr ;
1407 : :
1408 : : or_expr :
1409 : : xor_expr
1410 : : | or_expr '|' xor_expr
1411 : : {
1412 [ + - ][ + - ]: 32 : $$ = new AstExpression(EC_or, $1, $3);
1413 : : }
1414 : 32 : ;
1415 : :
1416 : : xor_expr :
1417 : : and_expr
1418 : : | xor_expr '^' and_expr
1419 : : {
1420 [ # # ][ # # ]: 0 : $$ = new AstExpression(EC_xor, $1, $3);
1421 : : }
1422 : 0 : ;
1423 : :
1424 : : and_expr :
1425 : : shift_expr
1426 : : | and_expr '&' shift_expr
1427 : : {
1428 [ # # ][ # # ]: 0 : $$ = new AstExpression(EC_and, $1, $3);
1429 : : }
1430 : 0 : ;
1431 : :
1432 : : shift_expr :
1433 : : add_expr
1434 : : | shift_expr IDL_LEFTSHIFT add_expr
1435 : : {
1436 [ # # ][ # # ]: 0 : $$ = new AstExpression(EC_left, $1, $3);
1437 : : }
1438 : 0 : | shift_expr IDL_RIGHTSHIFT add_expr
1439 : : {
1440 [ # # ][ # # ]: 0 : $$ = new AstExpression(EC_right, $1, $3);
1441 : : }
1442 : 0 : ;
1443 : :
1444 : : add_expr :
1445 : : mult_expr
1446 : : | add_expr '+' mult_expr
1447 : : {
1448 [ + - ][ + - ]: 100 : $$ = new AstExpression(EC_add, $1, $3);
1449 : : }
1450 : 100 : | add_expr '-' mult_expr
1451 : : {
1452 [ # # ][ # # ]: 0 : $$ = new AstExpression(EC_minus, $1, $3);
1453 : : }
1454 : 0 : ;
1455 : :
1456 : : mult_expr :
1457 : : unary_expr
1458 : : | mult_expr '*' unary_expr
1459 : : {
1460 [ # # ][ # # ]: 0 : $$ = new AstExpression(EC_mul, $1, $3);
1461 : : }
1462 : 0 : | mult_expr '/' unary_expr
1463 : : {
1464 [ # # ][ # # ]: 0 : $$ = new AstExpression(EC_div, $1, $3);
1465 : : }
1466 : 0 : | mult_expr '%' unary_expr
1467 : : {
1468 [ # # ][ # # ]: 0 : $$ = new AstExpression(EC_mod, $1, $3);
1469 : : }
1470 : 0 : ;
1471 : :
1472 : : unary_expr :
1473 : : primary_expr
1474 : : | '+' primary_expr
1475 : : {
1476 [ # # ][ # # ]: 0 : $$ = new AstExpression(EC_u_plus, $2, NULL);
1477 : : }
1478 : 0 : | '-' primary_expr
1479 : : {
1480 [ # # ][ # # ]: 0 : $$ = new AstExpression(EC_u_minus, $2, NULL);
1481 : : }
1482 : 0 : | '~' primary_expr
1483 : : {
1484 : : }
1485 : 0 : ;
1486 : :
1487 : : primary_expr :
1488 : : scoped_name
1489 : : {
1490 : : /*
1491 : : * An expression which is a scoped name is not resolved now,
1492 : : * but only when it is evaluated (such as when it is assigned
1493 : : * as a constant value)
1494 : : */
1495 [ + - ][ + - ]: 193 : $$ = new AstExpression($1);
1496 : : }
1497 : 193 : | literal
1498 : : | '(' const_expr ')'
1499 : : {
1500 : 0 : $$ = $2;
1501 : : }
1502 : 0 : ;
1503 : :
1504 : : literal :
1505 : : IDL_INTEGER_LITERAL
1506 : : {
1507 [ + - ][ + - ]: 15535 : $$ = new AstExpression($1);
1508 : : }
1509 : 15535 : | IDL_INTEGER_ULITERAL
1510 : : {
1511 [ + - ][ + - ]: 1 : $$ = new AstExpression($1);
1512 : : }
1513 : 1 : | IDL_FLOATING_PT_LITERAL
1514 : : {
1515 [ + - ][ + - ]: 20 : $$ = new AstExpression($1);
1516 : : }
1517 : 20 : | IDL_TRUE
1518 : : {
1519 [ # # ][ # # ]: 0 : $$ = new AstExpression((sal_Int32)1, ET_boolean);
1520 : : }
1521 : 0 : | IDL_FALSE
1522 : : {
1523 [ # # ][ # # ]: 0 : $$ = new AstExpression((sal_Int32)0, ET_boolean);
1524 : : }
1525 : 0 : ;
1526 : :
1527 : : positive_int_expr :
1528 : : const_expr
1529 : : {
1530 [ # # ]: 0 : $1->evaluate(EK_const);
1531 [ # # ][ # # ]: 0 : if ( !$1->coerce(ET_ulong) )
1532 : : {
1533 [ # # ][ # # ]: 0 : idlc()->error()->coercionError($1, ET_ulong);
1534 [ # # ][ # # ]: 0 : delete $1;
1535 : 0 : $$ = NULL;
1536 : : }
1537 : : }
1538 : 0 : ;
1539 : :
1540 : : const_type :
1541 : : integer_type
1542 : : | char_type
1543 : : | byte_type
1544 : : | boolean_type
1545 : : | floating_pt_type
1546 : : | scoped_name
1547 : : {
1548 [ + - ][ + - ]: 36 : AstScope* pScope = idlc()->scopes()->topNonNull();
1549 : 36 : AstDeclaration const * type = 0;
1550 : :
1551 : : /*
1552 : : * If the constant's type is a scoped name, it must resolve
1553 : : * to a scalar constant type
1554 : : */
1555 [ + - ][ + - ]: 36 : if ( pScope && (type = pScope->lookupByName(*$1)) ) {
[ + - ][ + - ]
1556 [ + - ][ + - ]: 36 : if (!idlc()->error()->checkPublished(type))
[ - + ]
1557 : : {
1558 : 0 : type = 0;
1559 : : }
1560 : : else
1561 : : {
1562 [ + - ]: 36 : type = resolveTypedefs(type);
1563 [ + - ]: 36 : if (type->getNodeType() == NT_predefined)
1564 : : {
1565 : : $$ = static_cast< AstBaseType const * >(type)->
1566 : 36 : getExprType();
1567 : : } else
1568 : 0 : $$ = ET_any;
1569 : : }
1570 : : } else
1571 : 0 : $$ = ET_any;
1572 : : }
1573 : 36 : ;
1574 : :
1575 : : exception_header :
1576 : : IDL_EXCEPTION
1577 : : {
1578 [ + - ]: 13137 : idlc()->setParseState(PS_ExceptSeen);
1579 : : }
1580 : 13137 : identifier
1581 : : {
1582 [ + - ]: 13137 : idlc()->setParseState(PS_ExceptIDSeen);
1583 [ + - ]: 13137 : checkIdentifier($3);
1584 : : }
1585 : 13137 : inheritance_spec
1586 : : {
1587 [ + - ]: 13137 : idlc()->setParseState(PS_InheritSpecSeen);
1588 : :
1589 [ + - ][ + - ]: 13137 : $$ = new FeInheritanceHeader(NT_exception, $3, $5, 0);
1590 [ + + ]: 13137 : delete $5;
1591 : : }
1592 : 13137 : ;
1593 : :
1594 : : exception_dcl :
1595 : : exception_header
1596 : : {
1597 [ + - ]: 13137 : idlc()->setParseState(PS_ExceptHeaderSeen);
1598 : :
1599 [ + - ][ + - ]: 13137 : AstScope* pScope = idlc()->scopes()->topNonNull();
1600 : 13137 : AstException* pExcept = NULL;
1601 : :
1602 [ + - ]: 13137 : if ( pScope )
1603 : : {
1604 : : AstException* pBase = static_cast< AstException* >(
1605 : 13137 : $1->getInherits());
1606 [ + - ][ + - ]: 13137 : pExcept = new AstException(*$1->getName(), pBase, pScope);
1607 [ + - ]: 13137 : pScope->addDeclaration(pExcept);
1608 : : }
1609 : : /*
1610 : : * Push the scope of the exception on the scopes stack
1611 : : */
1612 [ + - ][ + - ]: 13137 : idlc()->scopes()->push(pExcept);
[ + - ]
1613 [ + - ][ + - ]: 13137 : delete $1;
1614 : : }
1615 : 13137 : '{'
1616 : : {
1617 [ + - ]: 13137 : idlc()->setParseState(PS_ExceptSqSeen);
1618 : : }
1619 : 13137 : members
1620 : : {
1621 [ + - ]: 13137 : idlc()->setParseState(PS_ExceptBodySeen);
1622 : : }
1623 : 13137 : '}'
1624 : : {
1625 [ + - ]: 13137 : idlc()->setParseState(PS_ExceptQsSeen);
1626 : : /* this exception is finished, pop its scope from the stack */
1627 [ + - ][ + - ]: 13137 : idlc()->scopes()->pop();
1628 : : }
1629 : 13137 : ;
1630 : :
1631 : : property :
1632 : : flag_header
1633 : : simple_type_spec
1634 : : {
1635 [ + - ]: 23273 : idlc()->setParseState(PS_PropertyTypeSeen);
1636 : : }
1637 : 23273 : at_least_one_declarator
1638 : : {
1639 [ + - ]: 23273 : idlc()->setParseState(PS_PropertyCompleted);
1640 : :
1641 [ + - ][ + - ]: 23273 : AstScope* pScope = idlc()->scopes()->topNonNull();
1642 : 23273 : AstAttribute* pAttr = NULL;
1643 : 23273 : FeDeclList* pList = $4;
1644 : 23273 : FeDeclarator* pDecl = NULL;
1645 : 23273 : AstType const * pType = NULL;
1646 : :
1647 [ - + ]: 23273 : if ( pScope->getScopeNodeType() == NT_singleton )
1648 : : {
1649 [ # # ][ # # ]: 0 : idlc()->error()->error0(EIDL_ILLEGAL_ADD);
1650 : : } else
1651 : : {
1652 [ - + ]: 23273 : if ( ($1 & AF_ATTRIBUTE) == AF_ATTRIBUTE )
1653 [ # # ][ # # ]: 0 : idlc()->error()->flagError(EIDL_WRONGATTRIBUTEKEYWORD, AF_ATTRIBUTE);
1654 : :
1655 [ - + ]: 23273 : if ( ($1 & AF_PROPERTY) != AF_PROPERTY )
1656 [ # # ][ # # ]: 0 : idlc()->error()->flagError(EIDL_MISSINGATTRIBUTEKEYWORD, AF_PROPERTY);
1657 : :
1658 : : /*
1659 : : * Create nodes representing attributes and add them to the
1660 : : * enclosing scope
1661 : : */
1662 [ + - ][ + - ]: 23273 : if ( pScope && $2 && pList )
[ + - ]
1663 : : {
1664 : 23273 : FeDeclList::iterator iter = pList->begin();
1665 : 23273 : FeDeclList::iterator end = pList->end();
1666 : :
1667 [ + + ]: 46546 : while (iter != end)
1668 : : {
1669 : 23273 : pDecl = (*iter);
1670 [ - + ]: 23273 : if ( !pDecl )
1671 : : {
1672 : 0 : iter++;
1673 : 0 : continue;
1674 : : }
1675 : :
1676 [ + - ]: 23273 : pType = pDecl->compose($2);
1677 : :
1678 [ - + ]: 23273 : if ( !pType )
1679 : : {
1680 : 0 : iter++;
1681 : 0 : continue;
1682 : : }
1683 : :
1684 [ + - ][ + - ]: 23273 : pAttr = new AstAttribute(NT_property, $1, pType, pDecl->getName(), pScope);
1685 : :
1686 [ + - ]: 23273 : pScope->addDeclaration(pAttr);
1687 : 23273 : iter++;
1688 [ + - ][ + - ]: 23273 : delete pDecl;
1689 : : }
1690 : : }
1691 : : }
1692 : :
1693 [ + - ]: 23273 : if ( pList )
1694 [ + - ]: 23273 : delete pList;
1695 : : }
1696 : 23273 : | error ';'
1697 : : {
1698 [ # # ]: 0 : yyerror("property");
1699 : 0 : yyerrok;
1700 : : }
1701 : 0 : ;
1702 : :
1703 : : service_exports :
1704 : : service_exports service_export
1705 : : | /* EMPTY */
1706 : : ;
1707 : :
1708 : : service_export :
1709 : : service_interface_header
1710 : : at_least_one_scoped_name
1711 : : ';'
1712 : : {
1713 [ + - ]: 6414 : idlc()->setParseState(PS_ServiceMemberSeen);
1714 : :
1715 [ + - ][ + - ]: 6414 : AstScope* pScope = idlc()->scopes()->topNonNull();
1716 : 6414 : AstDeclaration* pDecl = NULL;
1717 : 6414 : AstInterfaceMember* pIMember = NULL;
1718 : :
1719 [ - + ]: 6414 : if ( pScope->getScopeNodeType() == NT_singleton )
1720 : : {
1721 [ # # ][ # # ]: 0 : idlc()->error()->error0(EIDL_ILLEGAL_ADD);
1722 : : } else
1723 : : {
1724 : : /*
1725 : : * Create a node representing a class member.
1726 : : * Store it in the enclosing scope
1727 : : */
1728 [ + - ][ + - ]: 6414 : if ( pScope && $2 )
1729 : : {
1730 : 6414 : StringList::iterator iter = $2->begin();
1731 : 6414 : StringList::iterator end = $2->end();
1732 : :
1733 [ + + ]: 12828 : while ( iter != end )
1734 : : {
1735 [ + - ]: 6414 : pDecl = pScope->lookupByName(*iter);
1736 [ + - ][ + - ]: 6414 : if ( pDecl && (pDecl->getNodeType() == NT_interface) )
[ + - ]
1737 : : {
1738 : : /* we relax the strict published check and allow to add new
1739 : : * interfaces if they are optional
1740 : : */
1741 : 6414 : bool bOptional = (($1 & AF_OPTIONAL) == AF_OPTIONAL);
1742 [ + - ][ + - ]: 6414 : if ( idlc()->error()->checkPublished(pDecl, bOptional) )
[ + - ]
1743 : : {
1744 : : pIMember = new AstInterfaceMember(
1745 [ + - ][ + - ]: 6414 : $1, (AstInterface*)pDecl, *iter, pScope);
1746 [ + - ]: 6414 : pScope->addDeclaration(pIMember);
1747 : : }
1748 : : } else
1749 : : {
1750 : : idlc()->error()->
1751 [ # # ][ # # ]: 0 : lookupError(EIDL_INTERFACEMEMBER_LOOKUP, *iter, scopeAsDecl(pScope));
[ # # ]
1752 : : }
1753 : 6414 : iter++;
1754 : : }
1755 : : }
1756 : : }
1757 [ + - ]: 6414 : delete $2;
1758 : : }
1759 : 6414 : | service_service_header
1760 : : at_least_one_scoped_name
1761 : : ';'
1762 : : {
1763 [ + - ]: 2173 : idlc()->setParseState(PS_ServiceMemberSeen);
1764 : :
1765 [ + - ][ + - ]: 2173 : AstScope* pScope = idlc()->scopes()->topNonNull();
1766 : 2173 : AstDeclaration* pDecl = NULL;
1767 : 2173 : AstServiceMember* pSMember = NULL;
1768 : :
1769 : : /*
1770 : : * Create a node representing a class member.
1771 : : * Store it in the enclosing scope
1772 : : */
1773 [ + - ][ + - ]: 2173 : if ( pScope && $2 )
1774 : : {
1775 : 2173 : StringList::iterator iter = $2->begin();
1776 : 2173 : StringList::iterator end = $2->end();
1777 : :
1778 [ + + ]: 4346 : while ( iter != end )
1779 : : {
1780 [ + - ]: 2173 : pDecl = pScope->lookupByName(*iter);
1781 [ + - ][ + - ]: 2173 : if ( pDecl && (pDecl->getNodeType() == NT_service) )
[ + - ]
1782 : : {
1783 [ + + ][ - + ]: 2173 : if ( pScope->getScopeNodeType() == NT_singleton && pScope->nMembers() > 0 )
[ - + ]
1784 [ # # ][ # # ]: 0 : idlc()->error()->error0(EIDL_ILLEGAL_ADD);
1785 [ + - ][ + - ]: 2173 : else if ( idlc()->error()->checkPublished(pDecl) )
[ + - ]
1786 : : {
1787 : : pSMember = new AstServiceMember(
1788 [ + - ][ + - ]: 2173 : $1, (AstService*)pDecl, *iter, pScope);
1789 [ + - ]: 2173 : pScope->addDeclaration(pSMember);
1790 : : }
1791 : : } else
1792 : : {
1793 : : idlc()->error()->
1794 [ # # ][ # # ]: 0 : lookupError(EIDL_SERVICEMEMBER_LOOKUP, *iter, scopeAsDecl(pScope));
[ # # ]
1795 : : }
1796 : 2173 : iter++;
1797 : : }
1798 : : }
1799 [ + - ]: 2173 : delete $2;
1800 : : }
1801 : 2173 : | IDL_OBSERVES
1802 : : at_least_one_scoped_name
1803 : : ';'
1804 : : {
1805 [ # # ]: 0 : idlc()->setParseState(PS_ServiceMemberSeen);
1806 : :
1807 [ # # ][ # # ]: 0 : AstScope* pScope = idlc()->scopes()->topNonNull();
1808 : 0 : AstDeclaration* pDecl = NULL;
1809 : 0 : AstObserves* pObserves = NULL;
1810 : :
1811 [ # # ]: 0 : if ( pScope->getScopeNodeType() == NT_singleton )
1812 : : {
1813 [ # # ][ # # ]: 0 : idlc()->error()->error0(EIDL_ILLEGAL_ADD);
1814 : : } else
1815 : : {
1816 : : /*
1817 : : * Create a node representing a class member.
1818 : : * Store it in the enclosing scope
1819 : : */
1820 [ # # ][ # # ]: 0 : if ( pScope && $2 )
1821 : : {
1822 : 0 : StringList::iterator iter = $2->begin();
1823 : 0 : StringList::iterator end = $2->end();
1824 : :
1825 [ # # ]: 0 : while ( iter != end )
1826 : : {
1827 [ # # ]: 0 : pDecl = pScope->lookupByName(*iter);
1828 [ # # ][ # # ]: 0 : if ( pDecl && (pDecl->getNodeType() == NT_interface) )
[ # # ]
1829 : : {
1830 [ # # ][ # # ]: 0 : pObserves = new AstObserves((AstInterface*)pDecl, *iter, pScope);
1831 [ # # ]: 0 : pScope->addDeclaration(pObserves);
1832 : : } else
1833 : : {
1834 : : idlc()->error()->
1835 [ # # ][ # # ]: 0 : lookupError(EIDL_INTERFACEMEMBER_LOOKUP, *iter, scopeAsDecl(pScope));
[ # # ]
1836 : : }
1837 : 0 : iter++;
1838 : : }
1839 : : }
1840 : : }
1841 [ # # ]: 0 : delete $2;
1842 : : }
1843 : 0 : | IDL_NEEDS
1844 : : at_least_one_scoped_name
1845 : : ';'
1846 : : {
1847 [ # # ]: 0 : idlc()->setParseState(PS_ServiceMemberSeen);
1848 : :
1849 [ # # ][ # # ]: 0 : AstScope* pScope = idlc()->scopes()->topNonNull();
1850 : 0 : AstDeclaration* pDecl = NULL;
1851 : 0 : AstNeeds* pNeeds = NULL;
1852 : :
1853 [ # # ]: 0 : if ( pScope->getScopeNodeType() == NT_singleton )
1854 : : {
1855 [ # # ][ # # ]: 0 : idlc()->error()->error0(EIDL_ILLEGAL_ADD);
1856 : : } else
1857 : : {
1858 : : /*
1859 : : * Create a node representing a class member.
1860 : : * Store it in the enclosing scope
1861 : : */
1862 [ # # ][ # # ]: 0 : if ( pScope && $2 )
1863 : : {
1864 : 0 : StringList::iterator iter = $2->begin();
1865 : 0 : StringList::iterator end = $2->end();
1866 : :
1867 [ # # ]: 0 : while ( iter != end )
1868 : : {
1869 [ # # ]: 0 : pDecl = pScope->lookupByName(*iter);
1870 [ # # ][ # # ]: 0 : if ( pDecl && (pDecl->getNodeType() == NT_service) )
[ # # ]
1871 : : {
1872 [ # # ][ # # ]: 0 : pNeeds = new AstNeeds((AstService*)pDecl, *iter, pScope);
1873 [ # # ]: 0 : pScope->addDeclaration(pNeeds);
1874 : : } else
1875 : : {
1876 : : idlc()->error()->
1877 [ # # ][ # # ]: 0 : lookupError(EIDL_SERVICEMEMBER_LOOKUP, *iter, scopeAsDecl(pScope));
[ # # ]
1878 : : }
1879 : 0 : iter++;
1880 : : }
1881 : : }
1882 : : }
1883 [ # # ]: 0 : delete $2;
1884 : : }
1885 : 0 : | property
1886 : : ';'
1887 : : {
1888 [ + - ]: 23273 : idlc()->setParseState(PS_PropertyDeclSeen);
1889 : : }
1890 : 23273 : ;
1891 : :
1892 : : service_interface_header :
1893 : : IDL_INTERFACE
1894 : : {
1895 [ + - ]: 4848 : idlc()->setParseState(PS_ServiceIFHeadSeen);
1896 : 4848 : $$ = AF_INVALID;
1897 : : }
1898 : 4848 : | flag_header
1899 : : IDL_INTERFACE
1900 : : {
1901 [ + - ]: 1566 : idlc()->setParseState(PS_ServiceIFHeadSeen);
1902 [ # # ][ - + ]: 1566 : if ( (AF_OPTIONAL != $1) && ( AF_INVALID != $1) )
1903 [ # # ][ # # ]: 0 : idlc()->error()->flagError(EIDL_OPTIONALEXPECTED, $1);
1904 : 1566 : $$ = $1;
1905 : : }
1906 : 1566 : ;
1907 : :
1908 : : service_service_header :
1909 : : IDL_SERVICE
1910 : : {
1911 [ + - ]: 1700 : idlc()->setParseState(PS_ServiceSHeadSeen);
1912 : 1700 : $$ = AF_INVALID;
1913 : : }
1914 : 1700 : | flag_header
1915 : : IDL_SERVICE
1916 : : {
1917 [ + - ]: 473 : idlc()->setParseState(PS_ServiceSHeadSeen);
1918 [ # # ][ - + ]: 473 : if ( (AF_OPTIONAL != $1) && ( AF_INVALID != $1) )
1919 [ # # ][ # # ]: 0 : idlc()->error()->flagError(EIDL_OPTIONALEXPECTED, $1);
1920 : 473 : $$ = $1;
1921 : : }
1922 : 473 : ;
1923 : :
1924 : : service_dcl :
1925 : : IDL_SERVICE
1926 : : {
1927 [ + - ]: 3797 : idlc()->setParseState(PS_ServiceSeen);
1928 : : }
1929 : 3797 : identifier
1930 : : {
1931 [ + - ]: 3797 : idlc()->setParseState(PS_ServiceIDSeen);
1932 [ + - ]: 3797 : checkIdentifier($3);
1933 : :
1934 [ + - ][ + - ]: 3797 : AstScope* pScope = idlc()->scopes()->topNonNull();
1935 : 3797 : AstService* pService = NULL;
1936 : :
1937 : : /*
1938 : : * Make a new service and add it to the enclosing scope
1939 : : */
1940 [ + - ]: 3797 : if (pScope != NULL)
1941 : : {
1942 [ + - ][ + - ]: 3797 : pService = new AstService(*$3, pScope);
1943 [ + - ]: 3797 : pScope->addDeclaration(pService);
1944 : : }
1945 [ + - ]: 3797 : delete $3;
1946 : : /*
1947 : : * Push it on the stack
1948 : : */
1949 [ + - ][ + - ]: 3797 : idlc()->scopes()->push(pService);
[ + - ]
1950 : : }
1951 : 3797 : service_dfn
1952 : : {
1953 : : /* this service is finished, pop its scope from the stack */
1954 [ + - ][ + - ]: 3797 : idlc()->scopes()->pop();
1955 : : }
1956 : 3797 : ;
1957 : :
1958 : : service_dfn:
1959 : : service_interface_dfn
1960 : : | service_obsolete_dfn
1961 : : ;
1962 : :
1963 : : service_interface_dfn:
1964 : : ':' scoped_name
1965 : : {
1966 [ + - ][ + - ]: 345 : AstScope * scope = idlc()->scopes()->nextToTop();
1967 : : // skip the scope pushed by service_dcl
1968 [ + - ]: 345 : AstDeclaration * decl = scope->lookupByName(*$2);
1969 [ + - ][ + - ]: 345 : if (decl != 0 && resolveTypedefs(decl)->getNodeType() == NT_interface) {
[ + - ][ + - ]
1970 [ + - ][ + - ]: 345 : if (idlc()->error()->checkPublished(decl)) {
[ + - ]
1971 [ + - ][ + - ]: 345 : idlc()->scopes()->top()->addDeclaration(decl);
[ + - ]
1972 : : }
1973 : : } else {
1974 : : idlc()->error()->lookupError(
1975 [ # # ][ # # ]: 0 : EIDL_INTERFACEMEMBER_LOOKUP, *$2, scopeAsDecl(scope));
[ # # ]
1976 : : }
1977 [ + - ]: 345 : delete $2;
1978 : : }
1979 : 345 : opt_service_body
1980 : : {
1981 [ + - ][ + - ]: 345 : AstService * s = static_cast< AstService * >(idlc()->scopes()->top());
[ + - ]
1982 [ + - ]: 345 : if (s != 0) {
1983 : 345 : s->setDefaultConstructor(!$4);
1984 : : }
1985 : : }
1986 : 345 : ;
1987 : :
1988 : : opt_service_body:
1989 : 235 : service_body { $$ = true; }
1990 : 235 : | /* empty */ { $$ = false; }
1991 : 110 : ;
1992 : :
1993 : : service_body:
1994 : : '{'
1995 : : constructors
1996 : : '}'
1997 : : ;
1998 : :
1999 : : constructors:
2000 : : constructors constructor
2001 : : | /* empty */
2002 : : ;
2003 : :
2004 : : constructor:
2005 : : identifier
2006 : : {
2007 [ + - ]: 250 : checkIdentifier($1);
2008 [ + - ][ + - ]: 250 : AstScope * scope = idlc()->scopes()->top();
2009 [ + - ][ + - ]: 250 : AstOperation * ctor = new AstOperation(OP_NONE, 0, *$1, scope);
2010 [ + - ]: 250 : delete $1;
2011 [ + - ]: 250 : scope->addDeclaration(ctor);
2012 [ + - ][ + - ]: 250 : idlc()->scopes()->push(ctor);
[ + - ]
2013 : : }
2014 : 250 : '('
2015 : : parameters
2016 : : ')'
2017 : : opt_raises
2018 : : {
2019 [ + - ][ + - ]: 250 : static_cast< AstOperation * >(idlc()->scopes()->top())->setExceptions(
2020 [ + - ][ + - ]: 250 : $6);
2021 [ + + ]: 250 : delete $6;
2022 [ + - ][ + - ]: 250 : idlc()->scopes()->pop();
2023 [ + - ][ + - ]: 500 : if (static_cast< AstService * >(idlc()->scopes()->top())->
[ + - ][ - + ]
2024 [ + - ]: 250 : checkLastConstructor())
2025 : : {
2026 [ # # ][ # # ]: 0 : idlc()->error()->error0(EIDL_SIMILAR_CONSTRUCTORS);
2027 : : }
2028 : : }
2029 : 250 : ';'
2030 : : ;
2031 : :
2032 : : singleton_dcl :
2033 : : IDL_SINGLETON
2034 : : {
2035 [ + - ]: 163 : idlc()->setParseState(PS_SingletonSeen);
2036 : : }
2037 : 163 : identifier
2038 : : {
2039 [ + - ]: 163 : idlc()->setParseState(PS_SingletonIDSeen);
2040 [ + - ]: 163 : checkIdentifier($3);
2041 : :
2042 [ + - ][ + - ]: 163 : AstScope* pScope = idlc()->scopes()->topNonNull();
2043 : 163 : AstService* pService = NULL;
2044 : :
2045 : : /*
2046 : : * Make a new service and add it to the enclosing scope
2047 : : */
2048 [ + - ]: 163 : if (pScope != NULL)
2049 : : {
2050 [ + - ][ + - ]: 163 : pService = new AstService(NT_singleton, *$3, pScope);
2051 [ + - ]: 163 : pScope->addDeclaration(pService);
2052 : : }
2053 [ + - ]: 163 : delete $3;
2054 : : /*
2055 : : * Push it on the stack
2056 : : */
2057 [ + - ][ + - ]: 163 : idlc()->scopes()->push(pService);
[ + - ]
2058 : : }
2059 : 163 : singleton_dfn
2060 : : {
2061 : : /* this singelton is finished, pop its scope from the stack */
2062 [ + - ][ + - ]: 163 : idlc()->scopes()->pop();
2063 : : }
2064 : 163 : ;
2065 : :
2066 : : singleton_dfn:
2067 : : singleton_interface_dfn
2068 : : | service_obsolete_dfn
2069 : : ;
2070 : :
2071 : : singleton_interface_dfn:
2072 : : ':' scoped_name
2073 : : {
2074 [ + - ][ + - ]: 158 : AstScope * scope = idlc()->scopes()->nextToTop();
2075 : : // skip the scope (needlessly) pushed by singleton_dcl
2076 [ + - ]: 158 : AstDeclaration * decl = scope->lookupByName(*$2);
2077 [ + - ][ + - ]: 158 : if (decl != 0 && resolveTypedefs(decl)->getNodeType() == NT_interface) {
[ + - ][ + - ]
2078 [ + - ][ + - ]: 158 : if (idlc()->error()->checkPublished(decl)) {
[ + - ]
2079 [ + - ][ + - ]: 158 : idlc()->scopes()->top()->addDeclaration(decl);
[ + - ]
2080 : : }
2081 : : } else {
2082 : : idlc()->error()->lookupError(
2083 [ # # ][ # # ]: 0 : EIDL_INTERFACEMEMBER_LOOKUP, *$2, scopeAsDecl(scope));
[ # # ]
2084 : : }
2085 [ + - ]: 158 : delete $2;
2086 : : }
2087 : 158 : ;
2088 : :
2089 : : service_obsolete_dfn:
2090 : : '{'
2091 : : {
2092 : : idlc()->setParseState(
2093 [ + - ][ + - ]: 3457 : idlc()->scopes()->top()->getScopeNodeType() == NT_service
2094 [ + - ][ + + ]: 3457 : ? PS_ServiceSqSeen : PS_SingletonSqSeen);
2095 : : }
2096 : 3457 : service_exports
2097 : : {
2098 : : idlc()->setParseState(
2099 [ + - ][ + - ]: 3457 : idlc()->scopes()->top()->getScopeNodeType() == NT_service
2100 [ + - ][ + + ]: 3457 : ? PS_ServiceBodySeen : PS_SingletonBodySeen);
2101 : : }
2102 : 3457 : '}'
2103 : : {
2104 : : idlc()->setParseState(
2105 [ + - ][ + - ]: 3457 : idlc()->scopes()->top()->getScopeNodeType() == NT_service
2106 [ + - ][ + + ]: 3457 : ? PS_ServiceQsSeen : PS_SingletonQsSeen);
2107 : : }
2108 : 3457 : ;
2109 : :
2110 : : type_dcl :
2111 : : IDL_TYPEDEF
2112 : : {
2113 [ + - ]: 961 : idlc()->setParseState(PS_TypedefSeen);
2114 : : }
2115 : 961 : type_declarator {}
2116 : 961 : | struct_type {}
2117 : 13686 : | union_type {}
2118 : 0 : | enum_type {}
2119 : 5727 : ;
2120 : :
2121 : : type_declarator :
2122 : : type_spec
2123 : : {
2124 [ + - ]: 961 : idlc()->setParseState(PS_TypeSpecSeen);
2125 [ - + ][ - + ]: 961 : if ($1 != 0 && $1->getNodeType() == NT_instantiated_struct) {
[ + - ]
2126 [ # # ][ # # ]: 0 : idlc()->error()->error0(EIDL_INSTANTIATED_STRUCT_TYPE_TYPEDEF);
2127 : : }
2128 : : }
2129 : 961 : at_least_one_declarator
2130 : : {
2131 [ + - ]: 961 : idlc()->setParseState(PS_DeclaratorsSeen);
2132 : :
2133 [ + - ][ + - ]: 961 : AstScope* pScope = idlc()->scopes()->topNonNull();
2134 : 961 : AstTypeDef* pTypeDef = NULL;
2135 : 961 : FeDeclList* pList = $3;
2136 : 961 : FeDeclarator* pDecl = NULL;
2137 : 961 : AstType const * pType = NULL;
2138 : :
2139 : : /*
2140 : : * Create nodes representing typedefs and add them to the
2141 : : * enclosing scope
2142 : : */
2143 [ + - ][ + - ]: 961 : if ( pScope && $1 && pList )
[ + - ]
2144 : : {
2145 : 961 : FeDeclList::iterator iter = pList->begin();
2146 : 961 : FeDeclList::iterator end = pList->end();
2147 : :
2148 [ + + ]: 1922 : while (iter != end)
2149 : : {
2150 : 961 : pDecl = (*iter);
2151 [ - + ]: 961 : if ( !pDecl )
2152 : : {
2153 : 0 : iter++;
2154 : 0 : continue;
2155 : : }
2156 : :
2157 [ + - ]: 961 : pType = pDecl->compose($1);
2158 : :
2159 [ - + ]: 961 : if ( !pType )
2160 : : {
2161 : 0 : iter++;
2162 : 0 : continue;
2163 : : }
2164 : :
2165 [ + - ][ + - ]: 961 : pTypeDef = new AstTypeDef(pType, pDecl->getName(), pScope);
2166 : :
2167 [ + - ]: 961 : pScope->addDeclaration(pTypeDef);
2168 : 961 : iter++;
2169 [ + - ][ + - ]: 961 : delete pDecl;
2170 : : }
2171 [ + - ]: 961 : delete pList;
2172 : : }
2173 : : }
2174 : 961 : ;
2175 : :
2176 : : at_least_one_declarator :
2177 : : declarator declarators
2178 : : {
2179 [ - + ]: 87691 : if ( $2 )
2180 : : {
2181 [ # # ]: 0 : $2->push_back($1);
2182 : 0 : $$ = $2;
2183 : : } else
2184 : : {
2185 [ + - ][ + - ]: 87691 : FeDeclList* pList = new FeDeclList();
2186 [ + - ]: 87691 : pList->push_back($1);
2187 : 87691 : $$ = pList;
2188 : : }
2189 : : }
2190 : 87691 : ;
2191 : :
2192 : : declarators :
2193 : : declarators
2194 : : ','
2195 : : {
2196 [ # # ]: 0 : idlc()->setParseState(PS_DeclsCommaSeen);
2197 : : }
2198 : 0 : declarator
2199 : : {
2200 [ # # ]: 0 : idlc()->setParseState(PS_DeclsDeclSeen);
2201 [ # # ]: 0 : if ( $1 )
2202 : : {
2203 [ # # ]: 0 : $1->push_back($4);
2204 : 0 : $$ = $1;
2205 : : } else
2206 : : {
2207 [ # # ][ # # ]: 0 : FeDeclList* pList = new FeDeclList();
2208 [ # # ]: 0 : pList->push_back($4);
2209 : 0 : $$ = pList;
2210 : : }
2211 : : }
2212 : 0 : | /* EMPTY */
2213 : : {
2214 : 87691 : $$ = NULL;
2215 : : }
2216 : 87691 : ;
2217 : :
2218 : : declarator :
2219 : : simple_declarator
2220 : : | complex_declarator
2221 : : ;
2222 : :
2223 : : simple_declarator :
2224 : : identifier
2225 : : {
2226 : : // For historic reasons, the struct com.sun.star.uno.Uik contains
2227 : : // members with illegal names (of the form "m_DataN"); avoid useless
2228 : : // warnings about them:
2229 [ + - ][ + - ]: 185619 : AstScope * scope = idlc()->scopes()->top();
2230 [ + - ][ + + ]: 238963 : if (scope == 0 || scope->getScopeNodeType() != NT_struct
[ + + ][ + + ]
2231 [ + - ]: 53344 : || (scopeAsDecl(scope)->getScopedName()
2232 [ + - ]: 53344 : != "com::sun::star::uno::Uik"))
2233 : : {
2234 [ + - ]: 177479 : checkIdentifier($1);
2235 : : }
2236 : :
2237 [ + - ][ + - ]: 185619 : $$ = new FeDeclarator(*$1, FeDeclarator::FD_simple, NULL);
2238 [ + - ]: 185619 : delete $1;
2239 : : }
2240 : 185619 : ;
2241 : :
2242 : : complex_declarator :
2243 : : array_declarator
2244 : : {
2245 [ # # ][ # # ]: 0 : $$ = new FeDeclarator($1->getLocalName(), FeDeclarator::FD_complex, $1);
2246 : : }
2247 : 0 : ;
2248 : :
2249 : : array_declarator :
2250 : : identifier
2251 : : {
2252 [ # # ]: 0 : idlc()->setParseState(PS_ArrayIDSeen);
2253 [ # # ]: 0 : checkIdentifier($1);
2254 : : }
2255 : 0 : at_least_one_array_dim
2256 : : {
2257 [ # # ]: 0 : idlc()->setParseState(PS_ArrayCompleted);
2258 [ # # ][ # # ]: 0 : $$ = new AstArray(*$1, NULL, *$3, idlc()->scopes()->bottom());
[ # # ][ # # ]
2259 [ # # ]: 0 : delete $1;
2260 : : }
2261 : 0 : ;
2262 : :
2263 : : at_least_one_array_dim :
2264 : : array_dim array_dims
2265 : : {
2266 [ # # ]: 0 : if( $2 )
2267 : : {
2268 [ # # ]: 0 : $2->push_front($1);
2269 : 0 : $$ = $2;
2270 : : } else
2271 : : {
2272 [ # # ][ # # ]: 0 : ExprList* pList = new ExprList();
2273 [ # # ]: 0 : pList->push_back($1);
2274 : 0 : $$ = pList;
2275 : : }
2276 : : }
2277 : 0 : ;
2278 : :
2279 : : array_dims :
2280 : : array_dims array_dim
2281 : : {
2282 [ # # ]: 0 : if( $1 )
2283 : : {
2284 [ # # ]: 0 : $1->push_back($2);
2285 : 0 : $$ = $1;
2286 : : } else
2287 : : {
2288 [ # # ][ # # ]: 0 : ExprList* pList = new ExprList();
2289 [ # # ]: 0 : pList->push_back($2);
2290 : 0 : $$ = pList;
2291 : : }
2292 : : }
2293 : 0 : | /* EMPTY */
2294 : : {
2295 : 0 : $$ = NULL;
2296 : : }
2297 : 0 : ;
2298 : :
2299 : : array_dim :
2300 : : '['
2301 : : {
2302 [ # # ]: 0 : idlc()->setParseState(PS_DimSqSeen);
2303 : : }
2304 : 0 : positive_int_expr
2305 : : {
2306 [ # # ]: 0 : idlc()->setParseState(PS_DimExprSeen);
2307 : : }
2308 : 0 : ']'
2309 : : {
2310 [ # # ]: 0 : idlc()->setParseState(PS_DimQsSeen);
2311 : : /*
2312 : : * Array dimensions are expressions which must be coerced to
2313 : : * positive integers
2314 : : */
2315 [ # # ][ # # ]: 0 : if ( !$3 || !$3->coerce(ET_uhyper) )
[ # # ][ # # ]
2316 : : {
2317 [ # # ][ # # ]: 0 : idlc()->error()->coercionError($3, ET_uhyper);
2318 : 0 : $$ = NULL;
2319 : : } else
2320 : 0 : $$ = $3;
2321 : : }
2322 : 0 : ;
2323 : :
2324 : : at_least_one_scoped_name :
2325 : : scoped_name scoped_names
2326 : : {
2327 [ - + ]: 8587 : if ($2)
2328 : : {
2329 [ # # ]: 0 : $2->push_front(*$1);
2330 : 0 : $$ = $2;
2331 : : } else
2332 : : {
2333 [ + - ][ + - ]: 8587 : StringList* pNames = new StringList();
2334 [ + - ]: 8587 : pNames->push_back(*$1);
2335 : 8587 : $$ = pNames;
2336 : : }
2337 [ + - ]: 8587 : delete($1);
2338 : : }
2339 : 8587 : ;
2340 : :
2341 : : scoped_names :
2342 : : scoped_names
2343 : : ','
2344 : : {
2345 [ # # ]: 0 : idlc()->setParseState(PS_SNListCommaSeen);
2346 : : }
2347 : 0 : scoped_name
2348 : : {
2349 [ # # ]: 0 : idlc()->setParseState(PS_ScopedNameSeen);
2350 [ # # ]: 0 : if ($1)
2351 : : {
2352 [ # # ]: 0 : $1->push_back(*$4);
2353 : 0 : $$ = $1;
2354 : : } else
2355 : : {
2356 [ # # ][ # # ]: 0 : StringList* pNames = new StringList();
2357 [ # # ]: 0 : pNames->push_back(*$4);
2358 : 0 : $$ = pNames;
2359 : : }
2360 [ # # ]: 0 : delete($4);
2361 : : }
2362 : 0 : | /* EMPTY */
2363 : : {
2364 : 8587 : $$ = NULL;
2365 : : }
2366 : 8587 : ;
2367 : :
2368 : : scoped_name :
2369 : : identifier
2370 : : {
2371 [ + - ]: 173588 : idlc()->setParseState(PS_SN_IDSeen);
2372 [ + - ]: 173588 : checkIdentifier($1);
2373 : 173588 : $$ = $1;
2374 : : }
2375 : 173588 : | IDL_SCOPESEPARATOR
2376 : : {
2377 [ + - ]: 14042 : idlc()->setParseState(PS_ScopeDelimSeen);
2378 : : }
2379 : 14042 : identifier
2380 : : {
2381 [ + - ]: 14042 : checkIdentifier($3);
2382 [ + - ]: 14042 : OString* pName = new OString("::");
2383 : 14042 : *pName += *$3;
2384 [ + - ]: 14042 : delete $3;
2385 : 14042 : $$ = pName;
2386 : : }
2387 : 14042 : | scoped_name
2388 : : IDL_SCOPESEPARATOR
2389 : : {
2390 : : }
2391 : 571509 : identifier
2392 : : {
2393 [ + - ]: 571509 : checkIdentifier($4);
2394 : 571509 : *$1 += ::rtl::OString("::");
2395 : 571509 : *$1 += *$4;
2396 [ + - ]: 571509 : delete $4;
2397 : 571509 : $$ = $1;
2398 : : }
2399 : 571509 : ;
2400 : :
2401 : : type_spec :
2402 : : simple_type_spec
2403 : : | constructed_type_spec
2404 : : ;
2405 : :
2406 : : simple_type_spec :
2407 : : fundamental_type
2408 : : | scoped_name opt_type_args
2409 : : {
2410 [ + - ]: 81086 : $$ = createNamedType($1, $2);
2411 : : }
2412 : 81086 : ;
2413 : :
2414 : : fundamental_type:
2415 : : base_type_spec
2416 : : {
2417 [ + - ][ + - ]: 164021 : $$ = idlc()->scopes()->bottom()->lookupPrimitiveType($1);
[ + - ]
2418 : : }
2419 : 164021 : | template_type_spec
2420 : : ;
2421 : :
2422 : : opt_type_args:
2423 : 159 : '<' type_args '>' { $$ = $2; }
2424 : 159 : | /* empty */ { $$ = 0; }
2425 : 90849 : ;
2426 : :
2427 : : type_args:
2428 : : type_arg
2429 : : {
2430 [ + - ][ + - ]: 159 : $$ = new DeclList;
2431 [ + - ]: 159 : $$->push_back(const_cast< AstDeclaration * >($1)); //TODO: const_cast
2432 : : }
2433 : 159 : | type_args ',' type_arg
2434 : : {
2435 [ + - ]: 52 : $1->push_back(const_cast< AstDeclaration * >($3)); //TODO: const_cast
2436 : 52 : $$ = $1;
2437 : : }
2438 : 52 : ;
2439 : :
2440 : : type_arg:
2441 : : simple_type_spec
2442 : : {
2443 [ + - ][ + - ]: 211 : if ($1 != 0 && static_cast< AstType const * >($1)->isUnsigned()) {
[ - + ][ - + ]
2444 [ # # ][ # # ]: 0 : idlc()->error()->error0(EIDL_UNSIGNED_TYPE_ARGUMENT);
2445 : : }
2446 : 211 : $$ = $1;
2447 : : }
2448 : 211 : ;
2449 : :
2450 : : base_type_spec :
2451 : : integer_type
2452 : : | floating_pt_type
2453 : : | char_type
2454 : : | boolean_type
2455 : : | byte_type
2456 : : | any_type
2457 : : | type_type
2458 : : | string_type
2459 : : ;
2460 : :
2461 : : integer_type :
2462 : : signed_int
2463 : : | unsigned_int
2464 : : ;
2465 : :
2466 : : signed_int :
2467 : : IDL_LONG
2468 : : {
2469 : 43992 : $$ = ET_long;
2470 : : }
2471 : 43992 : | IDL_HYPER
2472 : : {
2473 : 264 : $$ = ET_hyper;
2474 : : }
2475 : 264 : | IDL_SHORT
2476 : : {
2477 : 20643 : $$ = ET_short;
2478 : : }
2479 : 20643 : ;
2480 : :
2481 : : unsigned_int :
2482 : : IDL_UNSIGNED IDL_LONG
2483 : : {
2484 : 5058 : $$ = ET_ulong;
2485 : : }
2486 : 5058 : | IDL_UNSIGNED IDL_HYPER
2487 : : {
2488 : 29 : $$ = ET_uhyper;
2489 : : }
2490 : 29 : | IDL_UNSIGNED IDL_SHORT
2491 : : {
2492 : 4082 : $$ = ET_ushort;
2493 : : }
2494 : 4082 : ;
2495 : :
2496 : : floating_pt_type :
2497 : : IDL_DOUBLE
2498 : : {
2499 : 3109 : $$ = ET_double;
2500 : : }
2501 : 3109 : | IDL_FLOAT
2502 : : {
2503 : 1570 : $$ = ET_float;
2504 : : }
2505 : 1570 : ;
2506 : :
2507 : : char_type :
2508 : : IDL_CHAR
2509 : : {
2510 : 988 : $$ = ET_char;
2511 : : }
2512 : 988 : ;
2513 : :
2514 : : byte_type :
2515 : : IDL_BYTE
2516 : : {
2517 : 3106 : $$ = ET_byte;
2518 : : }
2519 : 3106 : ;
2520 : :
2521 : : boolean_type :
2522 : : IDL_BOOLEAN
2523 : : {
2524 : 22489 : $$ = ET_boolean;
2525 : : }
2526 : 22489 : ;
2527 : :
2528 : : any_type :
2529 : : IDL_ANY
2530 : : {
2531 : 19387 : $$ = ET_any;
2532 : : }
2533 : 19387 : ;
2534 : :
2535 : : type_type :
2536 : : IDL_TYPE
2537 : : {
2538 : 6341 : $$ = ET_type;
2539 : : }
2540 : 6341 : ;
2541 : :
2542 : : string_type :
2543 : : IDL_STRING
2544 : : {
2545 : 47646 : $$ = ET_string;
2546 : : }
2547 : 47646 : ;
2548 : :
2549 : : template_type_spec :
2550 : : sequence_type_spec
2551 : : | array_type
2552 : : ;
2553 : :
2554 : : constructed_type_spec :
2555 : : struct_type
2556 : : | union_type
2557 : : | enum_type
2558 : : ;
2559 : :
2560 : : array_type :
2561 : : simple_type_spec
2562 : : {
2563 [ # # ]: 0 : idlc()->setParseState(PS_ArrayTypeSeen);
2564 : : }
2565 : 0 : at_least_one_array_dim
2566 : : {
2567 [ # # ]: 0 : idlc()->setParseState(PS_ArrayCompleted);
2568 : :
2569 [ # # ][ # # ]: 0 : AstScope* pScope = idlc()->scopes()->bottom();
2570 : 0 : AstDeclaration* pDecl = NULL;
2571 : 0 : AstDeclaration* pArray = NULL;
2572 : :
2573 [ # # ]: 0 : if ( $1 )
2574 : : {
2575 [ # # ][ # # ]: 0 : pArray = new AstArray((AstType*)$1, *$3, idlc()->scopes()->bottom());
[ # # ][ # # ]
2576 [ # # ]: 0 : if ( pScope )
2577 : : {
2578 [ # # ]: 0 : pDecl = pScope->addDeclaration(pArray);
2579 [ # # ]: 0 : if ( pArray != pDecl )
2580 : : {
2581 : : // if array type already defined then use it
2582 [ # # ][ # # ]: 0 : delete pArray;
2583 : 0 : pArray = pDecl;
2584 : : }
2585 : : }
2586 : : }
2587 : 0 : $$ = pArray;
2588 : : }
2589 : 0 : ;
2590 : :
2591 : : sequence_type_spec :
2592 : : IDL_SEQUENCE
2593 : : {
2594 [ + - ]: 21282 : idlc()->setParseState(PS_SequenceSeen);
2595 : : /*
2596 : : * Push a sequence marker on scopes stack
2597 : : */
2598 [ + - ][ + - ]: 21282 : idlc()->scopes()->push(NULL);
2599 : : }
2600 : 21282 : '<'
2601 : : {
2602 [ + - ]: 21282 : idlc()->setParseState(PS_SequenceSqSeen);
2603 : : }
2604 : 21282 : simple_type_spec
2605 : : {
2606 [ + - ]: 21282 : idlc()->setParseState(PS_SequenceTypeSeen);
2607 : : }
2608 : 21282 : '>'
2609 : : {
2610 [ + - ]: 21282 : idlc()->setParseState(PS_SequenceQsSeen);
2611 : : /*
2612 : : * Remove sequence marker from scopes stack
2613 : : */
2614 [ + - ][ + - ]: 21282 : if (idlc()->scopes()->top() == NULL)
[ + - ]
2615 [ + - ][ + - ]: 21282 : idlc()->scopes()->pop();
2616 : : /*
2617 : : * Create a node representing a sequence
2618 : : */
2619 [ + - ][ + - ]: 21282 : AstScope* pScope = idlc()->scopes()->bottom();
2620 : 21282 : AstDeclaration* pDecl = NULL;
2621 : 21282 : AstDeclaration* pSeq = NULL;
2622 : :
2623 [ + - ]: 21282 : if ( $5 )
2624 : : {
2625 : 21282 : AstType *pType = (AstType*)$5;
2626 [ + - ]: 21282 : if ( pType )
2627 : : {
2628 [ + - ][ + - ]: 21282 : pSeq = new AstSequence(pType, pScope);
2629 : : /*
2630 : : * Add this AstSequence to the types defined in the global scope
2631 : : */
2632 [ + - ]: 21282 : pDecl = pScope->addDeclaration(pSeq);
2633 [ + + ]: 21282 : if ( pSeq != pDecl )
2634 : : {
2635 : : // if sequence type already defined then use it
2636 [ + - ][ + - ]: 8970 : delete pSeq;
2637 : 8970 : pSeq = pDecl;
2638 : : }
2639 : : }
2640 : : }
2641 : 21282 : $$ = pSeq;
2642 : : }
2643 : 21282 : | error '>'
2644 : : {
2645 [ # # ]: 0 : yyerror("sequence declaration");
2646 : 0 : yyerrok;
2647 : 0 : $$ = 0;
2648 : : }
2649 : 0 : ;
2650 : :
2651 : : struct_type :
2652 : : structure_header
2653 : : {
2654 [ + - ]: 13686 : idlc()->setParseState(PS_StructHeaderSeen);
2655 : :
2656 [ + - ][ + - ]: 13686 : AstScope* pScope = idlc()->scopes()->topNonNull();
2657 : 13686 : AstStruct* pStruct = NULL;
2658 : :
2659 [ + - ]: 13686 : if ( pScope )
2660 : : {
2661 : 13686 : AstStruct* pBase= static_cast< AstStruct* >($1->getInherits());
2662 : : pStruct = new AstStruct(
2663 [ + - ][ + - ]: 13686 : *$1->getName(), $1->getTypeParameters(), pBase, pScope);
2664 [ + - ]: 13686 : pScope->addDeclaration(pStruct);
2665 : : }
2666 : : /*
2667 : : * Push the scope of the struct on the scopes stack
2668 : : */
2669 [ + - ][ + - ]: 13686 : idlc()->scopes()->push(pStruct);
[ + - ]
2670 [ + - ][ + - ]: 13686 : delete $1;
2671 : : }
2672 : 13686 : '{'
2673 : : {
2674 [ + - ]: 13686 : idlc()->setParseState(PS_StructSqSeen);
2675 : : }
2676 : 13686 : at_least_one_member
2677 : : {
2678 [ + - ]: 13686 : idlc()->setParseState(PS_StructBodySeen);
2679 : : }
2680 : 13686 : '}'
2681 : : {
2682 [ + - ]: 13686 : idlc()->setParseState(PS_StructQsSeen);
2683 : : /* this exception is finished, pop its scope from the stack */
2684 [ + - ][ + - ]: 13686 : idlc()->scopes()->pop();
2685 : : }
2686 : 13686 : ;
2687 : :
2688 : : structure_header :
2689 : : IDL_STRUCT
2690 : : {
2691 [ + - ]: 13686 : idlc()->setParseState(PS_StructSeen);
2692 : : }
2693 : 13686 : identifier
2694 : : {
2695 [ + - ]: 13686 : idlc()->setParseState(PS_StructIDSeen);
2696 [ + - ]: 13686 : checkIdentifier($3);
2697 : : }
2698 : 13686 : opt_type_params
2699 : : inheritance_spec
2700 : : {
2701 [ + - ]: 13686 : idlc()->setParseState(PS_InheritSpecSeen);
2702 : :
2703 : : // Polymorphic struct type templates with base types would cause various
2704 : : // problems in language bindings, so forbid them here. For example,
2705 : : // GCC prior to version 3.4 fails with code like
2706 : : //
2707 : : // struct Base { ... };
2708 : : // template< typename typeparam_T > struct Derived: public Base {
2709 : : // int member1 CPPU_GCC3_ALIGN(Base);
2710 : : // ... };
2711 : : //
2712 : : // (Note that plain struct types with instantiated polymorphic struct
2713 : : // type bases, which might also cause problems in language bindings, are
2714 : : // already rejected on a syntactic level.)
2715 [ - + ][ + + ]: 13686 : if ($5 != 0 && $6 != 0) {
2716 [ # # ][ # # ]: 0 : idlc()->error()->error0(EIDL_STRUCT_TYPE_TEMPLATE_WITH_BASE);
2717 : : }
2718 : :
2719 [ + - ][ + - ]: 13686 : $$ = new FeInheritanceHeader(NT_struct, $3, $6, $5);
2720 [ + + ]: 13686 : delete $5;
2721 [ + + ]: 13686 : delete $6;
2722 : : }
2723 : 13686 : ;
2724 : :
2725 : : opt_type_params:
2726 : 49 : '<' type_params '>' { $$ = $2; }
2727 : 49 : | /* empty */ { $$ = 0; }
2728 : 13637 : ;
2729 : :
2730 : : type_params:
2731 : : identifier
2732 : : {
2733 [ + - ][ + - ]: 49 : $$ = new std::vector< rtl::OString >;
2734 [ + - ]: 49 : $$->push_back(*$1);
2735 [ + - ]: 49 : delete $1;
2736 : : }
2737 : 49 : | type_params ',' identifier
2738 : : {
2739 [ + - ][ + - ]: 19 : if (std::find($1->begin(), $1->end(), *$3) != $1->end()) {
[ - + ]
2740 [ # # ][ # # ]: 0 : idlc()->error()->error0(EIDL_IDENTICAL_TYPE_PARAMETERS);
2741 : : }
2742 [ + - ]: 19 : $1->push_back(*$3);
2743 [ + - ]: 19 : delete $3;
2744 : 19 : $$ = $1;
2745 : : }
2746 : 19 : ;
2747 : :
2748 : : at_least_one_member : member members ;
2749 : :
2750 : : members :
2751 : : members member
2752 : : | /* EMPTY */
2753 : : ;
2754 : :
2755 : : member :
2756 : : type_or_parameter
2757 : : {
2758 [ + - ]: 63457 : idlc()->setParseState(PS_MemberTypeSeen);
2759 : : }
2760 : 63457 : at_least_one_declarator
2761 : : {
2762 [ + - ]: 63457 : idlc()->setParseState(PS_MemberDeclsSeen);
2763 : : }
2764 : 63457 : ';'
2765 : : {
2766 [ + - ]: 63457 : idlc()->setParseState(PS_MemberDeclsCompleted);
2767 : :
2768 [ + - ][ + - ]: 63457 : AstScope* pScope = idlc()->scopes()->topNonNull();
2769 : 63457 : AstMember* pMember = NULL;
2770 : 63457 : FeDeclList* pList = $3;
2771 : 63457 : FeDeclarator* pDecl = NULL;
2772 : 63457 : AstType const * pType = NULL;
2773 : :
2774 : : // !!! check recursive type
2775 : :
2776 [ + - ][ + - ]: 63457 : if ( pScope && pList && $1 )
[ + - ]
2777 : : {
2778 : 63457 : FeDeclList::iterator iter = pList->begin();
2779 : 63457 : FeDeclList::iterator end = pList->end();
2780 [ + + ]: 126914 : while (iter != end)
2781 : : {
2782 : 63457 : pDecl = (*iter);
2783 [ - + ]: 63457 : if ( !pDecl )
2784 : : {
2785 : 0 : iter++;
2786 : 0 : continue;
2787 : : }
2788 : :
2789 [ + - ]: 63457 : pType = pDecl->compose($1);
2790 : :
2791 [ - + ]: 63457 : if ( !pType )
2792 : : {
2793 : 0 : iter++;
2794 : 0 : continue;
2795 : : }
2796 : :
2797 [ + - ][ + - ]: 63457 : pMember = new AstMember(pType, pDecl->getName(), pScope);
2798 : :
2799 [ + - ]: 63457 : if ( !pDecl->checkType($1) )
2800 : : {
2801 : : // WARNING
2802 : : }
2803 : :
2804 [ + - ]: 63457 : pScope->addDeclaration(pMember);
2805 : 63457 : iter++;
2806 [ + - ][ + - ]: 63457 : delete pDecl;
2807 : : }
2808 [ + - ]: 63457 : delete pList;
2809 : : }
2810 : : }
2811 : 63457 : | error ';'
2812 : : {
2813 [ # # ]: 0 : yyerror("member definition");
2814 : 0 : yyerrok;
2815 : : }
2816 : 0 : ;
2817 : :
2818 : : type_or_parameter:
2819 : : fundamental_type
2820 : : | scoped_name opt_type_args
2821 : : {
2822 : 9922 : AstDeclaration const * decl = 0;
2823 [ + - ][ + - ]: 9922 : AstStruct * scope = static_cast< AstStruct * >(idlc()->scopes()->top());
[ + - ]
2824 [ + - ][ + + ]: 9922 : if (scope != 0 && $2 == 0) {
2825 [ + - ]: 9916 : decl = scope->findTypeParameter(*$1);
2826 : : }
2827 [ + + ]: 9922 : if (decl != 0) {
2828 [ + - ]: 66 : delete $1;
2829 [ - + ]: 66 : delete $2;
2830 : : } else {
2831 [ + - ]: 9856 : decl = createNamedType($1, $2);
2832 [ + - ][ + - ]: 9856 : if (scope != 0 && includes(decl, scopeAsDecl(scope))) {
[ + - ][ + - ]
[ - + ][ - + ]
2833 : : idlc()->error()->error1(
2834 [ # # ][ # # ]: 0 : EIDL_RECURSIVE_TYPE, scopeAsDecl(scope));
[ # # ][ # # ]
2835 : 0 : decl = 0;
2836 : : }
2837 : : }
2838 : 9922 : $$ = decl;
2839 : : }
2840 : 9922 : ;
2841 : :
2842 : : enum_type :
2843 : : IDL_ENUM
2844 : : {
2845 [ + - ]: 5727 : idlc()->setParseState(PS_EnumSeen);
2846 : : }
2847 : 5727 : identifier
2848 : : {
2849 [ + - ]: 5727 : idlc()->setParseState(PS_EnumIDSeen);
2850 [ + - ]: 5727 : checkIdentifier($3);
2851 : :
2852 [ + - ][ + - ]: 5727 : AstScope* pScope = idlc()->scopes()->topNonNull();
2853 : 5727 : AstEnum* pEnum = NULL;
2854 : :
2855 : : /*
2856 : : * Create a node representing an enum and add it to its
2857 : : * enclosing scope
2858 : : */
2859 [ + - ]: 5727 : if (pScope != NULL)
2860 : : {
2861 [ + - ][ + - ]: 5727 : pEnum = new AstEnum(*$3, pScope);
2862 : : /*
2863 : : * Add it to its defining scope
2864 : : */
2865 [ + - ]: 5727 : pScope->addDeclaration(pEnum);
2866 : : }
2867 [ + - ]: 5727 : delete $3;
2868 : : /*
2869 : : * Push the enum scope on the scopes stack
2870 : : */
2871 [ + - ][ + - ]: 5727 : idlc()->scopes()->push(pEnum);
[ + - ]
2872 : :
2873 : : }
2874 : 5727 : '{'
2875 : : {
2876 [ + - ]: 5727 : idlc()->setParseState(PS_EnumSqSeen);
2877 : : }
2878 : 5727 : at_least_one_enumerator
2879 : : {
2880 [ + - ]: 5727 : idlc()->setParseState(PS_EnumBodySeen);
2881 : : }
2882 : 5727 : '}'
2883 : : {
2884 [ + - ]: 5727 : idlc()->setParseState(PS_EnumQsSeen);
2885 : : /*
2886 : : * Done with this enum. Pop its scope from the scopes stack
2887 : : */
2888 [ + - ][ - + ]: 5727 : if (idlc()->scopes()->top() == NULL)
[ + - ]
2889 : 0 : $$ = NULL;
2890 : : else
2891 : : {
2892 [ + - ][ + - ]: 5727 : $$ = (AstEnum*)idlc()->scopes()->topNonNull();
[ + - ]
2893 [ + - ][ + - ]: 5727 : idlc()->scopes()->pop();
2894 : : }
2895 : : }
2896 : 5727 : ;
2897 : :
2898 : : at_least_one_enumerator : enumerator enumerators ;
2899 : :
2900 : : enumerators :
2901 : : enumerators
2902 : : ','
2903 : : {
2904 [ + - ]: 72875 : idlc()->setParseState(PS_EnumCommaSeen);
2905 : : }
2906 : 72875 : enumerator
2907 : : | /* EMPTY */
2908 : : | error ','
2909 : : {
2910 [ # # ]: 0 : yyerror("enumerator definition");
2911 : 0 : yyerrok;
2912 : : }
2913 : 0 : ;
2914 : :
2915 : : enumerator :
2916 : : identifier
2917 : : {
2918 [ + - ]: 77704 : checkIdentifier($1);
2919 : :
2920 [ + - ][ + - ]: 77704 : AstScope* pScope = idlc()->scopes()->topNonNull();
2921 : 77704 : AstEnum* pEnum = NULL;
2922 : 77704 : AstConstant* pEnumVal = NULL;
2923 : :
2924 [ + - ][ + - ]: 77704 : if ( pScope && pScope->getScopeNodeType() == NT_enum)
[ + - ]
2925 : : {
2926 [ + - ]: 77704 : pEnum = (AstEnum*)pScope;
2927 [ + - ][ + - ]: 77704 : if (pEnum && $1)
2928 : : {
2929 [ + - ][ + - ]: 77704 : AstExpression* pExpr = new AstExpression(pEnum->getEnumValueCount());
2930 : : pEnumVal = new AstConstant(ET_long , NT_enum_val,
2931 [ + - ][ + - ]: 77704 : pExpr, *$1, pScope);
2932 : : }
2933 [ + - ][ - + ]: 77704 : if ( pEnum->checkValue(pEnumVal->getConstValue()) )
2934 [ # # ][ # # ]: 0 : idlc()->error()->error1(EIDL_EVAL_ERROR, pEnum);
2935 : :
2936 [ + - ]: 77704 : pScope->addDeclaration(pEnumVal);
2937 : : }
2938 [ + - ]: 77704 : delete $1;
2939 : : }
2940 : 77704 : | identifier
2941 : : '='
2942 : : const_expr
2943 : : {
2944 [ + - ]: 898 : checkIdentifier($1);
2945 : :
2946 [ + - ][ + - ]: 898 : AstScope* pScope = idlc()->scopes()->topNonNull();
2947 : 898 : AstEnum* pEnum = NULL;
2948 : 898 : AstConstant* pEnumVal = NULL;
2949 : :
2950 [ + - ][ + - ]: 898 : if ( $3 && pScope && pScope->getScopeNodeType() == NT_enum)
[ + - ][ + - ]
2951 : : {
2952 [ + - ]: 898 : $3->evaluate(EK_const);
2953 [ + - ][ + - ]: 898 : if ( $3->coerce(ET_long) )
2954 : : {
2955 [ + - ]: 898 : pEnum = (AstEnum*)pScope;
2956 [ + - ]: 898 : if (pEnum)
2957 : : {
2958 : : pEnumVal = new AstConstant(ET_long , NT_enum_val,
2959 [ + - ][ + - ]: 898 : $3, *$1, pScope);
2960 : : }
2961 [ + - ][ - + ]: 898 : if ( pEnum->checkValue(pEnumVal->getConstValue()) )
2962 [ # # ][ # # ]: 0 : idlc()->error()->error1(EIDL_EVAL_ERROR, pEnum);
2963 : :
2964 [ + - ]: 898 : pScope->addDeclaration(pEnumVal);
2965 : : } else
2966 : : {
2967 [ # # ][ # # ]: 0 : idlc()->error()->coercionError($3, ET_long);
2968 [ # # ][ # # ]: 0 : delete $3;
2969 : : }
2970 : : }
2971 [ + - ]: 898 : delete $1;
2972 : : }
2973 : 898 : ;
2974 : :
2975 : : union_type :
2976 : : IDL_UNION
2977 : : {
2978 [ # # ]: 0 : idlc()->setParseState(PS_UnionSeen);
2979 : : }
2980 : 0 : identifier
2981 : : {
2982 [ # # ]: 0 : idlc()->setParseState(PS_UnionIDSeen);
2983 [ # # ]: 0 : checkIdentifier($3);
2984 : : }
2985 : 0 : IDL_SWITCH
2986 : : {
2987 [ # # ]: 0 : idlc()->setParseState(PS_SwitchSeen);
2988 : : }
2989 : 0 : '('
2990 : : {
2991 [ # # ]: 0 : idlc()->setParseState(PS_SwitchOpenParSeen);
2992 : : }
2993 : 0 : switch_type_spec
2994 : : {
2995 [ # # ]: 0 : idlc()->setParseState(PS_SwitchTypeSeen);
2996 : : }
2997 : 0 : ')'
2998 : : {
2999 [ # # ]: 0 : idlc()->setParseState(PS_SwitchCloseParSeen);
3000 : :
3001 [ # # ][ # # ]: 0 : AstScope* pScope = idlc()->scopes()->topNonNull();
3002 : 0 : AstUnion* pUnion = NULL;
3003 : :
3004 : : /*
3005 : : * Create a node representing a union. Add it to its enclosing
3006 : : * scope
3007 : : */
3008 [ # # ][ # # ]: 0 : if ( $9 && pScope )
3009 : : {
3010 : 0 : AstType* pType = (AstType*)$9;
3011 [ # # ]: 0 : if ( !pType)
3012 : : {
3013 [ # # ][ # # ]: 0 : idlc()->error()->noTypeError($9);
3014 : : } else
3015 : : {
3016 [ # # ][ # # ]: 0 : pUnion = new AstUnion(*$3, pType, pScope);
3017 [ # # ]: 0 : pScope->addDeclaration(pUnion);
3018 : : }
3019 : : }
3020 [ # # ]: 0 : delete $3;
3021 : : /*
3022 : : * Push the scope of the union on the scopes stack
3023 : : */
3024 [ # # ][ # # ]: 0 : idlc()->scopes()->push(pUnion);
[ # # ]
3025 : : }
3026 : 0 : '{'
3027 : : {
3028 [ # # ]: 0 : idlc()->setParseState(PS_UnionSqSeen);
3029 : : }
3030 : 0 : at_least_one_case_branch
3031 : : {
3032 [ # # ]: 0 : idlc()->setParseState(PS_UnionBodySeen);
3033 : : }
3034 : 0 : '}'
3035 : : {
3036 [ # # ]: 0 : idlc()->setParseState(PS_UnionQsSeen);
3037 : : /* this union is finished, pop its scope from the stack */
3038 [ # # ][ # # ]: 0 : idlc()->scopes()->pop();
3039 : : }
3040 : 0 : ;
3041 : :
3042 : : switch_type_spec :
3043 : : integer_type
3044 : : {
3045 [ # # ][ # # ]: 0 : $$ = idlc()->scopes()->bottom()->lookupPrimitiveType($1);
[ # # ]
3046 : : }
3047 : 0 : | char_type
3048 : : {
3049 [ # # ][ # # ]: 0 : $$ = idlc()->scopes()->bottom()->lookupPrimitiveType($1);
[ # # ]
3050 : : }
3051 : 0 : | boolean_type
3052 : : {
3053 [ # # ][ # # ]: 0 : $$ = idlc()->scopes()->bottom()->lookupPrimitiveType($1);
[ # # ]
3054 : : }
3055 : 0 : | enum_type
3056 : : | scoped_name
3057 : : {
3058 [ # # ][ # # ]: 0 : AstScope* pScope = idlc()->scopes()->topNonNull();
3059 : 0 : AstBaseType* pBaseType = NULL;
3060 : 0 : AstDeclaration const * pDecl = NULL;
3061 : 0 : AstTypeDef* pTypeDef = NULL;
3062 : 0 : sal_Bool bFound = sal_False;
3063 : : /*
3064 : : * If the constant's type is a scoped name, it must resolve
3065 : : * to a scalar constant type
3066 : : */
3067 [ # # ][ # # ]: 0 : if ( pScope && (pDecl = pScope->lookupByName(*$1)) )
[ # # ][ # # ]
3068 : : {
3069 : : /*
3070 : : * Look through typedefs
3071 : : */
3072 [ # # ]: 0 : while ( !bFound )
3073 : : {
3074 [ # # # # ]: 0 : switch (pDecl->getNodeType())
3075 : : {
3076 : : case NT_enum:
3077 : 0 : $$ = pDecl;
3078 : 0 : bFound = sal_True;
3079 : 0 : break;
3080 : : case NT_predefined:
3081 : 0 : pBaseType = (AstBaseType*)pDecl;
3082 [ # # ]: 0 : if ( pBaseType )
3083 : : {
3084 [ # # ]: 0 : switch (pBaseType->getExprType())
3085 : : {
3086 : : case ET_short:
3087 : : case ET_ushort:
3088 : : case ET_long:
3089 : : case ET_ulong:
3090 : : case ET_hyper:
3091 : : case ET_uhyper:
3092 : : case ET_char:
3093 : : case ET_byte:
3094 : : case ET_boolean:
3095 : 0 : $$ = pBaseType;
3096 : 0 : bFound = sal_True;
3097 : 0 : break;
3098 : : default:
3099 : 0 : $$ = NULL;
3100 : 0 : bFound = sal_True;
3101 : 0 : break;
3102 : : }
3103 : : }
3104 : 0 : break;
3105 : : case NT_typedef:
3106 : 0 : pTypeDef = (AstTypeDef*)pDecl;
3107 [ # # ]: 0 : if ( pTypeDef )
3108 : 0 : pDecl = pTypeDef->getBaseType();
3109 : 0 : break;
3110 : : default:
3111 : 0 : $$ = NULL;
3112 : 0 : bFound = sal_True;
3113 : 0 : break;
3114 : : }
3115 : : }
3116 : : } else
3117 : 0 : $$ = NULL;
3118 : :
3119 [ # # ]: 0 : if ($$ == NULL)
3120 [ # # ][ # # ]: 0 : idlc()->error()->lookupError(*$1);
3121 : : }
3122 : 0 : ;
3123 : :
3124 : : at_least_one_case_branch : case_branch case_branches ;
3125 : :
3126 : : case_branches :
3127 : : case_branches case_branch
3128 : : | /* EMPTY */
3129 : : ;
3130 : :
3131 : : case_branch :
3132 : : at_least_one_case_label
3133 : : {
3134 [ # # ]: 0 : idlc()->setParseState(PS_UnionLabelSeen);
3135 : : }
3136 : 0 : element_spec
3137 : : {
3138 [ # # ]: 0 : idlc()->setParseState(PS_UnionElemSeen);
3139 : :
3140 [ # # ][ # # ]: 0 : AstScope* pScope = idlc()->scopes()->topNonNull();
3141 : 0 : AstUnionLabel* pLabel = NULL;
3142 : 0 : AstUnionBranch* pBranch = NULL;
3143 : 0 : AstMember* pMember = $3;
3144 : :
3145 : : /*
3146 : : * Create several nodes representing branches of a union.
3147 : : * Add them to the enclosing scope (the union scope)
3148 : : */
3149 [ # # ][ # # ]: 0 : if ( pScope && $1 && $3 )
[ # # ]
3150 : : {
3151 : 0 : LabelList::iterator iter = $1->begin();
3152 : 0 : LabelList::iterator end = $1->end();
3153 [ # # ]: 0 : for (;iter != end; iter++)
3154 : : {
3155 : 0 : pLabel = *iter;
3156 [ # # ]: 0 : if ( !pLabel )
3157 : : {
3158 : 0 : iter++;
3159 : 0 : continue;
3160 : : }
3161 : : pBranch = new AstUnionBranch(pLabel, pMember->getType(),
3162 [ # # ][ # # ]: 0 : pMember->getLocalName(), pScope);
3163 [ # # ]: 0 : pScope->addDeclaration(pBranch);
3164 : : }
3165 : : }
3166 [ # # ][ # # ]: 0 : if ( $1 ) delete($1);
3167 : : }
3168 : 0 : ;
3169 : :
3170 : : at_least_one_case_label :
3171 : : case_label case_labels
3172 : : {
3173 [ # # ]: 0 : if ( $2 )
3174 : : {
3175 [ # # ]: 0 : $2->push_front($1);
3176 : 0 : $$ = $2;
3177 : : } else
3178 : : {
3179 [ # # ][ # # ]: 0 : LabelList* pLabels = new LabelList();
3180 [ # # ]: 0 : pLabels->push_back($1);
3181 : 0 : $$ = pLabels;
3182 : : }
3183 : : }
3184 : 0 : ;
3185 : :
3186 : : case_labels :
3187 : : case_labels case_label
3188 : : {
3189 [ # # ]: 0 : if ( $1 )
3190 : : {
3191 [ # # ]: 0 : $1->push_back($2);
3192 : 0 : $$ = $1;
3193 : : } else
3194 : : {
3195 [ # # ][ # # ]: 0 : LabelList* pLabels = new LabelList();
3196 [ # # ]: 0 : pLabels->push_back($2);
3197 : 0 : $$ = pLabels;
3198 : : }
3199 : : }
3200 : 0 : | /* EMPTY */
3201 : : {
3202 : 0 : $$ = NULL;
3203 : : }
3204 : 0 : ;
3205 : :
3206 : : case_label :
3207 : : IDL_DEFAULT
3208 : : {
3209 [ # # ]: 0 : idlc()->setParseState(PS_DefaultSeen);
3210 : : }
3211 : 0 : ':'
3212 : : {
3213 [ # # ]: 0 : idlc()->setParseState(PS_LabelColonSeen);
3214 [ # # ][ # # ]: 0 : $$ = new AstUnionLabel(UL_default, NULL);
3215 : : }
3216 : 0 : | IDL_CASE
3217 : : {
3218 [ # # ]: 0 : idlc()->setParseState(PS_CaseSeen);
3219 : : }
3220 : 0 : const_expr
3221 : : {
3222 [ # # ]: 0 : idlc()->setParseState(PS_LabelExprSeen);
3223 : : }
3224 : 0 : ':'
3225 : : {
3226 [ # # ]: 0 : idlc()->setParseState(PS_LabelColonSeen);
3227 [ # # ][ # # ]: 0 : $$ = new AstUnionLabel(UL_label, $3);
3228 : : }
3229 : 0 : ;
3230 : :
3231 : : element_spec :
3232 : : type_spec
3233 : : {
3234 [ # # ]: 0 : idlc()->setParseState(PS_UnionElemTypeSeen);
3235 : : }
3236 : 0 : declarator
3237 : : {
3238 [ # # ]: 0 : idlc()->setParseState(PS_UnionElemDeclSeen);
3239 : : }
3240 : 0 : ';'
3241 : : {
3242 [ # # ]: 0 : idlc()->setParseState(PS_UnionElemCompleted);
3243 : :
3244 [ # # ][ # # ]: 0 : AstScope* pScope = idlc()->scopes()->topNonNull();
3245 : : /*
3246 : : * Check for illegal recursive use of type
3247 : : */
3248 : : // if ( $1 && AST_illegal_recursive_type($1))
3249 : : // idlc()->error()->error1(EIDL_RECURSIVE_TYPE, $1);
3250 : : /*
3251 : : * Create a field in a union branch
3252 : : */
3253 [ # # ][ # # ]: 0 : if ( $1 && $3 )
3254 : : {
3255 [ # # ]: 0 : AstType const * pType = $3->compose($1);
3256 [ # # ]: 0 : if ( !pType )
3257 : 0 : $$ = NULL;
3258 : : else
3259 [ # # ][ # # ]: 0 : $$ = new AstMember(pType, $3->getName(), pScope);
3260 : : } else
3261 : 0 : $$ = NULL;
3262 : :
3263 [ # # ][ # # ]: 0 : if ( $3 ) delete $3;
[ # # ]
3264 : : }
3265 : 0 : | error
3266 : : ';'
3267 : : {
3268 : 0 : $$ = NULL;
3269 : : }
3270 : 0 : ;
3271 : :
3272 : : identifier:
3273 : : IDL_IDENTIFIER
3274 [ + - ]: 7 : | IDL_GET { $$ = new OString("get"); }
3275 [ + - ]: 11 : | IDL_SET { $$ = new OString("set"); }
3276 [ # # ]: 4 : | IDL_PUBLISHED { $$ = new OString("published"); }
3277 : 0 : ;
3278 : :
3279 : : %%
3280 : :
3281 : : /*
3282 : : * Report an error situation discovered in a production
3283 : : */
3284 : 0 : void yyerror(char const *errmsg)
3285 : : {
3286 : 0 : idlc()->error()->syntaxError(idlc()->getParseState(), idlc()->getLineNumber(), errmsg);
3287 : 0 : idlc()->setParseState(PS_NoState);
3288 : 0 : }
|