version 1.2, 2015/04/20 18:10:13
|
version 1.3, 2015/04/20 18:19:53
|
|
|
%token TOK_DATETIME | %token TOK_DATETIME |
%token TOK_CHAR16 | %token TOK_CHAR16 |
%token TOK_STRING | %token TOK_STRING |
|
%token TOK_OBJECT |
%token TOK_BOOLEAN_VALUE | %token TOK_BOOLEAN_VALUE |
%token TOK_REF | %token TOK_REF |
%token TOK_SCOPE | %token TOK_SCOPE |
|
|
%token TOK_DISABLEOVERRIDE | %token TOK_DISABLEOVERRIDE |
%token TOK_RESTRICTED | %token TOK_RESTRICTED |
%token TOK_TOSUBCLASS | %token TOK_TOSUBCLASS |
|
%token TOK_TOINSTANCE |
%token TOK_TRANSLATABLE | %token TOK_TRANSLATABLE |
%token TOK_INSTANCE | %token TOK_INSTANCE |
%token TOK_OF | %token TOK_OF |
|
|
| |
%type <string> stringValue | %type <string> stringValue |
%type <string> TOK_STRING_VALUE | %type <string> TOK_STRING_VALUE |
|
%type <string> classNameIdentifier |
%type <string> identifier | %type <string> identifier |
%type <string> objectRef |
|
%type <integer> TOK_INTEGER_VALUE | %type <integer> TOK_INTEGER_VALUE |
%type <real> TOK_REAL_VALUE | %type <real> TOK_REAL_VALUE |
%type <character> TOK_CHAR_VALUE | %type <character> TOK_CHAR_VALUE |
|
|
%type <parameter> parameter | %type <parameter> parameter |
%type <parameterList> parameterList | %type <parameterList> parameterList |
%type <property> referenceDeclaration | %type <property> referenceDeclaration |
|
%type <property> dynamicReferenceDeclaration |
|
%type <property> staticEmbeddedInstanceDeclaration |
|
%type <property> dynamicEmbeddedInstanceDeclaration |
%type <methodDecl> methodDeclaration | %type <methodDecl> methodDeclaration |
%type <featureList> classFeatureList | %type <featureList> classFeatureList |
%type <featureList> classBody | %type <featureList> classBody |
|
|
%type <initializer> initializer | %type <initializer> initializer |
%type <initializer> arrayInitializer | %type <initializer> arrayInitializer |
%type <initializer> arrayInitializerList | %type <initializer> arrayInitializerList |
|
%type <initializer> scalarInitializer |
|
%type <initializer> nonAggregateInitializer |
|
%type <initializer> nonAggregateArrayInitializer |
|
%type <initializer> nonAggregateArrayInitializerList |
%type <flags> scope | %type <flags> scope |
%type <flags> scopeList | %type <flags> scopeList |
%type <flags> scopeExpr | %type <flags> scopeExpr |
%type <flags> flavor | %type <flags> flavor |
%type <flags> flavorList | %type <flags> flavorList |
|
%type <flags> qualifierFlavorList |
%type <flags> flavorExpr | %type <flags> flavorExpr |
%type <qualifier> qualifier | %type <qualifier> qualifier |
%type <qualifierList> qualifierList | %type <qualifierList> qualifierList |
|
|
%type <instanceDeclaration> instanceDeclaration | %type <instanceDeclaration> instanceDeclaration |
%type <property> valueInitializer | %type <property> valueInitializer |
%type <featureList> valueInitializerList | %type <featureList> valueInitializerList |
|
%type <string> TOK_CLASS |
|
%type <string> TOK_INSTANCE |
|
%type <string> TOK_OF |
|
%type <string> TOK_ANY |
|
%type <string> TOK_ASSOCIATION |
|
%type <string> TOK_INDICATION |
|
%type <string> TOK_REFERENCE |
|
%type <string> TOK_PROPERTY |
|
%type <string> TOK_QUALIFIER |
|
%type <string> TOK_TOSUBCLASS |
|
%type <string> TOK_TOINSTANCE |
|
%type <string> TOK_TRANSLATABLE |
|
%type <string> TOK_FLAVOR |
|
%type <string> TOK_BOOLEAN |
|
%type <string> TOK_DATETIME |
|
%type <string> TOK_STRING |
|
%type <string> TOK_OBJECT |
|
%type <string> TOK_PRAGMA |
| |
%% | %% |
| |
|
|
if (state.pragmaCallback) | if (state.pragmaCallback) |
(*state.pragmaCallback)($2, $4, state.pragmaCallbackData); | (*state.pragmaCallback)($2, $4, state.pragmaCallbackData); |
} | } |
|
else if (state.extensionsEnabled == MI_TRUE && strcmp($2, "deleteclass") == 0) |
|
{ |
|
yywarnf(ID_UNKNOWN_PRAGMA, |
|
"warning: nonstandard pragma: %s(%s)", $2, $4); |
|
|
|
if (state.pragmaCallback) |
|
(*state.pragmaCallback)($2, $4, state.pragmaCallbackData); |
|
} |
|
else |
|
{ |
|
yywarnf(ID_UNKNOWN_PRAGMA, |
|
"warning: unknown pragma: %s(%s)", $2, $4); |
|
|
|
if (state.pragmaCallback) |
|
(*state.pragmaCallback)($2, $4, state.pragmaCallbackData); |
|
} |
|
} |
|
| TOK_PRAGMA TOK_IDENT '(' stringValue ',' identifier ')' |
|
{ |
|
if (state.extensionsEnabled == MI_TRUE && strcmp($2, "deleteclass") == 0) |
|
{ |
|
yywarnf(ID_UNKNOWN_PRAGMA, |
|
"warning: nonstandard pragma: %s(%s)", $2, $4); |
|
|
|
if (state.pragmaCallback) |
|
(*state.pragmaCallback)($2, $4, state.pragmaCallbackData); |
|
} |
else | else |
{ | { |
yywarnf(ID_UNKNOWN_PRAGMA, | yywarnf(ID_UNKNOWN_PRAGMA, |
"warning: unknown pragma: %s=%s", $2, $4); |
"warning: unknown pragma: %s(%s)", $2, $4); |
| |
if (state.pragmaCallback) | if (state.pragmaCallback) |
(*state.pragmaCallback)($2, $4, state.pragmaCallbackData); | (*state.pragmaCallback)($2, $4, state.pragmaCallbackData); |
|
|
} | } |
| |
classDeclaration | classDeclaration |
: TOK_CLASS identifier classBody |
: TOK_CLASS classNameIdentifier classBody |
{ | { |
/* Check whether class already exists */ | /* Check whether class already exists */ |
if (FindClassDecl($2)) | if (FindClassDecl($2)) |
{ | { |
|
if (state.extensionsEnabled == MI_FALSE) |
|
{ |
yyerrorf(ID_CLASS_ALREADY_DEFINED, | yyerrorf(ID_CLASS_ALREADY_DEFINED, |
"class already defined: \"%s\"", $2); | "class already defined: \"%s\"", $2); |
YYABORT; | YYABORT; |
} | } |
|
else |
|
yywarnf(ID_CLASS_ALREADY_DEFINED, |
|
"class already defined: \"%s\"", $2); |
|
} |
| |
$$ = CALLOC_T(MI_ClassDecl, 1); | $$ = CALLOC_T(MI_ClassDecl, 1); |
$$->flags = MI_FLAG_CLASS; | $$->flags = MI_FLAG_CLASS; |
|
|
$$->methods = $3.methodList.data; | $$->methods = $3.methodList.data; |
$$->numMethods = $3.methodList.size; | $$->numMethods = $3.methodList.size; |
} | } |
| TOK_CLASS identifier ':' identifier classBody |
| TOK_CLASS classNameIdentifier ':' classNameIdentifier classBody |
{ | { |
const MI_ClassDecl* scd; | const MI_ClassDecl* scd; |
| |
/* Check whether class already exists */ | /* Check whether class already exists */ |
if (FindClassDecl($2)) | if (FindClassDecl($2)) |
{ | { |
|
if (state.extensionsEnabled == MI_FALSE) |
|
{ |
yyerrorf(ID_CLASS_ALREADY_DEFINED, | yyerrorf(ID_CLASS_ALREADY_DEFINED, |
"class already defined: \"%s\"", $2); | "class already defined: \"%s\"", $2); |
YYABORT; | YYABORT; |
} | } |
|
else |
|
yywarnf(ID_CLASS_ALREADY_DEFINED, |
|
"class already defined: \"%s\"", $2); |
|
} |
| |
/* Check whether superclass exists */ | /* Check whether superclass exists */ |
scd = FindClassDecl($4); | scd = FindClassDecl($4); |
|
|
$$->methods = $5.methodList.data; | $$->methods = $5.methodList.data; |
$$->numMethods = $5.methodList.size; | $$->numMethods = $5.methodList.size; |
} | } |
| qualifierExpr TOK_CLASS identifier classBody |
| qualifierExpr TOK_CLASS classNameIdentifier classBody |
{ | { |
/* Check qualifier scope */ | /* Check qualifier scope */ |
if (CheckScope(MI_FLAG_CLASS, &$1) != 0) | if (CheckScope(MI_FLAG_CLASS, &$1) != 0) |
|
|
/* Check whether class already exists */ | /* Check whether class already exists */ |
if (FindClassDecl($3)) | if (FindClassDecl($3)) |
{ | { |
|
if (state.extensionsEnabled == MI_FALSE) |
|
{ |
yyerrorf(ID_CLASS_ALREADY_DEFINED, | yyerrorf(ID_CLASS_ALREADY_DEFINED, |
"class already defined: \"%s\"", $3); | "class already defined: \"%s\"", $3); |
YYABORT; | YYABORT; |
} | } |
|
else |
|
yywarnf(ID_CLASS_ALREADY_DEFINED, |
|
"class already defined: \"%s\"", $3); |
|
} |
| |
$$ = CALLOC_T(MI_ClassDecl, 1); | $$ = CALLOC_T(MI_ClassDecl, 1); |
$$->flags = MI_FLAG_CLASS; | $$->flags = MI_FLAG_CLASS; |
|
|
$$->qualifiers = $1.data; | $$->qualifiers = $1.data; |
$$->numQualifiers = $1.size; | $$->numQualifiers = $1.size; |
} | } |
| qualifierExpr TOK_CLASS identifier ':' identifier classBody |
| qualifierExpr TOK_CLASS classNameIdentifier ':' classNameIdentifier classBody |
{ | { |
const MI_ClassDecl* scd; | const MI_ClassDecl* scd; |
| |
|
|
/* Check whether class already exists */ | /* Check whether class already exists */ |
if (FindClassDecl($3)) | if (FindClassDecl($3)) |
{ | { |
|
if (state.extensionsEnabled == MI_FALSE) |
|
{ |
yyerrorf(ID_CLASS_ALREADY_DEFINED, | yyerrorf(ID_CLASS_ALREADY_DEFINED, |
"class already defined: \"%s\"", $3); | "class already defined: \"%s\"", $3); |
YYABORT; | YYABORT; |
} | } |
|
else |
|
yywarnf(ID_CLASS_ALREADY_DEFINED, |
|
"class already defined: \"%s\"", $3); |
|
} |
| |
/* Check whether superclass exists */ | /* Check whether superclass exists */ |
scd = FindClassDecl($5); | scd = FindClassDecl($5); |
|
|
$1->flags |= GetQualFlags($1->qualifiers, $1->numQualifiers); | $1->flags |= GetQualFlags($1->qualifiers, $1->numQualifiers); |
PtrArray_Append((PtrArray*)&$$.propertySet, $1); | PtrArray_Append((PtrArray*)&$$.propertySet, $1); |
} | } |
|
| dynamicReferenceDeclaration |
|
{ |
|
$$.propertySet.data = NULL; |
|
$$.propertySet.size = 0; |
|
$$.methodList.data = NULL; |
|
$$.methodList.size = 0; |
|
$1->flags = MI_FLAG_PROPERTY; |
|
$1->flags |= GetQualFlags($1->qualifiers, $1->numQualifiers); |
|
PtrArray_Append((PtrArray*)&$$.propertySet, $1); |
|
} |
|
| staticEmbeddedInstanceDeclaration |
|
{ |
|
$$.propertySet.data = NULL; |
|
$$.propertySet.size = 0; |
|
$$.methodList.data = NULL; |
|
$$.methodList.size = 0; |
|
$1->flags = MI_FLAG_PROPERTY; |
|
$1->flags |= GetQualFlags($1->qualifiers, $1->numQualifiers); |
|
PtrArray_Append((PtrArray*)&$$.propertySet, $1); |
|
} |
|
| dynamicEmbeddedInstanceDeclaration |
|
{ |
|
$$.propertySet.data = NULL; |
|
$$.propertySet.size = 0; |
|
$$.methodList.data = NULL; |
|
$$.methodList.size = 0; |
|
$1->flags = MI_FLAG_PROPERTY; |
|
$1->flags |= GetQualFlags($1->qualifiers, $1->numQualifiers); |
|
PtrArray_Append((PtrArray*)&$$.propertySet, $1); |
|
} |
| classFeatureList propertyDeclaration | | classFeatureList propertyDeclaration |
{ | { |
if (CheckPropertyValueConstraints($2) != 0) | if (CheckPropertyValueConstraints($2) != 0) |
|
|
$2->flags |= GetQualFlags($2->qualifiers, $2->numQualifiers); | $2->flags |= GetQualFlags($2->qualifiers, $2->numQualifiers); |
PtrArray_Append((PtrArray*)&$$.propertySet, $2); | PtrArray_Append((PtrArray*)&$$.propertySet, $2); |
} | } |
|
| classFeatureList dynamicReferenceDeclaration |
|
{ |
|
if (FindProperty(&$1.propertySet, $2->name)) |
|
{ |
|
yyerrorf(ID_CLASS_FEATURE_ALREADY_DEFINED, |
|
"class feature already defined: \"%s\"", $2->name); |
|
YYABORT; |
|
} |
|
$2->flags = MI_FLAG_PROPERTY; |
|
$2->flags |= GetQualFlags($2->qualifiers, $2->numQualifiers); |
|
PtrArray_Append((PtrArray*)&$$.propertySet, $2); |
|
} |
|
| classFeatureList staticEmbeddedInstanceDeclaration |
|
{ |
|
if (FindProperty(&$1.propertySet, $2->name)) |
|
{ |
|
yyerrorf(ID_CLASS_FEATURE_ALREADY_DEFINED, |
|
"class feature already defined: \"%s\"", $2->name); |
|
YYABORT; |
|
} |
|
|
|
$2->flags = MI_FLAG_PROPERTY; |
|
$2->flags |= GetQualFlags($2->qualifiers, $2->numQualifiers); |
|
PtrArray_Append((PtrArray*)&$$.propertySet, $2); |
|
} |
|
| classFeatureList dynamicEmbeddedInstanceDeclaration |
|
{ |
|
if (FindProperty(&$1.propertySet, $2->name)) |
|
{ |
|
yyerrorf(ID_CLASS_FEATURE_ALREADY_DEFINED, |
|
"class feature already defined: \"%s\"", $2->name); |
|
YYABORT; |
|
} |
|
|
|
$2->flags = MI_FLAG_PROPERTY; |
|
$2->flags |= GetQualFlags($2->qualifiers, $2->numQualifiers); |
|
PtrArray_Append((PtrArray*)&$$.propertySet, $2); |
|
} |
| |
qualifierExpr | qualifierExpr |
: '[' qualifierList ']' | : '[' qualifierList ']' |
|
|
q->value = value; | q->value = value; |
$$ = q; | $$ = q; |
} | } |
| identifier ':' flavor |
| identifier ':' qualifierFlavorList |
{ | { |
MI_Qualifier* q; | MI_Qualifier* q; |
const MI_QualifierDecl* qd; | const MI_QualifierDecl* qd; |
|
|
q->value = NewTrueValue(); | q->value = NewTrueValue(); |
$$ = q; | $$ = q; |
} | } |
| identifier qualifierParameter ':' flavor |
| identifier qualifierParameter ':' qualifierFlavorList |
{ | { |
MI_Qualifier* q; | MI_Qualifier* q; |
const MI_QualifierDecl* qd; | const MI_QualifierDecl* qd; |
|
|
$$.data[0] = $2; | $$.data[0] = $2; |
$$.size = 1; | $$.size = 1; |
} | } |
| arrayInitializer |
| nonAggregateArrayInitializer |
{ | { |
$$ = $1; | $$ = $1; |
} | } |
|
|
$$ |= $3; | $$ |= $3; |
} | } |
| |
|
qualifierFlavorList |
|
: flavor |
|
{ |
|
$$ = $1; |
|
} |
|
| qualifierFlavorList flavor |
|
{ |
|
$$ |= $2; |
|
} |
|
|
flavor | flavor |
: TOK_ENABLEOVERRIDE | : TOK_ENABLEOVERRIDE |
{ | { |
|
|
{ | { |
$$ = MI_FLAG_TOSUBCLASS; | $$ = MI_FLAG_TOSUBCLASS; |
} | } |
|
| TOK_TOINSTANCE |
|
{ |
|
$$ = MI_FLAG_TOINSTANCE; |
|
if (state.extensionsEnabled == MI_FALSE) |
|
{ |
|
yyerrorf(ID_UNSUPPORTED, "Unsupported flavor: ToInstance"); |
|
YYABORT; |
|
} |
|
} |
| TOK_TRANSLATABLE | | TOK_TRANSLATABLE |
{ | { |
$$ = MI_FLAG_TRANSLATABLE; | $$ = MI_FLAG_TRANSLATABLE; |
|
|
$$->value = value; | $$->value = value; |
} | } |
| |
referenceDeclaration |
staticEmbeddedInstanceDeclaration |
: objectRef identifier ';' |
: classNameIdentifier identifier ';' |
{ | { |
const MI_ClassDecl* cd; | const MI_ClassDecl* cd; |
| |
|
|
} | } |
| |
$$ = CALLOC_T(MI_PropertyDecl, 1); | $$ = CALLOC_T(MI_PropertyDecl, 1); |
$$->type = MI_REFERENCE; |
$$->type = MI_INSTANCE; |
$$->name = $2; | $$->name = $2; |
$$->className = cd->name; | $$->className = cd->name; |
} | } |
| qualifierExpr objectRef identifier ';' |
| qualifierExpr classNameIdentifier identifier ';' |
{ | { |
const MI_ClassDecl* cd; | const MI_ClassDecl* cd; |
| |
|
|
YYABORT; | YYABORT; |
| |
$$ = CALLOC_T(MI_PropertyDecl, 1); | $$ = CALLOC_T(MI_PropertyDecl, 1); |
$$->type = MI_REFERENCE; |
$$->type = MI_INSTANCE; |
$$->name = $3; | $$->name = $3; |
$$->className = cd->name; | $$->className = cd->name; |
$$->qualifiers = $1.data; | $$->qualifiers = $1.data; |
$$->numQualifiers = $1.size; | $$->numQualifiers = $1.size; |
} | } |
| objectRef identifier initializer';' |
| classNameIdentifier identifier subscript ';' |
{ | { |
const MI_ClassDecl* cd; | const MI_ClassDecl* cd; |
| |
|
|
} | } |
| |
$$ = CALLOC_T(MI_PropertyDecl, 1); | $$ = CALLOC_T(MI_PropertyDecl, 1); |
$$->type = MI_REFERENCE; |
$$->type = MI_INSTANCEA; |
$$->name = $2; | $$->name = $2; |
$$->className = cd->name; | $$->className = cd->name; |
yywarnf(ID_IGNORED_INITIALIZER, "warning: ignored initializer"); |
$$->subscript = (MI_Uint32)$3; |
/* [TODO: use initializer */ |
|
} | } |
| qualifierExpr objectRef identifier initializer ';' |
| qualifierExpr classNameIdentifier identifier subscript ';' |
{ | { |
const MI_ClassDecl* cd; | const MI_ClassDecl* cd; |
| |
|
|
YYABORT; | YYABORT; |
| |
$$ = CALLOC_T(MI_PropertyDecl, 1); | $$ = CALLOC_T(MI_PropertyDecl, 1); |
$$->type = MI_REFERENCE; |
$$->type = MI_INSTANCEA; |
$$->name = $3; | $$->name = $3; |
$$->className = cd->name; | $$->className = cd->name; |
|
$$->subscript = (MI_Uint32)$4; |
$$->qualifiers = $1.data; | $$->qualifiers = $1.data; |
$$->numQualifiers = $1.size; | $$->numQualifiers = $1.size; |
yywarnf(ID_IGNORED_INITIALIZER, "warning: ignored initializer"); |
|
/* [TODO: use initializer */ |
|
} | } |
|
| classNameIdentifier identifier '=' initializer ';' |
|
{ |
|
const MI_ClassDecl* cd; |
| |
methodDeclaration |
/* Verify that class exists */ |
: dataType identifier '(' parameterList ')' ';' |
cd = FindClassDecl($1); |
|
if (!cd) |
{ | { |
$$ = CALLOC_T(MI_MethodDecl, 1); |
yyerrorf(ID_UNDEFINED_CLASS, "undefined class: \"%s\"", $1); |
|
YYABORT; |
|
} |
|
|
|
$$ = CALLOC_T(MI_PropertyDecl, 1); |
|
$$->type = MI_INSTANCE; |
$$->name = $2; | $$->name = $2; |
$$->parameters = $4.data; |
$$->className = cd->name; |
$$->numParameters = $4.size; |
yywarnf(ID_IGNORED_INITIALIZER, "warning: ignored initializer"); |
$$->returnType = $1; |
/* TODO: use initializer */ |
} | } |
| qualifierExpr dataType identifier '(' parameterList ')' ';' |
| qualifierExpr classNameIdentifier identifier '=' initializer ';' |
|
{ |
|
const MI_ClassDecl* cd; |
|
|
|
/* Verify that class exists */ |
|
cd = FindClassDecl($2); |
|
if (!cd) |
{ | { |
|
yyerrorf(ID_UNDEFINED_CLASS, "undefined class: \"%s\"", $2); |
|
YYABORT; |
|
} |
|
|
/* Check qualifier scope */ | /* Check qualifier scope */ |
if (CheckScope(MI_FLAG_METHOD, &$1) != 0) |
if (CheckScope(MI_FLAG_REFERENCE, &$1) != 0) |
YYABORT; | YYABORT; |
| |
$$ = CALLOC_T(MI_MethodDecl, 1); |
$$ = CALLOC_T(MI_PropertyDecl, 1); |
|
$$->type = MI_INSTANCE; |
$$->name = $3; | $$->name = $3; |
$$->parameters = $5.data; |
$$->className = cd->name; |
$$->numParameters = $5.size; |
|
$$->qualifiers = $1.data; | $$->qualifiers = $1.data; |
$$->numQualifiers = $1.size; | $$->numQualifiers = $1.size; |
$$->returnType = $2; |
yywarnf(ID_IGNORED_INITIALIZER, "warning: ignored initializer"); |
|
/* TODO: use initializer */ |
} | } |
| dataType identifier '(' ')' ';' |
| classNameIdentifier identifier subscript '=' initializer ';' |
{ | { |
MOF_ParameterList parameterList = PTRARRAY_INITIALIZER; |
const MI_ClassDecl* cd; |
| |
$$ = CALLOC_T(MI_MethodDecl, 1); |
/* Verify that class exists */ |
|
cd = FindClassDecl($1); |
|
if (!cd) |
|
{ |
|
yyerrorf(ID_UNDEFINED_CLASS, "undefined class: \"%s\"", $1); |
|
YYABORT; |
|
} |
|
|
|
$$ = CALLOC_T(MI_PropertyDecl, 1); |
|
$$->type = MI_INSTANCEA; |
$$->name = $2; | $$->name = $2; |
$$->parameters = parameterList.data; |
$$->className = cd->name; |
$$->numParameters = parameterList.size; |
$$->subscript = (MI_Uint32)$3; |
$$->returnType = $1; |
yywarnf(ID_IGNORED_INITIALIZER, "warning: ignored initializer"); |
|
/* TODO: use initializer */ |
} | } |
| qualifierExpr dataType identifier '(' ')' ';' |
| qualifierExpr classNameIdentifier identifier subscript '=' initializer ';' |
{ | { |
MOF_ParameterList parameterList = PTRARRAY_INITIALIZER; |
const MI_ClassDecl* cd; |
|
|
|
/* Verify that class exists */ |
|
cd = FindClassDecl($2); |
|
if (!cd) |
|
{ |
|
yyerrorf(ID_UNDEFINED_CLASS, "undefined class: \"%s\"", $2); |
|
YYABORT; |
|
} |
| |
/* Check qualifier scope */ | /* Check qualifier scope */ |
if (CheckScope(MI_FLAG_METHOD, &$1) != 0) |
if (CheckScope(MI_FLAG_REFERENCE, &$1) != 0) |
YYABORT; | YYABORT; |
| |
$$ = CALLOC_T(MI_MethodDecl, 1); |
$$ = CALLOC_T(MI_PropertyDecl, 1); |
|
$$->type = MI_INSTANCEA; |
$$->name = $3; | $$->name = $3; |
$$->parameters = parameterList.data; |
$$->className = cd->name; |
$$->numParameters = parameterList.size; |
$$->subscript = (MI_Uint32)$4; |
$$->qualifiers = $1.data; | $$->qualifiers = $1.data; |
$$->numQualifiers = $1.size; | $$->numQualifiers = $1.size; |
$$->returnType = $2; |
yywarnf(ID_IGNORED_INITIALIZER, "warning: ignored initializer"); |
|
/* TODO: use initializer */ |
} | } |
| |
dataType |
dynamicEmbeddedInstanceDeclaration |
: TOK_BOOLEAN |
: TOK_OBJECT identifier ';' |
{ |
|
$$ = MI_BOOLEAN; |
|
} |
|
| TOK_SINT8 |
|
{ | { |
$$ = MI_SINT8; |
if (state.extensionsEnabled == MI_FALSE) |
|
yywarnf(ID_UNSUPPORTED, "warning: OBJECT keyword is not supported"); |
|
$$ = CALLOC_T(MI_PropertyDecl, 1); |
|
$$->type = MI_INSTANCE; |
|
$$->name = $2; |
|
$$->className = "?"; |
} | } |
| TOK_UINT8 |
| qualifierExpr TOK_OBJECT identifier ';' |
{ | { |
$$ = MI_UINT8; |
if (state.extensionsEnabled == MI_FALSE) |
|
yywarnf(ID_UNSUPPORTED, "warning: OBJECT keyword is not supported"); |
|
$$ = CALLOC_T(MI_PropertyDecl, 1); |
|
$$->type = MI_INSTANCE; |
|
$$->name = $3; |
|
$$->className = "?"; |
|
$$->qualifiers = $1.data; |
|
$$->numQualifiers = $1.size; |
} | } |
| TOK_SINT16 |
| TOK_OBJECT identifier subscript ';' |
{ | { |
$$ = MI_SINT16; |
if (state.extensionsEnabled == MI_FALSE) |
|
yywarnf(ID_UNSUPPORTED, "warning: OBJECT keyword is not supported"); |
|
$$ = CALLOC_T(MI_PropertyDecl, 1); |
|
$$->type = MI_INSTANCEA; |
|
$$->name = $2; |
|
$$->className = "?"; |
|
$$->subscript = 0; |
} | } |
| TOK_UINT16 |
| qualifierExpr TOK_OBJECT identifier subscript ';' |
{ | { |
$$ = MI_UINT16; |
if (state.extensionsEnabled == MI_FALSE) |
|
yywarnf(ID_UNSUPPORTED, "warning: OBJECT keyword is not supported"); |
|
$$ = CALLOC_T(MI_PropertyDecl, 1); |
|
$$->type = MI_INSTANCEA; |
|
$$->name = $3; |
|
$$->className = "?"; |
|
$$->subscript = 0; |
|
$$->qualifiers = $1.data; |
|
$$->numQualifiers = $1.size; |
} | } |
| TOK_SINT32 |
| TOK_OBJECT identifier '=' initializer ';' |
{ | { |
$$ = MI_SINT32; |
if (state.extensionsEnabled == MI_FALSE) |
|
yywarnf(ID_UNSUPPORTED, "warning: OBJECT keyword is not supported"); |
|
$$ = CALLOC_T(MI_PropertyDecl, 1); |
|
$$->type = MI_INSTANCE; |
|
$$->name = $2; |
|
$$->className = "?"; |
|
yywarnf(ID_IGNORED_INITIALIZER, "warning: ignored initializer"); |
|
/* TODO: use initializer */ |
} | } |
| TOK_UINT32 |
| qualifierExpr TOK_OBJECT identifier '=' initializer ';' |
{ | { |
$$ = MI_UINT32; |
if (state.extensionsEnabled == MI_FALSE) |
|
yywarnf(ID_UNSUPPORTED, "warning: OBJECT keyword is not supported"); |
|
$$ = CALLOC_T(MI_PropertyDecl, 1); |
|
$$->type = MI_INSTANCE; |
|
$$->name = $3; |
|
$$->className = "?"; |
|
$$->qualifiers = $1.data; |
|
$$->numQualifiers = $1.size; |
|
yywarnf(ID_IGNORED_INITIALIZER, "warning: ignored initializer"); |
|
/* TODO: use initializer */ |
} | } |
| TOK_SINT64 |
| TOK_OBJECT identifier subscript '=' initializer ';' |
{ | { |
$$ = MI_SINT64; |
if (state.extensionsEnabled == MI_FALSE) |
|
yywarnf(ID_UNSUPPORTED, "warning: OBJECT keyword is not supported"); |
|
$$ = CALLOC_T(MI_PropertyDecl, 1); |
|
$$->type = MI_INSTANCEA; |
|
$$->name = $2; |
|
$$->className = "?"; |
|
$$->subscript = (MI_Uint32)$3; |
|
yywarnf(ID_IGNORED_INITIALIZER, "warning: ignored initializer"); |
|
/* TODO: use initializer */ |
} | } |
| TOK_UINT64 |
| qualifierExpr TOK_OBJECT identifier subscript '=' initializer ';' |
{ | { |
$$ = MI_UINT64; |
if (state.extensionsEnabled == MI_FALSE) |
|
yywarnf(ID_UNSUPPORTED, "warning: OBJECT keyword is not supported"); |
|
$$ = CALLOC_T(MI_PropertyDecl, 1); |
|
$$->type = MI_INSTANCEA; |
|
$$->name = $3; |
|
$$->className = "?"; |
|
$$->subscript = (MI_Uint32)$4; |
|
$$->qualifiers = $1.data; |
|
$$->numQualifiers = $1.size; |
|
yywarnf(ID_IGNORED_INITIALIZER, "warning: ignored initializer"); |
|
/* TODO: use initializer */ |
} | } |
| TOK_REAL32 |
|
|
referenceDeclaration |
|
: classNameIdentifier TOK_REF identifier ';' |
{ | { |
$$ = MI_REAL32; |
const MI_ClassDecl* cd; |
|
|
|
/* Verify that class exists */ |
|
cd = FindClassDecl($1); |
|
if (!cd) |
|
{ |
|
yyerrorf(ID_UNDEFINED_CLASS, "undefined class: \"%s\"", $1); |
|
YYABORT; |
} | } |
| TOK_REAL64 |
|
|
$$ = CALLOC_T(MI_PropertyDecl, 1); |
|
$$->type = MI_REFERENCE; |
|
$$->name = $3; |
|
$$->className = cd->name; |
|
} |
|
| qualifierExpr classNameIdentifier TOK_REF identifier ';' |
{ | { |
$$ = MI_REAL64; |
const MI_ClassDecl* cd; |
|
|
|
/* Verify that class exists */ |
|
cd = FindClassDecl($2); |
|
if (!cd) |
|
{ |
|
yyerrorf(ID_UNDEFINED_CLASS, "undefined class: \"%s\"", $2); |
|
YYABORT; |
} | } |
| TOK_CHAR16 |
|
|
/* Check qualifier scope */ |
|
if (CheckScope(MI_FLAG_REFERENCE, &$1) != 0) |
|
YYABORT; |
|
|
|
$$ = CALLOC_T(MI_PropertyDecl, 1); |
|
$$->type = MI_REFERENCE; |
|
$$->name = $4; |
|
$$->className = cd->name; |
|
$$->qualifiers = $1.data; |
|
$$->numQualifiers = $1.size; |
|
} |
|
| classNameIdentifier TOK_REF identifier '=' initializer ';' |
{ | { |
$$ = MI_CHAR16; |
const MI_ClassDecl* cd; |
|
|
|
/* Verify that class exists */ |
|
cd = FindClassDecl($1); |
|
if (!cd) |
|
{ |
|
yyerrorf(ID_UNDEFINED_CLASS, "undefined class: \"%s\"", $1); |
|
YYABORT; |
} | } |
| TOK_DATETIME |
|
|
$$ = CALLOC_T(MI_PropertyDecl, 1); |
|
$$->type = MI_REFERENCE; |
|
$$->name = $3; |
|
$$->className = cd->name; |
|
yywarnf(ID_IGNORED_INITIALIZER, "warning: ignored initializer"); |
|
/* [TODO: use initializer */ |
|
} |
|
| qualifierExpr classNameIdentifier TOK_REF identifier '=' initializer ';' |
{ | { |
$$ = MI_DATETIME; |
const MI_ClassDecl* cd; |
|
|
|
/* Verify that class exists */ |
|
cd = FindClassDecl($2); |
|
if (!cd) |
|
{ |
|
yyerrorf(ID_UNDEFINED_CLASS, "undefined class: \"%s\"", $2); |
|
YYABORT; |
} | } |
| TOK_STRING |
|
|
/* Check qualifier scope */ |
|
if (CheckScope(MI_FLAG_REFERENCE, &$1) != 0) |
|
YYABORT; |
|
|
|
$$ = CALLOC_T(MI_PropertyDecl, 1); |
|
$$->type = MI_REFERENCE; |
|
$$->name = $4; |
|
$$->className = cd->name; |
|
$$->qualifiers = $1.data; |
|
$$->numQualifiers = $1.size; |
|
yywarnf(ID_IGNORED_INITIALIZER, "warning: ignored initializer"); |
|
/* [TODO: use initializer */ |
|
} |
|
| classNameIdentifier TOK_REF identifier subscript ';' |
{ | { |
$$ = MI_STRING; |
const MI_ClassDecl* cd; |
|
|
|
/* Verify that class exists */ |
|
cd = FindClassDecl($1); |
|
if (!cd) |
|
{ |
|
yyerrorf(ID_UNDEFINED_CLASS, "undefined class: \"%s\"", $1); |
|
YYABORT; |
} | } |
| |
objectRef |
$$ = CALLOC_T(MI_PropertyDecl, 1); |
: identifier TOK_REF |
$$->type = MI_REFERENCEA; |
|
$$->name = $3; |
|
$$->className = cd->name; |
|
$$->subscript = (MI_Uint32)$4; |
|
} |
|
| qualifierExpr classNameIdentifier TOK_REF identifier subscript ';' |
{ | { |
$$ = $1; |
const MI_ClassDecl* cd; |
|
|
|
/* Verify that class exists */ |
|
cd = FindClassDecl($2); |
|
if (!cd) |
|
{ |
|
yyerrorf(ID_UNDEFINED_CLASS, "undefined class: \"%s\"", $2); |
|
YYABORT; |
|
} |
|
|
|
/* Check qualifier scope */ |
|
if (CheckScope(MI_FLAG_REFERENCE, &$1) != 0) |
|
YYABORT; |
|
|
|
$$ = CALLOC_T(MI_PropertyDecl, 1); |
|
$$->type = MI_REFERENCEA; |
|
$$->name = $4; |
|
$$->className = cd->name; |
|
$$->subscript = (MI_Uint32)$5; |
|
$$->qualifiers = $1.data; |
|
$$->numQualifiers = $1.size; |
|
} |
|
| classNameIdentifier TOK_REF identifier subscript '=' initializer ';' |
|
{ |
|
const MI_ClassDecl* cd; |
|
|
|
/* Verify that class exists */ |
|
cd = FindClassDecl($1); |
|
if (!cd) |
|
{ |
|
yyerrorf(ID_UNDEFINED_CLASS, "undefined class: \"%s\"", $1); |
|
YYABORT; |
|
} |
|
|
|
$$ = CALLOC_T(MI_PropertyDecl, 1); |
|
$$->type = MI_REFERENCEA; |
|
$$->name = $3; |
|
$$->className = cd->name; |
|
$$->subscript = (MI_Uint32)$4; |
|
yywarnf(ID_IGNORED_INITIALIZER, "warning: ignored initializer"); |
|
/* TODO: use initializer */ |
|
} |
|
| qualifierExpr classNameIdentifier TOK_REF identifier subscript '=' initializer ';' |
|
{ |
|
const MI_ClassDecl* cd; |
|
|
|
/* Verify that class exists */ |
|
cd = FindClassDecl($2); |
|
if (!cd) |
|
{ |
|
yyerrorf(ID_UNDEFINED_CLASS, "undefined class: \"%s\"", $2); |
|
YYABORT; |
|
} |
|
|
|
/* Check qualifier scope */ |
|
if (CheckScope(MI_FLAG_REFERENCE, &$1) != 0) |
|
YYABORT; |
|
|
|
$$ = CALLOC_T(MI_PropertyDecl, 1); |
|
$$->type = MI_REFERENCEA; |
|
$$->name = $4; |
|
$$->className = cd->name; |
|
$$->subscript = (MI_Uint32)$5; |
|
$$->qualifiers = $1.data; |
|
$$->numQualifiers = $1.size; |
|
yywarnf(ID_IGNORED_INITIALIZER, "warning: ignored initializer"); |
|
/* TODO: use initializer */ |
|
} |
|
|
|
dynamicReferenceDeclaration |
|
: TOK_OBJECT TOK_REF identifier ';' |
|
{ |
|
$$ = CALLOC_T(MI_PropertyDecl, 1); |
|
$$->type = MI_REFERENCE; |
|
$$->name = $3; |
|
$$->className = "?"; |
|
} |
|
| qualifierExpr TOK_OBJECT TOK_REF identifier ';' |
|
{ |
|
/* Check qualifier scope */ |
|
if (CheckScope(MI_FLAG_REFERENCE, &$1) != 0) |
|
YYABORT; |
|
|
|
$$ = CALLOC_T(MI_PropertyDecl, 1); |
|
$$->type = MI_REFERENCE; |
|
$$->name = $4; |
|
$$->className = "?"; |
|
$$->qualifiers = $1.data; |
|
$$->numQualifiers = $1.size; |
|
} |
|
| TOK_OBJECT TOK_REF identifier subscript ';' |
|
{ |
|
$$ = CALLOC_T(MI_PropertyDecl, 1); |
|
$$->type = MI_REFERENCEA; |
|
$$->name = $3; |
|
$$->className = "?"; |
|
$$->subscript = (MI_Uint32)$4; |
|
} |
|
| qualifierExpr TOK_OBJECT TOK_REF identifier subscript ';' |
|
{ |
|
/* Check qualifier scope */ |
|
if (CheckScope(MI_FLAG_REFERENCE, &$1) != 0) |
|
YYABORT; |
|
|
|
$$ = CALLOC_T(MI_PropertyDecl, 1); |
|
$$->type = MI_REFERENCEA; |
|
$$->name = $4; |
|
$$->className = "?"; |
|
$$->subscript = (MI_Uint32)$5; |
|
$$->qualifiers = $1.data; |
|
$$->numQualifiers = $1.size; |
|
} |
|
| TOK_OBJECT TOK_REF identifier '=' initializer ';' |
|
{ |
|
$$ = CALLOC_T(MI_PropertyDecl, 1); |
|
$$->type = MI_REFERENCE; |
|
$$->name = $3; |
|
$$->className = "?"; |
|
yywarnf(ID_IGNORED_INITIALIZER, "warning: ignored initializer"); |
|
/* TODO: use initializer */ |
|
} |
|
| TOK_OBJECT TOK_REF identifier subscript '=' initializer ';' |
|
{ |
|
$$ = CALLOC_T(MI_PropertyDecl, 1); |
|
$$->type = MI_REFERENCEA; |
|
$$->name = $3; |
|
$$->className = "?"; |
|
$$->subscript = (MI_Uint32)$4; |
|
yywarnf(ID_IGNORED_INITIALIZER, "warning: ignored initializer"); |
|
/* TODO: use initializer */ |
|
} |
|
| qualifierExpr TOK_OBJECT TOK_REF identifier '=' initializer ';' |
|
{ |
|
/* Check qualifier scope */ |
|
if (CheckScope(MI_FLAG_REFERENCE, &$1) != 0) |
|
YYABORT; |
|
|
|
$$ = CALLOC_T(MI_PropertyDecl, 1); |
|
$$->type = MI_REFERENCE; |
|
$$->name = $4; |
|
$$->className = "?"; |
|
$$->qualifiers = $1.data; |
|
$$->numQualifiers = $1.size; |
|
yywarnf(ID_IGNORED_INITIALIZER, "warning: ignored initializer"); |
|
/* TODO: use initializer */ |
|
} |
|
| qualifierExpr TOK_OBJECT TOK_REF identifier subscript '=' initializer ';' |
|
{ |
|
/* Check qualifier scope */ |
|
if (CheckScope(MI_FLAG_REFERENCE, &$1) != 0) |
|
YYABORT; |
|
|
|
$$ = CALLOC_T(MI_PropertyDecl, 1); |
|
$$->type = MI_REFERENCEA; |
|
$$->name = $4; |
|
$$->className = "?"; |
|
$$->subscript = (MI_Uint32)$5; |
|
$$->qualifiers = $1.data; |
|
$$->numQualifiers = $1.size; |
|
yywarnf(ID_IGNORED_INITIALIZER, "warning: ignored initializer"); |
|
/* TODO: use initializer */ |
|
} |
|
|
|
methodDeclaration |
|
: dataType identifier '(' parameterList ')' ';' |
|
{ |
|
$$ = CALLOC_T(MI_MethodDecl, 1); |
|
$$->name = $2; |
|
$$->parameters = $4.data; |
|
$$->numParameters = $4.size; |
|
$$->returnType = $1; |
|
} |
|
| qualifierExpr dataType identifier '(' parameterList ')' ';' |
|
{ |
|
/* Check qualifier scope */ |
|
if (CheckScope(MI_FLAG_METHOD, &$1) != 0) |
|
YYABORT; |
|
|
|
$$ = CALLOC_T(MI_MethodDecl, 1); |
|
$$->name = $3; |
|
$$->parameters = $5.data; |
|
$$->numParameters = $5.size; |
|
$$->qualifiers = $1.data; |
|
$$->numQualifiers = $1.size; |
|
$$->returnType = $2; |
|
} |
|
| dataType identifier '(' ')' ';' |
|
{ |
|
MOF_ParameterList parameterList = PTRARRAY_INITIALIZER; |
|
|
|
$$ = CALLOC_T(MI_MethodDecl, 1); |
|
$$->name = $2; |
|
$$->parameters = parameterList.data; |
|
$$->numParameters = parameterList.size; |
|
$$->returnType = $1; |
|
} |
|
| qualifierExpr dataType identifier '(' ')' ';' |
|
{ |
|
MOF_ParameterList parameterList = PTRARRAY_INITIALIZER; |
|
|
|
/* Check qualifier scope */ |
|
if (CheckScope(MI_FLAG_METHOD, &$1) != 0) |
|
YYABORT; |
|
|
|
$$ = CALLOC_T(MI_MethodDecl, 1); |
|
$$->name = $3; |
|
$$->parameters = parameterList.data; |
|
$$->numParameters = parameterList.size; |
|
$$->qualifiers = $1.data; |
|
$$->numQualifiers = $1.size; |
|
$$->returnType = $2; |
} | } |
| |
parameterList | parameterList |
|
|
$$->name = $2; | $$->name = $2; |
$$->type = $1; | $$->type = $1; |
} | } |
| objectRef identifier |
| classNameIdentifier TOK_REF identifier |
{ | { |
const MI_ClassDecl* cd; | const MI_ClassDecl* cd; |
| |
|
|
} | } |
| |
$$ = CALLOC_T(MI_ParameterDecl, 1); | $$ = CALLOC_T(MI_ParameterDecl, 1); |
$$->name = $2; |
$$->name = $3; |
$$->type = MI_REFERENCE; | $$->type = MI_REFERENCE; |
$$->className = cd->name; | $$->className = cd->name; |
} | } |
|
|
$$->qualifiers = $1.data; | $$->qualifiers = $1.data; |
$$->numQualifiers = $1.size; | $$->numQualifiers = $1.size; |
} | } |
| qualifierExpr objectRef identifier |
| qualifierExpr classNameIdentifier TOK_REF identifier |
{ | { |
const MI_ClassDecl* cd; | const MI_ClassDecl* cd; |
| |
|
|
YYABORT; | YYABORT; |
| |
$$ = CALLOC_T(MI_ParameterDecl, 1); | $$ = CALLOC_T(MI_ParameterDecl, 1); |
$$->name = $3; |
$$->name = $4; |
$$->type = MI_REFERENCE; | $$->type = MI_REFERENCE; |
$$->className = cd->name; | $$->className = cd->name; |
$$->qualifiers = $1.data; | $$->qualifiers = $1.data; |
|
|
$$->type = ARRAYOF($1); | $$->type = ARRAYOF($1); |
$$->subscript = (MI_Uint32)$3; | $$->subscript = (MI_Uint32)$3; |
} | } |
| objectRef identifier subscript |
| classNameIdentifier TOK_REF identifier subscript |
{ | { |
const MI_ClassDecl* cd; | const MI_ClassDecl* cd; |
| |
|
|
} | } |
| |
$$ = CALLOC_T(MI_ParameterDecl, 1); | $$ = CALLOC_T(MI_ParameterDecl, 1); |
$$->name = $2; |
$$->name = $3; |
$$->type = ARRAYOF(MI_REFERENCE); | $$->type = ARRAYOF(MI_REFERENCE); |
$$->className = cd->name; | $$->className = cd->name; |
$$->subscript = (MI_Uint32)$3; |
$$->subscript = (MI_Uint32)$4; |
} | } |
| qualifierExpr dataType identifier subscript | | qualifierExpr dataType identifier subscript |
{ | { |
|
|
$$->qualifiers = $1.data; | $$->qualifiers = $1.data; |
$$->numQualifiers = $1.size; | $$->numQualifiers = $1.size; |
} | } |
| qualifierExpr objectRef identifier subscript |
| qualifierExpr classNameIdentifier TOK_REF identifier subscript |
{ | { |
const MI_ClassDecl* cd; | const MI_ClassDecl* cd; |
| |
|
|
YYABORT; | YYABORT; |
| |
$$ = CALLOC_T(MI_ParameterDecl, 1); | $$ = CALLOC_T(MI_ParameterDecl, 1); |
$$->name = $3; |
$$->name = $4; |
$$->type = ARRAYOF(MI_REFERENCE); | $$->type = ARRAYOF(MI_REFERENCE); |
$$->className = cd->name; | $$->className = cd->name; |
$$->subscript = (MI_Uint32)$4; |
$$->subscript = (MI_Uint32)$5; |
$$->qualifiers = $1.data; | $$->qualifiers = $1.data; |
$$->numQualifiers = $1.size; | $$->numQualifiers = $1.size; |
} | } |
|
|
} | } |
| |
initializer | initializer |
: constantValue |
: scalarInitializer |
|
{ |
|
$$ = $1; |
|
} |
|
| arrayInitializer |
|
{ |
|
$$ = $1; |
|
} |
|
|
|
arrayInitializer |
|
: '{' arrayInitializerList '}' |
|
{ |
|
$$ = $2; |
|
} |
|
| '{' '}' |
|
{ |
|
$$.data = NULL; |
|
$$.size = 0; |
|
$$.isArray = 1; |
|
} |
|
|
|
arrayInitializerList |
|
: scalarInitializer |
{ | { |
memset(&$$, 0, sizeof($$)); | memset(&$$, 0, sizeof($$)); |
$$.data = CALLOC_T(MOF_ConstantValue, 1); | $$.data = CALLOC_T(MOF_ConstantValue, 1); |
$$.data[0] = $1; |
$$.data[0] = $1.data[0]; |
$$.size = 1; | $$.size = 1; |
|
$$.isArray = 1; |
} | } |
| arrayInitializer |
| arrayInitializerList ',' scalarInitializer |
{ | { |
|
$1.data = REALLOC_T(MOF_ConstantValue, $1.data, $1.size + 1); |
|
$1.data[$1.size] = $3.data[0]; |
|
$1.size++; |
$$ = $1; | $$ = $1; |
} | } |
|
|
|
scalarInitializer |
|
: constantValue |
|
{ |
|
memset(&$$, 0, sizeof($$)); |
|
$$.data = CALLOC_T(MOF_ConstantValue, 1); |
|
$$.data[0] = $1; |
|
$$.size = 1; |
|
} |
| TOK_ALIAS_IDENTIFIER | | TOK_ALIAS_IDENTIFIER |
{ | { |
memset(&$$, 0, sizeof($$)); | memset(&$$, 0, sizeof($$)); |
$$.data = CALLOC_T(MOF_ConstantValue, 1); | $$.data = CALLOC_T(MOF_ConstantValue, 1); |
$$.data[0].type = TOK_STRING_VALUE; | $$.data[0].type = TOK_STRING_VALUE; |
$$.data[0].value.string = $1; | $$.data[0].value.string = $1; |
$$.size = 0; |
$$.size = 1; |
|
/* TODO: look up alias, get and store instance decl. for alias */ |
|
} |
|
| TOK_INSTANCE TOK_OF classNameIdentifier '{' valueInitializerList '}' |
|
{ |
|
memset(&$$, 0, sizeof($$)); |
|
$$.data = CALLOC_T(MOF_ConstantValue, 1); |
|
$$.data[0].type = TOK_STRING_VALUE; |
|
$$.data[0].value.string = $3; |
|
$$.size = 1; |
|
/* TODO: look up class $3, validate property names/types, store dynamic instance properties in this instance */ |
} | } |
| |
arrayInitializer |
nonAggregateInitializer |
: '{' arrayInitializerList '}' |
: constantValue |
|
{ |
|
memset(&$$, 0, sizeof($$)); |
|
$$.data = CALLOC_T(MOF_ConstantValue, 1); |
|
$$.data[0] = $1; |
|
$$.size = 1; |
|
} |
|
| nonAggregateArrayInitializer |
|
{ |
|
$$ = $1; |
|
} |
|
|
|
nonAggregateArrayInitializer |
|
: '{' nonAggregateArrayInitializerList '}' |
{ | { |
$$ = $2; | $$ = $2; |
} | } |
|
| '{' '}' |
|
{ |
|
$$.data = NULL; |
|
$$.size = 0; |
|
$$.isArray = MI_TRUE; |
|
} |
| |
arrayInitializerList |
nonAggregateArrayInitializerList |
: constantValue | : constantValue |
{ | { |
memset(&$$, 0, sizeof($$)); | memset(&$$, 0, sizeof($$)); |
$$.data = CALLOC_T(MOF_ConstantValue, 1); | $$.data = CALLOC_T(MOF_ConstantValue, 1); |
$$.data[0] = $1; | $$.data[0] = $1; |
$$.size = 1; | $$.size = 1; |
$$.isArray = 1; |
$$.isArray = MI_TRUE; |
} | } |
| arrayInitializerList ',' constantValue |
| nonAggregateArrayInitializerList ',' constantValue |
{ | { |
$1.data = REALLOC_T(MOF_ConstantValue, $1.data, $1.size + 1); | $1.data = REALLOC_T(MOF_ConstantValue, $1.data, $1.size + 1); |
$1.data[$1.size] = $3; | $1.data[$1.size] = $3; |
$1.size++; | $1.size++; |
|
$1.isArray = MI_TRUE; |
$$ = $1; | $$ = $1; |
} | } |
| |
|
|
$$ = CALLOC_T(MI_QualifierDecl, 1); | $$ = CALLOC_T(MI_QualifierDecl, 1); |
$$->type = $2; | $$->type = $2; |
} | } |
| ':' dataType '=' initializer |
| ':' dataType '=' nonAggregateInitializer |
{ | { |
void* value; | void* value; |
| |
|
|
$$->type = ARRAYOF($2); | $$->type = ARRAYOF($2); |
$$->subscript = (MI_Uint32)$3; | $$->subscript = (MI_Uint32)$3; |
} | } |
| ':' dataType subscript '=' initializer |
| ':' dataType subscript '=' nonAggregateInitializer |
{ | { |
void* value = NULL; | void* value = NULL; |
| |
|
|
} | } |
| |
instanceDeclaration | instanceDeclaration |
: TOK_INSTANCE TOK_OF identifier instanceBody |
: TOK_INSTANCE TOK_OF classNameIdentifier instanceBody |
{ | { |
$$ = CALLOC_T(MI_InstanceDecl, 1); | $$ = CALLOC_T(MI_InstanceDecl, 1); |
$$->flags = 0; | $$->flags = 0; |
|
|
$$->properties = $4.propertySet.data; | $$->properties = $4.propertySet.data; |
$$->numProperties = $4.propertySet.size; | $$->numProperties = $4.propertySet.size; |
} | } |
| qualifierExpr TOK_INDICATION TOK_OF identifier instanceBody |
| qualifierExpr TOK_INSTANCE TOK_OF classNameIdentifier instanceBody |
{ | { |
$$ = CALLOC_T(MI_InstanceDecl, 1); | $$ = CALLOC_T(MI_InstanceDecl, 1); |
$$->flags = 0; | $$->flags = 0; |
|
|
$$->properties = $5.propertySet.data; | $$->properties = $5.propertySet.data; |
$$->numProperties = $5.propertySet.size; | $$->numProperties = $5.propertySet.size; |
} | } |
| qualifierExpr TOK_INDICATION TOK_OF identifier alias instanceBody |
| qualifierExpr TOK_INSTANCE TOK_OF classNameIdentifier alias instanceBody |
{ | { |
/* [TODO]: handle alias */ | /* [TODO]: handle alias */ |
$$ = CALLOC_T(MI_InstanceDecl, 1); | $$ = CALLOC_T(MI_InstanceDecl, 1); |
|
|
{ | { |
$$ = $2; | $$ = $2; |
} | } |
|
| '{' '}' ';' |
|
{ |
|
$$.propertySet.data = NULL; |
|
$$.propertySet.size = 0; |
|
$$.methodList.data = NULL; |
|
$$.methodList.size = 0; |
|
} |
| |
alias | alias |
: TOK_AS TOK_ALIAS_IDENTIFIER | : TOK_AS TOK_ALIAS_IDENTIFIER |
|
|
} | } |
| |
valueInitializer | valueInitializer |
: identifier '=' initializer ';' |
: identifier ';' |
|
{ |
|
$$ = CALLOC_T(MI_PropertyDecl, 1); |
|
$$->name = $1; |
|
$$->type = TOK_NULL; |
|
} |
|
| qualifierExpr identifier ';' |
|
{ |
|
$$ = CALLOC_T(MI_PropertyDecl, 1); |
|
$$->name = $2; |
|
$$->type = TOK_NULL; |
|
$$->qualifiers = $1.data; |
|
$$->numQualifiers = $1.size; |
|
} |
|
| identifier '=' initializer ';' |
{ | { |
void* value; | void* value; |
MI_Type type = InitializerToType(&$3); | MI_Type type = InitializerToType(&$3); |
|
|
if (InitializerToValue(&$3, type, &value) != 0) | if (InitializerToValue(&$3, type, &value) != 0) |
{ | { |
yyerrorf(ID_INVALID_INITIALIZER, "invalid initializer"); | yyerrorf(ID_INVALID_INITIALIZER, "invalid initializer"); |
|
|
} | } |
| |
identifier | identifier |
|
: classNameIdentifier |
|
{ |
|
$$ = $1; |
|
} |
|
| TOK_OBJECT |
|
{ |
|
$$ = "Object"; |
|
} |
|
| TOK_BOOLEAN |
|
{ |
|
$$ = "Boolean"; |
|
} |
|
| TOK_DATETIME |
|
{ |
|
$$ = "Datetime"; |
|
} |
|
| TOK_STRING |
|
{ |
|
$$ = "String"; |
|
} |
|
/* {S,U}INT{8,16,32,64} can also be added here */ |
|
|
|
/* Class names can appear at the beginning of property declarations (for embedded class |
|
types or before REF), so class names cannot collide with built-in type names, so |
|
they are more limited than identifer, above. */ |
|
classNameIdentifier |
: TOK_IDENT | : TOK_IDENT |
{ | { |
$$ = $1; | $$ = $1; |
} | } |
|
| TOK_PRAGMA |
|
{ |
|
$$ = $1; |
|
} |
|
| TOK_CLASS |
|
{ |
|
$$ = $1; |
|
} |
|
| TOK_OF |
|
{ |
|
$$ = $1; |
|
} |
|
| TOK_ANY |
|
{ |
|
$$ = $1; |
|
} |
| TOK_ASSOCIATION | | TOK_ASSOCIATION |
{ | { |
$$ = MOF_Strdup(&state.heap, "Association"); |
$$ = $1; |
} | } |
| TOK_INDICATION | | TOK_INDICATION |
{ | { |
$$ = MOF_Strdup(&state.heap, "Indication"); |
$$ = $1; |
} | } |
| TOK_REFERENCE | | TOK_REFERENCE |
{ | { |
$$ = MOF_Strdup(&state.heap, "Reference"); |
$$ = $1; |
} | } |
| TOK_PROPERTY | | TOK_PROPERTY |
{ | { |
$$ = MOF_Strdup(&state.heap, "Property"); |
$$ = $1; |
|
} |
|
| TOK_QUALIFIER |
|
{ |
|
$$ = $1; |
|
} |
|
| TOK_TOSUBCLASS |
|
{ |
|
$$ = $1; |
|
} |
|
| TOK_TOINSTANCE |
|
{ |
|
$$ = $1; |
|
} |
|
| TOK_TRANSLATABLE |
|
{ |
|
$$ = $1; |
|
} |
|
| TOK_FLAVOR |
|
{ |
|
$$ = $1; |
|
} |
|
|
|
dataType |
|
: TOK_BOOLEAN |
|
{ |
|
$$ = MI_BOOLEAN; |
|
} |
|
| TOK_SINT8 |
|
{ |
|
$$ = MI_SINT8; |
|
} |
|
| TOK_UINT8 |
|
{ |
|
$$ = MI_UINT8; |
|
} |
|
| TOK_SINT16 |
|
{ |
|
$$ = MI_SINT16; |
|
} |
|
| TOK_UINT16 |
|
{ |
|
$$ = MI_UINT16; |
|
} |
|
| TOK_SINT32 |
|
{ |
|
$$ = MI_SINT32; |
|
} |
|
| TOK_UINT32 |
|
{ |
|
$$ = MI_UINT32; |
|
} |
|
| TOK_SINT64 |
|
{ |
|
$$ = MI_SINT64; |
|
} |
|
| TOK_UINT64 |
|
{ |
|
$$ = MI_UINT64; |
|
} |
|
| TOK_REAL32 |
|
{ |
|
$$ = MI_REAL32; |
|
} |
|
| TOK_REAL64 |
|
{ |
|
$$ = MI_REAL64; |
|
} |
|
| TOK_CHAR16 |
|
{ |
|
$$ = MI_CHAR16; |
|
} |
|
| TOK_DATETIME |
|
{ |
|
$$ = MI_DATETIME; |
|
} |
|
| TOK_STRING |
|
{ |
|
$$ = MI_STRING; |
} | } |