LCOV - code coverage report
Current view: top level - libreoffice/idlc/source - parser.y (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 1304 0.0 %
Date: 2012-12-17 Functions: 0 6 0.0 %
Legend: Lines: hit not hit

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

Generated by: LCOV version 1.10