12fe1ca3dSAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 32fe1ca3dSAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 42fe1ca3dSAndrew Rist * or more contributor license agreements. See the NOTICE file 52fe1ca3dSAndrew Rist * distributed with this work for additional information 62fe1ca3dSAndrew Rist * regarding copyright ownership. The ASF licenses this file 72fe1ca3dSAndrew Rist * to you under the Apache License, Version 2.0 (the 82fe1ca3dSAndrew Rist * "License"); you may not use this file except in compliance 92fe1ca3dSAndrew Rist * with the License. You may obtain a copy of the License at 10cdf0e10cSrcweir * 112fe1ca3dSAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12cdf0e10cSrcweir * 132fe1ca3dSAndrew Rist * Unless required by applicable law or agreed to in writing, 142fe1ca3dSAndrew Rist * software distributed under the License is distributed on an 152fe1ca3dSAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 162fe1ca3dSAndrew Rist * KIND, either express or implied. See the License for the 172fe1ca3dSAndrew Rist * specific language governing permissions and limitations 182fe1ca3dSAndrew Rist * under the License. 19cdf0e10cSrcweir * 202fe1ca3dSAndrew Rist *************************************************************/ 212fe1ca3dSAndrew Rist 222fe1ca3dSAndrew Rist 23cdf0e10cSrcweir 24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove 25cdf0e10cSrcweir #include "precompiled_idlc.hxx" 26cdf0e10cSrcweir #include <idlc/errorhandler.hxx> 27cdf0e10cSrcweir #include <idlc/astinterface.hxx> 28cdf0e10cSrcweir 29cdf0e10cSrcweir using namespace ::rtl; 30cdf0e10cSrcweir 31cdf0e10cSrcweir static const sal_Char* errorCodeToMessage(ErrorCode eCode) 32cdf0e10cSrcweir { 33cdf0e10cSrcweir switch (eCode) 34cdf0e10cSrcweir { 35cdf0e10cSrcweir case EIDL_NONE: 36cdf0e10cSrcweir return "all is fine "; 37cdf0e10cSrcweir case EIDL_SYNTAX_ERROR: 38cdf0e10cSrcweir return ""; 39cdf0e10cSrcweir case EIDL_REDEF: 40cdf0e10cSrcweir return "illegal redefinition "; 41cdf0e10cSrcweir case EIDL_REDEF_SCOPE: 42cdf0e10cSrcweir return "illegal redefinition in scope "; 43cdf0e10cSrcweir case EIDL_DEF_USE: 44cdf0e10cSrcweir return "redefinition after use, "; 45cdf0e10cSrcweir case EIDL_MULTIPLE_BRANCH: 46cdf0e10cSrcweir return "union with duplicate branch label "; 47cdf0e10cSrcweir case EIDL_COERCION_FAILURE: 48cdf0e10cSrcweir return "coercion failure "; 49cdf0e10cSrcweir case EIDL_SCOPE_CONFLICT: 50cdf0e10cSrcweir return "definition scope is different than fwd declare scope, "; 51cdf0e10cSrcweir case EIDL_ONEWAY_CONFLICT: 52cdf0e10cSrcweir return "oneway operation with OUT|INOUT parameters or raises exceptions, "; 53cdf0e10cSrcweir case EIDL_DISC_TYPE: 54cdf0e10cSrcweir return "union with illegal discriminator type, "; 55cdf0e10cSrcweir case EIDL_LABEL_TYPE: 56cdf0e10cSrcweir return "label type incompatible with union discriminator type, "; 57cdf0e10cSrcweir case EIDL_ILLEGAL_ADD: 58cdf0e10cSrcweir return "illegal add operation, "; 59cdf0e10cSrcweir case EIDL_ILLEGAL_USE: 60cdf0e10cSrcweir return "illegal type used in expression, "; 61cdf0e10cSrcweir case EIDL_ILLEGAL_RAISES: 62cdf0e10cSrcweir return "non-exception type in raises(..) clause, "; 63cdf0e10cSrcweir case EIDL_CANT_INHERIT: 64cdf0e10cSrcweir return "cannot inherit "; 65cdf0e10cSrcweir case EIDL_LOOKUP_ERROR: 66cdf0e10cSrcweir return "error in lookup of symbol: "; 67cdf0e10cSrcweir case EIDL_INHERIT_FWD_ERROR: 68cdf0e10cSrcweir return ""; 69cdf0e10cSrcweir case EIDL_CONSTANT_EXPECTED: 70cdf0e10cSrcweir return "constant expected: "; 71cdf0e10cSrcweir case EIDL_NAME_CASE_ERROR: 72cdf0e10cSrcweir return "identifier used with two differing spellings: "; 73cdf0e10cSrcweir case EIDL_ENUM_VAL_EXPECTED: 74cdf0e10cSrcweir return "enumerator expected: "; 75cdf0e10cSrcweir case EIDL_ENUM_VAL_NOT_FOUND: 76cdf0e10cSrcweir return "enumerator by this name not defined: "; 77cdf0e10cSrcweir case EIDL_EVAL_ERROR: 78cdf0e10cSrcweir return "expression evaluation error: "; 79cdf0e10cSrcweir case EIDL_AMBIGUOUS: 80cdf0e10cSrcweir return "ambiguous definition: "; 81cdf0e10cSrcweir case EIDL_DECL_NOT_DEFINED: 82cdf0e10cSrcweir return "forward declared but never defined: "; 83cdf0e10cSrcweir case EIDL_FWD_DECL_LOOKUP: 84cdf0e10cSrcweir return ""; 85cdf0e10cSrcweir case EIDL_RECURSIVE_TYPE: 86cdf0e10cSrcweir return "illegal recursive use of type: "; 87cdf0e10cSrcweir case EIDL_NONVOID_ONEWAY: 88cdf0e10cSrcweir return "non-void return type in oneway operation: "; 89cdf0e10cSrcweir case EIDL_NOT_A_TYPE: 90cdf0e10cSrcweir return "specified symbol is not a type: "; 91cdf0e10cSrcweir case EIDL_TYPE_NOT_VALID: 92cdf0e10cSrcweir return "specified type is not valid in this context: "; 93cdf0e10cSrcweir case EIDL_INTERFACEMEMBER_LOOKUP: 94cdf0e10cSrcweir return "error in lookup of symbol, expected interface is not defined and no forward exists: "; 95cdf0e10cSrcweir case EIDL_SERVICEMEMBER_LOOKUP: 96cdf0e10cSrcweir return "error in lookup of symbol, expected service is not defined: "; 97cdf0e10cSrcweir case EIDL_TYPE_IDENT_CONFLICT: 98cdf0e10cSrcweir return "type and parameter/member name are equal: "; 99cdf0e10cSrcweir case EIDL_ONEWAY_RAISE_CONFLICT: 100cdf0e10cSrcweir return "oneway operation cannot raises exceptions: "; 101cdf0e10cSrcweir case EIDL_WRONGATTRIBUTEFLAG: 102cdf0e10cSrcweir return "the used flag is not valid in this context: "; 103cdf0e10cSrcweir case EIDL_DEFINED_ATTRIBUTEFLAG: 104cdf0e10cSrcweir return "flag is already set: "; 105cdf0e10cSrcweir case EIDL_WRONGATTRIBUTEKEYWORD: 106cdf0e10cSrcweir return "keyword not allowed: "; 107cdf0e10cSrcweir case EIDL_MISSINGATTRIBUTEKEYWORD: 108cdf0e10cSrcweir return "missing keyword: "; 109cdf0e10cSrcweir case EIDL_BAD_ATTRIBUTE_FLAGS: 110cdf0e10cSrcweir return 111cdf0e10cSrcweir "the 'attribute' flag is mandatory, and only the 'bound' and" 112cdf0e10cSrcweir " 'readonly' optional flags are accepted: "; 113cdf0e10cSrcweir case EIDL_OPTIONALEXPECTED: 114cdf0e10cSrcweir return "only the 'optional' flag is accepted: "; 115cdf0e10cSrcweir case EIDL_MIXED_INHERITANCE: 116cdf0e10cSrcweir return "interface inheritance declarations cannot appear in both an" 117cdf0e10cSrcweir " interface's header and its body"; 118cdf0e10cSrcweir case EIDL_DOUBLE_INHERITANCE: 119cdf0e10cSrcweir return 120cdf0e10cSrcweir "interface is (directly or indirectly) inherited more than once: "; 121cdf0e10cSrcweir case EIDL_DOUBLE_MEMBER: 122cdf0e10cSrcweir return 123cdf0e10cSrcweir "member is (directly or indirectly) declared more than once: "; 124cdf0e10cSrcweir case EIDL_CONSTRUCTOR_PARAMETER_NOT_IN: 125cdf0e10cSrcweir return 126cdf0e10cSrcweir "a service constructor parameter may not be an out or inout" 127cdf0e10cSrcweir " parameter"; 128cdf0e10cSrcweir case EIDL_CONSTRUCTOR_REST_PARAMETER_NOT_FIRST: 129cdf0e10cSrcweir return 130cdf0e10cSrcweir "no parameters may precede a rest parameter in a service" 131cdf0e10cSrcweir " constructor"; 132cdf0e10cSrcweir case EIDL_REST_PARAMETER_NOT_LAST: 133cdf0e10cSrcweir return "no parameters may follow a rest parameter"; 134cdf0e10cSrcweir case EIDL_REST_PARAMETER_NOT_ANY: 135cdf0e10cSrcweir return "a rest parameter must be of type any"; 136cdf0e10cSrcweir case EIDL_METHOD_HAS_REST_PARAMETER: 137cdf0e10cSrcweir return "a rest parameter may not be used on an interface method"; 138cdf0e10cSrcweir case EIDL_READONLY_ATTRIBUTE_SET_EXCEPTIONS: 139cdf0e10cSrcweir return "a readonly attribute may not have a setter raises clause"; 140cdf0e10cSrcweir case EIDL_UNSIGNED_TYPE_ARGUMENT: 141cdf0e10cSrcweir return "an unsigned type cannot be used as a type argument"; 142cdf0e10cSrcweir case EIDL_WRONG_NUMBER_OF_TYPE_ARGUMENTS: 143cdf0e10cSrcweir return 144cdf0e10cSrcweir "the number of given type arguments does not match the expected" 145cdf0e10cSrcweir " number of type parameters"; 146cdf0e10cSrcweir case EIDL_INSTANTIATED_STRUCT_TYPE_TYPEDEF: 147cdf0e10cSrcweir return 148cdf0e10cSrcweir "an instantiated polymorphic struct type cannot be used in a" 149cdf0e10cSrcweir " typedef"; 150cdf0e10cSrcweir case EIDL_IDENTICAL_TYPE_PARAMETERS: 151cdf0e10cSrcweir return "two type parameters have the same name"; 152cdf0e10cSrcweir case EIDL_STRUCT_TYPE_TEMPLATE_WITH_BASE: 153cdf0e10cSrcweir return "a polymorphic struct type template may not have a base type"; 154cdf0e10cSrcweir case EIDL_PUBLISHED_FORWARD: 155cdf0e10cSrcweir return 156cdf0e10cSrcweir "a published forward declaration of an interface type cannot be" 157cdf0e10cSrcweir " followed by an unpublished declaration of that type"; 158cdf0e10cSrcweir case EIDL_PUBLISHED_USES_UNPUBLISHED: 159cdf0e10cSrcweir return 160cdf0e10cSrcweir "an unpublished entity cannot be used in the declaration of a" 161cdf0e10cSrcweir " published entity: "; 162cdf0e10cSrcweir case EIDL_SIMILAR_CONSTRUCTORS: 163cdf0e10cSrcweir return "two constructors have identical lists of parameter types"; 164cdf0e10cSrcweir } 165*9c3cb57aSmseidel return "unknown error"; 166cdf0e10cSrcweir } 167cdf0e10cSrcweir 168cdf0e10cSrcweir static const sal_Char* warningCodeToMessage(WarningCode wCode) 169cdf0e10cSrcweir { 170cdf0e10cSrcweir switch (wCode) 171cdf0e10cSrcweir { 172cdf0e10cSrcweir case WIDL_EXPID_CONFLICT: 173cdf0e10cSrcweir return "exception id conflict: "; 174cdf0e10cSrcweir case WIDL_REQID_CONFLICT: 175cdf0e10cSrcweir return "request id conflict: "; 176cdf0e10cSrcweir case WIDL_INHERIT_IDCONFLICT: 177cdf0e10cSrcweir return "request id conflict in inheritance tree: "; 178cdf0e10cSrcweir case WIDL_TYPE_IDENT_CONFLICT: 179cdf0e10cSrcweir return "type and parameter|member name are equal: "; 180cdf0e10cSrcweir case WIDL_WRONG_NAMING_CONV: 181cdf0e10cSrcweir return "type or identifier doesn't fulfill the UNO naming convention: "; 182cdf0e10cSrcweir } 183a893be29SPedro Giffuni return "unknown warning"; 184cdf0e10cSrcweir } 185cdf0e10cSrcweir 186cdf0e10cSrcweir static const sal_Char* parseStateToMessage(ParseState state) 187cdf0e10cSrcweir { 188cdf0e10cSrcweir switch (state) 189cdf0e10cSrcweir { 190cdf0e10cSrcweir case PS_NoState: 191cdf0e10cSrcweir return "Statement can not be parsed"; 192cdf0e10cSrcweir case PS_TypeDeclSeen: 193cdf0e10cSrcweir return "Malformed type declaration"; 194cdf0e10cSrcweir case PS_ConstantDeclSeen: 195cdf0e10cSrcweir return "Malformed const declaration"; 196cdf0e10cSrcweir case PS_ExceptionDeclSeen: 197cdf0e10cSrcweir return "Malformed exception declaration"; 198cdf0e10cSrcweir case PS_InterfaceDeclSeen: 199cdf0e10cSrcweir return "Malformed interface declaration"; 200cdf0e10cSrcweir case PS_ServiceDeclSeen: 201cdf0e10cSrcweir return "Malformed servicve declaration"; 202cdf0e10cSrcweir case PS_ModuleDeclSeen: 203cdf0e10cSrcweir return "Malformed module declaration"; 204cdf0e10cSrcweir case PS_AttributeDeclSeen: 205cdf0e10cSrcweir return "Malformed attribute declaration"; 206cdf0e10cSrcweir case PS_PropertyDeclSeen: 207cdf0e10cSrcweir return "Malformed property declaration"; 208cdf0e10cSrcweir case PS_OperationDeclSeen: 209cdf0e10cSrcweir return "Malformed operation declaration"; 210cdf0e10cSrcweir case PS_InterfaceInheritanceDeclSeen: 211cdf0e10cSrcweir return "Malformed interface inheritance declaration"; 212cdf0e10cSrcweir case PS_ConstantsDeclSeen: 213cdf0e10cSrcweir return "Malformed constants declaration"; 214cdf0e10cSrcweir case PS_ServiceSeen: 215cdf0e10cSrcweir return "Missing service identifier following SERVICE keyword"; 216cdf0e10cSrcweir case PS_ServiceIDSeen: 217cdf0e10cSrcweir return "Missing '{' or illegal syntax following service identifier"; 218cdf0e10cSrcweir case PS_ServiceSqSeen: 219cdf0e10cSrcweir return "Illegal syntax following service '{' opener"; 220cdf0e10cSrcweir case PS_ServiceBodySeen: 221cdf0e10cSrcweir return "Illegal syntax following service '}' closer"; 222cdf0e10cSrcweir case PS_ServiceMemberSeen: 223cdf0e10cSrcweir return "Illegal syntax following service member declaration"; 224cdf0e10cSrcweir case PS_ServiceIFHeadSeen: 225cdf0e10cSrcweir return "Illegal syntax following header of an interface member"; 226cdf0e10cSrcweir case PS_ServiceSHeadSeen: 227cdf0e10cSrcweir return "Illegal syntax following header of an service member"; 228cdf0e10cSrcweir case PS_ModuleSeen: 229cdf0e10cSrcweir return "Missing module identifier following MODULE keyword"; 230cdf0e10cSrcweir case PS_ModuleIDSeen: 231cdf0e10cSrcweir return "Missing '{' or illegal syntax following module identifier"; 232cdf0e10cSrcweir case PS_ModuleSqSeen: 233cdf0e10cSrcweir return "Illegal syntax following module '{' opener"; 234cdf0e10cSrcweir case PS_ModuleQsSeen: 235cdf0e10cSrcweir return "Illegal syntax following module '}' closer"; 236cdf0e10cSrcweir case PS_ModuleBodySeen: 237cdf0e10cSrcweir return "Illegal syntax following module export(s)"; 238cdf0e10cSrcweir case PS_ConstantsSeen: 239cdf0e10cSrcweir return "Missing constants identifier following CONSTANTS keyword"; 240cdf0e10cSrcweir case PS_ConstantsIDSeen: 241cdf0e10cSrcweir return "Missing '{' or illegal syntax following constants identifier"; 242cdf0e10cSrcweir case PS_ConstantsSqSeen: 243cdf0e10cSrcweir return "Illegal syntax following module '{' opener"; 244cdf0e10cSrcweir case PS_ConstantsQsSeen: 245cdf0e10cSrcweir return "Illegal syntax following module '}' closer"; 246cdf0e10cSrcweir case PS_ConstantsBodySeen: 247cdf0e10cSrcweir return "Illegal syntax following constants export(s)"; 248cdf0e10cSrcweir case PS_InterfaceSeen: 249cdf0e10cSrcweir return "Missing interface identifier following INTERFACE keyword"; 250cdf0e10cSrcweir case PS_InterfaceIDSeen: 251cdf0e10cSrcweir return "Illegal syntax following interface identifier"; 252cdf0e10cSrcweir case PS_InterfaceHeadSeen: 253cdf0e10cSrcweir return "Illegal syntax following interface head"; 254cdf0e10cSrcweir case PS_InheritSpecSeen: 255cdf0e10cSrcweir return "Missing '{' or illegal syntax following inheritance spec"; 256cdf0e10cSrcweir case PS_ForwardDeclSeen: 257cdf0e10cSrcweir return "Missing ';' following forward interface declaration"; 258cdf0e10cSrcweir case PS_InterfaceSqSeen: 259cdf0e10cSrcweir return "Illegal syntax following interface '{' opener"; 260cdf0e10cSrcweir case PS_InterfaceQsSeen: 261cdf0e10cSrcweir return "Illegal syntax following interface '}' closer"; 262cdf0e10cSrcweir case PS_InterfaceBodySeen: 263cdf0e10cSrcweir return "Illegal syntax following interface export(s)"; 264cdf0e10cSrcweir case PS_InheritColonSeen: 265cdf0e10cSrcweir return "Illegal syntax following ':' starting inheritance list"; 266cdf0e10cSrcweir case PS_SNListCommaSeen: 267cdf0e10cSrcweir return "Found illegal scoped name in scoped name list"; 268cdf0e10cSrcweir case PS_ScopedNameSeen: 269cdf0e10cSrcweir return "Missing ',' following scoped name in scoped name list"; 270cdf0e10cSrcweir case PS_SN_IDSeen: 271cdf0e10cSrcweir return "Illegal component in scoped name"; 272cdf0e10cSrcweir case PS_ScopeDelimSeen: 273cdf0e10cSrcweir return "Illegal component in scoped name following '::'"; 274cdf0e10cSrcweir case PS_ConstSeen: 275cdf0e10cSrcweir return "Missing type or illegal syntax following CONST keyword"; 276cdf0e10cSrcweir case PS_ConstTypeSeen: 277cdf0e10cSrcweir return "Missing identifier or illegal syntax following const type"; 278cdf0e10cSrcweir case PS_ConstIDSeen: 279cdf0e10cSrcweir return "Missing '=' or illegal syntax after const identifier"; 280cdf0e10cSrcweir case PS_ConstAssignSeen: 281cdf0e10cSrcweir return "Missing value expr or illegal syntax following '='"; 282cdf0e10cSrcweir case PS_ConstExprSeen: 283cdf0e10cSrcweir return "Missing ';' or illegal syntax following value expr in const"; 284cdf0e10cSrcweir case PS_TypedefSeen: 285cdf0e10cSrcweir return "Missing type or illegal syntax following TYPEDEF keyword"; 286cdf0e10cSrcweir case PS_TypeSpecSeen: 287cdf0e10cSrcweir return "Missing declarators or illegal syntax following type spec"; 288cdf0e10cSrcweir case PS_DeclaratorsSeen: 289cdf0e10cSrcweir return "Illegal syntax following declarators in TYPEDEF declaration"; 290cdf0e10cSrcweir case PS_StructSeen: 291cdf0e10cSrcweir return "Missing struct identifier following STRUCT keyword"; 292cdf0e10cSrcweir case PS_StructHeaderSeen: 293cdf0e10cSrcweir return "Missing '{' or illegal syntax following struct inheritance spec"; 294cdf0e10cSrcweir case PS_StructIDSeen: 295cdf0e10cSrcweir return "Missing '{' or illegal syntax following struct identifier"; 296cdf0e10cSrcweir case PS_StructSqSeen: 297cdf0e10cSrcweir return "Illegal syntax following struct '{' opener"; 298cdf0e10cSrcweir case PS_StructQsSeen: 299cdf0e10cSrcweir return "Illegal syntax following struct '}' closer"; 300cdf0e10cSrcweir case PS_StructBodySeen: 301cdf0e10cSrcweir return "Illegal syntax following struct member(s)"; 302cdf0e10cSrcweir case PS_MemberTypeSeen: 303cdf0e10cSrcweir return "Illegal syntax or missing identifier following member type"; 304cdf0e10cSrcweir case PS_MemberDeclsSeen: 305cdf0e10cSrcweir return "Illegal syntax following member declarator(s)"; 306cdf0e10cSrcweir case PS_MemberDeclsCompleted: 307cdf0e10cSrcweir return "Missing ',' between member decls of same type(?)"; 308cdf0e10cSrcweir case PS_UnionSeen: 309cdf0e10cSrcweir return "Missing identifier following UNION keyword"; 310cdf0e10cSrcweir case PS_UnionIDSeen: 311cdf0e10cSrcweir return "Illegal syntax following union identifier"; 312cdf0e10cSrcweir case PS_SwitchSeen: 313cdf0e10cSrcweir return "Illegal syntax following SWITCH keyword"; 314cdf0e10cSrcweir case PS_SwitchOpenParSeen: 315cdf0e10cSrcweir return "Illegal syntax following '(' in switch in union"; 316cdf0e10cSrcweir case PS_SwitchTypeSeen: 317cdf0e10cSrcweir return "Illegal syntax following type decl in switch in union"; 318cdf0e10cSrcweir case PS_SwitchCloseParSeen: 319cdf0e10cSrcweir return "Missing union '{' opener"; 320cdf0e10cSrcweir case PS_UnionSqSeen: 321cdf0e10cSrcweir return "Illegal syntax following union '{' opener"; 322cdf0e10cSrcweir case PS_UnionQsSeen: 323cdf0e10cSrcweir return "Illegal syntax following union '}' closer"; 324cdf0e10cSrcweir case PS_DefaultSeen: 325cdf0e10cSrcweir return "Illegal syntax or missing ':' following DEFAULT keyword"; 326cdf0e10cSrcweir case PS_UnionLabelSeen: 327cdf0e10cSrcweir return "Illegal syntax following branch label in union"; 328cdf0e10cSrcweir case PS_LabelColonSeen: 329cdf0e10cSrcweir return "Illegal syntax following ':' in branch label in union"; 330cdf0e10cSrcweir case PS_LabelExprSeen: 331cdf0e10cSrcweir return "Illegal syntax following label expression in union"; 332cdf0e10cSrcweir case PS_UnionElemSeen: 333cdf0e10cSrcweir case PS_UnionElemCompleted: 334cdf0e10cSrcweir return "Illegal syntax following union element"; 335cdf0e10cSrcweir case PS_CaseSeen: 336cdf0e10cSrcweir return "Illegal syntax following CASE keyword in union"; 337cdf0e10cSrcweir case PS_UnionElemTypeSeen: 338cdf0e10cSrcweir return "Illegal syntax following type decl in union element"; 339cdf0e10cSrcweir case PS_UnionElemDeclSeen: 340cdf0e10cSrcweir return "Illegal syntax following declarator in union element"; 341cdf0e10cSrcweir case PS_UnionBodySeen: 342cdf0e10cSrcweir return "Illegal syntax following union body statement(s)"; 343cdf0e10cSrcweir case PS_EnumSeen: 344cdf0e10cSrcweir return "Illegal syntax or missing identifier following ENUM keyword"; 345cdf0e10cSrcweir case PS_EnumIDSeen: 346cdf0e10cSrcweir return "Illegal syntax or missing '{' following enum identifier"; 347cdf0e10cSrcweir case PS_EnumSqSeen: 348cdf0e10cSrcweir return "Illegal syntax following enum '{' opener"; 349cdf0e10cSrcweir case PS_EnumQsSeen: 350cdf0e10cSrcweir return "Illegal syntax following enum '}' closer"; 351cdf0e10cSrcweir case PS_EnumBodySeen: 352cdf0e10cSrcweir return "Illegal syntax following enum enumerator(s)"; 353cdf0e10cSrcweir case PS_EnumCommaSeen: 354cdf0e10cSrcweir return "Illegal syntax or missing identifier following ',' in enum"; 355cdf0e10cSrcweir case PS_SequenceSeen: 356cdf0e10cSrcweir return "Illegal syntax or missing '<' following SEQUENCE keyword"; 357cdf0e10cSrcweir case PS_SequenceSqSeen: 358cdf0e10cSrcweir return "Illegal syntax or missing type following '<' in sequence"; 359cdf0e10cSrcweir case PS_SequenceQsSeen: 360cdf0e10cSrcweir return "Illegal syntax following '>' in sequence"; 361cdf0e10cSrcweir case PS_SequenceTypeSeen: 362cdf0e10cSrcweir return "Illegal syntax following sequence type declaration"; 363cdf0e10cSrcweir case PS_ArrayIDSeen: 364cdf0e10cSrcweir return "Illegal syntax or missing dimensions after array identifier"; 365cdf0e10cSrcweir case PS_ArrayCompleted: 366cdf0e10cSrcweir return "Illegal syntax after array declaration"; 367cdf0e10cSrcweir case PS_DimSqSeen: 368cdf0e10cSrcweir return "Illegal syntax or missing size expr after '[' in array declaration"; 369cdf0e10cSrcweir case PS_DimQsSeen: 370cdf0e10cSrcweir return "Illegal syntax after ']' in array declaration"; 371cdf0e10cSrcweir case PS_DimExprSeen: 372cdf0e10cSrcweir return "Illegal syntax or missing ']' after size expr in array declaration"; 373cdf0e10cSrcweir case PS_FlagHeaderSeen: 374cdf0e10cSrcweir return "Illegal syntax after flags"; 375cdf0e10cSrcweir case PS_AttrSeen: 376cdf0e10cSrcweir return "Illegal syntax after ATTRIBUTE keyword"; 377cdf0e10cSrcweir case PS_AttrTypeSeen: 378cdf0e10cSrcweir return "Illegal syntax after type in attribute declaration"; 379cdf0e10cSrcweir case PS_AttrCompleted: 380cdf0e10cSrcweir return "Illegal syntax after attribute declaration"; 381cdf0e10cSrcweir case PS_ReadOnlySeen: 382cdf0e10cSrcweir return "Illegal syntax after READONLY keyword"; 383cdf0e10cSrcweir case PS_OptionalSeen: 384cdf0e10cSrcweir return "Illegal syntax after OPTIONAL keyword"; 385cdf0e10cSrcweir case PS_MayBeVoidSeen: 386cdf0e10cSrcweir return "Illegal syntax after MAYBEVOID keyword"; 387cdf0e10cSrcweir case PS_BoundSeen: 388cdf0e10cSrcweir return "Illegal syntax after BOUND keyword"; 389cdf0e10cSrcweir case PS_ConstrainedSeen: 390cdf0e10cSrcweir return "Illegal syntax after CONSTRAINED keyword"; 391cdf0e10cSrcweir case PS_TransientSeen: 392cdf0e10cSrcweir return "Illegal syntax after TRANSIENT keyword"; 393cdf0e10cSrcweir case PS_MayBeAmbigiousSeen: 394cdf0e10cSrcweir return "Illegal syntax after MAYBEAMBIGIOUS keyword"; 395cdf0e10cSrcweir case PS_MayBeDefaultSeen: 396cdf0e10cSrcweir return "Illegal syntax after MAYBEDEFAULT keyword"; 397cdf0e10cSrcweir case PS_RemoveableSeen: 398cdf0e10cSrcweir return "Illegal syntax after REMOVEABLE keyword"; 399cdf0e10cSrcweir case PS_PropertySeen: 400cdf0e10cSrcweir return "Illegal syntax after PROPERTY keyword"; 401cdf0e10cSrcweir case PS_PropertyTypeSeen: 402cdf0e10cSrcweir return "Illegal syntax after type in property declaration"; 403cdf0e10cSrcweir case PS_PropertyCompleted: 404cdf0e10cSrcweir return "Illegal syntax after property declaration"; 405cdf0e10cSrcweir case PS_ExceptSeen: 406cdf0e10cSrcweir return "Illegal syntax or missing identifier after EXCEPTION keyword"; 407cdf0e10cSrcweir case PS_ExceptHeaderSeen: 408cdf0e10cSrcweir return "Missing '{' or illegal syntax following exception inheritance spec"; 409cdf0e10cSrcweir case PS_ExceptIDSeen: 410cdf0e10cSrcweir return "Illegal syntax or missing '{' after exception identifier"; 411cdf0e10cSrcweir case PS_ExceptSqSeen: 412cdf0e10cSrcweir return "Illegal syntax after exception '{' opener"; 413cdf0e10cSrcweir case PS_ExceptQsSeen: 414cdf0e10cSrcweir return "Illegal syntax after exception '}' closer"; 415cdf0e10cSrcweir case PS_ExceptBodySeen: 416cdf0e10cSrcweir return "Illegal syntax after exception member(s)"; 417cdf0e10cSrcweir case PS_OpHeadSeen: 418cdf0e10cSrcweir return "Illegasl syntax after operation header"; 419cdf0e10cSrcweir case PS_OpTypeSeen: 420cdf0e10cSrcweir return "Illegal syntax or missing identifier after operation type"; 421cdf0e10cSrcweir case PS_OpIDSeen: 422cdf0e10cSrcweir return "Illegal syntax or missing '(' after operation identifier"; 423cdf0e10cSrcweir case PS_OpParsCompleted: 424cdf0e10cSrcweir return "Illegal syntax after operation parameter list"; 425cdf0e10cSrcweir case PS_OpCompleted: 426cdf0e10cSrcweir return "Illegal syntax after operation declaration"; 427cdf0e10cSrcweir case PS_OpSqSeen: 428cdf0e10cSrcweir return "Illegal syntax after operation parameter list '(' opener"; 429cdf0e10cSrcweir case PS_OpQsSeen: 430cdf0e10cSrcweir return "Illegal syntax after operation parameter list ')' closer"; 431cdf0e10cSrcweir case PS_OpParCommaSeen: 432cdf0e10cSrcweir return "Illegal syntax or missing direction in parameter declaration"; 433cdf0e10cSrcweir case PS_OpParDirSeen: 434cdf0e10cSrcweir return "Illegal syntax or missing type in parameter declaration"; 435cdf0e10cSrcweir case PS_OpParTypeSeen: 436cdf0e10cSrcweir return "Illegal syntax or missing declarator in parameter declaration"; 437cdf0e10cSrcweir case PS_OpParDeclSeen: 438cdf0e10cSrcweir return "Illegal syntax following parameter declarator"; 439cdf0e10cSrcweir case PS_OpOnewaySeen: 440cdf0e10cSrcweir return "Illegal syntax after ONEWAY keyword"; 441cdf0e10cSrcweir case PS_RaiseSeen: 442cdf0e10cSrcweir return "Illegal syntax or missing '(' after RAISES keyword"; 443cdf0e10cSrcweir case PS_RaiseSqSeen: 444cdf0e10cSrcweir return "Illegal syntax after RAISES '(' opener"; 445cdf0e10cSrcweir case PS_RaiseQsSeen: 446cdf0e10cSrcweir return "Illegal syntax after RAISES ')' closer"; 447cdf0e10cSrcweir case PS_DeclsCommaSeen: 448cdf0e10cSrcweir return "Illegal syntax after ',' in declarators list"; 449cdf0e10cSrcweir case PS_DeclsDeclSeen: 450cdf0e10cSrcweir return "Illegal syntax after declarator in declarators list"; 451cdf0e10cSrcweir default: 452cdf0e10cSrcweir return "no wider described syntax error"; 453cdf0e10cSrcweir } 454cdf0e10cSrcweir } 455cdf0e10cSrcweir 456cdf0e10cSrcweir static OString flagToString(sal_uInt32 flag) 457cdf0e10cSrcweir { 458cdf0e10cSrcweir OString flagStr; 459cdf0e10cSrcweir if ( (flag & AF_READONLY) == AF_READONLY ) 460cdf0e10cSrcweir flagStr += "'readonly'"; 461cdf0e10cSrcweir if ( (flag & AF_OPTIONAL) == AF_OPTIONAL ) 462cdf0e10cSrcweir flagStr += "'optional'"; 463cdf0e10cSrcweir if ( (flag & AF_MAYBEVOID) == AF_MAYBEVOID ) 464cdf0e10cSrcweir flagStr += "'maybevoid'"; 465cdf0e10cSrcweir if ( (flag & AF_BOUND) == AF_BOUND ) 466cdf0e10cSrcweir flagStr += "'bound'"; 467cdf0e10cSrcweir if ( (flag & AF_CONSTRAINED) == AF_CONSTRAINED ) 468cdf0e10cSrcweir flagStr += "'constrained'"; 469cdf0e10cSrcweir if ( (flag & AF_TRANSIENT) == AF_TRANSIENT ) 470cdf0e10cSrcweir flagStr += "'transient'"; 471cdf0e10cSrcweir if ( (flag & AF_MAYBEAMBIGUOUS) == AF_MAYBEAMBIGUOUS ) 472cdf0e10cSrcweir flagStr += "'maybeambiguous'"; 473cdf0e10cSrcweir if ( (flag & AF_MAYBEDEFAULT) == AF_MAYBEDEFAULT ) 474cdf0e10cSrcweir flagStr += "'maybedefault'"; 475cdf0e10cSrcweir if ( (flag & AF_REMOVEABLE) == AF_REMOVEABLE ) 476cdf0e10cSrcweir flagStr += "'removeable'"; 477cdf0e10cSrcweir if ( (flag & AF_ATTRIBUTE) == AF_ATTRIBUTE ) 478cdf0e10cSrcweir flagStr += "'attribute'"; 479cdf0e10cSrcweir if ( (flag & AF_PROPERTY) == AF_PROPERTY ) 480cdf0e10cSrcweir flagStr += "'property'"; 481cdf0e10cSrcweir if ( !flagStr.getLength() ) 482cdf0e10cSrcweir flagStr += "'unknown'"; 483cdf0e10cSrcweir 484cdf0e10cSrcweir return flagStr; 485cdf0e10cSrcweir } 486cdf0e10cSrcweir 487cdf0e10cSrcweir static void errorHeader(ErrorCode eCode, sal_Int32 lineNumber) 488cdf0e10cSrcweir { 489cdf0e10cSrcweir OString file; 490cdf0e10cSrcweir if ( idlc()->getFileName() == idlc()->getRealFileName() ) 491cdf0e10cSrcweir file = idlc()->getMainFileName(); 492cdf0e10cSrcweir else 493cdf0e10cSrcweir file = idlc()->getFileName(); 494cdf0e10cSrcweir 495cdf0e10cSrcweir fprintf(stderr, "%s(%lu) : %s", file.getStr(), 496cdf0e10cSrcweir sal::static_int_cast< unsigned long >(lineNumber), 497cdf0e10cSrcweir errorCodeToMessage(eCode)); 498cdf0e10cSrcweir } 499cdf0e10cSrcweir 500cdf0e10cSrcweir static void errorHeader(ErrorCode eCode) 501cdf0e10cSrcweir { 502cdf0e10cSrcweir errorHeader(eCode, idlc()->getLineNumber()); 503cdf0e10cSrcweir } 504cdf0e10cSrcweir 505cdf0e10cSrcweir static void warningHeader(WarningCode wCode) 506cdf0e10cSrcweir { 507cdf0e10cSrcweir OString file; 508cdf0e10cSrcweir if ( idlc()->getFileName() == idlc()->getRealFileName() ) 509cdf0e10cSrcweir file = idlc()->getMainFileName(); 510cdf0e10cSrcweir else 511cdf0e10cSrcweir file = idlc()->getFileName(); 512cdf0e10cSrcweir 513cdf0e10cSrcweir fprintf(stderr, "%s(%lu) : WARNING, %s", file.getStr(), 514cdf0e10cSrcweir sal::static_int_cast< unsigned long >(idlc()->getLineNumber()), 515cdf0e10cSrcweir warningCodeToMessage(wCode)); 516cdf0e10cSrcweir } 517cdf0e10cSrcweir 518cdf0e10cSrcweir void ErrorHandler::error0(ErrorCode e) 519cdf0e10cSrcweir { 520cdf0e10cSrcweir errorHeader(e); 521cdf0e10cSrcweir fprintf(stderr, "\n"); 522cdf0e10cSrcweir idlc()->incErrorCount(); 523cdf0e10cSrcweir } 524cdf0e10cSrcweir 525cdf0e10cSrcweir void ErrorHandler::error1(ErrorCode e, AstDeclaration const * d) 526cdf0e10cSrcweir { 527cdf0e10cSrcweir errorHeader(e); 528cdf0e10cSrcweir fprintf(stderr, "'%s'\n", d->getScopedName().getStr()); 529cdf0e10cSrcweir idlc()->incErrorCount(); 530cdf0e10cSrcweir } 531cdf0e10cSrcweir 532cdf0e10cSrcweir void ErrorHandler::error2( 533cdf0e10cSrcweir ErrorCode e, AstDeclaration const * d1, AstDeclaration const * d2) 534cdf0e10cSrcweir { 535cdf0e10cSrcweir errorHeader(e); 536cdf0e10cSrcweir fprintf(stderr, "'%s', '%s'\n", d1->getScopedName().getStr(), 537cdf0e10cSrcweir d2->getScopedName().getStr()); 538cdf0e10cSrcweir idlc()->incErrorCount(); 539cdf0e10cSrcweir } 540cdf0e10cSrcweir 541cdf0e10cSrcweir void ErrorHandler::error3(ErrorCode e, AstDeclaration* d1, AstDeclaration* d2, AstDeclaration* d3) 542cdf0e10cSrcweir { 543cdf0e10cSrcweir errorHeader(e); 544cdf0e10cSrcweir fprintf(stderr, "'%s', '%s', '%s'\n", d1->getScopedName().getStr(), 545cdf0e10cSrcweir d2->getScopedName().getStr(), d3->getScopedName().getStr()); 546cdf0e10cSrcweir idlc()->incErrorCount(); 547cdf0e10cSrcweir } 548cdf0e10cSrcweir 549cdf0e10cSrcweir void ErrorHandler::warning0(WarningCode w, const sal_Char* warningmsg) 550cdf0e10cSrcweir { 551cdf0e10cSrcweir if ( idlc()->getOptions()->isValid("-w") || idlc()->getOptions()->isValid("-we") ) { 552cdf0e10cSrcweir warningHeader(w); 553cdf0e10cSrcweir fprintf(stderr, "%s\n", warningmsg); 554cdf0e10cSrcweir } 555cdf0e10cSrcweir 556cdf0e10cSrcweir if ( idlc()->getOptions()->isValid("-we") ) 557cdf0e10cSrcweir idlc()->incErrorCount(); 558cdf0e10cSrcweir else 559cdf0e10cSrcweir idlc()->incWarningCount(); 560cdf0e10cSrcweir } 561cdf0e10cSrcweir 562cdf0e10cSrcweir void ErrorHandler::syntaxError(ParseState ps, sal_Int32 lineNumber, const sal_Char* errmsg) 563cdf0e10cSrcweir { 564cdf0e10cSrcweir errorHeader(EIDL_SYNTAX_ERROR, lineNumber); 565cdf0e10cSrcweir fprintf(stderr, "%s: %s\n", parseStateToMessage(ps), errmsg); 566cdf0e10cSrcweir idlc()->incErrorCount(); 567cdf0e10cSrcweir } 568cdf0e10cSrcweir 569cdf0e10cSrcweir void ErrorHandler::coercionError(AstExpression *pExpr, ExprType et) 570cdf0e10cSrcweir { 571cdf0e10cSrcweir errorHeader(EIDL_COERCION_FAILURE); 572cdf0e10cSrcweir fprintf(stderr, "'%s' to '%s'\n", pExpr->toString().getStr(), 573cdf0e10cSrcweir exprTypeToString(et)); 574cdf0e10cSrcweir idlc()->incErrorCount(); 575cdf0e10cSrcweir } 576cdf0e10cSrcweir 577cdf0e10cSrcweir void ErrorHandler::lookupError(const ::rtl::OString& n) 578cdf0e10cSrcweir { 579cdf0e10cSrcweir errorHeader(EIDL_LOOKUP_ERROR); 580cdf0e10cSrcweir fprintf(stderr, "'%s'\n", n.getStr()); 581cdf0e10cSrcweir idlc()->incErrorCount(); 582cdf0e10cSrcweir } 583cdf0e10cSrcweir 584cdf0e10cSrcweir void ErrorHandler::lookupError(ErrorCode e, const ::rtl::OString& n, AstDeclaration* pScope) 585cdf0e10cSrcweir { 586cdf0e10cSrcweir errorHeader(e); 587cdf0e10cSrcweir fprintf(stderr, "'%s' in '%s'\n", n.getStr(), pScope->getFullName().getStr()); 588cdf0e10cSrcweir idlc()->incErrorCount(); 589cdf0e10cSrcweir } 590cdf0e10cSrcweir 591cdf0e10cSrcweir void ErrorHandler::flagError(ErrorCode e, sal_uInt32 flag) 592cdf0e10cSrcweir { 593cdf0e10cSrcweir errorHeader(e); 594cdf0e10cSrcweir fprintf(stderr, "'%s'\n", flagToString(flag).getStr()); 595cdf0e10cSrcweir idlc()->incErrorCount(); 596cdf0e10cSrcweir } 597cdf0e10cSrcweir 598cdf0e10cSrcweir void ErrorHandler::noTypeError(AstDeclaration const * pDecl) 599cdf0e10cSrcweir { 600cdf0e10cSrcweir errorHeader(EIDL_NOT_A_TYPE); 601cdf0e10cSrcweir fprintf(stderr, "'%s'\n", pDecl->getScopedName().getStr()); 602cdf0e10cSrcweir idlc()->incErrorCount(); 603cdf0e10cSrcweir } 604cdf0e10cSrcweir 605cdf0e10cSrcweir namespace { 606cdf0e10cSrcweir 607cdf0e10cSrcweir char const * nodeTypeName(NodeType nodeType) { 608cdf0e10cSrcweir switch (nodeType) { 609cdf0e10cSrcweir case NT_interface: 610cdf0e10cSrcweir return "interface"; 611cdf0e10cSrcweir 612cdf0e10cSrcweir case NT_exception: 613cdf0e10cSrcweir return "exception"; 614cdf0e10cSrcweir 615cdf0e10cSrcweir case NT_struct: 616cdf0e10cSrcweir return "struct"; 617cdf0e10cSrcweir 618cdf0e10cSrcweir default: 619cdf0e10cSrcweir return ""; 620cdf0e10cSrcweir } 621cdf0e10cSrcweir } 622cdf0e10cSrcweir 623cdf0e10cSrcweir } 624cdf0e10cSrcweir 625cdf0e10cSrcweir void ErrorHandler::inheritanceError(NodeType nodeType, const OString* name, AstDeclaration* pDecl) 626cdf0e10cSrcweir { 627cdf0e10cSrcweir if ( nodeType == NT_interface && 628cdf0e10cSrcweir (pDecl->getNodeType() == NT_interface) && 629cdf0e10cSrcweir !((AstInterface*)pDecl)->isDefined() ) 630cdf0e10cSrcweir { 631cdf0e10cSrcweir errorHeader(EIDL_INHERIT_FWD_ERROR); 632cdf0e10cSrcweir fprintf(stderr, "interface '%s' cannot inherit from forward declared interface '%s'\n", 633cdf0e10cSrcweir name->getStr(), pDecl->getScopedName().getStr()); 634cdf0e10cSrcweir } else 635cdf0e10cSrcweir { 636cdf0e10cSrcweir errorHeader(EIDL_CANT_INHERIT); 637cdf0e10cSrcweir fprintf(stderr, "%s '%s' from '%s'\n", 638cdf0e10cSrcweir nodeTypeName(nodeType), name->getStr(), 639cdf0e10cSrcweir pDecl->getScopedName().getStr()); 640cdf0e10cSrcweir } 641cdf0e10cSrcweir idlc()->incErrorCount(); 642cdf0e10cSrcweir } 643cdf0e10cSrcweir 644cdf0e10cSrcweir void ErrorHandler::forwardLookupError(AstDeclaration* pForward, 645cdf0e10cSrcweir const ::rtl::OString& name) 646cdf0e10cSrcweir { 647cdf0e10cSrcweir errorHeader(EIDL_FWD_DECL_LOOKUP); 648cdf0e10cSrcweir fprintf(stderr, "trying to look up '%s' in undefined forward declared interface '%s'\n", 649cdf0e10cSrcweir pForward->getScopedName().getStr(), name.getStr()); 650cdf0e10cSrcweir idlc()->incErrorCount(); 651cdf0e10cSrcweir } 652cdf0e10cSrcweir 653cdf0e10cSrcweir void ErrorHandler::constantExpected(AstDeclaration* pDecl, 654cdf0e10cSrcweir const ::rtl::OString& name) 655cdf0e10cSrcweir { 656cdf0e10cSrcweir errorHeader(EIDL_CONSTANT_EXPECTED); 657cdf0e10cSrcweir fprintf(stderr, "'%s' is bound to '%s'\n", name.getStr(), pDecl->getScopedName().getStr()); 658cdf0e10cSrcweir idlc()->incErrorCount(); 659cdf0e10cSrcweir } 660cdf0e10cSrcweir 661cdf0e10cSrcweir void ErrorHandler::evalError(AstExpression* pExpr) 662cdf0e10cSrcweir { 663cdf0e10cSrcweir errorHeader(EIDL_EVAL_ERROR); 664cdf0e10cSrcweir fprintf(stderr, "'%s'\n", pExpr->toString().getStr()); 665cdf0e10cSrcweir idlc()->incErrorCount(); 666cdf0e10cSrcweir } 667cdf0e10cSrcweir 668cdf0e10cSrcweir void ErrorHandler::enumValExpected(AstUnion* pUnion) 669cdf0e10cSrcweir { 670cdf0e10cSrcweir errorHeader(EIDL_ENUM_VAL_EXPECTED); 671cdf0e10cSrcweir fprintf(stderr, " union %s\n", pUnion->getLocalName().getStr()); 672cdf0e10cSrcweir idlc()->incErrorCount(); 673cdf0e10cSrcweir } 674cdf0e10cSrcweir 675cdf0e10cSrcweir void ErrorHandler::enumValLookupFailure(AstUnion* pUnion, AstEnum* pEnum, const ::rtl::OString& name) 676cdf0e10cSrcweir { 677cdf0e10cSrcweir errorHeader(EIDL_ENUM_VAL_NOT_FOUND); 678cdf0e10cSrcweir fprintf(stderr, " union %s, enum %s, enumerator %s\n", 679cdf0e10cSrcweir pUnion->getLocalName().getStr(), 680cdf0e10cSrcweir pEnum->getLocalName().getStr(), name.getStr()); 681cdf0e10cSrcweir idlc()->incErrorCount(); 682cdf0e10cSrcweir } 683cdf0e10cSrcweir 684cdf0e10cSrcweir bool ErrorHandler::checkPublished(AstDeclaration const * decl, bool bOptional) { 685cdf0e10cSrcweir if (idlc()->isPublished() && !decl->isPublished() && !bOptional) { 686cdf0e10cSrcweir error1(EIDL_PUBLISHED_USES_UNPUBLISHED, decl); 687cdf0e10cSrcweir return false; 688cdf0e10cSrcweir } else { 689cdf0e10cSrcweir return true; 690cdf0e10cSrcweir } 691cdf0e10cSrcweir } 692