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 karl 1.31 //ATTN: BB 2001 BB P1 - Fixed size qualifier list max 20. Make larger or var
|
121 kumpf 1.50 CIMQualifierList g_qualifierList;
|
122 bob 1.3 CIMMethod *g_currentMethod = 0;
123 CIMClass *g_currentClass = 0;
124 CIMInstance *g_currentInstance = 0;
|
125 mike 1.41 String g_currentAliasRef; // Alias reference
126 String g_currentAliasDecl; // Alias declaration
|
127 kumpf 1.23 CIMName g_referenceClassName = CIMName();
|
128 kumpf 1.29 Array<CIMKeyBinding> g_KeyBindingArray; // it gets created empty
|
129 karl 1.45 TYPED_INITIALIZER_VALUE g_typedInitializerValue;
|
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 /* ---------------------------------------------------------------- */
153 void
|
154 kumpf 1.20 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 %type <strval> arrayInitializer constantValues
282 %type <strval> fileName referencedObject referenceName referencePath
283 %type <strval> integerValue TOK_REAL_VALUE TOK_CHAR_VALUE
284 %type <strval> namespaceHandle namespaceHandleRef
285 %type <strval> nonNullConstantValue
286 karl 1.45 %type <strval> pragmaName pragmaVal keyValuePairName qualifierName
287 %type <strval> referenceInitializer objectHandle
288 %type <strval> aliasInitializer
289 %type <strval> aliasIdentifier
290 %type <strval> stringValue stringValues initializer constantValue
291 %type <strval> TOK_ALIAS_IDENTIFIER alias
292 %type <strval> TOK_POSITIVE_DECIMAL_VALUE TOK_OCTAL_VALUE TOK_HEX_VALUE
|
293 kumpf 1.47 %type <strval> TOK_BINARY_VALUE TOK_SIGNED_DECIMAL_VALUE
|
294 karl 1.45 %type <strval> TOK_SIMPLE_IDENTIFIER TOK_STRING_VALUE
295 %type <strval> TOK_UNEXPECTED_CHAR
296 %type <typedinitializer> typedInitializer typedDefaultValue
|
297 kumpf 1.20 %type <typedinitializer> typedQualifierParameter
|
298 karl 1.45 %type <value> qualifierValue
|
299 karl 1.31
|
300 e.boden 1.34 %%
|
301 karl 1.31
302 /*
303 **------------------------------------------------------------------------------
304 **
305 ** Production rules section
306 **
307 **------------------------------------------------------------------------------
308 */
|
309 kumpf 1.17 mofSpec: mofProductions ;
|
310 bob 1.1
|
311 e.boden 1.34
|
312 bob 1.1 mofProductions: mofProduction mofProductions
313 | /* empty */ ;
|
314 e.boden 1.34
315
|
316 karl 1.16 // ATTN: P1 KS Apr 2002 Limit in (none) Directive handling. See FIXME below.
|
317 bob 1.1 mofProduction: compilerDirective { /* FIXME: Where do we put directives? */ }
|
318 karl 1.45 | qualifierDeclaration
|
319 kumpf 1.57 {
|
320 karl 1.45 cimmofParser::Instance()->addQualifier($1);
321 delete $1;
322 }
323 | classDeclaration
|
324 kumpf 1.57 {
|
325 karl 1.45 cimmofParser::Instance()->addClass($1);
326 }
327 | instanceDeclaration
328 {
329 cimmofParser::Instance()->addInstance($1);
330 } ;
|
331 e.boden 1.34
|
332 karl 1.31 /*
333 **------------------------------------------------------------------------------
334 **
335 ** class Declaration productions and processing
336 **
337 **------------------------------------------------------------------------------
338 */
|
339 bob 1.1 classDeclaration: classHead classBody
340 {
|
341 karl 1.31 YACCTRACE("classDeclaration");
|
342 jim.wunderlich 1.40 if (g_currentAliasDecl != String::EMPTY)
|
343 karl 1.61 {
344 cimmofParser::Instance()->addClassAlias(g_currentAliasDecl, $$);
345 }
|
346 bob 1.1 } ;
347
|
348 karl 1.61 // NOTE: class alias is deprecated and was removed from DSP0004 between
349 // versions 2.2 and 2.5. It was never implemented in this compiler but
350 // we catch the error in the cimmofParser for now.
|
351 bob 1.1 classHead: qualifierList TOK_CLASS className alias superClass
352 {
|
353 karl 1.31 // create new instance of class with className and superclassName
354 // put returned class object on stack
355 YACCTRACE("classHead:");
356 $$ = cimmofParser::Instance()->newClassDecl(*$3, *$5);
|
357 karl 1.45
|
358 karl 1.31 // put list of qualifiers into class
|
359 kumpf 1.50 applyQualifierList(g_qualifierList, *$$);
|
360 karl 1.45
|
361 jim.wunderlich 1.40 g_currentAliasRef = *$4;
|
362 karl 1.31 if (g_currentClass)
363 delete g_currentClass;
364 g_currentClass = $$;
365 delete $3;
366 delete $4;
367 delete $5;
|
368 kumpf 1.17 } ;
|
369 bob 1.1
|
370 e.boden 1.34
371 className: TOK_SIMPLE_IDENTIFIER {} ;
372
|
373 bob 1.1
|
374 kumpf 1.57 superClass: TOK_COLON className
375 {
376 $$ = new CIMName(*$2);
|
377 dmitry.mikulin 1.51 delete $2;
378 }
|
379 kumpf 1.57 | /* empty */
380 {
381 $$ = new CIMName();
|
382 dmitry.mikulin 1.51 }
|
383 bob 1.1
|
384 e.boden 1.34
|
385 bob 1.1 classBody: TOK_LEFTCURLYBRACE classFeatures TOK_RIGHTCURLYBRACE TOK_SEMICOLON
|
386 karl 1.45 | TOK_LEFTCURLYBRACE TOK_RIGHTCURLYBRACE TOK_SEMICOLON ;
|
387 bob 1.1
|
388 e.boden 1.34
|
389 bob 1.1 classFeatures: classFeature
|
390 karl 1.45 | classFeatures classFeature ;
|
391 bob 1.1
|
392 e.boden 1.34
|
393 kumpf 1.57 classFeature: propertyDeclaration
|
394 karl 1.45 {
395 YACCTRACE("classFeature:applyProperty");
396 cimmofParser::Instance()->applyProperty(*g_currentClass, *$1);
|
397 kumpf 1.57 delete $1;
|
398 karl 1.45 }
|
399 kumpf 1.57 | methodDeclaration
|
400 karl 1.45 {
401 YACCTRACE("classFeature:applyMethod");
|
402 kumpf 1.57 cimmofParser::Instance()->applyMethod(*g_currentClass, *$1);
|
403 karl 1.45 }
|
404 kumpf 1.57 | referenceDeclaration
|
405 karl 1.45 {
406 YACCTRACE("classFeature:applyProperty");
407 cimmofParser::Instance()->applyProperty(*g_currentClass, *$1);
|
408 kumpf 1.57 delete $1;
|
409 karl 1.45 };
|
410 bob 1.1
|
411 e.boden 1.34
412
413
414
415
|
416 karl 1.31 /*
417 **------------------------------------------------------------------------------
418 **
419 ** method Declaration productions and processing.
420 **
421 **------------------------------------------------------------------------------
422 */
423
|
424 karl 1.45 methodDeclaration: qualifierList methodHead methodBody methodEnd
|
425 bob 1.1 {
|
426 karl 1.45 YACCTRACE("methodDeclaration");
427 $$ = $2;
|
428 bob 1.1 } ;
429
|
430 e.boden 1.34
431
|
432 karl 1.31 // methodHead processes the datatype and methodName and puts qualifierList.
|
433 kumpf 1.50 // Note that the qualifierList is parsed in methodDeclaration and applied here
434 // so that it is not overwritten by parameter qualifier lists.
|
435 karl 1.45 methodHead: dataType methodName
|
436 bob 1.1 {
|
437 karl 1.31 YACCTRACE("methodHead");
438 if (g_currentMethod)
|
439 karl 1.45 delete g_currentMethod;
440
441 // create new method instance with pointer to method name and datatype
442 g_currentMethod = cimmofParser::Instance()->newMethod(*$2, $1) ;
|
443 karl 1.31
|
444 karl 1.45 // put new method on stack
445 $$ = g_currentMethod;
|
446 karl 1.31
|
447 karl 1.45 // apply the method qualifier list.
|
448 kumpf 1.50 applyQualifierList(g_qualifierList, *$$);
|
449 karl 1.31
|
450 karl 1.45 delete $2;
|
451 bob 1.1 } ;
452
|
453 e.boden 1.34
|
454 bob 1.1 methodBody: TOK_LEFTPAREN parameters TOK_RIGHTPAREN ;
455
|
456 e.boden 1.34
|
457 bob 1.1 methodEnd: TOK_SEMICOLON ;
458
|
459 e.boden 1.34
|
460 kumpf 1.57 methodName: TOK_SIMPLE_IDENTIFIER
461 {
462 $$ = new CIMName(*$1);
|
463 dmitry.mikulin 1.51 delete $1;
464 }
|
465 karl 1.31
|
466 e.boden 1.34
|
467 karl 1.31 //
468 // Productions for method parameters
469 //
470 parameters : parameter
|
471 karl 1.45 | parameters TOK_COMMA parameter
472 | /* empty */ ;
|
473 karl 1.31
|
474 e.boden 1.34
|
475 karl 1.45 parameter: qualifierList parameterType parameterName array
476 {
477 // ATTN: P2 2002 Question Need to create default value including type?
|
478 karl 1.31
|
479 karl 1.45 YACCTRACE("parameter:");
480 CIMParameter *p = 0;
481 cimmofParser *cp = cimmofParser::Instance();
482
483 // Create new parameter with name, type, isArray, array, referenceClassName
484 if ($4 == -1) {
485 p = cp->newParameter(*$3, $2, false, 0, g_referenceClassName);
486 }
487 else
488 {
489 p = cp->newParameter(*$3, $2, true, $4, g_referenceClassName);
490 }
|
491 e.boden 1.34
|
492 karl 1.45 g_referenceClassName = CIMName();
|
493 karl 1.31
|
494 karl 1.45 YACCTRACE("parameter:applyQualifierList");
|
495 kumpf 1.50 applyQualifierList(g_qualifierList, *p);
|
496 e.boden 1.34
|
497 karl 1.45 cp->applyParameter(*g_currentMethod, *p);
498 delete p;
499 delete $3;
500 } ;
|
501 e.boden 1.34
502
|
503 karl 1.45 parameterType: dataType { $$ = $1; }
504 | objectRef { $$ = CIMTYPE_REFERENCE; } ;
|
505 e.boden 1.34
506
|
507 karl 1.31 /*
508 **------------------------------------------------------------------------------
509 **
510 ** property Declaration productions and processing
511 **
512 **------------------------------------------------------------------------------
513 */
|
514 e.boden 1.34
|
515 karl 1.45 propertyDeclaration: qualifierList propertyBody propertyEnd
|
516 bob 1.1 {
|
517 karl 1.31 // set body to stack and apply qualifier list
518 // ATTN: the apply qualifer only works here because
519 // there are not lower level qualifiers. We do productions
520 // that might have lower level qualifiers differently by
|
521 karl 1.45 // setting up a xxxHead production where qualifiers are
|
522 karl 1.31 // applied.
523 YACCTRACE("propertyDeclaration:");
524 $$ = $2;
|
525 kumpf 1.50 applyQualifierList(g_qualifierList, *$$);
|
526 bob 1.1 } ;
527
|
528 e.boden 1.34
|
529 kumpf 1.18 propertyBody: dataType propertyName array typedDefaultValue
|
530 bob 1.1 {
|
531 karl 1.45 CIMValue *v = valueFactory::createValue($1, $3,
532 ($4->type == CIMMOF_NULL_VALUE), $4->value);
|
533 karl 1.61
534 // if scalar, $3 == -1 so set arrayDimension to zero.
|
535 kumpf 1.57 if ($3 == -1)
|
536 karl 1.45 {
|
537 karl 1.61 $$ = cimmofParser::Instance()->newProperty(*$2, *v, 0);
|
538 kumpf 1.57 }
539 else
|
540 karl 1.45 {
|
541 karl 1.61 $$ = cimmofParser::Instance()->newProperty(*$2, *v, $3);
|
542 karl 1.45 }
543
544 delete $2;
545 delete $4->value;
546 delete v;
|
547 bob 1.1 } ;
548
|
549 e.boden 1.34
|
550 bob 1.1 propertyEnd: TOK_SEMICOLON ;
|
551 e.boden 1.34
552
|
553 karl 1.31 /*
554 **------------------------------------------------------------------------------
555 **
556 ** reference Declaration productions and processing
557 **
558 **------------------------------------------------------------------------------
559 */
|
560 bob 1.1
561 referenceDeclaration: qualifierList referencedObject TOK_REF referenceName
|
562 karl 1.45 referencePath TOK_SEMICOLON
|
563 bob 1.1 {
|
564 karl 1.45 String s(*$2);
565 if (!String::equal(*$5, String::EMPTY))
566 s.append("." + *$5);
567 CIMValue *v = valueFactory::createValue(CIMTYPE_REFERENCE, -1, true, &s);
|
568 karl 1.61 $$ = cimmofParser::Instance()->newProperty(*$4, *v, 0, *$2);
|
569 kumpf 1.50 applyQualifierList(g_qualifierList, *$$);
|
570 karl 1.45 delete $2;
571 delete $4;
572 delete $5;
573 delete v;
|
574 bob 1.1 } ;
575
|
576 e.boden 1.34
|
577 bob 1.1 referencedObject: TOK_SIMPLE_IDENTIFIER { $$ = $1; } ;
578
|
579 e.boden 1.34
|
580 bob 1.1 referenceName: TOK_SIMPLE_IDENTIFIER { $$ = $1; };
581
|
582 e.boden 1.34
|
583 bob 1.1 referencePath: TOK_EQUAL stringValue { $$ = $2; }
|
584 karl 1.45 | /* empty */ { $$ = new String(String::EMPTY); } ;
|
585 bob 1.1
|
586 e.boden 1.34
|
587 kumpf 1.57 objectRef: className TOK_REF
|
588 dmitry.mikulin 1.51 {
|
589 kumpf 1.57 g_referenceClassName = *$1;
|
590 dmitry.mikulin 1.51 delete $1;
591 }
|
592 bob 1.1
|
593 e.boden 1.34
|
594 kumpf 1.57 parameterName: TOK_SIMPLE_IDENTIFIER
595 {
596 $$ = new CIMName(*$1);
|
597 dmitry.mikulin 1.51 delete $1;
598 }
|
599 bob 1.1
|
600 e.boden 1.34
|
601 kumpf 1.57 propertyName: TOK_SIMPLE_IDENTIFIER
602 {
603 $$ = new CIMName(*$1);
|
604 dmitry.mikulin 1.51 delete $1;
605 }
|
606 bob 1.1
|
607 karl 1.61 // array definition syntax with dimension integer found [xxx] or
608 // dimension integer empty or not array definition
609 array: TOK_LEFTSQUAREBRACKET TOK_POSITIVE_DECIMAL_VALUE TOK_RIGHTSQUAREBRACKET
|
610 kumpf 1.47 {
|
611 kumpf 1.48 $$ = (Uint32) valueFactory::stringToUint(*$2, CIMTYPE_UINT32);
|
612 karl 1.45 delete $2;
613 }
|
614 karl 1.61
615 // array syntax with no number []
|
616 karl 1.45 | TOK_LEFTSQUAREBRACKET TOK_RIGHTSQUAREBRACKET
617 { $$ = 0; }
|
618 karl 1.61
619 // no array definition syntax.
|
620 kumpf 1.57 | /* empty */
|
621 karl 1.45 { $$ = -1; } ;
622
623
624 typedDefaultValue: TOK_EQUAL typedInitializer { $$ = $2; }
|
625 kumpf 1.57 |
|
626 karl 1.45 { /* empty */
627 g_typedInitializerValue.type = CIMMOF_NULL_VALUE;
628 g_typedInitializerValue.value = new String(String::EMPTY);
629 $$ = &g_typedInitializerValue;
630 };
631
632
|
633 kumpf 1.57 initializer: constantValue
|
634 karl 1.45 { $$ = $1; }
635 | arrayInitializer
636 { $$ = $1; }
637 | referenceInitializer
638 { $$ = $1; } ;
|
639 bob 1.1
|
640 e.boden 1.34
|
641 karl 1.45 // The typedInitializer element is syntactially identical to
642 // the initializer element. However, the typedInitializer element
|
643 kumpf 1.17 // returns, in addition to the value, the type of the value.
|
644 karl 1.45 typedInitializer: nonNullConstantValue
645 {
646 g_typedInitializerValue.type = CIMMOF_CONSTANT_VALUE;
647 g_typedInitializerValue.value = $1;
648 $$ = &g_typedInitializerValue;
649 }
650 | TOK_NULL_VALUE
651 {
652 g_typedInitializerValue.type = CIMMOF_NULL_VALUE;
653 g_typedInitializerValue.value = new String(String::EMPTY);
654 $$ = &g_typedInitializerValue;
655 }
656 | arrayInitializer
657 {
658 g_typedInitializerValue.type = CIMMOF_ARRAY_VALUE;
659 g_typedInitializerValue.value = $1;
660 $$ = &g_typedInitializerValue;
661 }
662 | referenceInitializer
663 {
664 g_typedInitializerValue.type = CIMMOF_REFERENCE_VALUE;
665 karl 1.45 g_typedInitializerValue.value = $1;
666 $$ = &g_typedInitializerValue;
667 };
|
668 kumpf 1.17
|
669 e.boden 1.34
|
670 karl 1.32 // BUG 497 - Commmas embedded in strings in arrays change the
671 // strings. Aded function stringWComma to escape commas.
|
672 karl 1.45 constantValues: constantValue
673 {
674 *$$ = valueFactory::stringWComma(String(*$1)); }
675 | constantValues TOK_COMMA constantValue
676 {
677 YACCTRACE("constantValues:1, Value= " << *$3);
678 (*$$).append(",");
679 //(*$$).append(*$3);
680 (*$$).append(valueFactory::stringWComma(String(*$3)));
681 delete $3;
682 } ;
|
683 bob 1.1
|
684 e.boden 1.34
|
685 karl 1.45 // The nonNullConstantValue has been added to allow NULL
|
686 kumpf 1.17 // to be distinguished from the EMPTY STRING.
687
|
688 karl 1.45 constantValue: nonNullConstantValue
689 {$$ = $1;}
690 | TOK_NULL_VALUE
691 { $$ = new String(String::EMPTY); } ;
|
692 kumpf 1.17
|
693 e.boden 1.34
|
694 kumpf 1.17 nonNullConstantValue: integerValue { $$ = $1; }
|
695 karl 1.45 | TOK_REAL_VALUE
696 { $$ = $1; }
697 | TOK_CHAR_VALUE
698 { $$ = $1; }
699 | stringValues
700 { }
|
701 kumpf 1.57 | booleanValue
|
702 karl 1.45 {
703 $$ = new String($1 ? "T" : "F");
704 };
|
705 bob 1.1
|
706 e.boden 1.34
|
707 bob 1.1 integerValue: TOK_POSITIVE_DECIMAL_VALUE
|
708 karl 1.45 | TOK_OCTAL_VALUE
709 | TOK_HEX_VALUE
710 | TOK_BINARY_VALUE
|
711 kumpf 1.47 | TOK_SIGNED_DECIMAL_VALUE;
|
712 karl 1.45
713
714 booleanValue: TOK_FALSE
715 { $$ = 0; }
716 | TOK_TRUE
717 { $$ = 1; } ;
|
718 bob 1.1
|
719 e.boden 1.34
|
720 bob 1.1 stringValues: stringValue { $$ = $1; }
|
721 karl 1.45 | stringValues stringValue
722 {
723 (*$$).append(*$2); delete $2;
724 } ;
|
725 bob 1.1
|
726 e.boden 1.34
|
727 karl 1.45 stringValue: TOK_STRING_VALUE
728 {
|
729 e.boden 1.34 //String oldrep = *$1;
730 //String s(oldrep), s1(String::EMPTY);
|
731 bob 1.1 // Handle quoted quote
|
732 e.boden 1.34 //int len = s.size();
733 //if (s[len] == '\n') {
734 //error: new line inside a string constant unless it is quoted
735 //if (s[len - 2] == '\\') {
736 //if (len > 3)
|
737 karl 1.45 //s1 = s.subString(1, len-3);
|
738 e.boden 1.34 //} else {
739 //cimmof_error("New line in string constant");
740 //}
741 //cimmofParser::Instance()->increment_lineno();
742 //} else { // Can only be a quotation mark
743 //if (s[len - 2] == '\\') { // if it is quoted
744 //if (len > 3) s1 = s.subString(1, len-3);
745 //s1.append('\"');
746 //cimmof_yy_less(len-1);
747 //} else { // This is the normal case: real quotes on both end
748 //s1 = s.subString(1, len - 2) ;
749 //}
750 //}
751 //delete $1;
752 $$ = //new String(s1);
753 new String(*$1);
754 delete $1;
|
755 kumpf 1.17 } ;
|
756 bob 1.1
|
757 e.boden 1.34
|
758 karl 1.45 arrayInitializer:
759 TOK_LEFTCURLYBRACE constantValues TOK_RIGHTCURLYBRACE
760 { $$ = $2; }
761 | TOK_LEFTCURLYBRACE TOK_RIGHTCURLYBRACE
762 { $$ = new String(String::EMPTY); };
|
763 bob 1.1
|
764 e.boden 1.34
|
765 bob 1.1 referenceInitializer: objectHandle {}
|
766 karl 1.45 | aliasInitializer { } ;
|
767 bob 1.1
|
768 e.boden 1.34
|
769 bob 1.1 objectHandle: TOK_DQUOTE namespaceHandleRef modelPath TOK_DQUOTE
|
770 karl 1.45 {
|
771 kumpf 1.49 // The objectName string is decomposed for syntactical validation purposes
772 // and reassembled here for later parsing in creation of an CIMObjectPath
773 // instance
|
774 karl 1.45 String *s = new String(*$2);
775 if (!String::equal(*s, String::EMPTY) && $3)
|
776 karl 1.61 {
|
777 karl 1.45 (*s).append(":");
|
778 karl 1.61 }
779 if ($3)
780 {
|
781 kumpf 1.49 (*s).append($3->toString());
|
782 karl 1.45 }
783 $$ = s;
784 delete $2;
785 delete $3;
786 MOF_trace2 ("objectHandle done $$ = ", $$->getCString());
|
787 kumpf 1.17 } ;
|
788 bob 1.1
|
789 e.boden 1.34
|
790 karl 1.45 aliasInitializer : aliasIdentifier
791 {
792
793 CIMObjectPath AOP;
|
794 jim.wunderlich 1.40
|
795 karl 1.45 MOF_trace2("aliasInitializer $$ = ", $$->getCString());
796 MOF_trace2("aliasInitializer $1 = ", $1->getCString());
|
797 jim.wunderlich 1.40
|
798 karl 1.45 g_currentAliasRef = *$$;
|
799 jim.wunderlich 1.40
|
800 karl 1.45 MOF_trace2("aliasInitializer g_currentAliasRef = ",
801 g_currentAliasRef.getCString());
802 if (cimmofParser::Instance()->getInstanceAlias(g_currentAliasRef, AOP) == 0)
|
803 jim.wunderlich 1.40 {
|
804 karl 1.61 MOF_error("ERROR: aliasIdentifier NOT FOUND: aliasIdentifier = ",
805 g_currentAliasRef.getCString());
|
806 karl 1.45 yyerror("aliasInitializer - 'aliasIdentifier' NOT FOUND");
807 YYABORT;
|
808 jim.wunderlich 1.40 }
809
|
810 karl 1.45 String *s = new String(AOP.toString());
|
811 jim.wunderlich 1.40
|
812 karl 1.45 $$ = s;
813
814 delete $1;
815
816 MOF_trace2 ("aliasInitializer done $$ = ", $$->getCString());
|
817 jim.wunderlich 1.40
818 };
|
819 bob 1.3
|
820 e.boden 1.34
|
821 bob 1.1 namespaceHandleRef: namespaceHandle TOK_COLON
|
822 karl 1.45 { }
823 | /* empty */ { $$ = new String(String::EMPTY); };
|
824 bob 1.1
|
825 e.boden 1.34
|
826 bob 1.1 namespaceHandle: stringValue {};
827
|
828 karl 1.61 // create a model CIMObject path from <className>.<keyValuePairList>
829 modelPath: className TOK_PERIOD keyValuePairList
830 {
831 CIMObjectPath * m = new CIMObjectPath(String::EMPTY,
832 CIMNamespaceName(),
833 (*$1).getString(),
834 g_KeyBindingArray);
835
836 g_KeyBindingArray.clear();
837 delete $1;
|
838 e.boden 1.34
|
839 karl 1.61 $$ = m;
|
840 bob 1.1
|
841 karl 1.61 MOF_trace2 ("modelPath done $$ = ", $$->toString().getCString());
842 } ;
|
843 e.boden 1.34
|
844 karl 1.61 // gets the list of keyValuePairs into the global KeyBindingArray
845 // keyValuePairList := <keyValuePair> [, <keyValuePair>]
846 // Returns SS = 0 because value in global
|
847 karl 1.45 keyValuePairList: keyValuePair
848 { $$ = 0; }
849 | keyValuePairList TOK_COMMA keyValuePair
850 { $$ = 0; } ;
|
851 bob 1.1
|
852 karl 1.61 // parse one keybinding and append to global KeyBindingArray.
|
853 karl 1.45 keyValuePair: keyValuePairName TOK_EQUAL initializer
854 {
|
855 kumpf 1.49 CIMKeyBinding::Type keyBindingType;
856 Char16 firstChar = (*$3)[0];
|
857 dev.meetei 1.59 if (firstChar == '\"')
|
858 kumpf 1.49 keyBindingType = CIMKeyBinding::STRING;
859 else if ((firstChar == 'T') || (firstChar == 't') ||
860 (firstChar == 'F') || (firstChar == 'f'))
861 keyBindingType = CIMKeyBinding::BOOLEAN;
862 else
863 keyBindingType = CIMKeyBinding::NUMERIC;
864 CIMKeyBinding *kb = new CIMKeyBinding(*$1, *$3, keyBindingType);
|
865 karl 1.45 g_KeyBindingArray.append(*kb);
866 delete kb;
867 delete $1;
|
868 kumpf 1.57 delete $3;
|
869 karl 1.45 } ;
|
870 bob 1.1
|
871 e.boden 1.34
|
872 bob 1.1 keyValuePairName: TOK_SIMPLE_IDENTIFIER ;
873
|
874 e.boden 1.34
|
875 karl 1.45 alias: TOK_AS aliasIdentifier
876 {
877 $$ = $2;
878 g_currentAliasDecl = *$2;
879 MOF_trace2("aliasIdentifier $$ = ", $$->getCString());
880 MOF_trace2("aliasIdentifier g_currentAliasDecl = ",
881 g_currentAliasDecl.getCString());
882
883 }
884 | /* empty */ {
885 $$ = new String(String::EMPTY);
886 g_currentAliasDecl = String::EMPTY} ;
|
887 e.boden 1.34
|
888 bob 1.1
889 aliasIdentifier: TOK_ALIAS_IDENTIFIER ;
890
|
891 e.boden 1.34
|
892 karl 1.31 /*
893 **------------------------------------------------------------------------------
894 **
895 ** Instance Declaration productions and processing
896 **
|
897 jim.wunderlich 1.40 **-----------------------------------------------------------------------------
|
898 karl 1.31 */
899
|
900 bob 1.1 instanceDeclaration: instanceHead instanceBody
|
901 karl 1.45 {
902 $$ = g_currentInstance;
903 if (g_currentAliasDecl != String::EMPTY)
|
904 jim.wunderlich 1.40 {
|
905 karl 1.45 MOF_trace2("instanceDeclaration g_currentAliasDecl = ",
906 g_currentAliasDecl.getCString());
|
907 karl 1.61
|
908 karl 1.45 if (cimmofParser::Instance()->addInstanceAlias(
|
909 karl 1.61 g_currentAliasDecl, $$) == 0)
|
910 karl 1.45 {
911 // Error alias already exist
912 MOF_error("ERROR: alias ALREADY EXISTS: aliasIdentifier = ",
913 g_currentAliasDecl.getCString());
914 yyerror("instanceDeclaration - 'aliasIdentifier' ALREADY EXISTS");
915 YYABORT;
916 }
|
917 jim.wunderlich 1.40 }
|
918 bob 1.1 };
919
|
920 e.boden 1.34
921
|
922 karl 1.45 instanceHead: qualifierList TOK_INSTANCE TOK_OF className alias
|
923 bob 1.1 {
|
924 karl 1.45 if (g_currentInstance)
925 delete g_currentInstance;
926 g_currentAliasDecl = *$5;
927 g_currentInstance = cimmofParser::Instance()->newInstance(*$4);
928 // apply the qualifierlist to the current instance
929 $$ = g_currentInstance;
|
930 kumpf 1.50 applyQualifierList(g_qualifierList, *$$);
|
931 karl 1.45 delete $4;
932 delete $5;
933 if (g_currentAliasDecl != String::EMPTY)
|
934 karl 1.61 {
|
935 karl 1.45 MOF_trace2("instanceHead g_currentAliasDecl = ",
936 g_currentAliasDecl.getCString());
|
937 karl 1.61 }
|
938 bob 1.1 } ;
939
|
940 e.boden 1.34
941
|
942 bob 1.1 instanceBody: TOK_LEFTCURLYBRACE valueInitializers TOK_RIGHTCURLYBRACE
|
943 karl 1.45 TOK_SEMICOLON ;
|
944 bob 1.1
|
945 e.boden 1.34
946
|
947 bob 1.1 valueInitializers: valueInitializer
|
948 karl 1.45 | valueInitializers valueInitializer ;
|
949 bob 1.1
|
950 e.boden 1.34
951
|
952 kumpf 1.17 // ATTN-DE-P1-20020427: Processing NULL Initializer values is incomplete.
|
953 karl 1.45 // Currently only the arrayInitializer element has been modified to
|
954 kumpf 1.17 // return CIMMOF_NULL_VALUE
955 valueInitializer: qualifierList TOK_SIMPLE_IDENTIFIER TOK_EQUAL
|
956 karl 1.45 typedInitializer TOK_SEMICOLON
|
957 bob 1.1 {
|
958 kumpf 1.52 AutoPtr<String> identifier($2);
|
959 karl 1.45 cimmofParser *cp = cimmofParser::Instance();
960 // ATTN: P1 InstanceUpdate function 2001 BB Instance update needs
961 // work here and CIMOM
962 // a property. It must be fixed in the Common code first.
963 // What we have to do here is create a CIMProperty and initialize it with
964 // the value provided. The name of the property is $2 and it belongs
965 // to the class whose name is in g_currentInstance->getClassName().
966 // The steps are
967 // 2. Get property declaration's value object
|
968 kumpf 1.52 CIMProperty *oldprop =
969 cp->PropertyFromInstance(*g_currentInstance, *identifier);
|
970 karl 1.45 CIMValue *oldv = cp->ValueFromProperty(*oldprop);
971
972 // 3. create the new Value object of the same type
973
974 // We want createValue to interpret a value as an array if is enclosed
975 // in {}s (e.g., { 2 } or {2, 3, 5}) or it is NULL and the property is
976 // defined as an array. createValue is responsible for the actual
977 // validation.
978
979 CIMValue *v = valueFactory::createValue(oldv->getType(),
|
980 kumpf 1.53 (($4->type == CIMMOF_ARRAY_VALUE) ||
981 (($4->type == CIMMOF_NULL_VALUE) && oldprop->isArray()))?0:-1,
|
982 karl 1.45 ($4->type == CIMMOF_NULL_VALUE),
983 $4->value);
984
985
986 // 4. create a clone property with the new value
987 CIMProperty *newprop = cp->copyPropertyWithNewValue(*oldprop, *v);
988
989 // 5. apply the qualifiers;
|
990 kumpf 1.50 applyQualifierList(g_qualifierList, *newprop);
|
991 karl 1.45
992 // 6. and apply the CIMProperty to g_currentInstance.
993 cp->applyProperty(*g_currentInstance, *newprop);
994 delete $4->value;
995 delete oldprop;
996 delete oldv;
997 delete v;
998 delete newprop;
|
999 e.boden 1.34 };
1000
1001
1002
1003
|
1004 bob 1.1
|
1005 karl 1.31 /*
1006 **------------------------------------------------------------------------------
1007 **
1008 ** Compiler directive productions and processing
1009 **
1010 **------------------------------------------------------------------------------
1011 */
1012
|
1013 bob 1.1 compilerDirective: compilerDirectiveInclude
|
1014 karl 1.45 {
1015 //printf("compilerDirectiveInclude ");
1016 }
1017 | compilerDirectivePragma
1018 {
1019 //printf("compilerDirectivePragma ");
1020 } ;
|
1021 bob 1.1
|
1022 e.boden 1.34
|
1023 bob 1.1 compilerDirectiveInclude: TOK_PRAGMA TOK_INCLUDE TOK_LEFTPAREN fileName
|
1024 karl 1.45 TOK_RIGHTPAREN
1025 {
1026 cimmofParser::Instance()->enterInlineInclude(*$4); delete $4;
1027 };
|
1028 e.boden 1.34
|
1029 bob 1.1
1030 fileName: stringValue { $$ = $1; } ;
|
1031 e.boden 1.34
1032
|
1033 bob 1.1 compilerDirectivePragma: TOK_PRAGMA pragmaName
|
1034 karl 1.45 TOK_LEFTPAREN pragmaVal TOK_RIGHTPAREN
1035 {
1036 cimmofParser::Instance()->processPragma(*$2, *$4);
1037 delete $2;
1038 delete $4;
1039 };
|
1040 bob 1.1
|
1041 e.boden 1.34
1042
1043
|
1044 karl 1.31 /*
1045 **------------------------------------------------------------------------------
1046 **
1047 ** qualifier Declaration productions and processing
1048 **
1049 **------------------------------------------------------------------------------
1050 */
1051
|
1052 karl 1.60 /**
1053 qualifierDeclaration = QUALIFIER qualifierName qualifierType scope
1054 [ defaultFlavor ] ";"
1055 */
1056
|
1057 bob 1.1 qualifierDeclaration: TOK_QUALIFIER qualifierName qualifierValue scope
|
1058 karl 1.45 defaultFlavor TOK_SEMICOLON
|
1059 bob 1.1 {
|
1060 karl 1.45 $$ = cimmofParser::Instance()->newQualifierDecl(*$2, $3, *$4, *$5);
|
1061 karl 1.60 delete $2; // String created in qualifierName
|
1062 karl 1.45 delete $3; // CIMValue object created in qualifierValue production
|
1063 dmitry.mikulin 1.51 delete $4; // CIMScope object created in scope/metaElements production
|
1064 bob 1.1 } ;
1065
|
1066 karl 1.60 /**
1067 qualifierType = ":" dataType [ array ] [ defaultValue ]
1068 */
|
1069 kumpf 1.18 qualifierValue: TOK_COLON dataType array typedDefaultValue
|
1070 karl 1.60 {
1071 $$ = valueFactory::createValue($2, $3,
1072 ($4->type == CIMMOF_NULL_VALUE),
1073 $4->value);
1074 delete $4->value;
1075 } ;
|
1076 bob 1.1
|
1077 karl 1.60 /**
1078 scope = "," SCOPE "(" metaElement *( "," metaElement ) ")"
1079 */
1080 // empty implies no scope definition and is illegal
1081 scope: scope_begin metaElements TOK_RIGHTPAREN
1082 {
1083 $$ = $2;
1084 } ;
1085 | /* empty*/
1086 {
1087 // terminate in error, no scope statement
1088 yyerror("\"scope\" definition required on Qualifier Declaration");
1089 }
|
1090 e.boden 1.34
|
1091 karl 1.60 // Production set scope NONE
|
1092 karl 1.45 scope_begin: TOK_COMMA TOK_SCOPE TOK_LEFTPAREN
1093 {
|
1094 karl 1.60 g_scope = CIMScope (CIMScope::NONE);
|
1095 karl 1.45 } ;
|
1096 bob 1.1
|
1097 karl 1.60 /* aggregate the keywords used to define scope */
1098 metaElements: metaElement
|
1099 karl 1.61 { /* empty */
|
1100 karl 1.60 $$ = $1;
1101 }
|
1102 karl 1.45 | metaElements TOK_COMMA metaElement
|
1103 kumpf 1.57 {
1104 $$->addScope(*$3);
|
1105 dmitry.mikulin 1.51 delete $3;
1106 } ;
|
1107 e.boden 1.34
|
1108 karl 1.60 /* Resolve each possible scope keyword (metaElement). Each TOK adds a
1109 returns one scope type. The ASSOCIATION and INDICATION free the
1110 variable metaQualifierName since that could be set either by the
1111 Keywords as a Scope token or metaQualifier name (i.e. these keywords
|
1112 karl 1.61 usage is context sensitive)
|
1113 karl 1.60 metaElement = CLASS / ASSOCIATION / INDICATION / QUALIFIER
1114 PROPERTY / REFERENCE / METHOD / PARAMETER / ANY
1115 */
|
1116 kumpf 1.26 metaElement: TOK_CLASS { $$ = new CIMScope(CIMScope::CLASS); }
|
1117 karl 1.60 | TOK_ASSOCIATION { free(metaQualifierName);
1118 metaQualifierName = 0;
1119 $$ = new CIMScope(CIMScope::ASSOCIATION); }
1120 | TOK_INDICATION { free(metaQualifierName);
1121 metaQualifierName = 0;
1122 $$ = new CIMScope(CIMScope::INDICATION); }
|
1123 kumpf 1.26 | TOK_PROPERTY { $$ = new CIMScope(CIMScope::PROPERTY); }
1124 | TOK_REFERENCE { $$ = new CIMScope(CIMScope::REFERENCE); }
1125 | TOK_METHOD { $$ = new CIMScope(CIMScope::METHOD); }
1126 | TOK_PARAMETER { $$ = new CIMScope(CIMScope::PARAMETER); }
1127 | TOK_ANY { $$ = new CIMScope(CIMScope::ANY); } ;
|
1128 bob 1.1
|
1129 e.boden 1.34
|
1130 karl 1.60 // Set the default if no FlavorHead or accumulated explicitFlavors
1131 /**
1132 defaultFlavor = "," FLAVOR "(" flavor *( "," flavor ) ")"
1133 */
|
1134 bob 1.1 defaultFlavor: TOK_COMMA flavorHead explicitFlavors TOK_RIGHTPAREN
|
1135 karl 1.45 { $$ = &g_flavor; }
|
1136 kumpf 1.57 | /* empty */
|
1137 dmitry.mikulin 1.51 {
1138 g_flavor = CIMFlavor (CIMFlavor::NONE);
1139 $$ = &g_flavor;
1140 } ;
|
1141 bob 1.1
|
1142 karl 1.11 // Set the flavors for the defaults required: via DEFAULTS
|
1143 kumpf 1.57 flavorHead: TOK_FLAVOR TOK_LEFTPAREN
|
1144 karl 1.45 {g_flavor = CIMFlavor (CIMFlavor::NONE);};
|
1145 bob 1.1
|
1146 karl 1.60 // gather comma-separated explicitFlavor keywords into g_flavor
|
1147 bob 1.1 explicitFlavors: explicitFlavor
|
1148 karl 1.45 | explicitFlavors TOK_COMMA explicitFlavor ;
|
1149 bob 1.1
|
1150 karl 1.60 // Get an explicitFlavor keyword and add to the g_flavor variable
|
1151 karl 1.61 // This allows multiple instances of any keyword.
|
1152 karl 1.60 // Each entity simply sets a bit so that you may
|
1153 karl 1.15 // set disable and enable and we will not know which overrides the other.
|
1154 karl 1.60 // Should create the function to insure that you cannot enable then
1155 // disable or accept the latter and override the former.
|
1156 karl 1.45
1157 explicitFlavor: TOK_ENABLEOVERRIDE
1158 { g_flavor.addFlavor (CIMFlavor::ENABLEOVERRIDE); }
1159 | TOK_DISABLEOVERRIDE { g_flavor.addFlavor (CIMFlavor::DISABLEOVERRIDE); }
1160 | TOK_RESTRICTED { g_flavor.addFlavor (CIMFlavor::RESTRICTED); }
|
1161 kumpf 1.58 | TOK_TOSUBCLASS { g_flavor.addFlavor (CIMFlavor::TOSUBCLASS); }
|
1162 karl 1.45 | TOK_TRANSLATABLE { g_flavor.addFlavor (CIMFlavor::TRANSLATABLE); };
|
1163 bob 1.1
|
1164 e.boden 1.34
|
1165 karl 1.60 flavor: overrideFlavors
1166 {
1167 $$ = &g_flavor;
1168 }
|
1169 kumpf 1.57 | /* empty */
|
1170 karl 1.60 {
1171 g_flavor = CIMFlavor (CIMFlavor::NONE);
1172 $$ = &g_flavor;
1173 } ;
|
1174 e.boden 1.34
|
1175 bob 1.1 overrideFlavors: explicitFlavor
|
1176 karl 1.45 | overrideFlavors explicitFlavor ;
|
1177 bob 1.1
|
1178 e.boden 1.34
|
1179 bob 1.1 dataType: intDataType { $$ = $1; }
|
1180 karl 1.45 | realDataType { $$ = $1; }
1181 | TOK_DT_STR { $$ = CIMTYPE_STRING; }
1182 | TOK_DT_BOOL { $$ = CIMTYPE_BOOLEAN; }
1183 | TOK_DT_DATETIME { $$ = CIMTYPE_DATETIME; } ;
|
1184 kumpf 1.22
|
1185 e.boden 1.34
|
1186 kumpf 1.22 intDataType: TOK_DT_UINT8 { $$ = CIMTYPE_UINT8; }
|
1187 karl 1.45 | TOK_DT_SINT8 { $$ = CIMTYPE_SINT8; }
1188 | TOK_DT_UINT16 { $$ = CIMTYPE_UINT16; }
1189 | TOK_DT_SINT16 { $$ = CIMTYPE_SINT16; }
1190 | TOK_DT_UINT32 { $$ = CIMTYPE_UINT32; }
1191 | TOK_DT_SINT32 { $$ = CIMTYPE_SINT32; }
1192 | TOK_DT_UINT64 { $$ = CIMTYPE_UINT64; }
1193 | TOK_DT_SINT64 { $$ = CIMTYPE_SINT64; }
1194 | TOK_DT_CHAR16 { $$ = CIMTYPE_CHAR16; } ;
|
1195 karl 1.31
|
1196 e.boden 1.34
|
1197 kumpf 1.57 realDataType: TOK_DT_REAL32
|
1198 karl 1.45 { $$ =CIMTYPE_REAL32; }
|
1199 kumpf 1.57 | TOK_DT_REAL64
|
1200 karl 1.45 { $$ =CIMTYPE_REAL64; };
|
1201 e.boden 1.34
|
1202 karl 1.31 /*
1203 **------------------------------------------------------------------------------
1204 **
1205 ** Qualifier list and qualifier processing
1206 **
1207 **------------------------------------------------------------------------------
1208 */
|
1209 karl 1.45 qualifierList: qualifierListBegin qualifiers TOK_RIGHTSQUAREBRACKET
|
1210 kumpf 1.57 | /* empty */
|
1211 karl 1.45 {
|
1212 karl 1.46 //yydebug = 1; stderr = stdout;
|
1213 karl 1.45 };
|
1214 e.boden 1.34
|
1215 karl 1.45 qualifierListBegin: TOK_LEFTSQUAREBRACKET {
|
1216 karl 1.31 YACCTRACE("qualifierListbegin");
|
1217 kumpf 1.50 g_qualifierList.clear(); } ;
|
1218 bob 1.1
|
1219 karl 1.45 qualifiers: qualifier
1220 { }
1221 | qualifiers TOK_COMMA qualifier
1222 { } ;
|
1223 e.boden 1.34
|
1224 kumpf 1.20 qualifier: qualifierName typedQualifierParameter flavor
|
1225 bob 1.1 {
|
1226 karl 1.45 cimmofParser *p = cimmofParser::Instance();
1227 // The qualifier value can't be set until we know the contents of the
1228 // QualifierDeclaration. That's what QualifierValue() does.
1229 CIMValue *v = p->QualifierValue(*$1,
1230 ($2->type == CIMMOF_NULL_VALUE), *$2->value);
1231 $$ = p->newQualifier(*$1, *v, g_flavor);
|
1232 kumpf 1.50 g_qualifierList.add(*$$);
1233 delete $$;
|
1234 karl 1.45 delete $1;
1235 delete $2->value;
1236 delete v;
1237 } ;
|
1238 e.boden 1.34
|
1239 karl 1.60 // Qualifier name is a SIMPLE_ID or one of the possible metaQualifier names
1240 // i.e. Association or Indication.
1241 qualifierName: TOK_ASSOCIATION
1242 /* Allow the keywords for the metaqualiafiers but keep the
1243 case sensitivity by using name from Lexer */
1244 {
1245 g_flavor = CIMFlavor (CIMFlavor::NONE);
1246 $$ = new String(metaQualifierName);
1247 free(metaQualifierName);
1248 metaQualifierName = 0;
1249 }
1250 | TOK_INDICATION
1251 {
1252 g_flavor = CIMFlavor (CIMFlavor::NONE);
1253 $$ = new String(metaQualifierName);
1254 free(metaQualifierName);
1255 metaQualifierName = 0;
1256 }
1257 | TOK_SIMPLE_IDENTIFIER
1258 {
1259 // KS Probably hangover for case when no scope supplied
1260 karl 1.60 g_flavor = CIMFlavor (CIMFlavor::NONE);
1261 $$ = $1;
1262 };
|
1263 e.boden 1.34
|
1264 karl 1.45 typedQualifierParameter: TOK_LEFTPAREN nonNullConstantValue TOK_RIGHTPAREN
1265 {
1266 g_typedInitializerValue.type = CIMMOF_CONSTANT_VALUE;
1267 g_typedInitializerValue.value = $2;
1268 $$ = &g_typedInitializerValue;
1269 }
1270 | TOK_LEFTPAREN TOK_NULL_VALUE TOK_RIGHTPAREN
1271 {
1272 g_typedInitializerValue.type = CIMMOF_NULL_VALUE;
1273 g_typedInitializerValue.value = new String(String::EMPTY);
1274 $$ = &g_typedInitializerValue;
1275 }
1276 | arrayInitializer
1277 {
1278 g_typedInitializerValue.type = CIMMOF_ARRAY_VALUE;
1279 g_typedInitializerValue.value = $1;
1280 $$ = &g_typedInitializerValue;
1281 }
1282 | { /* empty */
1283 g_typedInitializerValue.type = CIMMOF_NULL_VALUE;
1284 g_typedInitializerValue.value = new String(String::EMPTY);
1285 karl 1.45 $$ = &g_typedInitializerValue;
1286 };
|
1287 bob 1.1
|
1288 e.boden 1.34
|
1289 bob 1.1 pragmaName: TOK_SIMPLE_IDENTIFIER { $$ = $1; } ;
1290
|
1291 e.boden 1.34
|
1292 bob 1.1 pragmaVal: TOK_STRING_VALUE { $$ = $1; } ;
1293
1294 %%
|
1295 jim.wunderlich 1.40
1296 /*
1297 **==============================================================================
1298 **
1299 ** MOF_error():
1300 **
1301 **==============================================================================
1302 */
1303 static void MOF_error(const char * str, const char * S)
1304 {
|
1305 karl 1.45 printf("%s %s\n", str, S);
|
1306 jim.wunderlich 1.40 }
1307
1308 /*
1309 **==============================================================================
1310 **
1311 ** MOF_trace():
1312 **
1313 **==============================================================================
1314 */
1315 // #define DEBUG_cimmof 1
1316
|
1317 karl 1.61 #ifdef DEBUG_cimmof
|
1318 jim.wunderlich 1.40 static void MOF_trace(const char* str)
1319 {
1320 printf("MOF_trace(): %s \n", str);
1321 }
1322
1323 static void MOF_trace2(const char * str, const char * S)
1324 {
|
1325 karl 1.45 printf("MOF_trace2(): %s %s\n", str, S);
|
1326 karl 1.61 }
1327
|
1328 jim.wunderlich 1.40 #endif // DEBUG_cimmof
|