1 martin 1.55 //%LICENSE////////////////////////////////////////////////////////////////
|
2 martin 1.56 //
|
3 martin 1.55 // Licensed to The Open Group (TOG) under one or more contributor license
4 // agreements. Refer to the OpenPegasusNOTICE.txt file distributed with
5 // this work for additional information regarding copyright ownership.
6 // Each contributor licenses this file to you under the OpenPegasus Open
7 // Source License; you may not use this file except in compliance with the
8 // License.
|
9 martin 1.56 //
|
10 martin 1.55 // Permission is hereby granted, free of charge, to any person obtaining a
11 // copy of this software and associated documentation files (the "Software"),
12 // to deal in the Software without restriction, including without limitation
13 // the rights to use, copy, modify, merge, publish, distribute, sublicense,
14 // and/or sell copies of the Software, and to permit persons to whom the
15 // Software is furnished to do so, subject to the following conditions:
|
16 martin 1.56 //
|
17 martin 1.55 // The above copyright notice and this permission notice shall be included
18 // in all copies or substantial portions of the Software.
|
19 martin 1.56 //
|
20 martin 1.55 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
21 martin 1.56 // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
22 martin 1.55 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
23 // IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
24 // CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
25 // TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
26 // SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
27 martin 1.56 //
|
28 martin 1.55 //////////////////////////////////////////////////////////////////////////
|
29 bob 1.1 %{
|
30 karl 1.60
|
31 bob 1.1 /* Flex grammar created from CIM Specification Version 2.2 Appendix A */
32
33 /*
34 Note the following implementation details:
35
36 1. The MOF specification has a production of type assocDeclaration,
37 but an association is just a type of classDeclaration with a few
38 special rules. At least for the first pass, I'm treating an
39 associationDeclaration as a classDeclaration and applying its
40 syntactical rules outside of the grammar definition.
41
42 2. Same with the indicationDeclaration. It appears to be a normal
43 classDeclaration with the INDICATION qualifier and no special
44 syntactical rules.
45
46 3. The Parser uses String objects throughout to represent
47 character data. However, the tokenizer underneath is probably
48 working with 8-bit chars. If we later use an extended character
49 compatible tokenizer, I anticipate NO CHANGE to this parser.
50
51 4. Besides the tokenizer, this parser uses 2 sets of outside
52 bob 1.1 services:
53 1)Class valueFactory. This has a couple of static methods
|
54 karl 1.45 that assist in creating CIMValue objects from Strings.
55 2)Class cimmofParser. This has a wide variety of methods
56 that fall into these catagories:
|
57 bob 1.1 a) Interfaces to the Repository. You call cimmofParser::
58 methods to query and store compiled CIM elements.
|
59 karl 1.45 b) Error handling.
|
60 bob 1.1 c) Data format conversions.
61 d) Tokenizer manipulation
62 e) Pragma handling
63 f) Alias Handling
64 */
65
|
66 e.boden 1.34
|
67 mike 1.7 #define YYSTACKSIZE 2000
68
|
69 bob 1.1 #include <cstdlib>
|
70 r.kieninger 1.54 #if !defined(PEGASUS_OS_ZOS) && !defined(PEGASUS_OS_VMS)
|
71 mike 1.43 #if defined(PEGASUS_OS_DARWIN)
|
72 dudhe.girish 1.33 #include <sys/malloc.h>
73 #else
|
74 bob 1.1 #include <malloc.h>
|
75 dudhe.girish 1.33 #endif
|
76 sage 1.14 #endif
|
77 bob 1.1 #include <cstdio>
78 #include <cstring>
|
79 mike 1.5 #include <Pegasus/Common/String.h>
|
80 kumpf 1.23 #include <Pegasus/Common/CIMName.h>
|
81 kumpf 1.47 #include <Pegasus/Common/StringConversion.h>
|
82 bob 1.1 #include "cimmofParser.h"
83 #include "valueFactory.h"
84 #include "memobjs.h"
|
85 kumpf 1.50 #include <Pegasus/Common/CIMQualifierList.h>
|
86 kumpf 1.52 #include <Pegasus/Common/AutoPtr.h>
|
87 bob 1.1
|
88 e.boden 1.34 //include any useful debugging stuff here
89
|
90 karl 1.31 /* Debugging the parser. Debugging is provided through
91 1. debug functions in Bison that are controlled by a compile time
92 flag (YYDEBUG) and a runtime flag (yydebug) which is redefined
93 to cimmof_debug.
94 2. Debug functions defined through YACCTRACE, a macro defined
95 in cimmofparser.h and turned on and off manually.
96 All debugging must be turned on manually at this point by
97 setting the YYDEBUG compile flag and also setting YACCTRACE.
98 */
|
99 karl 1.60 // Enable this define to compile Bison/Yacc tracing
100 // #define YYDEBUG 1
|
101 bob 1.1
|
102 e.boden 1.34 extern int cimmof_lex(void);
103 extern int cimmof_error(...);
|
104 bob 1.1 extern char *cimmof_text;
|
105 e.boden 1.34 extern void cimmof_yy_less(int n);
106 extern int cimmof_leng;
|
107 karl 1.60 extern char * metaQualifierName;
|
108 e.boden 1.34
|
109 bob 1.1
110 /* ------------------------------------------------------------------- */
111 /* These globals provide continuity between various pieces of a */
112 /* declaration. They are usually interpreted as "these modifiers were */
113 /* encountered and need to be applied to the finished object". For */
114 /* example, qualifiers are accumulated in g_qualifierList[] as they */
115 /* encountered, then applied to the production they qualify when it */
116 /* is completed. */
117 /* ------------------------------------------------------------------- */
|
118 kumpf 1.25 CIMFlavor g_flavor = CIMFlavor (CIMFlavor::NONE);
119 CIMScope g_scope = CIMScope ();
|
120 kumpf 1.50 CIMQualifierList g_qualifierList;
|
121 bob 1.3 CIMMethod *g_currentMethod = 0;
122 CIMClass *g_currentClass = 0;
123 CIMInstance *g_currentInstance = 0;
|
124 mike 1.41 String g_currentAliasRef; // Alias reference
125 String g_currentAliasDecl; // Alias declaration
|
126 kumpf 1.23 CIMName g_referenceClassName = CIMName();
|
127 kumpf 1.29 Array<CIMKeyBinding> g_KeyBindingArray; // it gets created empty
|
128 karl 1.45 TYPED_INITIALIZER_VALUE g_typedInitializerValue;
|
129 karl 1.63 int g_strValType;
|
130 bob 1.1
131 /* ------------------------------------------------------------------- */
|
132 karl 1.60 /* Pragmas, except for the Include pragma, are not handled yet */
|
133 karl 1.45 /* I don't understand them, so it may be a while before they are */
|
134 bob 1.1 /* ------------------------------------------------------------------- */
135 struct pragma {
136 String name;
137 String value;
138 };
139
140 /* ---------------------------------------------------------------- */
141 /* Use our general wrap manager to handle end-of-file */
142 /* ---------------------------------------------------------------- */
143 extern "C" {
144 int
145 cimmof_wrap() {
146 return cimmofParser::Instance()->wrapCurrentBuffer();
147 }
148 }
149
150 /* ---------------------------------------------------------------- */
151 /* Pass errors to our general log manager. */
|
152 karl 1.63 /* Appends the current text and msg parameter */
|
153 bob 1.1 /* ---------------------------------------------------------------- */
|
154 karl 1.63 void cimmof_error(const char *msg) {
|
155 bob 1.1 cimmofParser::Instance()->log_parse_error(cimmof_text, msg);
156 // printf("Error: %s\n", msg);
157 }
158
|
159 jim.wunderlich 1.40 static void MOF_error(const char * str, const char * S);
|
160 karl 1.61
161 #ifdef DEBUG_cimmof
|
162 jim.wunderlich 1.40 static void MOF_trace(const char* str);
163 static void MOF_trace2(const char * str, const char * S);
|
164 karl 1.61 #else
165 #define MOF_Trace(X)
166 #define MOF_trace2(X, Y)
167 #endif
|
168 jim.wunderlich 1.40
|
169 e.boden 1.34 %}
|
170 bob 1.1
|
171 karl 1.60 /* minimum version of Bison is 2.3. */
172 /* Do not use Bison versions gt 2.3 because of license issues in */
173 /* generated files. */
174 %require "2.3"
175
|
176 bob 1.1 %union {
|
177 e.boden 1.34 //char *strval;
178 CIMClass *mofclass;
179 CIMFlavor *flavor;
180 CIMInstance *instance;
181 CIMKeyBinding *keybinding;
182 CIMMethod *method;
183 CIMName *cimnameval;
184 CIMObjectPath *reference;
185 CIMProperty *property;
186 CIMQualifier *qualifier;
187 CIMQualifierDecl *mofqualifier;
188 CIMScope *scope;
189 CIMType datatype;
190 CIMValue *value;
191 int ival;
|
192 kumpf 1.49 CIMObjectPath *modelpath;
|
193 e.boden 1.34 String *strptr;
194 String *strval;
195 struct pragma *pragma;
196 TYPED_INITIALIZER_VALUE *typedinitializer;
|
197 bob 1.1 }
198
|
199 e.boden 1.34 %token TOK_ALIAS_IDENTIFIER
200 %token TOK_ANY
201 %token TOK_AS
202 %token TOK_ASSOCIATION
203 %token TOK_BINARY_VALUE
204 %token TOK_CHAR_VALUE
205 %token TOK_CLASS
206 %token TOK_COLON
207 %token TOK_COMMA
208 %token TOK_DISABLEOVERRIDE
209 %token TOK_DQUOTE
210 %token TOK_DT_BOOL
211 %token TOK_DT_CHAR16
212 %token TOK_DT_CHAR8
213 %token TOK_DT_DATETIME
214 %token TOK_DT_REAL32
215 %token TOK_DT_REAL64
216 %token TOK_DT_SINT16
217 %token TOK_DT_SINT32
218 %token TOK_DT_SINT64
219 %token TOK_DT_SINT8
220 e.boden 1.34 %token TOK_DT_STR
221 %token TOK_DT_UINT16
222 %token TOK_DT_UINT32
223 %token TOK_DT_UINT64
224 %token TOK_DT_UINT8
225 %token TOK_ENABLEOVERRIDE
226 %token TOK_END_OF_FILE
227 %token TOK_EQUAL
228 %token TOK_FALSE
229 %token TOK_FLAVOR
230 %token TOK_HEX_VALUE
231 %token TOK_INCLUDE
232 %token TOK_INDICATION
233 %token TOK_INSTANCE
|
234 bob 1.1 %token TOK_LEFTCURLYBRACE
|
235 e.boden 1.34 %token TOK_LEFTPAREN
|
236 bob 1.1 %token TOK_LEFTSQUAREBRACKET
|
237 e.boden 1.34 %token TOK_METHOD
|
238 bob 1.1 %token TOK_NULL_VALUE
239 %token TOK_OCTAL_VALUE
|
240 e.boden 1.34 %token TOK_OF
241 %token TOK_PARAMETER
|
242 bob 1.1 %token TOK_PERIOD
|
243 e.boden 1.34 %token TOK_POSITIVE_DECIMAL_VALUE
|
244 bob 1.1 %token TOK_PRAGMA
|
245 e.boden 1.34 %token TOK_PROPERTY
|
246 bob 1.1 %token TOK_QUALIFIER
|
247 e.boden 1.34 %token TOK_REAL_VALUE
248 %token TOK_REF
|
249 bob 1.1 %token TOK_REFERENCE
250 %token TOK_RESTRICTED
|
251 e.boden 1.34 %token TOK_RIGHTCURLYBRACE
252 %token TOK_RIGHTPAREN
253 %token TOK_RIGHTSQUAREBRACKET
254 %token TOK_SCOPE
255 %token TOK_SEMICOLON
256 %token TOK_SIGNED_DECIMAL_VALUE
257 %token TOK_SIMPLE_IDENTIFIER
258 %token TOK_STRING_VALUE
|
259 bob 1.1 %token TOK_TOSUBCLASS
260 %token TOK_TRANSLATABLE
|
261 e.boden 1.34 %token TOK_TRUE
|
262 bob 1.9 %token TOK_UNEXPECTED_CHAR
|
263 bob 1.1
|
264 kumpf 1.23
|
265 karl 1.45 %type <cimnameval> propertyName parameterName methodName className
266 %type <cimnameval> superClass
267 %type <datatype> dataType intDataType realDataType parameterType objectRef
268 %type <flavor> flavor defaultFlavor
269 %type <instance> instanceHead instanceDeclaration
270 %type <ival> array
271 %type <ival> booleanValue keyValuePairList
272 %type <keybinding> keyValuePair
273 %type <method> methodHead methodDeclaration
274 %type <modelpath> modelPath
275 %type <mofclass> classHead classDeclaration
276 %type <mofqualifier> qualifierDeclaration
277 %type <pragma> compilerDirectivePragma
278 %type <property> propertyBody propertyDeclaration referenceDeclaration
279 %type <qualifier> qualifier
280 %type <scope> scope metaElements metaElement
|
281 karl 1.63
282 %type <strval> arrayInitializer constantValueList
|
283 karl 1.45 %type <strval> fileName referencedObject referenceName referencePath
284 %type <strval> integerValue TOK_REAL_VALUE TOK_CHAR_VALUE
285 %type <strval> namespaceHandle namespaceHandleRef
286 %type <strval> nonNullConstantValue
287 %type <strval> pragmaName pragmaVal keyValuePairName qualifierName
288 %type <strval> referenceInitializer objectHandle
289 %type <strval> aliasInitializer
290 %type <strval> aliasIdentifier
291 %type <strval> stringValue stringValues initializer constantValue
292 %type <strval> TOK_ALIAS_IDENTIFIER alias
293 %type <strval> TOK_POSITIVE_DECIMAL_VALUE TOK_OCTAL_VALUE TOK_HEX_VALUE
|
294 kumpf 1.47 %type <strval> TOK_BINARY_VALUE TOK_SIGNED_DECIMAL_VALUE
|
295 karl 1.45 %type <strval> TOK_SIMPLE_IDENTIFIER TOK_STRING_VALUE
296 %type <strval> TOK_UNEXPECTED_CHAR
|
297 karl 1.63
|
298 karl 1.45 %type <typedinitializer> typedInitializer typedDefaultValue
|
299 kumpf 1.20 %type <typedinitializer> typedQualifierParameter
|
300 karl 1.63 %type <value> qualifierType
|
301 karl 1.31
|
302 e.boden 1.34 %%
|
303 karl 1.31
304 /*
305 **------------------------------------------------------------------------------
306 **
307 ** Production rules section
308 **
309 **------------------------------------------------------------------------------
310 */
|
311 kumpf 1.17 mofSpec: mofProductions ;
|
312 bob 1.1
|
313 e.boden 1.34
|
314 bob 1.1 mofProductions: mofProduction mofProductions
315 | /* empty */ ;
|
316 e.boden 1.34
317
|
318 karl 1.16 // ATTN: P1 KS Apr 2002 Limit in (none) Directive handling. See FIXME below.
|
319 bob 1.1 mofProduction: compilerDirective { /* FIXME: Where do we put directives? */ }
|
320 karl 1.45 | qualifierDeclaration
|
321 kumpf 1.57 {
|
322 karl 1.45 cimmofParser::Instance()->addQualifier($1);
323 delete $1;
324 }
325 | classDeclaration
|
326 kumpf 1.57 {
|
327 karl 1.45 cimmofParser::Instance()->addClass($1);
328 }
329 | instanceDeclaration
330 {
331 cimmofParser::Instance()->addInstance($1);
332 } ;
|
333 e.boden 1.34
|
334 karl 1.31 /*
335 **------------------------------------------------------------------------------
336 **
337 ** class Declaration productions and processing
338 **
339 **------------------------------------------------------------------------------
340 */
|
341 bob 1.1 classDeclaration: classHead classBody
342 {
|
343 karl 1.63 YACCTRACE("classDeclaration:");
|
344 jim.wunderlich 1.40 if (g_currentAliasDecl != String::EMPTY)
|
345 karl 1.61 {
346 cimmofParser::Instance()->addClassAlias(g_currentAliasDecl, $$);
347 }
|
348 bob 1.1 } ;
349
|
350 karl 1.61 // NOTE: class alias is deprecated and was removed from DSP0004 between
351 // versions 2.2 and 2.5. It was never implemented in this compiler but
352 // we catch the error in the cimmofParser for now.
|
353 bob 1.1 classHead: qualifierList TOK_CLASS className alias superClass
354 {
|
355 karl 1.31 // create new instance of class with className and superclassName
356 // put returned class object on stack
357 YACCTRACE("classHead:");
358 $$ = cimmofParser::Instance()->newClassDecl(*$3, *$5);
|
359 karl 1.45
|
360 karl 1.31 // put list of qualifiers into class
|
361 kumpf 1.50 applyQualifierList(g_qualifierList, *$$);
|
362 karl 1.45
|
363 jim.wunderlich 1.40 g_currentAliasRef = *$4;
|
364 karl 1.31 if (g_currentClass)
|
365 karl 1.63 {
|
366 karl 1.31 delete g_currentClass;
|
367 karl 1.63 }
|
368 karl 1.31 g_currentClass = $$;
369 delete $3;
370 delete $4;
371 delete $5;
|
372 kumpf 1.17 } ;
|
373 bob 1.1
|
374 e.boden 1.34
375 className: TOK_SIMPLE_IDENTIFIER {} ;
376
|
377 bob 1.1
|
378 kumpf 1.57 superClass: TOK_COLON className
|
379 karl 1.63 {
380 $$ = new CIMName(*$2);
381 delete $2;
382 }
383 | /* empty */
384 {
385 $$ = new CIMName();
386 }
|
387 bob 1.1
|
388 e.boden 1.34
|
389 bob 1.1 classBody: TOK_LEFTCURLYBRACE classFeatures TOK_RIGHTCURLYBRACE TOK_SEMICOLON
|
390 karl 1.45 | TOK_LEFTCURLYBRACE TOK_RIGHTCURLYBRACE TOK_SEMICOLON ;
|
391 bob 1.1
|
392 e.boden 1.34
|
393 bob 1.1 classFeatures: classFeature
|
394 karl 1.45 | classFeatures classFeature ;
|
395 bob 1.1
|
396 e.boden 1.34
|
397 kumpf 1.57 classFeature: propertyDeclaration
|
398 karl 1.45 {
399 YACCTRACE("classFeature:applyProperty");
400 cimmofParser::Instance()->applyProperty(*g_currentClass, *$1);
|
401 kumpf 1.57 delete $1;
|
402 karl 1.45 }
|
403 kumpf 1.57 | methodDeclaration
|
404 karl 1.45 {
405 YACCTRACE("classFeature:applyMethod");
|
406 kumpf 1.57 cimmofParser::Instance()->applyMethod(*g_currentClass, *$1);
|
407 karl 1.45 }
|
408 kumpf 1.57 | referenceDeclaration
|
409 karl 1.45 {
410 YACCTRACE("classFeature:applyProperty");
411 cimmofParser::Instance()->applyProperty(*g_currentClass, *$1);
|
412 kumpf 1.57 delete $1;
|
413 karl 1.45 };
|
414 bob 1.1
|
415 karl 1.31 /*
416 **------------------------------------------------------------------------------
417 **
418 ** method Declaration productions and processing.
419 **
420 **------------------------------------------------------------------------------
|
421 karl 1.63
422 methodDeclaration = [ qualifierList ] dataType methodName
423 "(" [ parameterList ] ")" ";"
|
424 karl 1.31 */
425
|
426 karl 1.45 methodDeclaration: qualifierList methodHead methodBody methodEnd
|
427 bob 1.1 {
|
428 karl 1.45 YACCTRACE("methodDeclaration");
429 $$ = $2;
|
430 bob 1.1 } ;
431
|
432 e.boden 1.34
|
433 karl 1.31 // methodHead processes the datatype and methodName and puts qualifierList.
|
434 kumpf 1.50 // Note that the qualifierList is parsed in methodDeclaration and applied here
435 // so that it is not overwritten by parameter qualifier lists.
|
436 karl 1.45 methodHead: dataType methodName
|
437 bob 1.1 {
|
438 karl 1.31 YACCTRACE("methodHead");
439 if (g_currentMethod)
|
440 karl 1.45 delete g_currentMethod;
441
442 // create new method instance with pointer to method name and datatype
443 g_currentMethod = cimmofParser::Instance()->newMethod(*$2, $1) ;
|
444 karl 1.31
|
445 karl 1.45 // put new method on stack
446 $$ = g_currentMethod;
|
447 karl 1.31
|
448 karl 1.45 // apply the method qualifier list.
|
449 kumpf 1.50 applyQualifierList(g_qualifierList, *$$);
|
450 karl 1.31
|
451 karl 1.45 delete $2;
|
452 bob 1.1 } ;
453
|
454 karl 1.63 methodBody: TOK_LEFTPAREN parameterList TOK_RIGHTPAREN ;
|
455 e.boden 1.34
|
456 bob 1.1 methodEnd: TOK_SEMICOLON ;
457
|
458 kumpf 1.57 methodName: TOK_SIMPLE_IDENTIFIER
459 {
460 $$ = new CIMName(*$1);
|
461 dmitry.mikulin 1.51 delete $1;
462 }
|
463 karl 1.31
464 //
|
465 karl 1.63 // Productions for method parameter list
|
466 karl 1.31 //
|
467 karl 1.63 /*
468 parameterList = parameter *( "," parameter )
469 */
470 parameterList : parameter
471 | parameterList TOK_COMMA parameter
|
472 karl 1.45 | /* empty */ ;
|
473 karl 1.31
|
474 karl 1.63 /*
475 parameter = [ qualifierList ] ( dataType / objectRef ) parameterName
476 [ array ]
477 */
|
478 karl 1.45 parameter: qualifierList parameterType parameterName array
479 {
480 // ATTN: P2 2002 Question Need to create default value including type?
|
481 karl 1.31
|
482 karl 1.45 YACCTRACE("parameter:");
483 CIMParameter *p = 0;
484 cimmofParser *cp = cimmofParser::Instance();
485
486 // Create new parameter with name, type, isArray, array, referenceClassName
|
487 karl 1.64 if ($4 == -1)
|
488 karl 1.63 {
|
489 karl 1.45 p = cp->newParameter(*$3, $2, false, 0, g_referenceClassName);
490 }
491 else
492 {
493 p = cp->newParameter(*$3, $2, true, $4, g_referenceClassName);
494 }
|
495 e.boden 1.34
|
496 karl 1.45 g_referenceClassName = CIMName();
|
497 karl 1.31
|
498 karl 1.45 YACCTRACE("parameter:applyQualifierList");
|
499 kumpf 1.50 applyQualifierList(g_qualifierList, *p);
|
500 e.boden 1.34
|
501 karl 1.45 cp->applyParameter(*g_currentMethod, *p);
502 delete p;
503 delete $3;
504 } ;
|
505 e.boden 1.34
506
|
507 karl 1.45 parameterType: dataType { $$ = $1; }
508 | objectRef { $$ = CIMTYPE_REFERENCE; } ;
|
509 e.boden 1.34
510
|
511 karl 1.31 /*
512 **------------------------------------------------------------------------------
513 **
514 ** property Declaration productions and processing
515 **
516 **------------------------------------------------------------------------------
|
517 karl 1.63
518 propertyDeclaration = [ qualifierList ] dataType propertyName
519 [ array ] [ defaultValue ] ";"
|
520 karl 1.31 */
|
521 e.boden 1.34
|
522 karl 1.45 propertyDeclaration: qualifierList propertyBody propertyEnd
|
523 bob 1.1 {
|
524 karl 1.31 // set body to stack and apply qualifier list
525 // ATTN: the apply qualifer only works here because
526 // there are not lower level qualifiers. We do productions
527 // that might have lower level qualifiers differently by
|
528 karl 1.45 // setting up a xxxHead production where qualifiers are
|
529 karl 1.31 // applied.
530 YACCTRACE("propertyDeclaration:");
531 $$ = $2;
|
532 kumpf 1.50 applyQualifierList(g_qualifierList, *$$);
|
533 bob 1.1 } ;
534
|
535 karl 1.63 /*
|
536 e.boden 1.34
|
537 karl 1.63 */
|
538 kumpf 1.18 propertyBody: dataType propertyName array typedDefaultValue
|
539 bob 1.1 {
|
540 karl 1.63 CIMValue *v = valueFactory::createValue($1,
541 $3,
542 ($4->type == typedInitializerValue::NULL_VALUE),
543 $4->nonNullParserType,
544 $4->value);
|
545 karl 1.61
|
546 karl 1.63 // set the value in the new property for the current instance
|
547 karl 1.61 // if scalar, $3 == -1 so set arrayDimension to zero.
|
548 karl 1.63 if ($3 == CIMMOF_EMPTY_ARRAY)
|
549 karl 1.45 {
|
550 karl 1.61 $$ = cimmofParser::Instance()->newProperty(*$2, *v, 0);
|
551 kumpf 1.57 }
552 else
|
553 karl 1.45 {
|
554 karl 1.61 $$ = cimmofParser::Instance()->newProperty(*$2, *v, $3);
|
555 karl 1.45 }
556
557 delete $2;
558 delete $4->value;
559 delete v;
|
560 bob 1.1 } ;
561
|
562 e.boden 1.34
|
563 bob 1.1 propertyEnd: TOK_SEMICOLON ;
|
564 e.boden 1.34
|
565 karl 1.31 /*
566 **------------------------------------------------------------------------------
567 **
568 ** reference Declaration productions and processing
569 **
570 **------------------------------------------------------------------------------
|
571 karl 1.63
572 referenceDeclaration = [ qualifierList ] objectRef referenceName
573 [ defaultValue ] ";"
|
574 karl 1.31 */
|
575 bob 1.1
576 referenceDeclaration: qualifierList referencedObject TOK_REF referenceName
|
577 karl 1.45 referencePath TOK_SEMICOLON
|
578 bob 1.1 {
|
579 karl 1.45 String s(*$2);
580 if (!String::equal(*$5, String::EMPTY))
|
581 karl 1.63 {
|
582 karl 1.45 s.append("." + *$5);
|
583 karl 1.63 }
584
585 CIMValue *v = valueFactory::createValue(
586 CIMTYPE_REFERENCE,
587 CIMMOF_EMPTY_ARRAY,
588 true,
589 strValTypeNS::NULL_VALUE,
590 &s);
591
|
592 karl 1.61 $$ = cimmofParser::Instance()->newProperty(*$4, *v, 0, *$2);
|
593 kumpf 1.50 applyQualifierList(g_qualifierList, *$$);
|
594 karl 1.45 delete $2;
595 delete $4;
596 delete $5;
597 delete v;
|
598 bob 1.1 } ;
599
|
600 e.boden 1.34
|
601 bob 1.1 referencedObject: TOK_SIMPLE_IDENTIFIER { $$ = $1; } ;
602
603 referenceName: TOK_SIMPLE_IDENTIFIER { $$ = $1; };
604
605 referencePath: TOK_EQUAL stringValue { $$ = $2; }
|
606 karl 1.45 | /* empty */ { $$ = new String(String::EMPTY); } ;
|
607 bob 1.1
|
608 e.boden 1.34
|
609 kumpf 1.57 objectRef: className TOK_REF
|
610 dmitry.mikulin 1.51 {
|
611 kumpf 1.57 g_referenceClassName = *$1;
|
612 dmitry.mikulin 1.51 delete $1;
613 }
|
614 bob 1.1
|
615 e.boden 1.34
|
616 kumpf 1.57 parameterName: TOK_SIMPLE_IDENTIFIER
617 {
618 $$ = new CIMName(*$1);
|
619 dmitry.mikulin 1.51 delete $1;
620 }
|
621 bob 1.1
|
622 e.boden 1.34
|
623 kumpf 1.57 propertyName: TOK_SIMPLE_IDENTIFIER
624 {
625 $$ = new CIMName(*$1);
|
626 dmitry.mikulin 1.51 delete $1;
627 }
|
628 bob 1.1
|
629 karl 1.63
630 /*
631 array = "[" [positiveDecimalValue] "]"
632
633 array definition syntax with dimension integer found [xxx] or
634 dimension integer empty or not array definition
635 NOTE: array type is ival (int) which allows positive and negative.
636 The Empty is actually -1
637 */
|
638 karl 1.64 array:
|
639 karl 1.63 // array syntax with [ number ]
640 TOK_LEFTSQUAREBRACKET TOK_POSITIVE_DECIMAL_VALUE TOK_RIGHTSQUAREBRACKET
|
641 kumpf 1.47 {
|
642 kumpf 1.48 $$ = (Uint32) valueFactory::stringToUint(*$2, CIMTYPE_UINT32);
|
643 karl 1.45 delete $2;
644 }
|
645 karl 1.61
646 // array syntax with no number []
|
647 karl 1.45 | TOK_LEFTSQUAREBRACKET TOK_RIGHTSQUAREBRACKET
648 { $$ = 0; }
|
649 karl 1.61
650 // no array definition syntax.
|
651 kumpf 1.57 | /* empty */
|
652 karl 1.63 { $$ = CIMMOF_EMPTY_ARRAY; } ;
|
653 karl 1.45
|
654 karl 1.63 /*
655 defaultValue = "=" initializer
656 Used in: TODO
657 Result: *typedInitializer
658 */
659 typedDefaultValue:
660 TOK_EQUAL typedInitializer { $$ = $2; }
661 | /* empty */
662 {
663 g_typedInitializerValue.setNull();
664 $$ = &g_typedInitializerValue;
665 };
|
666 karl 1.45
|
667 karl 1.63 /*
668 Used in: keyValuePair
669 Result: strval
670 TODO: This used by keyValue pair and therefore needs better definition
671 of the hint types.
672 */
673 initializer:
674 constantValue
|
675 karl 1.45 { $$ = $1; }
676 | arrayInitializer
677 { $$ = $1; }
678 | referenceInitializer
679 { $$ = $1; } ;
|
680 bob 1.1
|
681 e.boden 1.34
|
682 karl 1.45 // The typedInitializer element is syntactially identical to
683 // the initializer element. However, the typedInitializer element
|
684 kumpf 1.17 // returns, in addition to the value, the type of the value.
|
685 karl 1.63
686
687 /*
688 initializer = ConstantValue / arrayInitializer / referenceInitializer
689 arrayInitializer = "{" constantValue*( "," constantValue)"}"
690 constantValue = integerValue / realValue / charValue / stringValue /
691 datetimeValue / booleanValue / nullValue
692 integerValue = binaryValue / octalValue / decimalValue / hexValue
693 referenceInitializer = objectPath / aliasIdentifier
694 Result: struct typedInitializerValue in TYPED_INITIALIZER_VALUE
695 */
696 typedInitializer:
697 nonNullConstantValue
|
698 karl 1.45 {
|
699 karl 1.63 YACCTRACE("typedInitializer:nonNullConstantValue= " << *$1);
700 g_typedInitializerValue.set(
701 typedInitializerValue::CONSTANT_VALUE, $1);
702 g_typedInitializerValue.nonNullParserType = g_strValType;
|
703 karl 1.45 $$ = &g_typedInitializerValue;
704 }
705 | TOK_NULL_VALUE
706 {
|
707 karl 1.63 g_typedInitializerValue.setNull();
|
708 karl 1.45 $$ = &g_typedInitializerValue;
709 }
710 | arrayInitializer
711 {
|
712 karl 1.63 g_typedInitializerValue.set(
713 typedInitializerValue::ARRAY_VALUE, $1);
714 g_typedInitializerValue.nonNullParserType = g_strValType;
|
715 karl 1.45 $$ = &g_typedInitializerValue;
716 }
717 | referenceInitializer
718 {
|
719 karl 1.63 g_typedInitializerValue.set(
720 typedInitializerValue::REFERENCE_VALUE, $1);
721 g_typedInitializerValue.nonNullParserType = g_strValType;
|
722 karl 1.45 $$ = &g_typedInitializerValue;
723 };
|
724 kumpf 1.17
|
725 e.boden 1.34
|
726 karl 1.32 // BUG 497 - Commmas embedded in strings in arrays change the
|
727 karl 1.63 // strings. Added function stringEscapeComma to escape commas.
728 /*
729 Recursively build up list from comma-separated constant values.
730 Used in: arrayInitializer, initializer
731 Result: strval
732 TODO: Make this more efficient by building an array of strings and
733 eliminating the addition of the Escape code
734 */
735 constantValueList: constantValue
736 {
737 *$$ = valueFactory::stringEscapeComma(String(*$1));
738 }
739 | constantValueList TOK_COMMA constantValue
|
740 karl 1.45 {
|
741 karl 1.63 YACCTRACE("constantValueList:constantValueList TOK_COMMA "
742 "constantValue, Value= " << *$3);
|
743 karl 1.45 (*$$).append(",");
|
744 karl 1.63
745 // Append the new constantValue after escaping internal commas
746 (*$$).append(valueFactory::stringEscapeComma(String(*$3)));
|
747 karl 1.45 delete $3;
748 } ;
|
749 bob 1.1
|
750 e.boden 1.34
|
751 karl 1.63 /*
752 The nonNullConstantValue allows NULL to be distinguished from the EMPTY STRING.
|
753 kumpf 1.17
|
754 karl 1.63 Used in: constantValueList,
755 Result: strval
756 */
757
758 constantValue:
759 nonNullConstantValue
|
760 karl 1.45 {$$ = $1;}
761 | TOK_NULL_VALUE
|
762 karl 1.63 {
|
763 karl 1.64 g_typedInitializerValue.nonNullParserType =
|
764 karl 1.63 strValTypeNS::NULL_VALUE;
765 $$ = new String(String::EMPTY);
766 } ;
|
767 kumpf 1.17
|
768 karl 1.63 /* NOTE: This parses 5 types but loses the type separation
769 in returning the value. The known issue is that Strings and
770 Boolean returns look the same so that a String could be substituted
771 for a Boolean nonNullConstantValue and pass the parser. Since there
772 is no further way to understand whetner a string or Boolean was
773 returned, we can create an error like "true" where we meant true.
774 Bug 3574, Modified to save parseType in g_strValType
775 Used in: constantValue, typedInitializer, typedQualifierParameter
776 result: strval and the parseType in g_strValType for use in constructing
777 the typeInitializer struct
778 */
779 nonNullConstantValue:
780 integerValue
781 {
782 $$ = $1;
783 g_strValType = strValTypeNS::INTEGER_VALUE;
784 }
|
785 karl 1.45 | TOK_REAL_VALUE
|
786 karl 1.63 {
787 $$ = $1;
788 g_strValType = strValTypeNS::REAL_VALUE;
789 }
|
790 karl 1.45 | TOK_CHAR_VALUE
|
791 karl 1.63 {
792 $$ = $1;
793 g_strValType = strValTypeNS::CHAR_VALUE;
794 }
|
795 karl 1.45 | stringValues
|
796 karl 1.63 {
797 g_strValType = strValTypeNS::STRING_VALUE;
798 }
|
799 kumpf 1.57 | booleanValue
|
800 karl 1.63 {
801 g_strValType = strValTypeNS::BOOLEAN_VALUE;
802 $$ = new String($1 ? "T" : "F");
|
803 karl 1.45 };
|
804 bob 1.1
|
805 e.boden 1.34
|
806 bob 1.1 integerValue: TOK_POSITIVE_DECIMAL_VALUE
|
807 karl 1.45 | TOK_OCTAL_VALUE
808 | TOK_HEX_VALUE
809 | TOK_BINARY_VALUE
|
810 kumpf 1.47 | TOK_SIGNED_DECIMAL_VALUE;
|
811 karl 1.45
|
812 karl 1.63 /*
813 booleanValue = TRUE / FALSE
814 Used in: nonNullConstantValue
815 Result: ival
816 */
|
817 karl 1.45 booleanValue: TOK_FALSE
818 { $$ = 0; }
819 | TOK_TRUE
820 { $$ = 1; } ;
|
821 bob 1.1
|
822 karl 1.63 /*
823 Append multiple stringValue entities.
824 */
|
825 bob 1.1 stringValues: stringValue { $$ = $1; }
|
826 karl 1.45 | stringValues stringValue
827 {
828 (*$$).append(*$2); delete $2;
829 } ;
|
830 bob 1.1
|
831 e.boden 1.34
|
832 karl 1.45 stringValue: TOK_STRING_VALUE
833 {
|
834 e.boden 1.34 //String oldrep = *$1;
835 //String s(oldrep), s1(String::EMPTY);
|
836 bob 1.1 // Handle quoted quote
|
837 e.boden 1.34 //int len = s.size();
838 //if (s[len] == '\n') {
839 //error: new line inside a string constant unless it is quoted
840 //if (s[len - 2] == '\\') {
841 //if (len > 3)
|
842 karl 1.45 //s1 = s.subString(1, len-3);
|
843 e.boden 1.34 //} else {
844 //cimmof_error("New line in string constant");
845 //}
846 //cimmofParser::Instance()->increment_lineno();
847 //} else { // Can only be a quotation mark
848 //if (s[len - 2] == '\\') { // if it is quoted
849 //if (len > 3) s1 = s.subString(1, len-3);
850 //s1.append('\"');
851 //cimmof_yy_less(len-1);
852 //} else { // This is the normal case: real quotes on both end
853 //s1 = s.subString(1, len - 2) ;
854 //}
855 //}
856 //delete $1;
|
857 karl 1.63 //$$ = new String(s1);
858 $$ = new String(*$1);
|
859 e.boden 1.34 delete $1;
|
860 kumpf 1.17 } ;
|
861 bob 1.1
|
862 karl 1.63 /*
863 arrayInitializer = "{" constantValue*( "," constantValue)"}"
864
|
865 karl 1.64 Intiialize array of comma-separated constant values
|
866 e.boden 1.34
|
867 karl 1.63 Used in: Initializer, typedInitializer, typedQualifierParameter
868 Result: strVal
869 */
|
870 karl 1.45 arrayInitializer:
|
871 karl 1.63 TOK_LEFTCURLYBRACE constantValueList TOK_RIGHTCURLYBRACE
872 {
873 $$ = $2;
874 }
|
875 karl 1.45 | TOK_LEFTCURLYBRACE TOK_RIGHTCURLYBRACE
|
876 karl 1.63 {
877 $$ = new String(String::EMPTY);
878 };
|
879 bob 1.1
|
880 e.boden 1.34
|
881 bob 1.1 referenceInitializer: objectHandle {}
|
882 karl 1.45 | aliasInitializer { } ;
|
883 bob 1.1
|
884 e.boden 1.34
|
885 bob 1.1 objectHandle: TOK_DQUOTE namespaceHandleRef modelPath TOK_DQUOTE
|
886 karl 1.45 {
|
887 kumpf 1.49 // The objectName string is decomposed for syntactical validation purposes
888 // and reassembled here for later parsing in creation of an CIMObjectPath
889 // instance
|
890 karl 1.45 String *s = new String(*$2);
891 if (!String::equal(*s, String::EMPTY) && $3)
|
892 karl 1.61 {
|
893 karl 1.45 (*s).append(":");
|
894 karl 1.61 }
895 if ($3)
896 {
|
897 kumpf 1.49 (*s).append($3->toString());
|
898 karl 1.45 }
899 $$ = s;
900 delete $2;
901 delete $3;
902 MOF_trace2 ("objectHandle done $$ = ", $$->getCString());
|
903 kumpf 1.17 } ;
|
904 bob 1.1
|
905 e.boden 1.34
|
906 karl 1.45 aliasInitializer : aliasIdentifier
907 {
908
909 CIMObjectPath AOP;
|
910 jim.wunderlich 1.40
|
911 karl 1.45 MOF_trace2("aliasInitializer $$ = ", $$->getCString());
912 MOF_trace2("aliasInitializer $1 = ", $1->getCString());
|
913 jim.wunderlich 1.40
|
914 karl 1.45 g_currentAliasRef = *$$;
|
915 jim.wunderlich 1.40
|
916 karl 1.45 MOF_trace2("aliasInitializer g_currentAliasRef = ",
917 g_currentAliasRef.getCString());
918 if (cimmofParser::Instance()->getInstanceAlias(g_currentAliasRef, AOP) == 0)
|
919 jim.wunderlich 1.40 {
|
920 karl 1.61 MOF_error("ERROR: aliasIdentifier NOT FOUND: aliasIdentifier = ",
921 g_currentAliasRef.getCString());
|
922 karl 1.45 yyerror("aliasInitializer - 'aliasIdentifier' NOT FOUND");
923 YYABORT;
|
924 jim.wunderlich 1.40 }
925
|
926 karl 1.45 String *s = new String(AOP.toString());
|
927 jim.wunderlich 1.40
|
928 karl 1.45 $$ = s;
929
930 delete $1;
931
932 MOF_trace2 ("aliasInitializer done $$ = ", $$->getCString());
|
933 jim.wunderlich 1.40
934 };
|
935 bob 1.3
|
936 e.boden 1.34
|
937 bob 1.1 namespaceHandleRef: namespaceHandle TOK_COLON
|
938 karl 1.45 { }
939 | /* empty */ { $$ = new String(String::EMPTY); };
|
940 bob 1.1
|
941 e.boden 1.34
|
942 bob 1.1 namespaceHandle: stringValue {};
943
|
944 karl 1.61 // create a model CIMObject path from <className>.<keyValuePairList>
945 modelPath: className TOK_PERIOD keyValuePairList
946 {
947 CIMObjectPath * m = new CIMObjectPath(String::EMPTY,
948 CIMNamespaceName(),
949 (*$1).getString(),
950 g_KeyBindingArray);
951
952 g_KeyBindingArray.clear();
953 delete $1;
|
954 e.boden 1.34
|
955 karl 1.61 $$ = m;
|
956 bob 1.1
|
957 karl 1.61 MOF_trace2 ("modelPath done $$ = ", $$->toString().getCString());
958 } ;
|
959 e.boden 1.34
|
960 karl 1.61 // gets the list of keyValuePairs into the global KeyBindingArray
961 // keyValuePairList := <keyValuePair> [, <keyValuePair>]
962 // Returns SS = 0 because value in global
|
963 karl 1.45 keyValuePairList: keyValuePair
964 { $$ = 0; }
965 | keyValuePairList TOK_COMMA keyValuePair
966 { $$ = 0; } ;
|
967 bob 1.1
|
968 karl 1.63
969 /*
970 Parse one keybinding and append to global KeyBindingArray. calcualates
|
971 karl 1.64 keyBinding type from first char of string.
|
972 karl 1.63 */
|
973 karl 1.45 keyValuePair: keyValuePairName TOK_EQUAL initializer
974 {
|
975 kumpf 1.49 CIMKeyBinding::Type keyBindingType;
976 Char16 firstChar = (*$3)[0];
|
977 karl 1.63 // test for string type. TODO NOTSURE THIS IS CORRECT ANY MORE.
|
978 dev.meetei 1.59 if (firstChar == '\"')
|
979 karl 1.63 {
|
980 kumpf 1.49 keyBindingType = CIMKeyBinding::STRING;
|
981 karl 1.63 }
982 // test for boolean type (i.e. first char value)
|
983 kumpf 1.49 else if ((firstChar == 'T') || (firstChar == 't') ||
984 (firstChar == 'F') || (firstChar == 'f'))
|
985 karl 1.63 {
|
986 kumpf 1.49 keyBindingType = CIMKeyBinding::BOOLEAN;
|
987 karl 1.63 }
|
988 kumpf 1.49 else
|
989 karl 1.63 {
|
990 kumpf 1.49 keyBindingType = CIMKeyBinding::NUMERIC;
|
991 karl 1.63 }
|
992 kumpf 1.49 CIMKeyBinding *kb = new CIMKeyBinding(*$1, *$3, keyBindingType);
|
993 karl 1.45 g_KeyBindingArray.append(*kb);
994 delete kb;
995 delete $1;
|
996 kumpf 1.57 delete $3;
|
997 karl 1.45 } ;
|
998 bob 1.1
|
999 e.boden 1.34
|
1000 bob 1.1 keyValuePairName: TOK_SIMPLE_IDENTIFIER ;
1001
|
1002 e.boden 1.34
|
1003 karl 1.45 alias: TOK_AS aliasIdentifier
1004 {
1005 $$ = $2;
1006 g_currentAliasDecl = *$2;
1007 MOF_trace2("aliasIdentifier $$ = ", $$->getCString());
1008 MOF_trace2("aliasIdentifier g_currentAliasDecl = ",
1009 g_currentAliasDecl.getCString());
1010
1011 }
|
1012 karl 1.64 | /* empty */
|
1013 karl 1.63 {
1014 $$ = new String(String::EMPTY);
1015 g_currentAliasDecl = String::EMPTY;
1016 } ;
|
1017 e.boden 1.34
|
1018 bob 1.1
1019 aliasIdentifier: TOK_ALIAS_IDENTIFIER ;
1020
|
1021 e.boden 1.34
|
1022 karl 1.31 /*
1023 **------------------------------------------------------------------------------
1024 **
1025 ** Instance Declaration productions and processing
1026 **
|
1027 jim.wunderlich 1.40 **-----------------------------------------------------------------------------
|
1028 karl 1.31 */
1029
|
1030 bob 1.1 instanceDeclaration: instanceHead instanceBody
|
1031 karl 1.45 {
1032 $$ = g_currentInstance;
1033 if (g_currentAliasDecl != String::EMPTY)
|
1034 jim.wunderlich 1.40 {
|
1035 karl 1.45 MOF_trace2("instanceDeclaration g_currentAliasDecl = ",
1036 g_currentAliasDecl.getCString());
|
1037 karl 1.61
|
1038 karl 1.45 if (cimmofParser::Instance()->addInstanceAlias(
|
1039 karl 1.61 g_currentAliasDecl, $$) == 0)
|
1040 karl 1.45 {
1041 // Error alias already exist
1042 MOF_error("ERROR: alias ALREADY EXISTS: aliasIdentifier = ",
1043 g_currentAliasDecl.getCString());
1044 yyerror("instanceDeclaration - 'aliasIdentifier' ALREADY EXISTS");
1045 YYABORT;
1046 }
|
1047 jim.wunderlich 1.40 }
|
1048 bob 1.1 };
1049
|
1050 e.boden 1.34
|
1051 karl 1.45 instanceHead: qualifierList TOK_INSTANCE TOK_OF className alias
|
1052 bob 1.1 {
|
1053 karl 1.45 if (g_currentInstance)
1054 delete g_currentInstance;
1055 g_currentAliasDecl = *$5;
1056 g_currentInstance = cimmofParser::Instance()->newInstance(*$4);
1057 // apply the qualifierlist to the current instance
1058 $$ = g_currentInstance;
|
1059 kumpf 1.50 applyQualifierList(g_qualifierList, *$$);
|
1060 karl 1.45 delete $4;
1061 delete $5;
1062 if (g_currentAliasDecl != String::EMPTY)
|
1063 karl 1.61 {
|
1064 karl 1.45 MOF_trace2("instanceHead g_currentAliasDecl = ",
1065 g_currentAliasDecl.getCString());
|
1066 karl 1.61 }
|
1067 bob 1.1 } ;
1068
|
1069 e.boden 1.34
|
1070 karl 1.63 instanceBody: TOK_LEFTCURLYBRACE valueInitializerList TOK_RIGHTCURLYBRACE
|
1071 karl 1.45 TOK_SEMICOLON ;
|
1072 bob 1.1
|
1073 e.boden 1.34
|
1074 karl 1.63 valueInitializerList:
1075 valueInitializer
1076 | valueInitializerList valueInitializer ;
|
1077 e.boden 1.34
1078
|
1079 kumpf 1.17 // ATTN-DE-P1-20020427: Processing NULL Initializer values is incomplete.
|
1080 karl 1.45 // Currently only the arrayInitializer element has been modified to
|
1081 karl 1.63 // return typedInitializerValue::NULL_VALUE
|
1082 kumpf 1.17 valueInitializer: qualifierList TOK_SIMPLE_IDENTIFIER TOK_EQUAL
|
1083 karl 1.45 typedInitializer TOK_SEMICOLON
|
1084 bob 1.1 {
|
1085 kumpf 1.52 AutoPtr<String> identifier($2);
|
1086 karl 1.45 cimmofParser *cp = cimmofParser::Instance();
1087 // ATTN: P1 InstanceUpdate function 2001 BB Instance update needs
1088 // work here and CIMOM
1089 // a property. It must be fixed in the Common code first.
1090 // What we have to do here is create a CIMProperty and initialize it with
1091 // the value provided. The name of the property is $2 and it belongs
1092 // to the class whose name is in g_currentInstance->getClassName().
1093 // The steps are
1094 // 2. Get property declaration's value object
|
1095 kumpf 1.52 CIMProperty *oldprop =
1096 cp->PropertyFromInstance(*g_currentInstance, *identifier);
|
1097 karl 1.63
|
1098 karl 1.45 CIMValue *oldv = cp->ValueFromProperty(*oldprop);
1099
1100 // 3. create the new Value object of the same type
1101
1102 // We want createValue to interpret a value as an array if is enclosed
1103 // in {}s (e.g., { 2 } or {2, 3, 5}) or it is NULL and the property is
1104 // defined as an array. createValue is responsible for the actual
1105 // validation.
1106
1107 CIMValue *v = valueFactory::createValue(oldv->getType(),
|
1108 karl 1.63 (($4->type == typedInitializerValue::ARRAY_VALUE) ||
1109 (($4->type == typedInitializerValue::NULL_VALUE)
1110 && (oldprop->isArray()))? 0 : CIMMOF_EMPTY_ARRAY),
1111 ($4->type == typedInitializerValue::NULL_VALUE),
1112 $4->nonNullParserType,
|
1113 karl 1.45 $4->value);
1114
1115 // 4. create a clone property with the new value
1116 CIMProperty *newprop = cp->copyPropertyWithNewValue(*oldprop, *v);
1117
1118 // 5. apply the qualifiers;
|
1119 kumpf 1.50 applyQualifierList(g_qualifierList, *newprop);
|
1120 karl 1.45
1121 // 6. and apply the CIMProperty to g_currentInstance.
1122 cp->applyProperty(*g_currentInstance, *newprop);
1123 delete $4->value;
1124 delete oldprop;
1125 delete oldv;
1126 delete v;
1127 delete newprop;
|
1128 e.boden 1.34 };
1129
1130
|
1131 karl 1.31 /*
1132 **------------------------------------------------------------------------------
1133 **
1134 ** Compiler directive productions and processing
1135 **
1136 **------------------------------------------------------------------------------
1137 */
1138
|
1139 bob 1.1 compilerDirective: compilerDirectiveInclude
|
1140 karl 1.45 {
1141 //printf("compilerDirectiveInclude ");
1142 }
1143 | compilerDirectivePragma
1144 {
1145 //printf("compilerDirectivePragma ");
1146 } ;
|
1147 bob 1.1
|
1148 e.boden 1.34
|
1149 bob 1.1 compilerDirectiveInclude: TOK_PRAGMA TOK_INCLUDE TOK_LEFTPAREN fileName
|
1150 karl 1.45 TOK_RIGHTPAREN
1151 {
1152 cimmofParser::Instance()->enterInlineInclude(*$4); delete $4;
1153 };
|
1154 e.boden 1.34
|
1155 bob 1.1
1156 fileName: stringValue { $$ = $1; } ;
|
1157 e.boden 1.34
1158
|
1159 bob 1.1 compilerDirectivePragma: TOK_PRAGMA pragmaName
|
1160 karl 1.45 TOK_LEFTPAREN pragmaVal TOK_RIGHTPAREN
1161 {
1162 cimmofParser::Instance()->processPragma(*$2, *$4);
1163 delete $2;
1164 delete $4;
1165 };
|
1166 bob 1.1
|
1167 e.boden 1.34
|
1168 karl 1.31 /*
1169 **------------------------------------------------------------------------------
1170 **
1171 ** qualifier Declaration productions and processing
1172 **
1173 **------------------------------------------------------------------------------
1174 */
1175
|
1176 karl 1.63 /*
1177 qualifierDeclaration = QUALIFIER qualifierName qualifierType scope
1178 [ defaultFlavor ] ";"
1179
1180 This is really QualifierTypeDeclaration. It defines the characteristics of the
1181 qualifier.
1182
1183 Note: What we call qualifierValue is qualifierType in BNF.
|
1184 karl 1.60 */
1185
|
1186 karl 1.63 qualifierDeclaration: TOK_QUALIFIER qualifierName qualifierType scope
|
1187 karl 1.45 defaultFlavor TOK_SEMICOLON
|
1188 bob 1.1 {
|
1189 karl 1.45 $$ = cimmofParser::Instance()->newQualifierDecl(*$2, $3, *$4, *$5);
|
1190 karl 1.60 delete $2; // String created in qualifierName
|
1191 karl 1.45 delete $3; // CIMValue object created in qualifierValue production
|
1192 dmitry.mikulin 1.51 delete $4; // CIMScope object created in scope/metaElements production
|
1193 bob 1.1 } ;
1194
|
1195 karl 1.63 /*
1196 qualifierType = ":" dataType [ array ] [ defaultValue ]
|
1197 karl 1.60 */
|
1198 karl 1.63 qualifierType: TOK_COLON dataType array typedDefaultValue
|
1199 karl 1.60 {
|
1200 karl 1.63 $$ = valueFactory::createValue(
1201 $2,
1202 $3,
1203 ($4->type == typedInitializerValue::NULL_VALUE),
1204 $4->nonNullParserType,
1205 $4->value);
|
1206 karl 1.60 delete $4->value;
1207 } ;
|
1208 bob 1.1
|
1209 karl 1.63 /*
|
1210 karl 1.60 scope = "," SCOPE "(" metaElement *( "," metaElement ) ")"
1211 */
1212 // empty implies no scope definition and is illegal
1213 scope: scope_begin metaElements TOK_RIGHTPAREN
1214 {
1215 $$ = $2;
1216 } ;
1217 | /* empty*/
1218 {
1219 // terminate in error, no scope statement
1220 yyerror("\"scope\" definition required on Qualifier Declaration");
1221 }
|
1222 e.boden 1.34
|
1223 karl 1.60 // Production set scope NONE
|
1224 karl 1.45 scope_begin: TOK_COMMA TOK_SCOPE TOK_LEFTPAREN
1225 {
|
1226 karl 1.60 g_scope = CIMScope (CIMScope::NONE);
|
1227 karl 1.45 } ;
|
1228 bob 1.1
|
1229 karl 1.60 /* aggregate the keywords used to define scope */
|
1230 karl 1.64 metaElements:
|
1231 karl 1.63 metaElement
|
1232 karl 1.61 { /* empty */
|
1233 karl 1.60 $$ = $1;
1234 }
|
1235 karl 1.45 | metaElements TOK_COMMA metaElement
|
1236 kumpf 1.57 {
1237 $$->addScope(*$3);
|
1238 dmitry.mikulin 1.51 delete $3;
1239 } ;
|
1240 e.boden 1.34
|
1241 karl 1.60 /* Resolve each possible scope keyword (metaElement). Each TOK adds a
|
1242 karl 1.63 one scope type. The ASSOCIATION and INDICATION free the
|
1243 karl 1.60 variable metaQualifierName since that could be set either by the
1244 Keywords as a Scope token or metaQualifier name (i.e. these keywords
|
1245 karl 1.61 usage is context sensitive)
|
1246 karl 1.63
|
1247 karl 1.60 metaElement = CLASS / ASSOCIATION / INDICATION / QUALIFIER
1248 PROPERTY / REFERENCE / METHOD / PARAMETER / ANY
1249 */
|
1250 kumpf 1.26 metaElement: TOK_CLASS { $$ = new CIMScope(CIMScope::CLASS); }
|
1251 karl 1.60 | TOK_ASSOCIATION { free(metaQualifierName);
1252 metaQualifierName = 0;
1253 $$ = new CIMScope(CIMScope::ASSOCIATION); }
1254 | TOK_INDICATION { free(metaQualifierName);
1255 metaQualifierName = 0;
1256 $$ = new CIMScope(CIMScope::INDICATION); }
|
1257 kumpf 1.26 | TOK_PROPERTY { $$ = new CIMScope(CIMScope::PROPERTY); }
1258 | TOK_REFERENCE { $$ = new CIMScope(CIMScope::REFERENCE); }
1259 | TOK_METHOD { $$ = new CIMScope(CIMScope::METHOD); }
1260 | TOK_PARAMETER { $$ = new CIMScope(CIMScope::PARAMETER); }
1261 | TOK_ANY { $$ = new CIMScope(CIMScope::ANY); } ;
|
1262 bob 1.1
|
1263 e.boden 1.34
|
1264 karl 1.63
1265 /*
1266 Set the default if no FlavorHead or accumulated explicitFlavors
1267
1268 defaultFlavor = "," FLAVOR "(" flavor *( "," flavor ) ")"
|
1269 karl 1.60 */
|
1270 karl 1.63 defaultFlavor:
1271 TOK_COMMA flavorHead explicitFlavors TOK_RIGHTPAREN
1272 { $$ = &g_flavor; }
|
1273 kumpf 1.57 | /* empty */
|
1274 karl 1.63 {
1275 g_flavor = CIMFlavor (CIMFlavor::NONE);
1276 $$ = &g_flavor;
1277 } ;
|
1278 bob 1.1
|
1279 karl 1.11 // Set the flavors for the defaults required: via DEFAULTS
|
1280 kumpf 1.57 flavorHead: TOK_FLAVOR TOK_LEFTPAREN
|
1281 karl 1.63 {
1282 g_flavor = CIMFlavor (CIMFlavor::NONE);
1283 };
|
1284 bob 1.1
|
1285 karl 1.60 // gather comma-separated explicitFlavor keywords into g_flavor
|
1286 bob 1.1 explicitFlavors: explicitFlavor
|
1287 karl 1.45 | explicitFlavors TOK_COMMA explicitFlavor ;
|
1288 bob 1.1
|
1289 karl 1.60 // Get an explicitFlavor keyword and add to the g_flavor variable
|
1290 karl 1.61 // This allows multiple instances of any keyword.
|
1291 karl 1.60 // Each entity simply sets a bit so that you may
|
1292 karl 1.15 // set disable and enable and we will not know which overrides the other.
|
1293 karl 1.60 // Should create the function to insure that you cannot enable then
1294 // disable or accept the latter and override the former.
|
1295 karl 1.45
1296 explicitFlavor: TOK_ENABLEOVERRIDE
1297 { g_flavor.addFlavor (CIMFlavor::ENABLEOVERRIDE); }
1298 | TOK_DISABLEOVERRIDE { g_flavor.addFlavor (CIMFlavor::DISABLEOVERRIDE); }
1299 | TOK_RESTRICTED { g_flavor.addFlavor (CIMFlavor::RESTRICTED); }
|
1300 kumpf 1.58 | TOK_TOSUBCLASS { g_flavor.addFlavor (CIMFlavor::TOSUBCLASS); }
|
1301 karl 1.45 | TOK_TRANSLATABLE { g_flavor.addFlavor (CIMFlavor::TRANSLATABLE); };
|
1302 bob 1.1
|
1303 e.boden 1.34
|
1304 karl 1.60 flavor: overrideFlavors
1305 {
|
1306 karl 1.64 $$ = &g_flavor;
|
1307 karl 1.60 }
|
1308 kumpf 1.57 | /* empty */
|
1309 karl 1.64 {
|
1310 karl 1.60 g_flavor = CIMFlavor (CIMFlavor::NONE);
1311 $$ = &g_flavor;
|
1312 karl 1.64 } ;
|
1313 e.boden 1.34
|
1314 bob 1.1 overrideFlavors: explicitFlavor
|
1315 karl 1.45 | overrideFlavors explicitFlavor ;
|
1316 bob 1.1
|
1317 karl 1.63 /*
1318 Parse CIM Data types into CIMTYPE values
1319 */
|
1320 bob 1.1 dataType: intDataType { $$ = $1; }
|
1321 karl 1.45 | realDataType { $$ = $1; }
1322 | TOK_DT_STR { $$ = CIMTYPE_STRING; }
1323 | TOK_DT_BOOL { $$ = CIMTYPE_BOOLEAN; }
1324 | TOK_DT_DATETIME { $$ = CIMTYPE_DATETIME; } ;
|
1325 kumpf 1.22
|
1326 e.boden 1.34
|
1327 kumpf 1.22 intDataType: TOK_DT_UINT8 { $$ = CIMTYPE_UINT8; }
|
1328 karl 1.45 | TOK_DT_SINT8 { $$ = CIMTYPE_SINT8; }
1329 | TOK_DT_UINT16 { $$ = CIMTYPE_UINT16; }
1330 | TOK_DT_SINT16 { $$ = CIMTYPE_SINT16; }
1331 | TOK_DT_UINT32 { $$ = CIMTYPE_UINT32; }
1332 | TOK_DT_SINT32 { $$ = CIMTYPE_SINT32; }
1333 | TOK_DT_UINT64 { $$ = CIMTYPE_UINT64; }
1334 | TOK_DT_SINT64 { $$ = CIMTYPE_SINT64; }
1335 | TOK_DT_CHAR16 { $$ = CIMTYPE_CHAR16; } ;
|
1336 karl 1.31
|
1337 e.boden 1.34
|
1338 kumpf 1.57 realDataType: TOK_DT_REAL32
|
1339 karl 1.45 { $$ =CIMTYPE_REAL32; }
|
1340 kumpf 1.57 | TOK_DT_REAL64
|
1341 karl 1.45 { $$ =CIMTYPE_REAL64; };
|
1342 e.boden 1.34
|
1343 karl 1.31 /*
1344 **------------------------------------------------------------------------------
1345 **
1346 ** Qualifier list and qualifier processing
1347 **
1348 **------------------------------------------------------------------------------
1349 */
|
1350 karl 1.45 qualifierList: qualifierListBegin qualifiers TOK_RIGHTSQUAREBRACKET
|
1351 kumpf 1.57 | /* empty */
|
1352 karl 1.45 {
|
1353 karl 1.46 //yydebug = 1; stderr = stdout;
|
1354 karl 1.45 };
|
1355 e.boden 1.34
|
1356 karl 1.45 qualifierListBegin: TOK_LEFTSQUAREBRACKET {
|
1357 karl 1.31 YACCTRACE("qualifierListbegin");
|
1358 kumpf 1.50 g_qualifierList.clear(); } ;
|
1359 bob 1.1
|
1360 karl 1.45 qualifiers: qualifier
1361 { }
1362 | qualifiers TOK_COMMA qualifier
1363 { } ;
|
1364 karl 1.63 /*
1365 qualifier = qualifierName [ qualifierParameter ] [ ":" 1*flavor ]
1366 ; DEPRECATED: The ABNF rule [ ":" 1*flavor ] is used
1367 ; for the concept of implicitly defined qualifier types
1368 ; and is deprecated. See DSP 0004 5.1.2.16 for details.
1369 */
|
1370 kumpf 1.20 qualifier: qualifierName typedQualifierParameter flavor
|
1371 bob 1.1 {
|
1372 karl 1.45 cimmofParser *p = cimmofParser::Instance();
1373 // The qualifier value can't be set until we know the contents of the
1374 // QualifierDeclaration. That's what QualifierValue() does.
1375 CIMValue *v = p->QualifierValue(*$1,
|
1376 karl 1.63 ($2->type == typedInitializerValue::NULL_VALUE),
1377 g_strValType,
1378 *$2->value);
|
1379 karl 1.45 $$ = p->newQualifier(*$1, *v, g_flavor);
|
1380 kumpf 1.50 g_qualifierList.add(*$$);
1381 delete $$;
|
1382 karl 1.45 delete $1;
1383 delete $2->value;
1384 delete v;
1385 } ;
|
1386 e.boden 1.34
|
1387 karl 1.60 // Qualifier name is a SIMPLE_ID or one of the possible metaQualifier names
1388 // i.e. Association or Indication.
1389 qualifierName: TOK_ASSOCIATION
1390 /* Allow the keywords for the metaqualiafiers but keep the
1391 case sensitivity by using name from Lexer */
1392 {
1393 g_flavor = CIMFlavor (CIMFlavor::NONE);
1394 $$ = new String(metaQualifierName);
1395 free(metaQualifierName);
1396 metaQualifierName = 0;
1397 }
1398 | TOK_INDICATION
1399 {
1400 g_flavor = CIMFlavor (CIMFlavor::NONE);
1401 $$ = new String(metaQualifierName);
1402 free(metaQualifierName);
1403 metaQualifierName = 0;
1404 }
|
1405 karl 1.64
1406 // Added because "Reference" is a documented qualifier in addition to
1407 // being a keyword in the syntax.
1408 | TOK_REFERENCE
1409 {
1410 g_flavor = CIMFlavor (CIMFlavor::NONE);
1411 $$ = new String("Reference");
1412 }
|
1413 karl 1.60 | TOK_SIMPLE_IDENTIFIER
1414 {
1415 g_flavor = CIMFlavor (CIMFlavor::NONE);
1416 $$ = $1;
1417 };
|
1418 karl 1.63 /*
1419 qualifierParameter = "(" constantValue ")" / arrayInitializer
1420 RESULT: info in g_typedInitializerValue.
1421 */
|
1422 karl 1.45 typedQualifierParameter: TOK_LEFTPAREN nonNullConstantValue TOK_RIGHTPAREN
1423 {
|
1424 karl 1.63 g_typedInitializerValue.set(
1425 typedInitializerValue::CONSTANT_VALUE, $2);
1426 g_typedInitializerValue.nonNullParserType = g_strValType;
|
1427 karl 1.45 $$ = &g_typedInitializerValue;
1428 }
1429 | TOK_LEFTPAREN TOK_NULL_VALUE TOK_RIGHTPAREN
1430 {
|
1431 karl 1.63 g_typedInitializerValue.setNull();
|
1432 karl 1.45 $$ = &g_typedInitializerValue;
1433 }
1434 | arrayInitializer
1435 {
|
1436 karl 1.63 g_typedInitializerValue.set(
1437 typedInitializerValue::ARRAY_VALUE, $1);
1438 g_typedInitializerValue.nonNullParserType = g_strValType;
|
1439 karl 1.45 $$ = &g_typedInitializerValue;
1440 }
1441 | { /* empty */
|
1442 karl 1.63 g_typedInitializerValue.setNull();
|
1443 karl 1.45 $$ = &g_typedInitializerValue;
1444 };
|
1445 bob 1.1
|
1446 e.boden 1.34
|
1447 bob 1.1 pragmaName: TOK_SIMPLE_IDENTIFIER { $$ = $1; } ;
1448
|
1449 e.boden 1.34
|
1450 bob 1.1 pragmaVal: TOK_STRING_VALUE { $$ = $1; } ;
1451
1452 %%
|
1453 jim.wunderlich 1.40
1454 /*
1455 **==============================================================================
1456 **
1457 ** MOF_error():
1458 **
1459 **==============================================================================
1460 */
1461 static void MOF_error(const char * str, const char * S)
1462 {
|
1463 karl 1.45 printf("%s %s\n", str, S);
|
1464 jim.wunderlich 1.40 }
1465
1466 /*
1467 **==============================================================================
1468 **
1469 ** MOF_trace():
1470 **
1471 **==============================================================================
1472 */
1473 // #define DEBUG_cimmof 1
1474
|
1475 karl 1.61 #ifdef DEBUG_cimmof
|
1476 jim.wunderlich 1.40 static void MOF_trace(const char* str)
1477 {
1478 printf("MOF_trace(): %s \n", str);
1479 }
1480
1481 static void MOF_trace2(const char * str, const char * S)
1482 {
|
1483 karl 1.45 printf("MOF_trace2(): %s %s\n", str, S);
|
1484 karl 1.61 }
1485
|
1486 jim.wunderlich 1.40 #endif // DEBUG_cimmof
|