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