(file) Return to mof.y CVS log (file) (dir) Up to [OMI] / omi / mof

   1 mike  1.1 %{
   2           
   3           #include "config.h"
   4           #include <stdio.h>
   5           #include <stdlib.h>
   6           #include <string.h>
   7           #include "config.h"
   8           #include "buffer.h"
   9           #include "types.h"
  10           #include "state.h"
  11           #include "ptrarray.h"
  12           
  13           #define ARRAYOF(TYPE) ((MI_Uint32)TYPE | (MI_Uint32)MI_ARRAY_BIT)
  14           
  15           extern int yylex();
  16           extern int openIncludeFile(const char* path);
  17           
  18           %}
  19           
  20           %union
  21           {
  22 mike  1.1     MI_Boolean boolean;
  23               MI_Sint64 integer;
  24               MI_Real64 real;
  25               MI_Char16 character;
  26               char* string;
  27               char* identifier;
  28               char* dollarIdentifier;
  29               MI_Type type;
  30               MI_PropertyDecl* property;
  31               MI_MethodDecl* methodDecl;
  32               MI_ParameterDecl* parameter;
  33               MOF_ParameterList parameterList;
  34               MOF_FeatureList featureList;
  35               MI_QualifierDecl* qualifierDeclaration;
  36               MOF_ConstantValue constantValue;
  37               MOF_Initializer initializer;
  38               MI_Uint32 flags;
  39               MI_Qualifier* qualifier;
  40               MOF_QualifierList qualifierList;
  41               MI_ClassDecl* classDeclaration;
  42               MI_InstanceDecl* instanceDeclaration;
  43 mike  1.1 }
  44           
  45           %start mofSpecification
  46           
  47           %token TOK_ERROR
  48           %token TOK_BOOLEAN
  49           %token TOK_SINT8
  50           %token TOK_UINT8
  51           %token TOK_SINT16
  52           %token TOK_UINT16
  53           %token TOK_SINT32
  54           %token TOK_UINT32
  55           %token TOK_SINT64
  56           %token TOK_UINT64
  57           %token TOK_REAL32
  58           %token TOK_REAL64
  59           %token TOK_DATETIME
  60           %token TOK_CHAR16
  61           %token TOK_STRING
  62 krisbash 1.3 %token TOK_OBJECT
  63 mike     1.1 %token TOK_BOOLEAN_VALUE
  64              %token TOK_REF
  65              %token TOK_SCOPE
  66              %token TOK_CLASS
  67              %token TOK_ASSOCIATION
  68              %token TOK_INDICATION
  69              %token TOK_QUALIFIER
  70              %token TOK_PROPERTY
  71              %token TOK_REFERENCE
  72              %token TOK_METHOD
  73              %token TOK_PARAMETER
  74              %token TOK_ANY
  75              %token TOK_FLAVOR
  76              %token TOK_ENABLEOVERRIDE
  77              %token TOK_DISABLEOVERRIDE
  78              %token TOK_RESTRICTED
  79              %token TOK_TOSUBCLASS
  80 krisbash 1.3 %token TOK_TOINSTANCE
  81 mike     1.1 %token TOK_TRANSLATABLE
  82              %token TOK_INSTANCE
  83              %token TOK_OF
  84              %token TOK_AS
  85              %token TOK_PRAGMA
  86              %token TOK_SCHEMA
  87              %token TOK_INTEGER_VALUE
  88              %token TOK_REAL_VALUE
  89              %token TOK_STRING_VALUE
  90              %token TOK_CHAR_VALUE
  91              %token TOK_IDENT
  92              %token TOK_ALIAS_IDENTIFIER
  93              %token TOK_NULL
  94              
  95              %type <string> stringValue
  96              %type <string> TOK_STRING_VALUE
  97 krisbash 1.3 %type <string> classNameIdentifier
  98 mike     1.1 %type <string> identifier
  99              %type <integer> TOK_INTEGER_VALUE
 100              %type <real> TOK_REAL_VALUE
 101              %type <character> TOK_CHAR_VALUE
 102              %type <boolean> TOK_BOOLEAN_VALUE
 103              %type <string> TOK_IDENT
 104              %type <string> TOK_ALIAS_IDENTIFIER
 105              %type <string> alias
 106              %type <constantValue> constantValue
 107              %type <type> dataType
 108              %type <property> propertyDeclaration
 109              %type <parameter> parameter
 110              %type <parameterList> parameterList
 111              %type <property> referenceDeclaration
 112 krisbash 1.3 %type <property> dynamicReferenceDeclaration
 113              %type <property> staticEmbeddedInstanceDeclaration
 114              %type <property> dynamicEmbeddedInstanceDeclaration
 115 mike     1.1 %type <methodDecl> methodDeclaration 
 116              %type <featureList> classFeatureList
 117              %type <featureList> classBody
 118              %type <featureList> instanceBody
 119              %type <qualifierDeclaration> qualifierDeclaration
 120              %type <qualifierDeclaration> qualifierType
 121              %type <integer> subscript
 122              %type <initializer> initializer
 123              %type <initializer> arrayInitializer
 124              %type <initializer> arrayInitializerList
 125 krisbash 1.3 %type <initializer> scalarInitializer
 126              %type <initializer> nonAggregateInitializer
 127              %type <initializer> nonAggregateArrayInitializer
 128              %type <initializer> nonAggregateArrayInitializerList
 129 mike     1.1 %type <flags> scope
 130              %type <flags> scopeList
 131              %type <flags> scopeExpr
 132              %type <flags> flavor
 133              %type <flags> flavorList
 134 krisbash 1.3 %type <flags> qualifierFlavorList
 135 mike     1.1 %type <flags> flavorExpr
 136              %type <qualifier> qualifier
 137              %type <qualifierList> qualifierList
 138              %type <qualifierList> qualifierExpr
 139              %type <initializer> qualifierParameter
 140              %type <classDeclaration> classDeclaration
 141              %type <instanceDeclaration> instanceDeclaration
 142              %type <property> valueInitializer
 143              %type <featureList> valueInitializerList 
 144 krisbash 1.3 %type <string> TOK_CLASS
 145              %type <string> TOK_INSTANCE
 146              %type <string> TOK_OF
 147              %type <string> TOK_ANY
 148              %type <string> TOK_ASSOCIATION
 149              %type <string> TOK_INDICATION
 150              %type <string> TOK_REFERENCE
 151              %type <string> TOK_PROPERTY
 152              %type <string> TOK_QUALIFIER
 153              %type <string> TOK_TOSUBCLASS
 154              %type <string> TOK_TOINSTANCE
 155              %type <string> TOK_TRANSLATABLE
 156              %type <string> TOK_FLAVOR
 157              %type <string> TOK_BOOLEAN
 158              %type <string> TOK_DATETIME
 159              %type <string> TOK_STRING
 160              %type <string> TOK_OBJECT
 161              %type <string> TOK_PRAGMA
 162 mike     1.1 
 163              %%
 164              
 165              mofSpecification
 166                  : mofProduction
 167                  {
 168                  }
 169                  | mofSpecification mofProduction
 170                  { 
 171                  }
 172                  | TOK_ERROR
 173                  {
 174                      YYABORT;
 175                  }
 176              
 177              mofProduction
 178                  : compilerDirective
 179                  {
 180                  }
 181                  | classDeclaration
 182                  {
 183 mike     1.1         /* [TODO: validate the class here] */
 184                      $1->flags = MI_FLAG_CLASS;
 185                      $1->flags |= GetQualFlags($1->qualifiers, $1->numQualifiers);
 186                      if (FinalizeClass($1) != 0)
 187                          YYABORT;
 188                          
 189                      AddClassDecl($1);
 190              
 191                      if (state.classDeclCallback)
 192                          (*state.classDeclCallback)($1, state.classDeclCallbackData);
 193                  }
 194                  | qualifierDeclaration
 195                  {
 196                      AddQualifierDeclaration($1);
 197              
 198                      if (state.qualifierDeclCallback)
 199                          (*state.qualifierDeclCallback)($1, state.qualifierDeclCallbackData);
 200                  }
 201                  | instanceDeclaration
 202                  {
 203                      if (FinalizeInstance($1) != 0)
 204 mike     1.1             YYABORT;
 205              
 206                      AddInstanceDecl($1);
 207              
 208                      if (state.instanceDeclCallback)
 209                          (*state.instanceDeclCallback)($1, state.instanceDeclCallbackData);
 210                  }
 211              
 212              compilerDirective
 213                  : TOK_PRAGMA TOK_IDENT '(' stringValue ')'
 214                  {
 215                      if (strcmp($2, "include") == 0)
 216                      {
 217                          if (openIncludeFile($4) != 0)
 218                              YYABORT;
 219                      }
 220                      else if (strcmp($2, "instancelocale") == 0)
 221                      {
 222                          if (state.pragmaCallback)
 223                              (*state.pragmaCallback)($2, $4, state.pragmaCallbackData);
 224                      }
 225 mike     1.1         else if (strcmp($2, "locale") == 0)
 226                      {
 227                          if (state.pragmaCallback)
 228                              (*state.pragmaCallback)($2, $4, state.pragmaCallbackData);
 229                      }
 230                      else if (strcmp($2, "namespace") == 0)
 231                      {
 232                          if (state.pragmaCallback)
 233                              (*state.pragmaCallback)($2, $4, state.pragmaCallbackData);
 234                      }
 235 krisbash 1.3         else if (state.extensionsEnabled == MI_TRUE && strcmp($2, "deleteclass") == 0)
 236                      {
 237                          yywarnf(ID_UNKNOWN_PRAGMA, 
 238                              "warning: nonstandard pragma: %s(%s)", $2, $4);
 239              
 240                          if (state.pragmaCallback)
 241                              (*state.pragmaCallback)($2, $4, state.pragmaCallbackData);
 242                      }
 243                      else
 244                      {
 245                          yywarnf(ID_UNKNOWN_PRAGMA, 
 246                              "warning: unknown pragma: %s(%s)", $2, $4);
 247              
 248                          if (state.pragmaCallback)
 249                              (*state.pragmaCallback)($2, $4, state.pragmaCallbackData);
 250                      }
 251                  }
 252                  | TOK_PRAGMA TOK_IDENT '(' stringValue ',' identifier ')'
 253                  {
 254                      if (state.extensionsEnabled == MI_TRUE && strcmp($2, "deleteclass") == 0)
 255                      {
 256 krisbash 1.3             yywarnf(ID_UNKNOWN_PRAGMA, 
 257                              "warning: nonstandard pragma: %s(%s)", $2, $4);
 258              
 259                          if (state.pragmaCallback)
 260                              (*state.pragmaCallback)($2, $4, state.pragmaCallbackData);
 261                      }
 262 mike     1.1         else
 263                      {
 264                          yywarnf(ID_UNKNOWN_PRAGMA, 
 265 krisbash 1.3                 "warning: unknown pragma: %s(%s)", $2, $4);
 266 mike     1.1 
 267                          if (state.pragmaCallback)
 268                              (*state.pragmaCallback)($2, $4, state.pragmaCallbackData);
 269                      }
 270                  }
 271              
 272              classDeclaration
 273 krisbash 1.3     : TOK_CLASS classNameIdentifier classBody
 274 mike     1.1     {
 275                      /* Check whether class already exists */
 276                      if (FindClassDecl($2))
 277                      {
 278 krisbash 1.3             if (state.extensionsEnabled == MI_FALSE)
 279                          {
 280                              yyerrorf(ID_CLASS_ALREADY_DEFINED, 
 281                                  "class already defined: \"%s\"", $2);
 282                              YYABORT;
 283                          }
 284                          else
 285                              yywarnf(ID_CLASS_ALREADY_DEFINED, 
 286                                  "class already defined: \"%s\"", $2);
 287 mike     1.1         }
 288              
 289                      $$ = CALLOC_T(MI_ClassDecl, 1);
 290                      $$->flags = MI_FLAG_CLASS;
 291                      $$->name = $2;
 292                      $$->properties = $3.propertySet.data;
 293                      $$->numProperties = $3.propertySet.size;
 294                      $$->methods = $3.methodList.data;
 295                      $$->numMethods = $3.methodList.size;
 296                  }
 297 krisbash 1.3     | TOK_CLASS classNameIdentifier ':' classNameIdentifier classBody
 298 mike     1.1     {
 299                      const MI_ClassDecl* scd;
 300              
 301                      /* Check whether class already exists */
 302                      if (FindClassDecl($2))
 303                      {
 304 krisbash 1.3             if (state.extensionsEnabled == MI_FALSE)
 305                          {
 306                              yyerrorf(ID_CLASS_ALREADY_DEFINED, 
 307                                  "class already defined: \"%s\"", $2);
 308                              YYABORT;
 309                          }
 310                          else
 311                              yywarnf(ID_CLASS_ALREADY_DEFINED, 
 312                                  "class already defined: \"%s\"", $2);
 313 mike     1.1         }
 314               
 315                      /* Check whether superclass exists */
 316                      scd = FindClassDecl($4);
 317              
 318                      if (!scd)
 319                      {
 320                          yyerrorf(ID_UNDEFINED_SUPERCLASS, 
 321                              "super class of \"%s\" is undefined: \"%s\"", $2, $4);
 322                          YYABORT;
 323                      }
 324              
 325                      $$ = CALLOC_T(MI_ClassDecl, 1);
 326                      $$->flags = MI_FLAG_CLASS;
 327                      $$->name = $2;
 328                      $$->superClass = $4;
 329                      $$->superClassDecl = (MI_ClassDecl*)scd;
 330                      $$->properties = $5.propertySet.data;
 331                      $$->numProperties = $5.propertySet.size;
 332                      $$->methods = $5.methodList.data;
 333                      $$->numMethods = $5.methodList.size;
 334 mike     1.1     }
 335 krisbash 1.3     | qualifierExpr TOK_CLASS classNameIdentifier classBody
 336 mike     1.1     {
 337                      /* Check qualifier scope */
 338                      if (CheckScope(MI_FLAG_CLASS, &$1) != 0)
 339                          YYABORT;
 340              
 341                      /* Check whether class already exists */
 342                      if (FindClassDecl($3))
 343                      {
 344 krisbash 1.3             if (state.extensionsEnabled == MI_FALSE)
 345                          {
 346                              yyerrorf(ID_CLASS_ALREADY_DEFINED, 
 347                                  "class already defined: \"%s\"", $3);
 348                              YYABORT;
 349                          }
 350                          else
 351                              yywarnf(ID_CLASS_ALREADY_DEFINED, 
 352                                  "class already defined: \"%s\"", $3);
 353 mike     1.1         }
 354              
 355                      $$ = CALLOC_T(MI_ClassDecl, 1);
 356                      $$->flags = MI_FLAG_CLASS;
 357                      $$->name = $3;
 358                      $$->properties = $4.propertySet.data;
 359                      $$->numProperties = $4.propertySet.size;
 360                      $$->methods = $4.methodList.data;
 361                      $$->numMethods = $4.methodList.size;
 362                      $$->qualifiers = $1.data;
 363                      $$->numQualifiers = $1.size;
 364                  }
 365 krisbash 1.3     | qualifierExpr TOK_CLASS classNameIdentifier ':' classNameIdentifier classBody
 366 mike     1.1     {
 367                      const MI_ClassDecl* scd;
 368              
 369                      /* Check qualifier scope */
 370                      if (CheckScope(MI_FLAG_CLASS, &$1) != 0)
 371                          YYABORT;
 372              
 373                      /* Check whether class already exists */
 374                      if (FindClassDecl($3))
 375                      {
 376 krisbash 1.3             if (state.extensionsEnabled == MI_FALSE)
 377                          {
 378                              yyerrorf(ID_CLASS_ALREADY_DEFINED, 
 379                                  "class already defined: \"%s\"", $3);
 380                              YYABORT;
 381                          }
 382                          else
 383                              yywarnf(ID_CLASS_ALREADY_DEFINED, 
 384                                  "class already defined: \"%s\"", $3);
 385 mike     1.1         }
 386              
 387                      /* Check whether superclass exists */
 388                      scd = FindClassDecl($5);
 389              
 390                      if (!scd)
 391                      {
 392                          yyerrorf(ID_UNDEFINED_SUPERCLASS, 
 393                              "super class of \"%s\" is undefined: \"%s\"", $3, $5);
 394                          YYABORT;
 395                      }
 396              
 397                      $$ = CALLOC_T(MI_ClassDecl, 1);
 398                      $$->flags = MI_FLAG_CLASS;
 399                      $$->name = $3;
 400                      $$->superClass = scd->name;
 401                      $$->superClassDecl = (MI_ClassDecl*)scd;
 402                      $$->properties = $6.propertySet.data;
 403                      $$->numProperties = $6.propertySet.size;
 404                      $$->methods = $6.methodList.data;
 405                      $$->numMethods = $6.methodList.size;
 406 mike     1.1         $$->qualifiers = $1.data;
 407                      $$->numQualifiers = $1.size;
 408                  }
 409              
 410              classBody
 411                  : '{' classFeatureList '}' ';'
 412                  {
 413                      $$ = $2;
 414                  }
 415                  | '{' '}' ';'
 416                  {
 417                      $$.propertySet.data = NULL;
 418                      $$.propertySet.size = 0;
 419                      $$.methodList.data = NULL;
 420                      $$.methodList.size = 0;
 421                  }
 422              
 423              classFeatureList
 424                  : propertyDeclaration
 425                  {
 426                      if (CheckPropertyValueConstraints($1) != 0)
 427 mike     1.1         {
 428                          YYABORT;
 429                      }
 430                      $$.propertySet.data = NULL;
 431                      $$.propertySet.size = 0;
 432                      $$.methodList.data = NULL;
 433                      $$.methodList.size = 0;
 434                      $1->flags = MI_FLAG_PROPERTY;
 435                      $1->flags |= GetQualFlags($1->qualifiers, $1->numQualifiers);
 436                      PtrArray_Append((PtrArray*)&$$.propertySet, $1);
 437                  }
 438                  | methodDeclaration
 439                  {
 440                      $$.propertySet.data = NULL;
 441                      $$.propertySet.size = 0;
 442                      $$.methodList.data = NULL;
 443                      $$.methodList.size = 0;
 444                      $1->flags = MI_FLAG_METHOD;
 445                      $1->flags |= GetQualFlags($1->qualifiers, $1->numQualifiers);
 446                      PtrArray_Append((PtrArray*)&$$.methodList, $1);
 447                  }
 448 mike     1.1     | referenceDeclaration
 449                  {
 450                      $$.propertySet.data = NULL;
 451                      $$.propertySet.size = 0;
 452                      $$.methodList.data = NULL;
 453                      $$.methodList.size = 0;
 454                      $1->flags = MI_FLAG_PROPERTY;
 455                      $1->flags |= GetQualFlags($1->qualifiers, $1->numQualifiers);
 456                      PtrArray_Append((PtrArray*)&$$.propertySet, $1);
 457                  }
 458 krisbash 1.3     | dynamicReferenceDeclaration
 459                  {
 460                      $$.propertySet.data = NULL;
 461                      $$.propertySet.size = 0;
 462                      $$.methodList.data = NULL;
 463                      $$.methodList.size = 0;
 464                      $1->flags = MI_FLAG_PROPERTY;
 465                      $1->flags |= GetQualFlags($1->qualifiers, $1->numQualifiers);
 466                      PtrArray_Append((PtrArray*)&$$.propertySet, $1);
 467                  }
 468                  | staticEmbeddedInstanceDeclaration
 469                  {
 470                      $$.propertySet.data = NULL;
 471                      $$.propertySet.size = 0;
 472                      $$.methodList.data = NULL;
 473                      $$.methodList.size = 0;
 474                      $1->flags = MI_FLAG_PROPERTY;
 475                      $1->flags |= GetQualFlags($1->qualifiers, $1->numQualifiers);
 476                      PtrArray_Append((PtrArray*)&$$.propertySet, $1);
 477                  }
 478                  | dynamicEmbeddedInstanceDeclaration
 479 krisbash 1.3     {
 480                      $$.propertySet.data = NULL;
 481                      $$.propertySet.size = 0;
 482                      $$.methodList.data = NULL;
 483                      $$.methodList.size = 0;
 484                      $1->flags = MI_FLAG_PROPERTY;
 485                      $1->flags |= GetQualFlags($1->qualifiers, $1->numQualifiers);
 486                      PtrArray_Append((PtrArray*)&$$.propertySet, $1);
 487                  }
 488 mike     1.1     | classFeatureList propertyDeclaration
 489                  {
 490                      if (CheckPropertyValueConstraints($2) != 0)
 491                      {
 492                          YYABORT;
 493                      }
 494              
 495                      if (FindProperty(&$1.propertySet, $2->name))
 496                      {
 497                          yyerrorf(ID_CLASS_FEATURE_ALREADY_DEFINED, 
 498                              "class feature already defined: \"%s\"", $2->name);
 499                          YYABORT;
 500                      }
 501              
 502                      $2->flags = MI_FLAG_PROPERTY;
 503                      $2->flags |= GetQualFlags($2->qualifiers, $2->numQualifiers);
 504                      PtrArray_Append((PtrArray*)&$$.propertySet, $2);
 505                  }
 506                  | classFeatureList methodDeclaration
 507                  {
 508                      if (FindMethod(&$1.methodList, $2->name))
 509 mike     1.1         {
 510                          yyerrorf(ID_CLASS_FEATURE_ALREADY_DEFINED, 
 511                              "class feature already defined: \"%s\"", $2->name);
 512                          YYABORT;
 513                      }
 514              
 515                      $2->flags = MI_FLAG_METHOD;
 516                      $2->flags |= GetQualFlags($2->qualifiers, $2->numQualifiers);
 517                      PtrArray_Append((PtrArray*)&$$.methodList, $2);
 518                  }
 519                  | classFeatureList referenceDeclaration
 520                  {
 521                      if (FindProperty(&$1.propertySet, $2->name))
 522                      {
 523                          yyerrorf(ID_CLASS_FEATURE_ALREADY_DEFINED, 
 524                              "class feature already defined: \"%s\"", $2->name);
 525                          YYABORT;
 526                      }
 527              
 528                      $2->flags = MI_FLAG_PROPERTY;
 529                      $2->flags |= GetQualFlags($2->qualifiers, $2->numQualifiers);
 530 mike     1.1         PtrArray_Append((PtrArray*)&$$.propertySet, $2);
 531                  }
 532 krisbash 1.3     | classFeatureList dynamicReferenceDeclaration
 533                  {
 534                      if (FindProperty(&$1.propertySet, $2->name))
 535                      {
 536                          yyerrorf(ID_CLASS_FEATURE_ALREADY_DEFINED,
 537                              "class feature already defined: \"%s\"", $2->name);
 538                          YYABORT;
 539                      }
 540                      $2->flags = MI_FLAG_PROPERTY;
 541                      $2->flags |= GetQualFlags($2->qualifiers, $2->numQualifiers);
 542                      PtrArray_Append((PtrArray*)&$$.propertySet, $2);
 543                  }
 544                  | classFeatureList staticEmbeddedInstanceDeclaration
 545                  {
 546                      if (FindProperty(&$1.propertySet, $2->name))
 547                      {
 548                          yyerrorf(ID_CLASS_FEATURE_ALREADY_DEFINED,
 549                              "class feature already defined: \"%s\"", $2->name);
 550                          YYABORT;
 551                      }
 552              
 553 krisbash 1.3         $2->flags = MI_FLAG_PROPERTY;
 554                      $2->flags |= GetQualFlags($2->qualifiers, $2->numQualifiers);
 555                      PtrArray_Append((PtrArray*)&$$.propertySet, $2);
 556                  }
 557                  | classFeatureList dynamicEmbeddedInstanceDeclaration
 558                  {
 559                      if (FindProperty(&$1.propertySet, $2->name))
 560                      {
 561                          yyerrorf(ID_CLASS_FEATURE_ALREADY_DEFINED,
 562                              "class feature already defined: \"%s\"", $2->name);
 563                          YYABORT;
 564                      }
 565              
 566                      $2->flags = MI_FLAG_PROPERTY;
 567                      $2->flags |= GetQualFlags($2->qualifiers, $2->numQualifiers);
 568                      PtrArray_Append((PtrArray*)&$$.propertySet, $2);
 569                  }
 570 mike     1.1 
 571              qualifierExpr
 572                  : '[' qualifierList ']'
 573                  {
 574                      $$ = $2;
 575                  }
 576              
 577              qualifierList
 578                  : qualifier
 579                  {
 580                      $$.data = NULL;
 581                      $$.size = 0;
 582                      PtrArray_Append((PtrArray*)&$$, $1);
 583                  }
 584                  | qualifierList ',' qualifier
 585                  {
 586                      if (FindQualifier(&$1, $3->name))
 587                      {
 588                          yyerrorf(ID_DUPLICATE_QUALIFIER, 
 589                              "duplicate qualifier: \"%s\"", $3->name);
 590                          YYABORT;
 591 mike     1.1         }
 592              
 593                      PtrArray_Append((PtrArray*)&$$, $3);
 594                  }
 595              
 596              qualifier
 597                  : identifier
 598                  {
 599                      MI_Qualifier* q;
 600                      const MI_QualifierDecl* qd;
 601              
 602                      qd = FindQualifierDeclaration($1);
 603              
 604                      if (!qd)
 605                      {
 606                          yyerrorf(ID_UNDEFINED_QUALIFIER, "undefined qualifier: \"%s\"", $1);
 607                          YYABORT;
 608                      }
 609              
 610                      if (qd->type != MI_BOOLEAN)
 611                      {
 612 mike     1.1             yyerrorf(ID_MISSING_QUALIFIER_INITIALIZER, 
 613                              "qualifier is missing initializer: \"%s\"", $1);
 614                          YYABORT;
 615                      }
 616                      
 617                      
 618                      q = CALLOC_T(MI_Qualifier, 1);
 619                      q->name = qd->name; /* use casing of qualifier declaration name */
 620                      q->type = qd->type;
 621                      q->flavor = qd->flavor;
 622                      q->value = NewTrueValue();
 623                      $$ = q;
 624                  }
 625                  | identifier qualifierParameter
 626                  {
 627                      MI_Qualifier* q;
 628                      const MI_QualifierDecl* qd;
 629                      void* value;
 630              
 631                      qd = FindQualifierDeclaration($1);
 632              
 633 mike     1.1         if (!qd)
 634                      {
 635                          yyerrorf(ID_UNDEFINED_QUALIFIER, "undefined qualifier: \"%s\"", $1);
 636                          YYABORT;
 637                      }
 638              
 639                      if (InitializerToValue(&$2, qd->type, &value) != 0)
 640                      {
 641                          yyerrorf(ID_INVALID_QUALIFIER_INITIALIZER, 
 642                              "invalid initializer for qualifer: \"%s\"", $1);
 643                          YYABORT;
 644                      }
 645                      
 646                      q = CALLOC_T(MI_Qualifier, 1);
 647                      q->name = qd->name; /* use casing of qualifier declaration name */
 648                      q->type = qd->type;
 649                      q->flavor = qd->flavor;
 650                      q->value = value;
 651                      $$ = q;
 652                  }
 653 krisbash 1.3     | identifier ':' qualifierFlavorList
 654 mike     1.1     {
 655                      MI_Qualifier* q;
 656                      const MI_QualifierDecl* qd;
 657              
 658                      qd = FindQualifierDeclaration($1);
 659              
 660                      if (!qd)
 661                      {
 662                          yyerrorf(ID_UNDEFINED_QUALIFIER, "undefined qualifier: \"%s\"", $1);
 663                          YYABORT;
 664                      }
 665              
 666                      if (qd->type != MI_BOOLEAN)
 667                      {
 668                          yyerrorf(ID_MISSING_QUALIFIER_INITIALIZER, 
 669                              "qualifier is missing initializer: \"%s\"", $1);
 670                          YYABORT;
 671                      }
 672                      
 673                      q = CALLOC_T(MI_Qualifier, 1);
 674                      q->name = qd->name; /* use casing of qualifier declaration name */
 675 mike     1.1         q->type = qd->type;
 676                      q->flavor = PropagateFlavors($3, qd->flavor);
 677                      q->value = NewTrueValue();
 678                      $$ = q;
 679                  }
 680 krisbash 1.3     | identifier qualifierParameter ':' qualifierFlavorList
 681 mike     1.1     {
 682                      MI_Qualifier* q;
 683                      const MI_QualifierDecl* qd;
 684                      void* value;
 685              
 686                      qd = FindQualifierDeclaration($1);
 687              
 688                      if (!qd)
 689                      {
 690                          yyerrorf(ID_UNDEFINED_QUALIFIER, "undefined qualifier: \"%s\"", $1);
 691                          YYABORT;
 692                      }
 693              
 694                      if (InitializerToValue(&$2, qd->type, &value) != 0)
 695                      {
 696                          yyerrorf(ID_INVALID_QUALIFIER_INITIALIZER, 
 697                              "invalid initializer for qualifer: \"%s\"", $1);
 698                          YYABORT;
 699                      }
 700                      
 701                      q = CALLOC_T(MI_Qualifier, 1);
 702 mike     1.1         q->name = qd->name; /* use casing of qualifier declaration name */
 703                      q->type = qd->type;
 704                      q->value = value;
 705                      q->flavor = PropagateFlavors($4, qd->flavor);
 706                      $$ = q;
 707                  }
 708              
 709              qualifierParameter
 710                  : '(' constantValue ')'
 711                  {
 712                      memset(&$$, 0, sizeof($$));
 713                      $$.data = CALLOC_T(MOF_ConstantValue, 1);
 714                      $$.data[0] = $2;
 715                      $$.size = 1;
 716                  }
 717 krisbash 1.3     | nonAggregateArrayInitializer
 718 mike     1.1     {
 719                      $$ = $1;
 720                  }
 721              
 722              flavorList
 723                  : flavor
 724                  {
 725                      $$ = $1;
 726                  }
 727                  | flavorList ',' flavor
 728                  {
 729                      $$ |= $3;
 730                  }
 731              
 732 krisbash 1.3 qualifierFlavorList
 733                  : flavor
 734                  {
 735                      $$ = $1;
 736                  }
 737                  | qualifierFlavorList flavor
 738                  {
 739                      $$ |= $2;
 740                  }
 741              
 742 mike     1.1 flavor
 743                  : TOK_ENABLEOVERRIDE
 744                  {
 745                      $$ = MI_FLAG_ENABLEOVERRIDE;
 746                  }
 747                  | TOK_DISABLEOVERRIDE
 748                  {
 749                      $$ = MI_FLAG_DISABLEOVERRIDE;
 750                  }
 751                  | TOK_RESTRICTED
 752                  {
 753                      $$ = MI_FLAG_RESTRICTED;
 754                  }
 755                  | TOK_TOSUBCLASS
 756                  {
 757                      $$ = MI_FLAG_TOSUBCLASS;
 758                  }
 759 krisbash 1.3     | TOK_TOINSTANCE
 760                  {
 761                      $$ = MI_FLAG_TOINSTANCE;
 762                      if (state.extensionsEnabled == MI_FALSE)
 763                      {
 764                          yyerrorf(ID_UNSUPPORTED, "Unsupported flavor: ToInstance");
 765                          YYABORT;
 766                      }
 767                  }
 768 mike     1.1     | TOK_TRANSLATABLE
 769                  {
 770                      $$ = MI_FLAG_TRANSLATABLE;
 771                  }
 772              
 773              propertyDeclaration
 774                  : dataType identifier ';'
 775                  {
 776                      $$ = CALLOC_T(MI_PropertyDecl, 1);
 777                      $$->name = $2;
 778                      $$->type = $1;
 779                  }
 780                  | qualifierExpr dataType identifier ';'
 781                  {
 782                      /* Check qualifier scope */
 783                      if (CheckScope(MI_FLAG_PROPERTY, &$1) != 0)
 784                          YYABORT;
 785              
 786                      $$ = CALLOC_T(MI_PropertyDecl, 1);
 787                      $$->name = $3;
 788                      $$->type = $2;
 789 mike     1.1         $$->qualifiers = $1.data;
 790                      $$->numQualifiers = $1.size;
 791                  }
 792                  | dataType identifier subscript ';'
 793                  {
 794                      $$ = CALLOC_T(MI_PropertyDecl, 1);
 795                      $$->name = $2;
 796                      $$->type = ARRAYOF($1);
 797                      $$->subscript = (MI_Uint32)$3;
 798                  }
 799                  | qualifierExpr dataType identifier subscript ';'
 800                  {
 801                      /* Check qualifier scope */
 802                      if (CheckScope(MI_FLAG_PROPERTY, &$1) != 0)
 803                          YYABORT;
 804              
 805                      $$ = CALLOC_T(MI_PropertyDecl, 1);
 806                      $$->name = $3;
 807                      $$->type = ARRAYOF($2);
 808                      $$->qualifiers = $1.data;
 809                      $$->numQualifiers = $1.size;
 810 mike     1.1         $$->subscript = (MI_Uint32)$4;
 811                  }
 812                  | dataType identifier '=' initializer ';'
 813                  {
 814                      void* value;
 815              
 816                      if (InitializerToValue(&$4, $1, &value) != 0)
 817                      {
 818                          yyerrorf(ID_INVALID_INITIALIZER, "invalid initializer");
 819                          YYABORT;
 820                      }
 821              
 822                      $$ = CALLOC_T(MI_PropertyDecl, 1);
 823                      $$->name = $2;
 824                      $$->type = $1;
 825                      $$->value = value;
 826                  }
 827                  | qualifierExpr dataType identifier '=' initializer ';'
 828                  {
 829                      void* value;
 830              
 831 mike     1.1         /* Check qualifier scope */
 832                      if (CheckScope(MI_FLAG_PROPERTY, &$1) != 0)
 833                          YYABORT;
 834              
 835                      if (InitializerToValue(&$5, $2, &value) != 0)
 836                      {
 837                          yyerrorf(ID_INVALID_INITIALIZER, "invalid initializer");
 838                          YYABORT;
 839                      }
 840              
 841                      $$ = CALLOC_T(MI_PropertyDecl, 1);
 842                      $$->name = $3;
 843                      $$->type = $2;
 844                      $$->qualifiers = $1.data;
 845                      $$->numQualifiers = $1.size;
 846                      $$->value = value;
 847                  }
 848                  | dataType identifier subscript '=' initializer ';'
 849                  {
 850                      void* value;
 851              
 852 mike     1.1         if (InitializerToValue(&$5, ARRAYOF($1), &value) != 0)
 853                      {
 854                          yyerrorf(ID_INVALID_INITIALIZER, "invalid initializer");
 855                          YYABORT;
 856                      }
 857              
 858                      $$ = CALLOC_T(MI_PropertyDecl, 1);
 859                      $$->name = $2;
 860                      $$->type = ARRAYOF($1);
 861                      $$->subscript = (MI_Uint32)$3;
 862                      $$->value = value;
 863                  }
 864                  | qualifierExpr dataType identifier subscript '=' initializer ';'
 865                  {
 866                      void* value;
 867              
 868                      /* Check qualifier scope */
 869                      if (CheckScope(MI_FLAG_PROPERTY, &$1) != 0)
 870                          YYABORT;
 871              
 872                      if (InitializerToValue(&$6, ARRAYOF($2), &value) != 0)
 873 mike     1.1         {
 874                          yyerrorf(ID_INVALID_INITIALIZER, "invalid initializer");
 875                          YYABORT;
 876                      }
 877              
 878                      $$ = CALLOC_T(MI_PropertyDecl, 1);
 879                      $$->name = $3;
 880                      $$->type = ARRAYOF($2);
 881                      $$->qualifiers = $1.data;
 882                      $$->numQualifiers = $1.size;
 883                      $$->subscript = (MI_Uint32)$4;
 884                      $$->value = value;
 885                  }
 886              
 887 krisbash 1.3 staticEmbeddedInstanceDeclaration
 888                  : classNameIdentifier identifier ';'
 889 mike     1.1     {
 890                      const MI_ClassDecl* cd;
 891              
 892                      /* Verify that class exists */
 893                      cd = FindClassDecl($1);
 894                      if (!cd)
 895                      {
 896                          yyerrorf(ID_UNDEFINED_CLASS, "undefined class: \"%s\"", $1);
 897                          YYABORT;
 898                      }
 899              
 900                      $$ = CALLOC_T(MI_PropertyDecl, 1);
 901 krisbash 1.3         $$->type = MI_INSTANCE;
 902 mike     1.1         $$->name = $2;
 903                      $$->className = cd->name;
 904                  }
 905 krisbash 1.3     | qualifierExpr classNameIdentifier identifier ';'
 906 mike     1.1     {
 907                      const MI_ClassDecl* cd;
 908              
 909                      /* Verify that class exists */
 910                      cd = FindClassDecl($2);
 911                      if (!cd)
 912                      {
 913                          yyerrorf(ID_UNDEFINED_CLASS, "undefined class: \"%s\"", $2);
 914                          YYABORT;
 915                      }
 916              
 917                      /* Check qualifier scope */
 918                      if (CheckScope(MI_FLAG_REFERENCE, &$1) != 0)
 919                          YYABORT;
 920              
 921                      $$ = CALLOC_T(MI_PropertyDecl, 1);
 922 krisbash 1.3         $$->type = MI_INSTANCE;
 923 mike     1.1         $$->name = $3;
 924                      $$->className = cd->name;
 925                      $$->qualifiers = $1.data;
 926                      $$->numQualifiers = $1.size;
 927                  }
 928 krisbash 1.3     | classNameIdentifier identifier subscript ';'
 929 mike     1.1     {
 930                      const MI_ClassDecl* cd;
 931              
 932                      /* Verify that class exists */
 933                      cd = FindClassDecl($1);
 934                      if (!cd)
 935                      {
 936                          yyerrorf(ID_UNDEFINED_CLASS, "undefined class: \"%s\"", $1);
 937                          YYABORT;
 938                      }
 939              
 940                      $$ = CALLOC_T(MI_PropertyDecl, 1);
 941 krisbash 1.3         $$->type = MI_INSTANCEA;
 942 mike     1.1         $$->name = $2;
 943                      $$->className = cd->name;
 944 krisbash 1.3         $$->subscript = (MI_Uint32)$3;
 945 mike     1.1     }
 946 krisbash 1.3     | qualifierExpr classNameIdentifier identifier subscript ';'
 947 mike     1.1     {
 948                      const MI_ClassDecl* cd;
 949              
 950                      /* Verify that class exists */
 951                      cd = FindClassDecl($2);
 952                      if (!cd)
 953                      {
 954                          yyerrorf(ID_UNDEFINED_CLASS, "undefined class: \"%s\"", $2);
 955                          YYABORT;
 956                      }
 957              
 958                      /* Check qualifier scope */
 959                      if (CheckScope(MI_FLAG_REFERENCE, &$1) != 0)
 960                          YYABORT;
 961              
 962                      $$ = CALLOC_T(MI_PropertyDecl, 1);
 963 krisbash 1.3         $$->type = MI_INSTANCEA;
 964 mike     1.1         $$->name = $3;
 965                      $$->className = cd->name;
 966 krisbash 1.3         $$->subscript = (MI_Uint32)$4;
 967 mike     1.1         $$->qualifiers = $1.data;
 968                      $$->numQualifiers = $1.size;
 969                  }
 970 krisbash 1.3     | classNameIdentifier identifier '=' initializer ';'
 971                  {
 972                      const MI_ClassDecl* cd;
 973              
 974                      /* Verify that class exists */
 975                      cd = FindClassDecl($1);
 976                      if (!cd)
 977                      {
 978                          yyerrorf(ID_UNDEFINED_CLASS, "undefined class: \"%s\"", $1);
 979                          YYABORT;
 980                      }
 981 mike     1.1 
 982 krisbash 1.3         $$ = CALLOC_T(MI_PropertyDecl, 1);
 983                      $$->type = MI_INSTANCE;
 984 mike     1.1         $$->name = $2;
 985 krisbash 1.3         $$->className = cd->name;
 986                      yywarnf(ID_IGNORED_INITIALIZER, "warning: ignored initializer");
 987                      /* TODO: use initializer */
 988 mike     1.1     }
 989 krisbash 1.3     | qualifierExpr classNameIdentifier identifier '=' initializer ';'
 990 mike     1.1     {
 991 krisbash 1.3         const MI_ClassDecl* cd;
 992              
 993                      /* Verify that class exists */
 994                      cd = FindClassDecl($2);
 995                      if (!cd)
 996                      {
 997                          yyerrorf(ID_UNDEFINED_CLASS, "undefined class: \"%s\"", $2);
 998                          YYABORT;
 999                      }
1000              
1001 mike     1.1         /* Check qualifier scope */
1002 krisbash 1.3         if (CheckScope(MI_FLAG_REFERENCE, &$1) != 0)
1003 mike     1.1             YYABORT;
1004              
1005 krisbash 1.3         $$ = CALLOC_T(MI_PropertyDecl, 1);
1006                      $$->type = MI_INSTANCE;
1007 mike     1.1         $$->name = $3;
1008 krisbash 1.3         $$->className = cd->name;
1009 mike     1.1         $$->qualifiers = $1.data;
1010                      $$->numQualifiers = $1.size;
1011 krisbash 1.3         yywarnf(ID_IGNORED_INITIALIZER, "warning: ignored initializer");
1012                      /* TODO: use initializer */
1013 mike     1.1     }
1014 krisbash 1.3     | classNameIdentifier identifier subscript '=' initializer ';'
1015 mike     1.1     {
1016 krisbash 1.3         const MI_ClassDecl* cd;
1017              
1018                      /* Verify that class exists */
1019                      cd = FindClassDecl($1);
1020                      if (!cd)
1021                      {
1022                          yyerrorf(ID_UNDEFINED_CLASS, "undefined class: \"%s\"", $1);
1023                          YYABORT;
1024                      }
1025 mike     1.1 
1026 krisbash 1.3         $$ = CALLOC_T(MI_PropertyDecl, 1);
1027                      $$->type = MI_INSTANCEA;
1028 mike     1.1         $$->name = $2;
1029 krisbash 1.3         $$->className = cd->name;
1030                      $$->subscript = (MI_Uint32)$3;
1031                      yywarnf(ID_IGNORED_INITIALIZER, "warning: ignored initializer");
1032                      /* TODO: use initializer */
1033 mike     1.1     }
1034 krisbash 1.3     | qualifierExpr classNameIdentifier identifier subscript '=' initializer ';'
1035 mike     1.1     {
1036 krisbash 1.3         const MI_ClassDecl* cd;
1037              
1038                      /* Verify that class exists */
1039                      cd = FindClassDecl($2);
1040                      if (!cd)
1041                      {
1042                          yyerrorf(ID_UNDEFINED_CLASS, "undefined class: \"%s\"", $2);
1043                          YYABORT;
1044                      }
1045 mike     1.1 
1046                      /* Check qualifier scope */
1047 krisbash 1.3         if (CheckScope(MI_FLAG_REFERENCE, &$1) != 0)
1048 mike     1.1             YYABORT;
1049              
1050 krisbash 1.3         $$ = CALLOC_T(MI_PropertyDecl, 1);
1051                      $$->type = MI_INSTANCEA;
1052 mike     1.1         $$->name = $3;
1053 krisbash 1.3         $$->className = cd->name;
1054                      $$->subscript = (MI_Uint32)$4;
1055 mike     1.1         $$->qualifiers = $1.data;
1056                      $$->numQualifiers = $1.size;
1057 krisbash 1.3         yywarnf(ID_IGNORED_INITIALIZER, "warning: ignored initializer");
1058                      /* TODO: use initializer */
1059 mike     1.1     }
1060              
1061 krisbash 1.3 dynamicEmbeddedInstanceDeclaration
1062                  : TOK_OBJECT identifier ';'
1063 mike     1.1     {
1064 krisbash 1.3         if (state.extensionsEnabled == MI_FALSE)
1065                          yywarnf(ID_UNSUPPORTED, "warning: OBJECT keyword is not supported");
1066                      $$ = CALLOC_T(MI_PropertyDecl, 1);
1067                      $$->type = MI_INSTANCE;
1068                      $$->name = $2;
1069                      $$->className = "?";
1070 mike     1.1     }
1071 krisbash 1.3     | qualifierExpr TOK_OBJECT identifier ';'
1072 mike     1.1     {
1073 krisbash 1.3         if (state.extensionsEnabled == MI_FALSE)
1074                          yywarnf(ID_UNSUPPORTED, "warning: OBJECT keyword is not supported");
1075                      $$ = CALLOC_T(MI_PropertyDecl, 1);
1076                      $$->type = MI_INSTANCE;
1077                      $$->name = $3;
1078                      $$->className = "?";
1079                      $$->qualifiers = $1.data;
1080                      $$->numQualifiers = $1.size;
1081 mike     1.1     }
1082 krisbash 1.3     | TOK_OBJECT identifier subscript ';'
1083 mike     1.1     {
1084 krisbash 1.3         if (state.extensionsEnabled == MI_FALSE)
1085                          yywarnf(ID_UNSUPPORTED, "warning: OBJECT keyword is not supported");
1086                      $$ = CALLOC_T(MI_PropertyDecl, 1);
1087                      $$->type = MI_INSTANCEA;
1088                      $$->name = $2;
1089                      $$->className = "?";
1090                      $$->subscript = 0;
1091 mike     1.1     }
1092 krisbash 1.3     | qualifierExpr TOK_OBJECT identifier subscript ';'
1093 mike     1.1     {
1094 krisbash 1.3         if (state.extensionsEnabled == MI_FALSE)
1095                          yywarnf(ID_UNSUPPORTED, "warning: OBJECT keyword is not supported");
1096                      $$ = CALLOC_T(MI_PropertyDecl, 1);
1097                      $$->type = MI_INSTANCEA;
1098                      $$->name = $3;
1099                      $$->className = "?";
1100                      $$->subscript = 0;
1101                      $$->qualifiers = $1.data;
1102                      $$->numQualifiers = $1.size;
1103 mike     1.1     }
1104 krisbash 1.3     | TOK_OBJECT identifier '=' initializer ';'
1105 mike     1.1     {
1106 krisbash 1.3         if (state.extensionsEnabled == MI_FALSE)
1107                          yywarnf(ID_UNSUPPORTED, "warning: OBJECT keyword is not supported");
1108                      $$ = CALLOC_T(MI_PropertyDecl, 1);
1109                      $$->type = MI_INSTANCE;
1110                      $$->name = $2;
1111                      $$->className = "?";
1112                      yywarnf(ID_IGNORED_INITIALIZER, "warning: ignored initializer");
1113                      /* TODO: use initializer */
1114 mike     1.1     }
1115 krisbash 1.3     | qualifierExpr TOK_OBJECT identifier '=' initializer ';'
1116 mike     1.1     {
1117 krisbash 1.3         if (state.extensionsEnabled == MI_FALSE)
1118                          yywarnf(ID_UNSUPPORTED, "warning: OBJECT keyword is not supported");
1119                      $$ = CALLOC_T(MI_PropertyDecl, 1);
1120                      $$->type = MI_INSTANCE;
1121                      $$->name = $3;
1122                      $$->className = "?";
1123                      $$->qualifiers = $1.data;
1124                      $$->numQualifiers = $1.size;
1125                      yywarnf(ID_IGNORED_INITIALIZER, "warning: ignored initializer");
1126                      /* TODO: use initializer */
1127 mike     1.1     }
1128 krisbash 1.3     | TOK_OBJECT identifier subscript '=' initializer ';'
1129 mike     1.1     {
1130 krisbash 1.3         if (state.extensionsEnabled == MI_FALSE)
1131                          yywarnf(ID_UNSUPPORTED, "warning: OBJECT keyword is not supported");
1132                      $$ = CALLOC_T(MI_PropertyDecl, 1);
1133                      $$->type = MI_INSTANCEA;
1134                      $$->name = $2;
1135                      $$->className = "?";
1136                      $$->subscript = (MI_Uint32)$3;
1137                      yywarnf(ID_IGNORED_INITIALIZER, "warning: ignored initializer");
1138                      /* TODO: use initializer */
1139 mike     1.1     }
1140 krisbash 1.3     | qualifierExpr TOK_OBJECT identifier subscript '=' initializer ';'
1141 mike     1.1     {
1142 krisbash 1.3         if (state.extensionsEnabled == MI_FALSE)
1143                          yywarnf(ID_UNSUPPORTED, "warning: OBJECT keyword is not supported");
1144                      $$ = CALLOC_T(MI_PropertyDecl, 1);
1145                      $$->type = MI_INSTANCEA;
1146                      $$->name = $3;
1147                      $$->className = "?";
1148                      $$->subscript = (MI_Uint32)$4;
1149                      $$->qualifiers = $1.data;
1150                      $$->numQualifiers = $1.size;
1151                      yywarnf(ID_IGNORED_INITIALIZER, "warning: ignored initializer");
1152                      /* TODO: use initializer */
1153 mike     1.1     }
1154 krisbash 1.3 
1155              referenceDeclaration
1156                  : classNameIdentifier TOK_REF identifier ';'
1157 mike     1.1     {
1158 krisbash 1.3         const MI_ClassDecl* cd;
1159              
1160                      /* Verify that class exists */
1161                      cd = FindClassDecl($1);
1162                      if (!cd)
1163                      {
1164                          yyerrorf(ID_UNDEFINED_CLASS, "undefined class: \"%s\"", $1);
1165                          YYABORT;
1166                      }
1167              
1168                      $$ = CALLOC_T(MI_PropertyDecl, 1);
1169                      $$->type = MI_REFERENCE;
1170                      $$->name = $3;
1171                      $$->className = cd->name;
1172                  }
1173                  | qualifierExpr classNameIdentifier TOK_REF identifier ';'
1174                  {
1175                      const MI_ClassDecl* cd;
1176              
1177                      /* Verify that class exists */
1178                      cd = FindClassDecl($2);
1179 krisbash 1.3         if (!cd)
1180                      {
1181                          yyerrorf(ID_UNDEFINED_CLASS, "undefined class: \"%s\"", $2);
1182                          YYABORT;
1183                      }
1184              
1185                      /* Check qualifier scope */
1186                      if (CheckScope(MI_FLAG_REFERENCE, &$1) != 0)
1187                          YYABORT;
1188              
1189                      $$ = CALLOC_T(MI_PropertyDecl, 1);
1190                      $$->type = MI_REFERENCE;
1191                      $$->name = $4;
1192                      $$->className = cd->name;
1193                      $$->qualifiers = $1.data;
1194                      $$->numQualifiers = $1.size;
1195                  }
1196                  | classNameIdentifier TOK_REF identifier '=' initializer ';'
1197                  {
1198                      const MI_ClassDecl* cd;
1199              
1200 krisbash 1.3         /* Verify that class exists */
1201                      cd = FindClassDecl($1);
1202                      if (!cd)
1203                      {
1204                          yyerrorf(ID_UNDEFINED_CLASS, "undefined class: \"%s\"", $1);
1205                          YYABORT;
1206                      }
1207              
1208                      $$ = CALLOC_T(MI_PropertyDecl, 1);
1209                      $$->type = MI_REFERENCE;
1210                      $$->name = $3;
1211                      $$->className = cd->name;
1212                      yywarnf(ID_IGNORED_INITIALIZER, "warning: ignored initializer");
1213                      /* [TODO: use initializer */
1214                  }
1215                  | qualifierExpr classNameIdentifier TOK_REF identifier '=' initializer ';'
1216                  {
1217                      const MI_ClassDecl* cd;
1218              
1219                      /* Verify that class exists */
1220                      cd = FindClassDecl($2);
1221 krisbash 1.3         if (!cd)
1222                      {
1223                          yyerrorf(ID_UNDEFINED_CLASS, "undefined class: \"%s\"", $2);
1224                          YYABORT;
1225                      }
1226              
1227                      /* Check qualifier scope */
1228                      if (CheckScope(MI_FLAG_REFERENCE, &$1) != 0)
1229                          YYABORT;
1230              
1231                      $$ = CALLOC_T(MI_PropertyDecl, 1);
1232                      $$->type = MI_REFERENCE;
1233                      $$->name = $4;
1234                      $$->className = cd->name;
1235                      $$->qualifiers = $1.data;
1236                      $$->numQualifiers = $1.size;
1237                      yywarnf(ID_IGNORED_INITIALIZER, "warning: ignored initializer");
1238                      /* [TODO: use initializer */
1239                  }
1240                  | classNameIdentifier TOK_REF identifier subscript ';'
1241                  {
1242 krisbash 1.3         const MI_ClassDecl* cd;
1243              
1244                      /* Verify that class exists */
1245                      cd = FindClassDecl($1);
1246                      if (!cd)
1247                      {
1248                          yyerrorf(ID_UNDEFINED_CLASS, "undefined class: \"%s\"", $1);
1249                          YYABORT;
1250                      }
1251              
1252                      $$ = CALLOC_T(MI_PropertyDecl, 1);
1253                      $$->type = MI_REFERENCEA;
1254                      $$->name = $3;
1255                      $$->className = cd->name;
1256                      $$->subscript = (MI_Uint32)$4;
1257                  }
1258                  | qualifierExpr classNameIdentifier TOK_REF identifier subscript ';'
1259                  {
1260                      const MI_ClassDecl* cd;
1261              
1262                      /* Verify that class exists */
1263 krisbash 1.3         cd = FindClassDecl($2);
1264                      if (!cd)
1265                      {
1266                          yyerrorf(ID_UNDEFINED_CLASS, "undefined class: \"%s\"", $2);
1267                          YYABORT;
1268                      }
1269              
1270                      /* Check qualifier scope */
1271                      if (CheckScope(MI_FLAG_REFERENCE, &$1) != 0)
1272                          YYABORT;
1273              
1274                      $$ = CALLOC_T(MI_PropertyDecl, 1);
1275                      $$->type = MI_REFERENCEA;
1276                      $$->name = $4;
1277                      $$->className = cd->name;
1278                      $$->subscript = (MI_Uint32)$5;
1279                      $$->qualifiers = $1.data;
1280                      $$->numQualifiers = $1.size;
1281                  }
1282                  | classNameIdentifier TOK_REF identifier subscript '=' initializer ';'
1283                  {
1284 krisbash 1.3         const MI_ClassDecl* cd;
1285              
1286                      /* Verify that class exists */
1287                      cd = FindClassDecl($1);
1288                      if (!cd)
1289                      {
1290                          yyerrorf(ID_UNDEFINED_CLASS, "undefined class: \"%s\"", $1);
1291                          YYABORT;
1292                      }
1293              
1294                      $$ = CALLOC_T(MI_PropertyDecl, 1);
1295                      $$->type = MI_REFERENCEA;
1296                      $$->name = $3;
1297                      $$->className = cd->name;
1298                      $$->subscript = (MI_Uint32)$4;
1299                      yywarnf(ID_IGNORED_INITIALIZER, "warning: ignored initializer");
1300                      /* TODO: use initializer */
1301                  }
1302                  | qualifierExpr classNameIdentifier TOK_REF identifier subscript '=' initializer ';'
1303                  {
1304                      const MI_ClassDecl* cd;
1305 krisbash 1.3 
1306                      /* Verify that class exists */
1307                      cd = FindClassDecl($2);
1308                      if (!cd)
1309                      {
1310                          yyerrorf(ID_UNDEFINED_CLASS, "undefined class: \"%s\"", $2);
1311                          YYABORT;
1312                      }
1313              
1314                      /* Check qualifier scope */
1315                      if (CheckScope(MI_FLAG_REFERENCE, &$1) != 0)
1316                          YYABORT;
1317              
1318                      $$ = CALLOC_T(MI_PropertyDecl, 1);
1319                      $$->type = MI_REFERENCEA;
1320                      $$->name = $4;
1321                      $$->className = cd->name;
1322                      $$->subscript = (MI_Uint32)$5;
1323                      $$->qualifiers = $1.data;
1324                      $$->numQualifiers = $1.size;
1325                      yywarnf(ID_IGNORED_INITIALIZER, "warning: ignored initializer");
1326 krisbash 1.3         /* TODO: use initializer */
1327                  }
1328              
1329              dynamicReferenceDeclaration
1330                  : TOK_OBJECT TOK_REF identifier ';'
1331                  {
1332                      $$ = CALLOC_T(MI_PropertyDecl, 1);
1333                      $$->type = MI_REFERENCE;
1334                      $$->name = $3;
1335                      $$->className = "?";
1336                  }
1337                  | qualifierExpr TOK_OBJECT TOK_REF identifier ';'
1338                  {
1339                      /* Check qualifier scope */
1340                      if (CheckScope(MI_FLAG_REFERENCE, &$1) != 0)
1341                          YYABORT;
1342              
1343                      $$ = CALLOC_T(MI_PropertyDecl, 1);
1344                      $$->type = MI_REFERENCE;
1345                      $$->name = $4;
1346                      $$->className = "?";
1347 krisbash 1.3         $$->qualifiers = $1.data;
1348                      $$->numQualifiers = $1.size;
1349                  }
1350                  | TOK_OBJECT TOK_REF identifier subscript ';'
1351                  {
1352                      $$ = CALLOC_T(MI_PropertyDecl, 1);
1353                      $$->type = MI_REFERENCEA;
1354                      $$->name = $3;
1355                      $$->className = "?";
1356                      $$->subscript = (MI_Uint32)$4;
1357 mike     1.1     }
1358 krisbash 1.3     | qualifierExpr TOK_OBJECT TOK_REF identifier subscript ';'
1359 mike     1.1     {
1360 krisbash 1.3         /* Check qualifier scope */
1361                      if (CheckScope(MI_FLAG_REFERENCE, &$1) != 0)
1362                          YYABORT;
1363              
1364                      $$ = CALLOC_T(MI_PropertyDecl, 1);
1365                      $$->type = MI_REFERENCEA;
1366                      $$->name = $4;
1367                      $$->className = "?";
1368                      $$->subscript = (MI_Uint32)$5;
1369                      $$->qualifiers = $1.data;
1370                      $$->numQualifiers = $1.size;
1371 mike     1.1     }
1372 krisbash 1.3     | TOK_OBJECT TOK_REF identifier '=' initializer ';'
1373 mike     1.1     {
1374 krisbash 1.3         $$ = CALLOC_T(MI_PropertyDecl, 1);
1375                      $$->type = MI_REFERENCE;
1376                      $$->name = $3;
1377                      $$->className = "?";
1378                      yywarnf(ID_IGNORED_INITIALIZER, "warning: ignored initializer");
1379                      /* TODO: use initializer */
1380 mike     1.1     }
1381 krisbash 1.3     | TOK_OBJECT TOK_REF identifier subscript '=' initializer ';'
1382 mike     1.1     {
1383 krisbash 1.3         $$ = CALLOC_T(MI_PropertyDecl, 1);
1384                      $$->type = MI_REFERENCEA;
1385                      $$->name = $3;
1386                      $$->className = "?";
1387                      $$->subscript = (MI_Uint32)$4;
1388                      yywarnf(ID_IGNORED_INITIALIZER, "warning: ignored initializer");
1389                      /* TODO: use initializer */
1390 mike     1.1     }
1391 krisbash 1.3     | qualifierExpr TOK_OBJECT TOK_REF identifier '=' initializer ';'
1392                  {
1393                      /* Check qualifier scope */
1394                      if (CheckScope(MI_FLAG_REFERENCE, &$1) != 0)
1395                          YYABORT;
1396              
1397                      $$ = CALLOC_T(MI_PropertyDecl, 1);
1398                      $$->type = MI_REFERENCE;
1399                      $$->name = $4;
1400                      $$->className = "?";
1401                      $$->qualifiers = $1.data;
1402                      $$->numQualifiers = $1.size;
1403                      yywarnf(ID_IGNORED_INITIALIZER, "warning: ignored initializer");
1404                      /* TODO: use initializer */
1405              	}
1406                  | qualifierExpr TOK_OBJECT TOK_REF identifier subscript '=' initializer ';'
1407                  {
1408                      /* Check qualifier scope */
1409                      if (CheckScope(MI_FLAG_REFERENCE, &$1) != 0)
1410                          YYABORT;
1411              
1412 krisbash 1.3         $$ = CALLOC_T(MI_PropertyDecl, 1);
1413                      $$->type = MI_REFERENCEA;
1414                      $$->name = $4;
1415                      $$->className = "?";
1416                      $$->subscript = (MI_Uint32)$5;
1417                      $$->qualifiers = $1.data;
1418                      $$->numQualifiers = $1.size;
1419                      yywarnf(ID_IGNORED_INITIALIZER, "warning: ignored initializer");
1420                      /* TODO: use initializer */
1421              	}
1422              
1423              methodDeclaration
1424                  : dataType identifier '(' parameterList ')' ';'
1425 mike     1.1     {
1426 krisbash 1.3         $$ = CALLOC_T(MI_MethodDecl, 1);
1427                      $$->name = $2;
1428                      $$->parameters = $4.data;
1429                      $$->numParameters = $4.size;
1430                      $$->returnType = $1;
1431 mike     1.1     }
1432 krisbash 1.3     | qualifierExpr dataType identifier '(' parameterList ')' ';'
1433 mike     1.1     {
1434 krisbash 1.3         /* Check qualifier scope */
1435                      if (CheckScope(MI_FLAG_METHOD, &$1) != 0)
1436                          YYABORT;
1437              
1438                      $$ = CALLOC_T(MI_MethodDecl, 1);
1439                      $$->name = $3;
1440                      $$->parameters = $5.data;
1441                      $$->numParameters = $5.size;
1442                      $$->qualifiers = $1.data;
1443                      $$->numQualifiers = $1.size;
1444                      $$->returnType = $2;
1445 mike     1.1     }
1446 krisbash 1.3     | dataType identifier '(' ')' ';'
1447                  {
1448                      MOF_ParameterList parameterList = PTRARRAY_INITIALIZER;
1449 mike     1.1 
1450 krisbash 1.3         $$ = CALLOC_T(MI_MethodDecl, 1);
1451                      $$->name = $2;
1452                      $$->parameters = parameterList.data;
1453                      $$->numParameters = parameterList.size;
1454                      $$->returnType = $1;
1455                  }
1456                  | qualifierExpr dataType identifier '(' ')' ';'
1457 mike     1.1     {
1458 krisbash 1.3         MOF_ParameterList parameterList = PTRARRAY_INITIALIZER;
1459              
1460                      /* Check qualifier scope */
1461                      if (CheckScope(MI_FLAG_METHOD, &$1) != 0)
1462                          YYABORT;
1463              
1464                      $$ = CALLOC_T(MI_MethodDecl, 1);
1465                      $$->name = $3;
1466                      $$->parameters = parameterList.data;
1467                      $$->numParameters = parameterList.size;
1468                      $$->qualifiers = $1.data;
1469                      $$->numQualifiers = $1.size;
1470                      $$->returnType = $2;
1471 mike     1.1     }
1472              
1473              parameterList
1474                  : parameter
1475                  {
1476                      $1->flags = MI_FLAG_PARAMETER;
1477                      $1->flags |= GetQualFlags($1->qualifiers, $1->numQualifiers);
1478                      $$.data = NULL;
1479                      $$.size = 0;
1480                      PtrArray_Append((PtrArray*)&$$, $1);
1481                  }
1482                  | parameterList ',' parameter
1483                  {
1484                      if (FindParameter(&$1, $3->name))
1485                      {
1486                          yyerrorf(ID_PARAMETER_ALREADY_DEFINED, 
1487                              "parameter already defined: \"%s\"", $3->name);
1488                          YYABORT;
1489                      }
1490              
1491                      $3->flags = MI_FLAG_PARAMETER;
1492 mike     1.1         $3->flags |= GetQualFlags($3->qualifiers, $3->numQualifiers);
1493                      PtrArray_Append((PtrArray*)&$$, $3);
1494                  }
1495              
1496              parameter
1497                  : dataType identifier
1498                  {
1499                      $$ = CALLOC_T(MI_ParameterDecl, 1);
1500                      $$->name = $2;
1501                      $$->type = $1;
1502                  }
1503 krisbash 1.3     | classNameIdentifier TOK_REF identifier
1504 mike     1.1     {
1505                      const MI_ClassDecl* cd;
1506              
1507                      /* Verify that class exists */
1508                      cd = FindClassDecl($1);
1509                      if (!cd)
1510                      {
1511                          yyerrorf(ID_UNDEFINED_CLASS, "undefined class: \"%s\"", $1);
1512                          YYABORT;
1513                      }
1514              
1515                      $$ = CALLOC_T(MI_ParameterDecl, 1);
1516 krisbash 1.3         $$->name = $3;
1517 mike     1.1         $$->type = MI_REFERENCE;
1518                      $$->className = cd->name;
1519                  }
1520                  | qualifierExpr dataType identifier
1521                  {
1522                      /* Check qualifier scope */
1523                      if (CheckScope(MI_FLAG_PARAMETER, &$1) != 0)
1524                          YYABORT;
1525              
1526                      $$ = CALLOC_T(MI_ParameterDecl, 1);
1527                      $$->name = $3;
1528                      $$->type = $2;
1529                      $$->qualifiers = $1.data;
1530                      $$->numQualifiers = $1.size;
1531                  }
1532 krisbash 1.3     | qualifierExpr classNameIdentifier TOK_REF identifier
1533 mike     1.1     {
1534                      const MI_ClassDecl* cd;
1535              
1536                      /* Verify that class exists */
1537                      cd = FindClassDecl($2);
1538                      if (!cd)
1539                      {
1540                          yyerrorf(ID_UNDEFINED_CLASS, "undefined class: \"%s\"", $2);
1541                          YYABORT;
1542                      }
1543              
1544                      /* Check qualifier scope */
1545                      if (CheckScope(MI_FLAG_PARAMETER, &$1) != 0)
1546                          YYABORT;
1547              
1548                      $$ = CALLOC_T(MI_ParameterDecl, 1);
1549 krisbash 1.3         $$->name = $4;
1550 mike     1.1         $$->type = MI_REFERENCE;
1551                      $$->className = cd->name;
1552                      $$->qualifiers = $1.data;
1553                      $$->numQualifiers = $1.size;
1554                  }
1555                  | dataType identifier subscript
1556                  {
1557                      $$ = CALLOC_T(MI_ParameterDecl, 1);
1558                      $$->name = $2;
1559                      $$->type = ARRAYOF($1);
1560                      $$->subscript = (MI_Uint32)$3;
1561                  }
1562 krisbash 1.3     | classNameIdentifier TOK_REF identifier subscript
1563 mike     1.1     {
1564                      const MI_ClassDecl* cd;
1565              
1566                      /* Verify that class exists */
1567                      cd = FindClassDecl($1);
1568                      if (!cd)
1569                      {
1570                          yyerrorf(ID_UNDEFINED_CLASS, "undefined class: \"%s\"", $1);
1571                          YYABORT;
1572                      }
1573              
1574                      $$ = CALLOC_T(MI_ParameterDecl, 1);
1575 krisbash 1.3         $$->name = $3;
1576 mike     1.1         $$->type = ARRAYOF(MI_REFERENCE);
1577                      $$->className = cd->name;
1578 krisbash 1.3         $$->subscript = (MI_Uint32)$4;
1579 mike     1.1     }
1580                  | qualifierExpr dataType identifier subscript
1581                  {
1582                      /* Check qualifier scope */
1583                      if (CheckScope(MI_FLAG_PARAMETER, &$1) != 0)
1584                          YYABORT;
1585              
1586                      $$ = CALLOC_T(MI_ParameterDecl, 1);
1587                      $$->name = $3;
1588                      $$->type = ARRAYOF($2);
1589                      $$->subscript = (MI_Uint32)$4;
1590                      $$->qualifiers = $1.data;
1591                      $$->numQualifiers = $1.size;
1592                  }
1593 krisbash 1.3     | qualifierExpr classNameIdentifier TOK_REF identifier subscript
1594 mike     1.1     {
1595                      const MI_ClassDecl* cd;
1596              
1597                      /* Verify that class exists */
1598                      cd = FindClassDecl($2);
1599                      if (!cd)
1600                      {
1601                          yyerrorf(ID_UNDEFINED_CLASS, "undefined class: \"%s\"", $2);
1602                          YYABORT;
1603                      }
1604              
1605                      /* Check qualifier scope */
1606                      if (CheckScope(MI_FLAG_PARAMETER, &$1) != 0)
1607                          YYABORT;
1608              
1609                      $$ = CALLOC_T(MI_ParameterDecl, 1);
1610 krisbash 1.3         $$->name = $4;
1611 mike     1.1         $$->type = ARRAYOF(MI_REFERENCE);
1612                      $$->className = cd->name;
1613 krisbash 1.3         $$->subscript = (MI_Uint32)$5;
1614 mike     1.1         $$->qualifiers = $1.data;
1615                      $$->numQualifiers = $1.size;
1616                  }
1617              
1618              subscript
1619                  : '[' TOK_INTEGER_VALUE ']'
1620                  {
1621                      if ($2 <= 0)
1622                      {
1623                          yyerrorf(ID_ILLEGAL_ARRAY_SUBSCRIPT, 
1624                              "illegal array subscript: " SINT64_FMT, $2);
1625                          YYABORT;
1626                      }
1627              
1628                      $$ = $2;
1629                  }
1630                  | '[' ']'
1631                  {
1632                      /* 0 signifies a dynamic array */
1633                      $$ = 0;
1634                  }
1635 mike     1.1 
1636              initializer
1637 krisbash 1.3     : scalarInitializer
1638                  {
1639                      $$ = $1;
1640                  }
1641                  | arrayInitializer
1642                  {
1643                      $$ = $1;
1644                  }
1645              
1646              arrayInitializer
1647                  : '{' arrayInitializerList '}'
1648                  {
1649                      $$ = $2;
1650                  }
1651                  | '{' '}'
1652                  {
1653                      $$.data = NULL;
1654                      $$.size = 0;
1655                      $$.isArray = 1;
1656                  }
1657              
1658 krisbash 1.3 arrayInitializerList
1659                  : scalarInitializer
1660 mike     1.1     {
1661                      memset(&$$, 0, sizeof($$));
1662                      $$.data = CALLOC_T(MOF_ConstantValue, 1);
1663 krisbash 1.3         $$.data[0] = $1.data[0];
1664 mike     1.1         $$.size = 1;
1665 krisbash 1.3         $$.isArray = 1;
1666 mike     1.1     }
1667 krisbash 1.3     | arrayInitializerList ',' scalarInitializer
1668 mike     1.1     {
1669 krisbash 1.3         $1.data = REALLOC_T(MOF_ConstantValue, $1.data, $1.size + 1);
1670                      $1.data[$1.size] = $3.data[0];
1671                      $1.size++;
1672 mike     1.1         $$ = $1;
1673                  }
1674 krisbash 1.3 
1675              scalarInitializer
1676                  : constantValue
1677                  {
1678                      memset(&$$, 0, sizeof($$));
1679                      $$.data = CALLOC_T(MOF_ConstantValue, 1);
1680                      $$.data[0] = $1;
1681                      $$.size = 1;
1682                  }
1683 mike     1.1     | TOK_ALIAS_IDENTIFIER
1684                  {
1685                      memset(&$$, 0, sizeof($$));
1686                      $$.data = CALLOC_T(MOF_ConstantValue, 1);
1687                      $$.data[0].type = TOK_STRING_VALUE;
1688                      $$.data[0].value.string = $1;
1689 krisbash 1.3         $$.size = 1;
1690                      /* TODO: look up alias, get and store instance decl. for alias */
1691                  }
1692                  | TOK_INSTANCE TOK_OF classNameIdentifier '{' valueInitializerList '}'
1693                  {
1694                      memset(&$$, 0, sizeof($$));
1695                      $$.data = CALLOC_T(MOF_ConstantValue, 1);
1696                      $$.data[0].type = TOK_STRING_VALUE;
1697                      $$.data[0].value.string = $3;
1698                      $$.size = 1;
1699                      /* TODO: look up class $3, validate property names/types, store dynamic instance properties in this instance */
1700                  }
1701              
1702              nonAggregateInitializer
1703                  : constantValue
1704                  {
1705                      memset(&$$, 0, sizeof($$));
1706                      $$.data = CALLOC_T(MOF_ConstantValue, 1);
1707                      $$.data[0] = $1;
1708                      $$.size = 1;
1709                  }
1710 krisbash 1.3     | nonAggregateArrayInitializer
1711                  {
1712                      $$ = $1;
1713 mike     1.1     }
1714              
1715 krisbash 1.3 nonAggregateArrayInitializer
1716                  : '{' nonAggregateArrayInitializerList '}'
1717 mike     1.1     {
1718                      $$ = $2;
1719                  }
1720 krisbash 1.3     | '{' '}'
1721                  {
1722                      $$.data = NULL;
1723                      $$.size = 0;
1724                      $$.isArray = MI_TRUE;
1725                  }
1726 mike     1.1 
1727 krisbash 1.3 nonAggregateArrayInitializerList
1728 mike     1.1     : constantValue
1729                  {
1730                      memset(&$$, 0, sizeof($$));
1731                      $$.data = CALLOC_T(MOF_ConstantValue, 1);
1732                      $$.data[0] = $1;
1733                      $$.size = 1;
1734 krisbash 1.3         $$.isArray = MI_TRUE;
1735 mike     1.1     }
1736 krisbash 1.3     | nonAggregateArrayInitializerList ',' constantValue
1737 mike     1.1     {
1738                      $1.data = REALLOC_T(MOF_ConstantValue, $1.data, $1.size + 1);
1739                      $1.data[$1.size] = $3;
1740                      $1.size++;
1741 krisbash 1.3         $1.isArray = MI_TRUE;
1742 mike     1.1         $$ = $1;
1743                  }
1744              
1745              constantValue
1746                  : TOK_INTEGER_VALUE
1747                  {
1748                      $$.type = TOK_INTEGER_VALUE;
1749                      $$.value.integer = $1;
1750                  }
1751                  | TOK_REAL_VALUE
1752                  {
1753                      $$.type = TOK_REAL_VALUE;
1754                      $$.value.real = $1;
1755                  }
1756                  | TOK_CHAR_VALUE
1757                  {
1758                      $$.type = TOK_CHAR_VALUE;
1759                      $$.value.character = $1;
1760                  }
1761                  | stringValue
1762                  {
1763 mike     1.1         $$.type = TOK_STRING_VALUE;
1764                      $$.value.string = $1;
1765                  }
1766                  | TOK_BOOLEAN_VALUE
1767                  {
1768                      $$.type = TOK_BOOLEAN_VALUE;
1769                      $$.value.boolean = $1;
1770                  }
1771                  | TOK_NULL
1772                  {
1773                      $$.type = TOK_NULL;
1774                  }
1775              
1776              stringValue
1777                  : TOK_STRING_VALUE
1778                  {
1779              	$$ = $1;
1780                  }
1781                  | stringValue TOK_STRING_VALUE
1782                  {
1783                      size_t size = strlen($1) + strlen($2) + 1;
1784 mike     1.1         $$ = (char*)MOF_Realloc(&state.heap, $1, size);
1785                      Strcat($$, size, $2);
1786                      MOF_Free(&state.heap, $2);
1787                  }
1788              
1789              qualifierDeclaration
1790                  : TOK_QUALIFIER identifier qualifierType scopeExpr ';'
1791                  {
1792                      $3->name = $2;
1793                      $3->scope = $4;
1794                      $3->flavor = 0;
1795                      $$ = $3;
1796                  }
1797                  | TOK_QUALIFIER identifier qualifierType scopeExpr flavorExpr ';'
1798                  {
1799                      $3->name = $2;
1800                      $3->scope = $4;
1801                      $3->flavor = $5;
1802                      $$ = $3;
1803                  }
1804              
1805 mike     1.1 qualifierType
1806                  : ':' dataType
1807                  {
1808                      $$ = CALLOC_T(MI_QualifierDecl, 1);
1809                      $$->type = $2;
1810                  }
1811 krisbash 1.3     | ':' dataType '=' nonAggregateInitializer
1812 mike     1.1     {
1813                      void* value;
1814              
1815                      if (InitializerToValue(&$4, $2, &value) != 0)
1816                      {
1817                          yyerrorf(ID_INVALID_INITIALIZER, "invalid initializer");
1818                          YYABORT;
1819                      }
1820              
1821                      $$ = CALLOC_T(MI_QualifierDecl, 1);
1822                      $$->type = $2;
1823                      $$->value = value;
1824                      ReleaseInitializer(&$4);
1825                  }
1826                  | ':' dataType subscript
1827                  {
1828                      $$ = CALLOC_T(MI_QualifierDecl, 1);
1829                      $$->type = ARRAYOF($2);
1830                      $$->subscript = (MI_Uint32)$3;
1831                  }
1832 krisbash 1.3     | ':' dataType subscript '=' nonAggregateInitializer
1833 mike     1.1     {
1834                      void* value = NULL;
1835              
1836                      if (InitializerToValue(&$5, ARRAYOF($2), &value) != 0)
1837                      {
1838                          yyerrorf(ID_INVALID_INITIALIZER, "invalid initializer");
1839                          YYABORT;
1840                      }
1841              
1842                      $$ = CALLOC_T(MI_QualifierDecl, 1);
1843                      $$->type = ARRAYOF($2);
1844                      $$->subscript = (MI_Uint32)$3;
1845                      $$->value = value;
1846                      ReleaseInitializer(&$5);
1847                  }
1848              
1849              scopeExpr
1850                  : ',' TOK_SCOPE '(' scopeList ')'
1851                  {
1852                      $$ = $4;
1853                  }
1854 mike     1.1 
1855              scopeList
1856                  : scope
1857                  {
1858                      $$ = $1;
1859                  }
1860                  | scopeList ',' scope
1861                  {
1862                      $$ |= $3;
1863                  }
1864              
1865              scope
1866                  : TOK_CLASS
1867                  {
1868                      $$ = MI_FLAG_CLASS;
1869                  }
1870                  | TOK_ASSOCIATION
1871                  {
1872                      $$ = MI_FLAG_ASSOCIATION;
1873                  }
1874                  | TOK_INDICATION
1875 mike     1.1     {
1876                      $$ = MI_FLAG_INDICATION;
1877                  }
1878                  | TOK_PROPERTY
1879                  {
1880                      $$ = MI_FLAG_PROPERTY;
1881                  }
1882                  | TOK_REFERENCE
1883                  {
1884                      $$ = MI_FLAG_REFERENCE;
1885                  }
1886                  | TOK_METHOD
1887                  {
1888                      $$ = MI_FLAG_METHOD;
1889                  }
1890                  | TOK_PARAMETER
1891                  {
1892                      $$ = MI_FLAG_PARAMETER;
1893                  }
1894                  | TOK_ANY
1895                  {
1896 mike     1.1         $$ = MI_FLAG_ANY;
1897                  }
1898              
1899              flavorExpr
1900                  : ',' TOK_FLAVOR '(' flavorList ')'
1901                  {
1902                      /* Reject incompatiable ToSubclass and Restricted flavors */
1903                      if ($4 & MI_FLAG_TOSUBCLASS && $4 & MI_FLAG_RESTRICTED)
1904                      {
1905                          yyerrorf(ID_INCOMPATIBLE_FLAVORS, "incompatible flavors: %s/%s", 
1906                              "ToSubclass", "Restricted");
1907                          YYABORT;
1908                      }
1909              
1910                      /* Reject incompatiable EnableOverride and DisableOverride flavors */
1911                      if ($4 & MI_FLAG_ENABLEOVERRIDE && $4 & MI_FLAG_DISABLEOVERRIDE)
1912                      {
1913                          yyerrorf(ID_INCOMPATIBLE_FLAVORS, "incompatible flavors: %s/%s", 
1914                              "EnableOverride", "DisableOverride");
1915                          YYABORT;
1916                      }
1917 mike     1.1 
1918                      $$ = $4;
1919                  }
1920              
1921              instanceDeclaration
1922 krisbash 1.3     : TOK_INSTANCE TOK_OF classNameIdentifier instanceBody
1923 mike     1.1     {
1924                      $$ = CALLOC_T(MI_InstanceDecl, 1);
1925                      $$->flags = 0;
1926                      $$->name = $3;
1927                      $$->properties = $4.propertySet.data;
1928                      $$->numProperties = $4.propertySet.size;
1929                  }
1930 krisbash 1.3     | qualifierExpr TOK_INSTANCE TOK_OF classNameIdentifier instanceBody
1931 mike     1.1     {
1932                      $$ = CALLOC_T(MI_InstanceDecl, 1);
1933                      $$->flags = 0;
1934                      $$->name = $4;
1935                      $$->properties = $5.propertySet.data;
1936                      $$->numProperties = $5.propertySet.size;
1937                      $$->qualifiers = $1.data;
1938                      $$->numQualifiers = $1.size;
1939                  }
1940                  | TOK_INSTANCE TOK_OF identifier alias instanceBody
1941                  {
1942                      /* [TODO]: handle alias */
1943                      $$ = CALLOC_T(MI_InstanceDecl, 1);
1944                      $$->flags = 0;
1945                      $$->name = $3;
1946                      $$->properties = $5.propertySet.data;
1947                      $$->numProperties = $5.propertySet.size;
1948                  }
1949 krisbash 1.3     | qualifierExpr TOK_INSTANCE TOK_OF classNameIdentifier alias instanceBody
1950 mike     1.1     {
1951                      /* [TODO]: handle alias */
1952                      $$ = CALLOC_T(MI_InstanceDecl, 1);
1953                      $$->flags = 0;
1954                      $$->name = $4;
1955                      $$->properties = $6.propertySet.data;
1956                      $$->numProperties = $6.propertySet.size;
1957                      $$->qualifiers = $1.data;
1958                      $$->numQualifiers = $1.size;
1959                  }
1960              
1961              instanceBody
1962                  : '{' valueInitializerList '}' ';'
1963                  {
1964                      $$ = $2;
1965                  }
1966 krisbash 1.3     | '{' '}' ';'
1967                  {
1968                      $$.propertySet.data = NULL;
1969                      $$.propertySet.size = 0;
1970                      $$.methodList.data = NULL;
1971                      $$.methodList.size = 0;
1972                  }
1973 mike     1.1 
1974              alias
1975                  : TOK_AS TOK_ALIAS_IDENTIFIER
1976                  {
1977                      $$ = $2;
1978                  }
1979              
1980              valueInitializerList
1981                  : valueInitializer
1982                  {
1983                      $$.propertySet.data = NULL;
1984                      $$.propertySet.size = 0;
1985                      $1->flags = MI_FLAG_PROPERTY;
1986                      $1->flags |= GetQualFlags($1->qualifiers, $1->numQualifiers);
1987                      PtrArray_Append((PtrArray*)&$$.propertySet, $1);
1988                  }
1989                  | valueInitializerList valueInitializer
1990                  {
1991                      if (FindProperty(&$1.propertySet, $2->name))
1992                      {
1993                          yyerrorf(ID_CLASS_FEATURE_ALREADY_DEFINED, 
1994 mike     1.1                 "instance property already defined: \"%s\"", $2->name);
1995                          YYABORT;
1996                      }
1997              
1998                      $2->flags = MI_FLAG_PROPERTY;
1999                      $2->flags |= GetQualFlags($2->qualifiers, $2->numQualifiers);
2000                      PtrArray_Append((PtrArray*)&$$.propertySet, $2);
2001                  }
2002              
2003              valueInitializer
2004 krisbash 1.3     : identifier ';'
2005                  {
2006                      $$ = CALLOC_T(MI_PropertyDecl, 1);
2007                      $$->name = $1;
2008                      $$->type = TOK_NULL;
2009                  }
2010                  | qualifierExpr identifier ';'
2011                  {
2012                      $$ = CALLOC_T(MI_PropertyDecl, 1);
2013                      $$->name = $2;
2014                      $$->type = TOK_NULL;
2015                      $$->qualifiers = $1.data;
2016                      $$->numQualifiers = $1.size;
2017                  }
2018                  | identifier '=' initializer ';'
2019 mike     1.1     {
2020                      void* value;
2021                      MI_Type type = InitializerToType(&$3);
2022                      if (InitializerToValue(&$3, type, &value) != 0)
2023                      {
2024                          yyerrorf(ID_INVALID_INITIALIZER, "invalid initializer");
2025                          YYABORT;
2026                      }
2027              
2028                      $$ = CALLOC_T(MI_PropertyDecl, 1);
2029                      $$->name = $1;
2030                      $$->type = type;
2031                      $$->value = value;
2032                  }
2033                  | qualifierExpr identifier '=' initializer ';'
2034                  {
2035                      void* value;
2036                      MI_Type type = InitializerToType(&$4);
2037              
2038                      if (InitializerToValue(&$4, type, &value) != 0)
2039                      {
2040 mike     1.1             yyerrorf(ID_INVALID_INITIALIZER, "invalid initializer");
2041                          YYABORT;
2042                      }
2043              
2044                      $$ = CALLOC_T(MI_PropertyDecl, 1);
2045                      $$->name = $2;
2046                      $$->type = type;
2047                      $$->value = value;
2048                      $$->qualifiers = $1.data;
2049                      $$->numQualifiers = $1.size;
2050                  }
2051              
2052              identifier
2053 krisbash 1.3     : classNameIdentifier
2054                  {
2055                      $$ = $1;
2056                  }
2057                  | TOK_OBJECT
2058                  {
2059                      $$ = "Object";
2060                  }
2061                  | TOK_BOOLEAN
2062                  {
2063                      $$ = "Boolean";
2064                  }
2065                  | TOK_DATETIME
2066                  {
2067                      $$ = "Datetime";
2068                  }
2069                  | TOK_STRING
2070                  {
2071                      $$ = "String";
2072                  }
2073                  /* {S,U}INT{8,16,32,64} can also be added here */
2074 krisbash 1.3 
2075              /* Class names can appear at the beginning of property declarations (for embedded class
2076                 types or before REF), so class names cannot collide with built-in type names, so
2077                 they are more limited than identifer, above. */
2078              classNameIdentifier
2079                  : TOK_IDENT
2080                  {
2081                      $$ = $1;
2082                  }
2083                  | TOK_PRAGMA
2084                  {
2085                      $$ = $1;
2086                  }
2087                  | TOK_CLASS
2088                  {
2089                      $$ = $1;
2090                  }
2091                  | TOK_OF
2092                  {
2093                      $$ = $1;
2094                  }
2095 krisbash 1.3     | TOK_ANY
2096 mike     1.1     {
2097                      $$ = $1;
2098                  }
2099                  | TOK_ASSOCIATION
2100                  {
2101 krisbash 1.3         $$ = $1;
2102 mike     1.1     }
2103                  | TOK_INDICATION
2104                  {
2105 krisbash 1.3         $$ = $1;
2106 mike     1.1     }
2107                  | TOK_REFERENCE
2108                  {
2109 krisbash 1.3         $$ = $1;
2110 mike     1.1     }
2111                  | TOK_PROPERTY
2112                  {
2113 krisbash 1.3         $$ = $1;
2114                  }
2115                  | TOK_QUALIFIER
2116                  {
2117                      $$ = $1;
2118                  }
2119                  | TOK_TOSUBCLASS
2120                  {
2121                      $$ = $1;
2122                  }
2123                  | TOK_TOINSTANCE
2124                  {
2125                      $$ = $1;
2126                  }
2127                  | TOK_TRANSLATABLE
2128                  {
2129                      $$ = $1;
2130                  }
2131                  | TOK_FLAVOR
2132                  {
2133                      $$ = $1;
2134 krisbash 1.3     }
2135              
2136              dataType
2137                  : TOK_BOOLEAN
2138                  {
2139                      $$ = MI_BOOLEAN;
2140                  }
2141                  | TOK_SINT8
2142                  {
2143                      $$ = MI_SINT8;
2144                  }
2145                  | TOK_UINT8
2146                  {
2147                      $$ = MI_UINT8;
2148                  }
2149                  | TOK_SINT16
2150                  {
2151                      $$ = MI_SINT16;
2152                  }
2153                  | TOK_UINT16
2154                  {
2155 krisbash 1.3         $$ = MI_UINT16;
2156                  }
2157                  | TOK_SINT32
2158                  {
2159                      $$ = MI_SINT32;
2160                  }
2161                  | TOK_UINT32
2162                  {
2163                      $$ = MI_UINT32;
2164                  }
2165                  | TOK_SINT64
2166                  {
2167                      $$ = MI_SINT64;
2168                  }
2169                  | TOK_UINT64
2170                  {
2171                      $$ = MI_UINT64;
2172                  }
2173                  | TOK_REAL32
2174                  {
2175                      $$ = MI_REAL32;
2176 krisbash 1.3     }
2177                  | TOK_REAL64
2178                  {
2179                      $$ = MI_REAL64;
2180                  }
2181                  | TOK_CHAR16
2182                  {
2183                      $$ = MI_CHAR16;
2184                  }
2185                  | TOK_DATETIME
2186                  {
2187                      $$ = MI_DATETIME;
2188                  }
2189                  | TOK_STRING
2190                  {
2191                      $$ = MI_STRING;
2192 mike     1.1     }

ViewCVS 0.9.2