4 * Syntax rules for parsing the SMIng MIB module language.
6 * Copyright (c) 1999 Frank Strauss, Technical University of Braunschweig.
8 * See the file "COPYING" for information on usage and redistribution
9 * of this file, and for a DISCLAIMER OF ALL WARRANTIES.
11 * @(#) $Id: parser-sming.y 7966 2008-03-27 21:25:52Z schoenw $
20 #define _ISOC99_SOURCE
40 #include "parser-sming.h"
41 #include "scanner-sming.h"
52 * These arguments are passed to yyparse() and yylex().
54 #define YYPARSE_PARAM parserPtr
55 #define YYLEX_PARAM parserPtr
59 #define thisParserPtr ((Parser *)parserPtr)
60 #define thisModulePtr (((Parser *)parserPtr)->modulePtr)
65 * NOTE: The argument lvalp ist not really a void pointer. Unfortunately,
66 * we don't know it better at this point. bison generated C code declares
67 * YYSTYPE just a few lines below based on the `%union' declaration.
69 extern int yylex(void *lvalp, Parser *parserPtr);
73 static char *typeIdentifier, *macroIdentifier, *identityIdentifier,
74 *classIdentifier, *attributeIdentifier;
75 static char *importModulename = NULL;
76 static Type *typePtr = NULL;
77 static Macro *macroPtr = NULL;
78 static Identity *identityPtr = NULL;
79 static Class *classPtr = NULL;
80 static Attribute *attributePtr = NULL;
81 static Event *eventPtr = NULL;
82 static SmiBasetype defaultBasetype = SMI_BASETYPE_UNKNOWN;
83 static NamedNumber *namedNumberPtr = NULL;
84 static int bitsFlag = 0; /* used to differentiate bits definition from enum*/
85 static int attributeFlag = 0; /*
86 *Used to differentiate between attribute and
87 *and typedef to tie the type statement
88 *respectively to class or module.
92 #define SMI_EPOCH 631152000 /* 01 Jan 1990 00:00:00 */
96 findType(char *spec, Parser *parserPtr, Module *modulePtr)
102 type = strstr(spec, "::");
104 typePtr = findTypeByModuleAndName(modulePtr, spec);
106 importPtr = findImportByName(spec, modulePtr);
108 typePtr = findTypeByModulenameAndName(importPtr->export.module,
113 module = strtok(spec, ":");
115 typePtr = findTypeByModulenameAndName(module, type);
122 findIdentity(char *spec, Parser *parserPtr, Module *modulePtr)
124 Identity *identityPtr;
126 char *module, *identity;
128 identity = strstr(spec, "::");
130 identityPtr = findIdentityByModuleAndName(modulePtr, spec);
132 importPtr = findImportByName(spec, modulePtr);
134 identityPtr = findIdentityByModulenameAndName(importPtr->export.module,
139 module = strtok(spec, ":");
140 identity = &identity[2];
141 identityPtr = findIdentityByModulenameAndName(module, identity);
147 findClass(char *spec, Parser *parserPtr, Module *modulePtr)
151 char *module, *class;
153 class = strstr(spec, "::");
155 classPtr = findClassByModuleAndName(modulePtr, spec);
157 importPtr = findImportByName(spec, modulePtr);
159 classPtr = findClassByModulenameAndName(importPtr->export.module,
164 module = strtok(spec, ":");
166 classPtr = findClassByModulenameAndName(module, class);
172 checkTypes(Parser *parserPtr, Module *modulePtr)
176 for(typePtr = modulePtr->firstTypePtr;
177 typePtr; typePtr = typePtr->nextPtr) {
180 * Complain about empty description clauses.
183 if (! parserPtr->flags & SMI_FLAG_NODESCR
184 && (! typePtr->export.description
185 || ! typePtr->export.description[0])) {
186 smiPrintErrorAtLine(parserPtr, ERR_EMPTY_DESCRIPTION,
187 typePtr->line, typePtr->export.name);
190 smiCheckNamedNumberRedefinition(parserPtr, typePtr);
191 smiCheckNamedNumberSubtyping(parserPtr, typePtr);
198 checkDate(Parser *parserPtr, char *date)
205 memset(&tm, 0, sizeof(tm));
209 if (len == 10 || len == 16) {
210 for (i = 0; i < len; i++) {
211 if (((i < 4 || i == 5 || i == 6 || i == 8 || i == 9 || i == 11
212 || i == 12 || i == 14 || i == 15) && ! isdigit((int)date[i]))
213 || ((i == 4 || i == 7) && date[i] != '-')
214 || (i == 10 && date[i] != ' ')
215 || (i == 13 && date[i] != ':')) {
216 smiPrintError(parserPtr, ERR_DATE_CHARACTER, date);
217 anytime = (time_t) -1;
222 smiPrintError(parserPtr, ERR_DATE_LENGTH, date);
223 anytime = (time_t) -1;
227 for (i = 0, p = date, tm.tm_year = 0; i < 4; i++, p++) {
228 tm.tm_year = tm.tm_year * 10 + (*p - '0');
231 tm.tm_mon = (p[0]-'0') * 10 + (p[1]-'0');
233 tm.tm_mday = (p[0]-'0') * 10 + (p[1]-'0');
237 tm.tm_hour = (p[0]-'0') * 10 + (p[1]-'0');
239 tm.tm_min = (p[0]-'0') * 10 + (p[1]-'0');
242 if (tm.tm_mon < 1 || tm.tm_mon > 12) {
243 smiPrintError(parserPtr, ERR_DATE_MONTH, date);
245 if (tm.tm_mday < 1 || tm.tm_mday > 31) {
246 smiPrintError(parserPtr, ERR_DATE_DAY, date);
248 if (tm.tm_hour < 0 || tm.tm_hour > 23) {
249 smiPrintError(parserPtr, ERR_DATE_HOUR, date);
251 if (tm.tm_min < 0 || tm.tm_min > 59) {
252 smiPrintError(parserPtr, ERR_DATE_MINUTES, date);
259 anytime = timegm(&tm);
261 if (anytime == (time_t) -1) {
262 smiPrintError(parserPtr, ERR_DATE_VALUE, date);
264 if (anytime < SMI_EPOCH) {
265 smiPrintError(parserPtr, ERR_DATE_IN_PAST, date);
267 if (anytime > time(NULL)) {
268 smiPrintError(parserPtr, ERR_DATE_IN_FUTURE, date);
273 return (anytime == (time_t) -1) ? 0 : anytime;
276 static char *hexToStr(char *hexStr, int len)
283 char* res =(char*)malloc(sizeof(char)*len/2+1);
284 char* tmp =(char*)malloc(sizeof(char)*3);
288 for(i=2; i+1<len; i+=2)
293 hex2char.l = strtol(tmp,NULL,16);
294 res[j] = hex2char.ch;
305 static void createBitsValue(SmiValue *valuePtr, Type *typePtr)
307 List *bitsListPtr, *valueListPtr, *p, *pp, *nextPtr;
310 if (valuePtr->basetype != SMI_BASETYPE_BITS)
313 bitsListPtr = typePtr->listPtr;
314 valueListPtr = (void *)valuePtr->value.ptr;
315 for (nBits = 0, p = bitsListPtr; p; p = p->nextPtr) {
316 if (nBits < 1+((NamedNumber *)(p->ptr))->export.value.value.unsigned64) {
317 nBits = 1+((NamedNumber *)(p->ptr))->export.value.value.unsigned64;
320 valuePtr->value.ptr = smiMalloc((nBits+7)/8);
321 memset(valuePtr->value.ptr, 0, (nBits+7)/8);
322 valuePtr->len = (nBits+7)/8;
323 for (p = valueListPtr; p;) {
324 for (pp = bitsListPtr; pp; pp = pp->nextPtr) {
326 ((NamedNumber *)(pp->ptr))->export.name)) {
327 bit = (int)(((NamedNumber *)(pp->ptr))->export.value.value.unsigned64);
328 valuePtr->value.ptr[bit/8] |=
333 nextPtr = p->nextPtr;
343 * The grammars start symbol.
350 * We call the parser from within the parser when IMPORTing modules,
351 * hence we need reentrant parser code. This is a bison feature.
361 char *id; /* identifier name */
362 int rc; /* >=0: ok, <0: error */
363 time_t date; /* a date value */
368 Identity *identityPtr;
372 Attribute *attributePtr;
376 Refinement *refinementPtr;
379 NamedNumber *namedNumberPtr;
383 Revision *revisionPtr;
389 * Tokens and their attributes.
395 %token <text>ucIdentifier
396 %token <text>lcIdentifier
398 %token <text>floatValue
399 %token <text>textSegment
400 %token <text>decimalNumber
401 %token <text>hexadecimalNumber
404 %token <rc>moduleKeyword
405 %token <rc>importKeyword
406 %token <rc>revisionKeyword
407 %token <rc>identityKeyword
408 %token <rc>oidKeyword
409 %token <rc>dateKeyword
410 %token <rc>organizationKeyword
411 %token <rc>contactKeyword
412 %token <rc>descriptionKeyword
413 %token <rc>referenceKeyword
414 %token <rc>extensionKeyword
415 %token <rc>typedefKeyword
416 %token <rc>typeKeyword
417 %token <rc>formatKeyword
418 %token <rc>unitsKeyword
419 %token <rc>statusKeyword
420 %token <rc>accessKeyword
421 %token <rc>defaultKeyword
422 %token <rc>impliedKeyword
423 %token <rc>indexKeyword
424 %token <rc>augmentsKeyword
425 %token <rc>reordersKeyword
426 %token <rc>sparseKeyword
427 %token <rc>expandsKeyword
428 %token <rc>createKeyword
429 %token <rc>membersKeyword
430 %token <rc>objectsKeyword
431 %token <rc>mandatoryKeyword
432 %token <rc>optionalKeyword
433 %token <rc>refineKeyword
434 %token <rc>abnfKeyword
435 %token <rc>OctetStringKeyword
436 %token <rc>ObjectIdentifierKeyword
437 %token <rc>Integer32Keyword
438 %token <rc>Unsigned32Keyword
439 %token <rc>Integer64Keyword
440 %token <rc>Unsigned64Keyword
441 %token <rc>Float32Keyword
442 %token <rc>Float64Keyword
443 %token <rc>Float128Keyword
444 %token <rc>BitsKeyword
445 %token <rc>EnumerationKeyword
446 %token <rc>currentKeyword
447 %token <rc>deprecatedKeyword
448 %token <rc>obsoleteKeyword
449 %token <rc>readonlyKeyword
450 %token <rc>readwriteKeyword
452 %token <rc>parentKeyword
453 %token <rc>classKeyword
454 %token <rc>extendsKeyword
455 %token <rc>attributeKeyword
456 %token <rc>uniqueKeyword
457 %token <rc>eventKeyword
458 %token <rc>PointerKeyword
459 %token <rc>eventonlyKeyword
460 %token <rc>neginfKeyword
461 %token <rc>posinfKeyword
462 %token <rc>snanKeyword
463 %token <rc>qnanKeyword
467 * Types of non-terminal symbols.
471 %type <rc>moduleStatement_optsep_0n
472 %type <rc>moduleStatement_optsep_1n
473 %type <rc>moduleStatement_optsep
474 %type <modulePtr>moduleStatement
475 %type <rc>extensionStatement_stmtsep_0n
476 %type <rc>extensionStatement_stmtsep_1n
477 %type <rc>extensionStatement_stmtsep
478 %type <macroPtr>extensionStatement
479 %type <rc>identityStatement_stmtsep_0n
480 %type <rc>identityStatement_stmtsep_1n
481 %type <rc>identityStatement_stmtsep
482 %type <identityPtr>identityStatement
483 %type <identityPtr>parentStatement_stmtsep_01
484 %type <identityPtr>parentStatement
485 %type <rc>typedefStatement_stmtsep_0n
486 %type <rc>typedefStatement_stmtsep_1n
487 %type <rc>typedefStatement_stmtsep
488 %type <typePtr>typedefStatement
489 %type <rc>attributeStatement_stmtsep_0n
490 %type <rc>attributeStatement_stmtsep_1n
491 %type <rc>attributeStatement_stmtsep
492 %type <attributePtr>attributeStatement
493 %type <rc>eventStatement_stmtsep_0n
494 %type <rc>eventStatement_stmtsep_1n
495 %type <rc>eventStatement_stmtsep
496 %type <eventPtr>eventStatement
497 %type <rc>classStatement_stmtsep_0n
498 %type <rc>classStatement_stmtsep_1n
499 %type <rc>classStatement_stmtsep
500 %type <classPtr>classStatement
501 %type <classPtr>extendsStatement_stmtsep_01
502 %type <classPtr>extendsStatement
503 %type <rc>importStatement_stmtsep_0n
504 %type <rc>importStatement_stmtsep_1n
505 %type <rc>importStatement_stmtsep
506 %type <listPtr>importStatement
507 %type <rc>revisionStatement_stmtsep_0n
508 %type <rc>revisionStatement_stmtsep_1n
509 %type <rc>revisionStatement_stmtsep
510 %type <revisionPtr>revisionStatement
511 %type <typePtr>typedefTypeStatement
512 %type <attributePtr>attributeTypeStatement
513 %type <date>dateStatement
514 %type <text>organizationStatement
515 %type <text>contactStatement
516 %type <text>formatStatement_stmtsep_01
517 %type <text>formatStatement
518 %type <text>unitsStatement_stmtsep_01
519 %type <text>unitsStatement
520 %type <status>statusStatement_stmtsep_01
521 %type <status>statusStatement
522 %type <valuePtr>defaultStatement_stmtsep_01
523 %type <valuePtr>defaultStatement
524 %type <access>accessStatement_stmtsep_01
525 %type <access>accessStatement
527 %type <text>descriptionStatement_stmtsep_01
528 %type <text>descriptionStatement
529 %type <text>referenceStatement_stmtsep_01
530 %type <text>referenceStatement
531 %type <text>abnfStatement_stmtsep_01
532 %type <text>abnfStatement
533 %type <typePtr>refinedBaseType_refinedType
534 %type <typePtr>refinedBaseType
535 %type <typePtr>refinedType
536 %type <attributePtr>attribute_refinedBaseType_refinedType
537 %type <attributePtr>attribute_refinedBaseType
538 %type <attributePtr>attribute_refinedType
539 %type <listPtr>optsep_anySpec_01
540 %type <listPtr>anySpec
541 %type <listPtr>optsep_numberSpec_01
542 %type <listPtr>numberSpec
543 %type <listPtr>furtherNumberElement_0n
544 %type <listPtr>furtherNumberElement_1n
545 %type <rangePtr>furtherNumberElement
546 %type <rangePtr>numberElement
547 %type <valuePtr>numberUpperLimit_01
548 %type <valuePtr>numberUpperLimit
549 %type <listPtr>optsep_floatSpec_01
550 %type <listPtr>floatSpec
551 %type <listPtr>furtherFloatElement_0n
552 %type <listPtr>furtherFloatElement_1n
553 %type <rangePtr>furtherFloatElement
554 %type <rangePtr>floatElement
555 %type <text>floatUpperLimit_01
556 %type <text>floatUpperLimit
557 %type <text>specialFloatValue
558 %type <listPtr>optsep_pointerRestr_01
559 %type <text>pointerRestr
560 %type <listPtr>bitsOrEnumerationSpec
561 %type <listPtr>bitsOrEnumerationList
562 %type <listPtr>furtherBitsOrEnumerationItem_0n
563 %type <listPtr>furtherBitsOrEnumerationItem_1n
564 %type <namedNumberPtr>furtherBitsOrEnumerationItem
565 %type <namedNumberPtr>bitsOrEnumerationItem
566 %type <listPtr>identifierList
567 %type <listPtr>furtherIdentifier_0n
568 %type <listPtr>furtherIdentifier_1n
569 %type <text>furtherIdentifier
570 %type <listPtr>uniqueStatement_stmtsep_01
571 %type <listPtr>uniqueStatement
572 %type <listPtr>uniqueSpec
573 %type <listPtr>bitsValue
574 %type <listPtr>bitsList
575 %type <listPtr>furtherLcIdentifier_0n
576 %type <listPtr>furtherLcIdentifier_1n
577 %type <text>furtherLcIdentifier
578 %type <text>identifier
579 %type <text>qucIdentifier
580 %type <text>qlcIdentifier
582 %type <text>optsep_textSegment_0n
583 %type <text>optsep_textSegment_1n
584 %type <text>optsep_textSegment
588 %type <valuePtr>anyValue
590 %type <valuePtr>number
591 %type <valuePtr>negativeNumber
592 %type <valuePtr>signedNumber
593 %type <rc>optsep_comma_01
608 * One mibFile may contain multiple MIB modules.
609 * It's also possible that there's no module in a file.
611 smingFile: optsep moduleStatement_optsep_0n
614 * Return the number of successfully
621 moduleStatement_optsep_0n: /* empty */
625 | moduleStatement_optsep_1n
631 moduleStatement_optsep_1n: moduleStatement_optsep
635 | moduleStatement_optsep_1n moduleStatement_optsep
638 * Sum up the number of successfully parsed
639 * modules or return -1, if at least one
642 if (($1 >= 0) && ($2 >= 0)) {
650 moduleStatement_optsep: moduleStatement optsep
653 * If we got a (Module *) return rc == 1,
654 * otherwise parsing failed (rc == -1).
664 moduleStatement: moduleKeyword sep ucIdentifier
666 thisParserPtr->modulePtr = findModuleByName($3);
667 if (!thisParserPtr->modulePtr) {
668 thisParserPtr->modulePtr =
670 smiStrdup(thisParserPtr->path),
674 smiPrintError(thisParserPtr,
675 ERR_MODULE_ALREADY_LOADED,
679 * this aborts parsing the whole file,
680 * not only the current module.
684 thisModulePtr->export.language = SMI_LANGUAGE_SMING;
685 thisParserPtr->modulePtr->numImportedIdentifiers
687 thisParserPtr->modulePtr->numStatements = 0;
688 thisParserPtr->modulePtr->numModuleIdentities = 0;
689 thisParserPtr->firstIndexlabelPtr = NULL;
690 thisParserPtr->identityObjectName = NULL;
693 importStatement_stmtsep_0n
694 organizationStatement stmtsep
697 setModuleOrganization(thisParserPtr->modulePtr,
701 contactStatement stmtsep
704 setModuleContactInfo(thisParserPtr->modulePtr,
708 descriptionStatement stmtsep
711 setModuleDescription(thisParserPtr->modulePtr,
715 referenceStatement_stmtsep_01
718 setModuleReference(thisParserPtr->modulePtr,
722 revisionStatement_stmtsep_0n
723 extensionStatement_stmtsep_0n
724 identityStatement_stmtsep_0n
725 typedefStatement_stmtsep_0n
726 classStatement_stmtsep_0n
729 checkTypes(thisParserPtr, thisModulePtr);
735 extensionStatement_stmtsep_0n: /* empty */
739 | extensionStatement_stmtsep_1n
742 * Return the number of successfully
743 * parsed extension statements.
749 extensionStatement_stmtsep_1n: extensionStatement_stmtsep
753 | extensionStatement_stmtsep_1n
754 extensionStatement_stmtsep
757 * Sum up the number of successfully parsed
758 * extensions or return -1, if at least one
761 if (($1 >= 0) && ($2 >= 0)) {
769 extensionStatement_stmtsep: extensionStatement stmtsep
772 * If we got a (Type *) return rc == 1,
773 * otherwise parsing failed (rc == -1).
783 extensionStatement: extensionKeyword sep lcIdentifier
785 macroIdentifier = $3;
786 macroPtr = addMacro(macroIdentifier,
789 setMacroDecl(macroPtr, SMI_DECL_EXTENSION);
792 statusStatement_stmtsep_01
794 if (macroPtr && $8) {
795 setMacroStatus(macroPtr, $8);
798 descriptionStatement_stmtsep_01
800 if (macroPtr && $10) {
801 setMacroDescription(macroPtr, $10,
805 referenceStatement_stmtsep_01
807 if (macroPtr && $12) {
808 setMacroReference(macroPtr, $12,
812 abnfStatement_stmtsep_01
814 if (macroPtr && $14) {
815 setMacroAbnf(macroPtr, $14,
826 typedefStatement_stmtsep_0n: /* empty */
830 | typedefStatement_stmtsep_1n
833 * Return the number of successfully
834 * parsed typedef statements.
840 typedefStatement_stmtsep_1n: typedefStatement_stmtsep
844 | typedefStatement_stmtsep_1n
845 typedefStatement_stmtsep
848 * Sum up the number of successfully parsed
849 * typedefs or return -1, if at least one
852 if (($1 >= 0) && ($2 >= 0)) {
860 typedefStatement_stmtsep: typedefStatement stmtsep
863 * If we got a (Type *) return rc == 1,
864 * otherwise parsing failed (rc == -1).
874 typedefStatement: typedefKeyword sep ucIdentifier
878 *check for duplicate names in the module
881 findType(typeIdentifier, thisParserPtr,thisModulePtr))
882 if( typePtr->modulePtr == thisParserPtr->modulePtr)
883 smiPrintError(thisParserPtr,
884 ERR_DUPLICATE_TYPE_NAME,
888 typedefTypeStatement stmtsep
891 if ($8->export.name) {
893 * If the exact type has been found
894 * and no new Type structure has been
895 * created, we have to create a
898 typePtr = duplicateType($8, 0,
903 typePtr = setTypeName(typePtr, typeIdentifier);
904 setTypeDecl(typePtr, SMI_DECL_TYPEDEF);
906 defaultBasetype = typePtr->export.basetype;
908 defaultStatement_stmtsep_01
910 if (typePtr && $11) {
911 if(typePtr->export.basetype ==
913 //check ENUM value for correctness
916 if(namedNumberPtr = findNamedNumberByName(typePtr,
919 $11 = &namedNumberPtr->export.value;
921 else{ smiPrintError(thisParserPtr,
922 ERR_ENUM_NAME_NOT_DEFINED,
926 //NOTE that the bits default value is set in the anyval
928 setTypeValue(typePtr, $11);
931 formatStatement_stmtsep_01
934 && smiCheckFormat(thisParserPtr,
935 typePtr->export.basetype,
937 setTypeFormat(typePtr, $13);
940 unitsStatement_stmtsep_01
942 if (typePtr && $15) {
943 setTypeUnits(typePtr, $15);
946 statusStatement_stmtsep_01
948 if (typePtr && $17) {
949 setTypeStatus(typePtr, $17);
952 descriptionStatement_stmtsep_01
954 if (typePtr && $19) {
955 setTypeDescription(typePtr, $19,
959 referenceStatement_stmtsep_01
961 if (typePtr && $21) {
962 setTypeReference(typePtr, $21, thisParserPtr);
967 smiCheckNamedNumberSubtyping(thisParserPtr , typePtr);
968 smiCheckNamedNumbersOrder(thisParserPtr , typePtr);
969 smiCheckNamedNumberRedefinition(thisParserPtr , typePtr);
972 free(typeIdentifier);
973 defaultBasetype = SMI_BASETYPE_UNKNOWN;
977 classStatement_stmtsep_0n: /* empty */
981 | classStatement_stmtsep_1n
984 * Return the number of successfully
985 * parsed typedef statements.
991 classStatement_stmtsep_1n: classStatement_stmtsep
995 | classStatement_stmtsep_1n
996 classStatement_stmtsep
999 * Sum up the number of successfully parsed
1000 * classes or return -1, if at least one
1003 if (($1 >= 0) && ($2 >= 0)) {
1011 classStatement_stmtsep: classStatement stmtsep
1014 * If we got a (Type *) return rc == 1,
1015 * otherwise parsing failed (rc == -1).
1025 classStatement: classKeyword sep ucIdentifier
1027 classIdentifier = $3;
1028 if(findClassByModuleAndName(thisModulePtr, classIdentifier))
1030 smiPrintError(thisParserPtr,
1031 ERR_DUPLICATE_CLASS_NAME,
1032 attributeIdentifier);
1035 classPtr = addClass(classIdentifier,
1037 setClassDecl(classPtr, SMI_DECL_CLASS);
1041 extendsStatement_stmtsep_01
1044 classPtr->parentPtr = $8;
1046 attributeStatement_stmtsep_0n
1047 uniqueStatement_stmtsep_01
1050 Attribute *tmpAttribute;
1054 //Check for "magic" value #@# that defines
1055 //scalar class. See NOTE after Class definitino in data.h
1056 if(!strcmp((char*)($11->ptr),"#@#"))
1058 classPtr->uniqueList = (List*)malloc(sizeof(List));
1059 classPtr->uniqueList->ptr = classPtr;
1060 classPtr->uniqueList->nextPtr = NULL;
1066 //convert all attribute names to atributes
1067 for(tmpList; tmpList; tmpList=tmpList->nextPtr)
1070 (Attribute*)smiGetAttribute(&(classPtr->export),(char*)(tmpList->ptr)))
1072 smiFree(tmpList->ptr);
1073 tmpList->ptr = tmpAttribute;
1077 smiFree(tmpList->ptr);
1078 tmpList->ptr = NULL;
1079 smiPrintError(thisParserPtr,
1080 ERR_ATTRIBUTE_NOT_FOUND,
1081 attributeIdentifier);
1085 classPtr->uniqueList = $11;
1089 eventStatement_stmtsep_0n
1090 statusStatement_stmtsep_01
1092 if (classPtr && $14) {
1093 setClassStatus(classPtr, $14);
1096 descriptionStatement_stmtsep_01
1098 if (classPtr && $16) {
1099 setClassDescription(classPtr, $16,
1103 referenceStatement_stmtsep_01
1105 if (classPtr && $18) {
1106 setClassReference(classPtr, $18,
1117 attributeStatement_stmtsep_0n: /* empty */
1121 | attributeStatement_stmtsep_1n
1124 * Return the number of successfully
1125 * parsed typedef statements.
1131 attributeStatement_stmtsep_1n: attributeStatement_stmtsep
1135 | attributeStatement_stmtsep_1n
1136 attributeStatement_stmtsep
1139 * Sum up the number of successfully parsed
1140 * attributes or return -1, if at least one
1143 if (($1 >= 0) && ($2 >= 0)) {
1151 attributeStatement_stmtsep: attributeStatement stmtsep
1154 * If we got a (Type *) return rc == 1,
1155 * otherwise parsing failed (rc == -1).
1165 attributeStatement: attributeKeyword sep lcIdentifier
1167 attributeIdentifier = $3;
1168 attributePtr = (Attribute*)smiGetAttribute(&(classPtr->export),
1169 attributeIdentifier);
1172 smiPrintError(thisParserPtr,
1173 ERR_DUPLICATE_ATTRIBUTE_NAME,
1174 attributeIdentifier);
1175 attributePtr = NULL;
1179 attributeTypeStatement
1183 setAttributeName(attributePtr,
1184 attributeIdentifier);
1185 setAttributeDecl(attributePtr,
1186 SMI_DECL_ATTRIBUTE);
1187 defaultBasetype = attributePtr->export.basetype;
1190 accessStatement_stmtsep_01
1192 if($10 && attributePtr){
1193 /* check whether there's access for class reference,
1194 which is not allowed */
1195 if(attributePtr->parentClassPtr)
1196 smiPrintError(thisParserPtr,
1197 ERR_ATTRIBUTE_CLASS_ACCESS,
1198 attributeIdentifier);
1200 setAttributeAccess(attributePtr,$10);
1203 else if(attributePtr && attributePtr->parentTypePtr)
1205 smiPrintError(thisParserPtr,
1206 ERR_ATTRIBUTE_MISSING_ACCESS,
1207 attributeIdentifier);
1210 defaultStatement_stmtsep_01
1212 if($12 && attributePtr){
1213 if(attributePtr->parentClassPtr)
1214 smiPrintError(thisParserPtr,
1215 ERR_ATTRIBUTE_CLASS_DEFAULT,
1216 attributeIdentifier);
1218 attributePtr->export.value = *$12;
1221 else if(attributePtr)
1223 attributePtr->export.value.basetype =
1224 SMI_BASETYPE_UNKNOWN;
1227 formatStatement_stmtsep_01
1229 if($14 && attributePtr){
1230 if(attributePtr->parentClassPtr)
1231 smiPrintError(thisParserPtr,
1232 ERR_ATTRIBUTE_CLASS_FORMAT,
1233 attributeIdentifier);
1235 if (smiCheckFormat(thisParserPtr,
1236 attributePtr->export.basetype,$14, 0))
1238 attributePtr->export.format = $14;
1243 unitsStatement_stmtsep_01
1245 if($16 && attributePtr){
1246 if(attributePtr->parentClassPtr)
1247 smiPrintError(thisParserPtr,
1248 ERR_ATTRIBUTE_CLASS_UNITS,
1249 attributeIdentifier);
1251 attributePtr->export.units = $16;
1255 statusStatement_stmtsep_01
1257 if (attributePtr && $18)
1258 attributePtr->export.status = $18;
1260 descriptionStatement_stmtsep_01
1262 if (attributePtr && $20)
1263 attributePtr->export.description = $20;
1265 referenceStatement_stmtsep_01
1267 if (attributePtr && $22)
1268 attributePtr->export.reference = $22;
1273 attributePtr = NULL;
1274 defaultBasetype = SMI_BASETYPE_UNKNOWN;
1278 eventStatement_stmtsep_0n: /* empty */
1282 | eventStatement_stmtsep_1n
1285 * Return the number of successfully
1286 * parsed event statements.
1292 eventStatement_stmtsep_1n: eventStatement_stmtsep
1296 | eventStatement_stmtsep_1n
1297 eventStatement_stmtsep
1300 * Sum up the number of successfully parsed
1301 * events or return -1, if at least one
1304 if (($1 >= 0) && ($2 >= 0)) {
1312 eventStatement_stmtsep: eventStatement stmtsep
1315 * If we got a (Type *) return rc == 1,
1316 * otherwise parsing failed (rc == -1).
1326 eventStatement: eventKeyword sep lcIdentifier
1328 //TODO check for repeated names
1329 eventPtr=addEvent($3,classPtr,thisParserPtr);
1332 statusStatement_stmtsep_01
1335 eventPtr->export.status = $8;
1337 descriptionStatement_stmtsep_01
1340 eventPtr->export.description = $10;
1342 referenceStatement_stmtsep_01
1345 eventPtr->export.reference = $12;
1354 importStatement_stmtsep_0n: /* empty */
1358 | importStatement_stmtsep_1n
1364 importStatement_stmtsep_1n: importStatement_stmtsep
1368 | importStatement_stmtsep_1n importStatement_stmtsep
1371 * Sum up the number of successfully parsed
1372 * imports or return -1, if at least one
1375 if (($1 >= 0) && ($2 >= 0)) {
1383 importStatement_stmtsep: importStatement stmtsep
1386 * If we got an (Object *) return rc == 1,
1387 * otherwise parsing failed (rc == -1).
1397 importStatement: importKeyword sep ucIdentifier
1399 importModulename = smiStrdup($3);
1404 List *listPtr, *nextPtr;
1406 for (listPtr = $8; listPtr; listPtr = nextPtr) {
1407 addImport(listPtr->ptr, thisParserPtr);
1408 thisParserPtr->modulePtr->
1409 numImportedIdentifiers++;
1410 nextPtr = listPtr->nextPtr;
1414 optsep ')' optsep ';'
1417 char *s = importModulename;
1419 modulePtr = findModuleByName(s);
1421 modulePtr = loadModule(s, thisParserPtr);
1423 checkImports(modulePtr, thisParserPtr);
1429 revisionStatement_stmtsep_0n: /* empty */
1433 | revisionStatement_stmtsep_1n
1439 revisionStatement_stmtsep_1n: revisionStatement_stmtsep
1443 | revisionStatement_stmtsep_1n revisionStatement_stmtsep
1446 * Sum up the number of successfully parsed
1447 * revisions or return -1, if at least one
1450 if (($1 >= 0) && ($2 >= 0)) {
1458 revisionStatement_stmtsep: revisionStatement stmtsep
1461 * If we got a (Revision *) return rc == 1,
1462 * otherwise parsing failed (rc == -1).
1472 revisionStatement: revisionKeyword optsep '{' stmtsep
1473 dateStatement stmtsep
1474 descriptionStatement stmtsep
1477 $$ = addRevision($5, $7, thisParserPtr);
1481 identityStatement_stmtsep_0n: /* empty */
1485 | identityStatement_stmtsep_1n
1488 * Return the number of successfully
1489 * parsed identity statements.
1495 identityStatement_stmtsep_1n: identityStatement_stmtsep
1499 | identityStatement_stmtsep_1n
1500 identityStatement_stmtsep
1503 * Sum up the number of successfully parsed
1504 * identities or return -1, if at least one
1507 if (($1 >= 0) && ($2 >= 0)) {
1515 identityStatement_stmtsep: identityStatement stmtsep
1518 * If we got a (Type *) return rc == 1,
1519 * otherwise parsing failed (rc == -1).
1529 identityStatement: identityKeyword sep lcIdentifier
1531 identityIdentifier = $3;
1532 identityPtr = addIdentity(identityIdentifier,
1534 setIdentityDecl(identityPtr, SMI_DECL_IDENTITY);
1537 parentStatement_stmtsep_01
1539 if(identityPtr && $8) {
1540 setIdentityParent(identityPtr,$8);
1543 statusStatement_stmtsep_01
1545 if (identityPtr && $10) {
1546 setIdentityStatus(identityPtr, $10);
1549 descriptionStatement_stmtsep_01
1551 if (identityPtr && $12) {
1552 setIdentityDescription(identityPtr, $12,
1556 referenceStatement_stmtsep_01
1558 setIdentityReference(identityPtr, $14,
1568 typedefTypeStatement: typeKeyword sep refinedBaseType_refinedType optsep ';'
1574 attributeTypeStatement: typeKeyword sep attribute_refinedBaseType_refinedType optsep ';'
1580 dateStatement: dateKeyword sep date optsep ';'
1586 organizationStatement: organizationKeyword sep text optsep ';'
1592 contactStatement: contactKeyword sep text optsep ';'
1598 formatStatement_stmtsep_01: /* empty */
1602 | formatStatement stmtsep
1608 formatStatement: formatKeyword sep format optsep ';'
1614 unitsStatement_stmtsep_01: /* empty */
1618 | unitsStatement stmtsep
1624 unitsStatement: unitsKeyword sep units optsep ';'
1630 statusStatement_stmtsep_01: /* empty */
1632 $$ = SMI_STATUS_CURRENT;
1634 | statusStatement stmtsep
1640 statusStatement: statusKeyword sep status optsep ';'
1646 uniqueStatement_stmtsep_01:
1650 | uniqueStatement stmtsep
1656 uniqueStatement: uniqueKeyword sep '(' uniqueSpec ')' optsep ';'
1662 uniqueSpec: optsep_comma_01
1664 $$ = smiMalloc(sizeof(List));
1665 $$->ptr = "#@#"; //used to indicate that unique
1666 //statement is present and empty
1667 //i.e. the class is scalar
1670 | lcIdentifier furtherLcIdentifier_0n optsep_comma_01
1672 $$ = smiMalloc(sizeof(List));
1681 extendsStatement_stmtsep_01: /* empty */
1685 | extendsStatement stmtsep
1691 extendsStatement: extendsKeyword sep ucIdentifier optsep ';'
1693 $$ = findClass($3, thisParserPtr,thisModulePtr);
1694 if(!$$)smiPrintError(thisParserPtr,
1701 defaultStatement_stmtsep_01: /* empty */
1705 | defaultStatement stmtsep
1711 defaultStatement: defaultKeyword sep anyValue optsep ';'
1717 accessStatement_stmtsep_01: /* empty */
1719 $$ = SMI_ACCESS_UNKNOWN;
1721 | accessStatement stmtsep
1727 accessStatement: accessKeyword sep access optsep ';'
1733 access: readonlyKeyword
1735 $$ = SMI_ACCESS_READ_ONLY;
1739 $$ = SMI_ACCESS_READ_WRITE;
1743 $$ = SMI_ACCESS_EVENT_ONLY;
1747 parentStatement_stmtsep_01: /* empty */
1751 | parentStatement stmtsep
1757 parentStatement: parentKeyword sep lcIdentifier optsep ';'
1759 $$ = findIdentity($3, thisParserPtr, thisModulePtr);
1760 if(!$$)smiPrintError(thisParserPtr,
1761 ERR_IDENTITY_PARENT_NOT_FOUND,
1766 descriptionStatement_stmtsep_01: /* empty */
1770 | descriptionStatement stmtsep
1776 descriptionStatement: descriptionKeyword sep text optsep ';'
1782 referenceStatement_stmtsep_01: /* empty */
1786 | referenceStatement stmtsep
1792 referenceStatement: referenceKeyword sep text optsep ';'
1798 abnfStatement_stmtsep_01: /* empty */
1802 | abnfStatement stmtsep
1808 abnfStatement: abnfKeyword sep text optsep ';'
1816 refinedBaseType_refinedType: refinedBaseType
1826 attribute_refinedBaseType_refinedType: attribute_refinedBaseType
1830 | attribute_refinedType
1837 refinedBaseType: OctetStringKeyword optsep_numberSpec_01
1842 $$ = smiHandle->typeOctetStringPtr;
1844 $$ = duplicateType(smiHandle->typeOctetStringPtr, 0,
1846 setTypeParent($$, smiHandle->typeOctetStringPtr);
1847 setTypeList($$, $2);
1848 for (p = $2; p; p = p->nextPtr)
1849 ((Range *)p->ptr)->typePtr = $$;
1852 | ObjectIdentifierKeyword
1854 $$ = smiHandle->typeObjectIdentifierPtr;
1856 | Integer32Keyword optsep_numberSpec_01
1861 $$ = smiHandle->typeInteger32Ptr;
1863 $$ = duplicateType(smiHandle->typeInteger32Ptr, 0,
1865 setTypeParent($$, smiHandle->typeInteger32Ptr);
1866 setTypeList($$, $2);
1867 for (p = $2; p; p = p->nextPtr)
1868 ((Range *)p->ptr)->typePtr = $$;
1871 | Unsigned32Keyword optsep_numberSpec_01
1876 $$ = smiHandle->typeUnsigned32Ptr;
1878 $$ = duplicateType(smiHandle->typeUnsigned32Ptr, 0,
1880 setTypeParent($$, smiHandle->typeUnsigned32Ptr);
1881 setTypeList($$, $2);
1882 for (p = $2; p; p = p->nextPtr)
1883 ((Range *)p->ptr)->typePtr = $$;
1886 | Integer64Keyword optsep_numberSpec_01
1891 $$ = smiHandle->typeInteger64Ptr;
1893 $$ = duplicateType(smiHandle->typeInteger64Ptr, 0,
1895 setTypeParent($$, smiHandle->typeInteger64Ptr);
1896 setTypeList($$, $2);
1897 for (p = $2; p; p = p->nextPtr)
1898 ((Range *)p->ptr)->typePtr = $$;
1901 | Unsigned64Keyword optsep_numberSpec_01
1906 $$ = smiHandle->typeUnsigned64Ptr;
1908 $$ = duplicateType(smiHandle->typeUnsigned64Ptr, 0,
1910 setTypeParent($$, smiHandle->typeUnsigned64Ptr);
1911 setTypeList($$, $2);
1912 for (p = $2; p; p = p->nextPtr)
1913 ((Range *)p->ptr)->typePtr = $$;
1916 | Float32Keyword optsep_floatSpec_01
1921 $$ = smiHandle->typeFloat32Ptr;
1923 $$ = duplicateType(smiHandle->typeFloat32Ptr, 0,
1925 setTypeParent($$, smiHandle->typeFloat32Ptr);
1926 setTypeList($$, $2);
1927 for (p = $2; p; p = p->nextPtr)
1928 ((Range *)p->ptr)->typePtr = $$;
1931 | Float64Keyword optsep_floatSpec_01
1936 $$ = smiHandle->typeFloat64Ptr;
1938 $$ = duplicateType(smiHandle->typeFloat64Ptr, 0,
1940 setTypeParent($$, smiHandle->typeFloat64Ptr);
1941 setTypeList($$, $2);
1942 for (p = $2; p; p = p->nextPtr)
1943 ((Range *)p->ptr)->typePtr = $$;
1946 | Float128Keyword optsep_floatSpec_01
1951 $$ = smiHandle->typeFloat128Ptr;
1953 $$ = duplicateType(smiHandle->typeFloat128Ptr, 0,
1955 setTypeParent($$, smiHandle->typeFloat128Ptr);
1956 setTypeList($$, $2);
1957 for (p = $2; p; p = p->nextPtr)
1958 ((Range *)p->ptr)->typePtr = $$;
1961 | PointerKeyword optsep_pointerRestr_01
1964 $$ = smiHandle->typePointerPtr;
1966 $$ = duplicateType(smiHandle->typePointerPtr, 0,
1968 setTypeParent($$, smiHandle->typePointerPtr);
1969 setTypeList($$, $2);
1972 | EnumerationKeyword bitsOrEnumerationSpec
1977 $$ = smiHandle->typeEnumPtr;
1979 $$ = duplicateType(smiHandle->typeEnumPtr, 0,
1981 setTypeParent($$, smiHandle->typeEnumPtr);
1982 setTypeList($$, $2);
1983 for (p = $2; p; p = p->nextPtr)
1984 ((NamedNumber *)p->ptr)->typePtr = $$;
1989 bitsFlag = 1; //Since Enum elements can be
1990 //negative we must make sure
1991 //that bits is not negative,
1992 //so we raise bitsFlag and
1993 //give error if there is
1996 bitsOrEnumerationSpec
2001 $$ = smiHandle->typeBitsPtr;
2003 $$ = duplicateType(smiHandle->typeBitsPtr, 0,
2005 setTypeParent($$, smiHandle->typeBitsPtr);
2006 setTypeList($$, $3);
2007 for (p = $3; p; p = p->nextPtr)
2008 ((NamedNumber *)p->ptr)->typePtr = $$;
2011 bitsFlag = 0;//reset flag
2016 attribute_refinedBaseType: OctetStringKeyword optsep_numberSpec_01
2019 $$ = duplicateTypeToAttribute(smiHandle->typeOctetStringPtr,
2020 classPtr, thisParserPtr);
2021 setAttributeParentType($$, smiHandle->typeOctetStringPtr);
2023 setAttributeList($$, $2);
2024 for (p = $2; p; p = p->nextPtr)
2025 ((Range *)p->ptr)->typePtr = (Type*)$$;
2028 | ObjectIdentifierKeyword
2030 $$ = duplicateTypeToAttribute(
2031 smiHandle->typeObjectIdentifierPtr, classPtr, thisParserPtr);
2032 setAttributeParentType($$, smiHandle->typeObjectIdentifierPtr);
2034 | Integer32Keyword optsep_numberSpec_01
2038 $$ = duplicateTypeToAttribute(smiHandle->typeInteger32Ptr,
2039 classPtr, thisParserPtr);
2040 setAttributeParentType($$, smiHandle->typeInteger32Ptr);
2042 setAttributeList($$, $2);
2043 for (p = $2; p; p = p->nextPtr)
2044 ((Range *)p->ptr)->typePtr = (Type*)$$;
2047 | Unsigned32Keyword optsep_numberSpec_01
2051 $$ = duplicateTypeToAttribute(smiHandle->typeUnsigned32Ptr,
2052 classPtr, thisParserPtr);
2053 setAttributeParentType($$, smiHandle->typeUnsigned32Ptr);
2055 setAttributeList($$, $2);
2056 for (p = $2; p; p = p->nextPtr)
2057 ((Range *)p->ptr)->typePtr = (Type*)$$;
2060 | Integer64Keyword optsep_numberSpec_01
2064 $$ = duplicateTypeToAttribute(smiHandle->typeInteger64Ptr,
2065 classPtr, thisParserPtr);
2066 setAttributeParentType($$, smiHandle->typeInteger64Ptr);
2068 setAttributeList($$, $2);
2069 for (p = $2; p; p = p->nextPtr)
2070 ((Range *)p->ptr)->typePtr = (Type*)$$;
2073 | Unsigned64Keyword optsep_numberSpec_01
2077 $$ = duplicateTypeToAttribute(smiHandle->typeUnsigned64Ptr,
2078 classPtr, thisParserPtr);
2079 setAttributeParentType($$, smiHandle->typeUnsigned64Ptr);
2081 setAttributeList($$, $2);
2082 for (p = $2; p; p = p->nextPtr)
2083 ((Range *)p->ptr)->typePtr = (Type*)$$;
2086 | Float32Keyword optsep_floatSpec_01
2090 $$ = duplicateTypeToAttribute(smiHandle->typeFloat32Ptr,
2091 classPtr, thisParserPtr);
2092 setAttributeParentType($$, smiHandle->typeFloat32Ptr);
2094 setAttributeList($$, $2);
2095 for (p = $2; p; p = p->nextPtr)
2096 ((Range *)p->ptr)->typePtr = (Type*)$$;
2099 | Float64Keyword optsep_floatSpec_01
2103 $$ = duplicateTypeToAttribute(smiHandle->typeFloat64Ptr,
2104 classPtr, thisParserPtr);
2105 setAttributeParentType($$, smiHandle->typeFloat64Ptr);
2107 setAttributeList($$, $2);
2108 for (p = $2; p; p = p->nextPtr)
2109 ((Range *)p->ptr)->typePtr = (Type*)$$;
2112 | Float128Keyword optsep_floatSpec_01
2116 $$ = duplicateTypeToAttribute(smiHandle->typeFloat128Ptr,
2117 classPtr, thisParserPtr);
2118 setAttributeParentType($$, smiHandle->typeFloat128Ptr);
2120 setAttributeList($$, $2);
2121 for (p = $2; p; p = p->nextPtr)
2122 ((Range *)p->ptr)->typePtr = (Type*)$$;
2125 | PointerKeyword optsep_pointerRestr_01
2127 $$ = duplicateTypeToAttribute(smiHandle->typePointerPtr,
2128 classPtr, thisParserPtr);
2129 setAttributeParentType($$, smiHandle->typePointerPtr);
2131 setAttributeList($$, $2);
2134 | EnumerationKeyword bitsOrEnumerationSpec
2138 $$ = duplicateTypeToAttribute(smiHandle->typeEnumPtr,
2139 classPtr, thisParserPtr);
2140 setAttributeParentType($$, smiHandle->typeEnumPtr);
2142 setAttributeList($$, $2);
2143 for (p = $2; p; p = p->nextPtr)
2144 ((NamedNumber *)p->ptr)->typePtr = (Type*)$$;
2149 bitsFlag = 1; //Since Enum elements can be
2150 //negative we must make sure
2151 //that bits is not negative,
2152 //so we raise bitsFlag and
2153 //give error if there is
2156 bitsOrEnumerationSpec
2160 $$ = duplicateTypeToAttribute(smiHandle->typeBitsPtr,
2161 classPtr, thisParserPtr);
2162 setAttributeParentType($$, smiHandle->typeBitsPtr);
2164 setAttributeList($$, $1);
2165 for (p = $1; p; p = p->nextPtr)
2166 ((NamedNumber *)(p->ptr))->typePtr = (Type*)$$;
2169 bitsFlag = 0; /* reset flag */
2173 refinedType: qucIdentifier optsep_anySpec_01
2175 typePtr = findType($1, thisParserPtr,
2177 if (typePtr && $2) {
2178 typePtr = duplicateType(typePtr, 0,
2180 setTypeList(typePtr, $2);
2187 attribute_refinedType: qucIdentifier optsep_anySpec_01
2190 typePtr = findType($1, thisParserPtr,
2192 if (typePtr && $2) {
2193 attributePtr = duplicateTypeToAttribute(typePtr,
2194 classPtr, thisParserPtr);
2195 setAttributeList(attributePtr, $2);
2196 setAttributeParentType(attributePtr, typePtr);
2197 } else if( typePtr ){
2198 attributePtr = duplicateTypeToAttribute(typePtr,
2199 classPtr, thisParserPtr);
2200 setAttributeParentType(attributePtr, typePtr);
2202 smiPrintError(thisParserPtr, ERR_UNKNOWN_TYPE, $1);
2203 attributePtr = NULL;
2204 } else if (tmp = findClass($1,
2205 thisParserPtr,thisModulePtr)){
2206 attributePtr = addAttribute($1, classPtr, thisParserPtr);
2207 setAttributeParentClass(attributePtr, tmp);
2209 attributePtr = NULL;
2210 smiPrintError(thisParserPtr,
2211 ERR_UNKNOWN_TYPE_OR_CLASS, $1);
2219 optsep_anySpec_01: /* empty */
2239 optsep_numberSpec_01: /* empty */
2249 numberSpec: '(' optsep numberElement furtherNumberElement_0n
2252 $$ = smiMalloc(sizeof(List));
2258 furtherNumberElement_0n: /* empty */
2262 | furtherNumberElement_1n
2268 furtherNumberElement_1n: furtherNumberElement
2270 $$ = smiMalloc(sizeof(List));
2274 | furtherNumberElement_1n furtherNumberElement
2278 p = smiMalloc(sizeof(List));
2281 for (pp = $1; pp->nextPtr; pp = pp->nextPtr);
2287 furtherNumberElement: optsep '|' optsep numberElement
2293 numberElement: signedNumber numberUpperLimit_01
2295 $$ = smiMalloc(sizeof(Range));
2296 $$->export.minValue = *$1;
2298 $$->export.maxValue = *$2;
2301 $$->export.maxValue = *$1;
2307 numberUpperLimit_01: /* empty */
2317 numberUpperLimit: optsep DOT_DOT optsep signedNumber
2323 optsep_floatSpec_01: /* empty */
2333 floatSpec: '(' optsep floatElement furtherFloatElement_0n
2336 $$ = smiMalloc(sizeof(List));
2342 furtherFloatElement_0n: /* empty */
2346 | furtherFloatElement_1n
2352 furtherFloatElement_1n: furtherFloatElement
2354 $$ = smiMalloc(sizeof(List));
2358 | furtherFloatElement_1n furtherFloatElement
2362 p = smiMalloc(sizeof(List));
2365 for (pp = $1; pp->nextPtr; pp = pp->nextPtr);
2371 furtherFloatElement: optsep '|' optsep floatElement
2377 floatElement: floatValue floatUpperLimit_01
2379 $$ = smiMalloc(sizeof(Range));
2380 $$->export.minValue.basetype = SMI_BASETYPE_FLOAT64;
2381 $$->export.minValue.value.float64 = strtod($1, NULL);
2383 $$->export.maxValue.basetype =
2384 SMI_BASETYPE_FLOAT64;
2385 $$->export.maxValue.value.float64 =
2388 $$->export.maxValue = $$->export.minValue;
2393 floatUpperLimit_01: /* empty */
2403 floatUpperLimit: optsep DOT_DOT optsep floatValue
2428 optsep_pointerRestr_01: /* empty */
2432 | optsep pointerRestr
2434 NamedNumber *nn =(NamedNumber*)smiMalloc(sizeof(NamedNumber));
2435 $$ = smiMalloc(sizeof(List));
2437 nn->export.name = $2;
2441 pointerRestr: '(' optsep qlcIdentifier optsep ')'
2447 bitsOrEnumerationSpec: '(' optsep bitsOrEnumerationList optsep ')'
2453 bitsOrEnumerationList: bitsOrEnumerationItem furtherBitsOrEnumerationItem_0n
2456 $$ = smiMalloc(sizeof(List));
2462 furtherBitsOrEnumerationItem_0n: /* empty */
2466 | furtherBitsOrEnumerationItem_1n
2472 furtherBitsOrEnumerationItem_1n: furtherBitsOrEnumerationItem
2474 $$ = smiMalloc(sizeof(List));
2478 | furtherBitsOrEnumerationItem_1n
2479 furtherBitsOrEnumerationItem
2483 p = smiMalloc(sizeof(List));
2486 for (pp = $1; pp->nextPtr; pp = pp->nextPtr);
2493 furtherBitsOrEnumerationItem: optsep ',' optsep bitsOrEnumerationItem
2499 bitsOrEnumerationItem: lcIdentifier optsep '(' optsep signedNumber optsep ')'
2501 $$ = smiMalloc(sizeof(NamedNumber));
2502 $$->export.name = $1;
2503 $$->export.value = *$5;
2507 identifierList: identifier furtherIdentifier_0n optsep_comma_01
2509 $$ = smiMalloc(sizeof(List));
2515 furtherIdentifier_0n: /* empty */
2519 | furtherIdentifier_1n
2525 furtherIdentifier_1n: furtherIdentifier
2527 $$ = smiMalloc(sizeof(List));
2531 | furtherIdentifier_1n furtherIdentifier
2535 p = smiMalloc(sizeof(List));
2538 for (pp = $1; pp->nextPtr; pp = pp->nextPtr);
2544 furtherIdentifier: optsep ',' optsep identifier
2550 bitsValue: '(' optsep bitsList optsep ')'
2556 bitsList: optsep_comma_01
2560 | lcIdentifier furtherLcIdentifier_0n optsep_comma_01
2562 $$ = smiMalloc(sizeof(List));
2568 //NOTE used also for unique statement
2569 furtherLcIdentifier_0n: /* empty */
2573 | furtherLcIdentifier_1n
2579 furtherLcIdentifier_1n: furtherLcIdentifier
2581 $$ = smiMalloc(sizeof(List));
2585 | furtherLcIdentifier_1n furtherLcIdentifier
2589 p = smiMalloc(sizeof(List));
2592 for (pp = $1; pp->nextPtr; pp = pp->nextPtr);
2598 furtherLcIdentifier: optsep ',' optsep lcIdentifier
2604 identifier: ucIdentifier
2614 qucIdentifier: ucIdentifier COLON_COLON ucIdentifier
2618 s = smiMalloc(strlen($1) +
2620 sprintf(s, "%s::%s", $1, $3);
2631 qlcIdentifier: ucIdentifier COLON_COLON lcIdentifier
2635 s = smiMalloc(strlen($1) +
2637 sprintf(s, "%s::%s", $1, $3);
2646 text: textSegment optsep_textSegment_0n
2650 $$ = smiMalloc(strlen($1) + strlen($2) + 1);
2659 while (len > 0 && $$[len-1] == '\n') {
2665 optsep_textSegment_0n: /* empty */
2669 | optsep_textSegment_1n
2675 optsep_textSegment_1n: optsep_textSegment
2679 | optsep_textSegment_1n optsep_textSegment
2681 $$ = smiMalloc(strlen($1) + strlen($2) + 1);
2689 optsep_textSegment: optsep textSegment
2697 $$ = checkDate(thisParserPtr, $1);
2714 * The type of `anyValue' must be determined from the
2715 * context. `anyValue' appears only in default value clauses. Hence,
2716 * we set a global variable defaultBasetype in the object type
2717 * declaring clause to remember the expected type. Here, we use this
2718 * variable to build an SmiValue with the appropriate base type.
2722 if (defaultBasetype == SMI_BASETYPE_BITS) {
2723 $$ = smiMalloc(sizeof(SmiValue));
2724 $$->basetype = SMI_BASETYPE_BITS;
2725 $$->value.ptr = (void*)($1);
2726 //set the bits value in the value.integer32
2728 createBitsValue($$,typePtr);
2730 else if(attributePtr){
2732 (Type*)smiGetAttributeParentType(&(attributePtr->export)));
2735 smiPrintError(thisParserPtr,
2736 ERR_UNEXPECTED_VALUETYPE);
2742 /* Note: might also be an OID or signed */
2743 switch (defaultBasetype) {
2744 case SMI_BASETYPE_UNSIGNED32:
2745 $$ = smiMalloc(sizeof(SmiValue));
2746 $$->basetype = SMI_BASETYPE_UNSIGNED32;
2747 $$->value.unsigned32 = strtoul($1, NULL, 10);
2749 case SMI_BASETYPE_UNSIGNED64:
2750 $$ = smiMalloc(sizeof(SmiValue));
2751 $$->basetype = SMI_BASETYPE_UNSIGNED64;
2752 $$->value.unsigned64 = strtoull($1, NULL, 10);
2754 case SMI_BASETYPE_INTEGER32:
2755 $$ = smiMalloc(sizeof(SmiValue));
2756 $$->basetype = SMI_BASETYPE_INTEGER32;
2757 $$->value.integer32 = strtol($1, NULL, 10);
2759 case SMI_BASETYPE_INTEGER64:
2760 $$ = smiMalloc(sizeof(SmiValue));
2761 $$->basetype = SMI_BASETYPE_INTEGER64;
2762 $$->value.integer64 = strtoll($1, NULL, 10);
2764 case SMI_BASETYPE_OBJECTIDENTIFIER:
2765 $$ = smiMalloc(sizeof(SmiValue));
2766 $$->basetype = SMI_BASETYPE_OBJECTIDENTIFIER;
2767 $$->len = strlen($1);
2768 $$->value.ptr = smiStrdup($1);
2772 smiPrintError(thisParserPtr,
2773 ERR_UNEXPECTED_VALUETYPE);
2780 switch (defaultBasetype) {
2781 case SMI_BASETYPE_INTEGER32:
2782 $$ = smiMalloc(sizeof(SmiValue));
2783 $$->basetype = SMI_BASETYPE_INTEGER32;
2784 $$->value.integer32 = - strtol($2, NULL, 10);
2786 case SMI_BASETYPE_INTEGER64:
2787 $$ = smiMalloc(sizeof(SmiValue));
2788 $$->basetype = SMI_BASETYPE_INTEGER64;
2789 $$->value.integer64 = - strtoll($2, NULL, 10);
2792 smiPrintError(thisParserPtr,
2793 ERR_UNEXPECTED_VALUETYPE);
2800 /* Note: might also be an octet string */
2801 switch (defaultBasetype) {
2802 case SMI_BASETYPE_UNSIGNED32:
2803 $$ = smiMalloc(sizeof(SmiValue));
2804 $$->basetype = SMI_BASETYPE_UNSIGNED32;
2805 $$->value.unsigned32 = strtoul($1, NULL, 16);
2807 case SMI_BASETYPE_UNSIGNED64:
2808 $$ = smiMalloc(sizeof(SmiValue));
2809 $$->basetype = SMI_BASETYPE_UNSIGNED64;
2810 $$->value.unsigned64 = strtoull($1, NULL, 16);
2812 case SMI_BASETYPE_INTEGER32:
2813 $$ = smiMalloc(sizeof(SmiValue));
2814 $$->basetype = SMI_BASETYPE_INTEGER32;
2815 $$->value.integer32 = strtol($1, NULL, 16);
2817 case SMI_BASETYPE_INTEGER64:
2818 $$ = smiMalloc(sizeof(SmiValue));
2819 $$->basetype = SMI_BASETYPE_INTEGER64;
2820 $$->value.integer64 = strtoll($1, NULL, 16);
2822 case SMI_BASETYPE_OCTETSTRING:
2823 $$ = smiMalloc(sizeof(SmiValue));
2824 $$->basetype = SMI_BASETYPE_OCTETSTRING;
2825 $$->value.ptr = hexToStr($1,strlen($1));
2826 $$->len = strlen($$->value.ptr);
2829 smiPrintError(thisParserPtr,
2830 ERR_UNEXPECTED_VALUETYPE);
2837 /* Note: might also be an OID */
2838 switch (defaultBasetype) {
2839 case SMI_BASETYPE_FLOAT32:
2840 $$ = smiMalloc(sizeof(SmiValue));
2841 $$->basetype = SMI_BASETYPE_FLOAT32;
2842 $$->value.float32 = strtof($1,NULL);
2843 if(errno == ERANGE){
2844 smiPrintError(thisParserPtr,
2845 ERR_FLOAT_OVERFLOW, $1);
2849 case SMI_BASETYPE_FLOAT64:
2850 $$ = smiMalloc(sizeof(SmiValue));
2851 $$->basetype = SMI_BASETYPE_FLOAT64;
2852 $$->value.float64 = strtod($1,NULL);
2853 if(errno == ERANGE){
2854 smiPrintError(thisParserPtr,
2855 ERR_FLOAT_OVERFLOW, $1);
2859 case SMI_BASETYPE_FLOAT128:
2860 $$ = smiMalloc(sizeof(SmiValue));
2861 $$->basetype = SMI_BASETYPE_FLOAT128;
2862 $$->value.float128 = strtold($1,NULL);
2863 if(errno == ERANGE){
2864 smiPrintError(thisParserPtr,
2865 ERR_FLOAT_OVERFLOW, $1);
2869 case SMI_BASETYPE_OBJECTIDENTIFIER:
2870 $$ = smiMalloc(sizeof(SmiValue));
2871 $$->basetype = SMI_BASETYPE_OBJECTIDENTIFIER;
2872 $$->value.ptr = smiMalloc(strlen($1)+1);
2873 strcpy($$->value.ptr,$1);
2874 $$->len = strlen($$->value.ptr);
2877 smiPrintError(thisParserPtr,
2878 ERR_UNEXPECTED_VALUETYPE);
2886 switch (defaultBasetype) {
2887 case SMI_BASETYPE_FLOAT32:
2888 $$ = smiMalloc(sizeof(SmiValue));
2889 $$->basetype = SMI_BASETYPE_FLOAT32;
2890 $$->value.float32 = - strtof($2,NULL);
2891 if(errno == ERANGE){
2892 smiPrintError(thisParserPtr,
2893 ERR_FLOAT_OVERFLOW, $2);
2897 case SMI_BASETYPE_FLOAT64:
2898 $$ = smiMalloc(sizeof(SmiValue));
2899 $$->basetype = SMI_BASETYPE_FLOAT64;
2900 $$->value.float64 = - strtof($2,NULL);
2901 if(errno == ERANGE){
2902 smiPrintError(thisParserPtr,
2903 ERR_FLOAT_OVERFLOW, $2);
2907 case SMI_BASETYPE_FLOAT128:
2908 $$ = smiMalloc(sizeof(SmiValue));
2909 $$->basetype = SMI_BASETYPE_FLOAT128;
2910 $$->value.float128 = - strtof($2,NULL);
2911 if(errno == ERANGE){
2912 smiPrintError(thisParserPtr,
2913 ERR_FLOAT_OVERFLOW, $2);
2918 smiPrintError(thisParserPtr,
2919 ERR_UNEXPECTED_VALUETYPE);
2926 /* Note: might also be an OID */
2927 switch (defaultBasetype) {
2928 case SMI_BASETYPE_FLOAT32:
2929 $$ = smiMalloc(sizeof(SmiValue));
2930 $$->basetype = SMI_BASETYPE_FLOAT32;
2931 $$->value.float32 = strtof($1,NULL);
2932 if(errno == ERANGE){
2933 smiPrintError(thisParserPtr,
2934 ERR_FLOAT_OVERFLOW, $1);
2938 case SMI_BASETYPE_FLOAT64:
2939 $$ = smiMalloc(sizeof(SmiValue));
2940 $$->basetype = SMI_BASETYPE_FLOAT64;
2941 $$->value.float64 = strtod($1,NULL);
2942 if(errno == ERANGE){
2943 smiPrintError(thisParserPtr,
2944 ERR_FLOAT_OVERFLOW, $1);
2948 case SMI_BASETYPE_FLOAT128:
2949 $$ = smiMalloc(sizeof(SmiValue));
2950 $$->basetype = SMI_BASETYPE_FLOAT128;
2951 $$->value.float128 = strtold($1,NULL);
2952 if(errno == ERANGE){
2953 smiPrintError(thisParserPtr,
2954 ERR_FLOAT_OVERFLOW, $1);
2959 smiPrintError(thisParserPtr,
2960 ERR_UNEXPECTED_VALUETYPE);
2967 if (defaultBasetype == SMI_BASETYPE_OCTETSTRING) {
2968 $$ = smiMalloc(sizeof(SmiValue));
2969 $$->basetype = SMI_BASETYPE_OCTETSTRING;
2971 $$->len = strlen($1);
2973 smiPrintError(thisParserPtr,
2974 ERR_UNEXPECTED_VALUETYPE);
2980 /* Note: might be an Enumeration item or OID */
2981 /* TODO: convert if it's an oid? */
2982 switch (defaultBasetype) {
2983 case SMI_BASETYPE_ENUM:
2984 $$ = smiMalloc(sizeof(SmiValue));
2985 $$->basetype = SMI_BASETYPE_ENUM;
2987 $$->len = strlen($1);
2988 /* TODO: XXX convert to int */
2990 case SMI_BASETYPE_OBJECTIDENTIFIER:
2991 $$ = smiMalloc(sizeof(SmiValue));
2992 $$->basetype = SMI_BASETYPE_OBJECTIDENTIFIER;
2994 $$->len = strlen($1);
2995 /* TODO: XXX convert to oid if found */
2997 case SMI_BASETYPE_POINTER:
2998 $$ = smiMalloc(sizeof(SmiValue));
2999 $$->basetype = SMI_BASETYPE_OBJECTIDENTIFIER;
3001 $$->len = strlen($1);
3002 /* TODO: XXX check if valid reference found */
3005 smiPrintError(thisParserPtr,
3006 ERR_UNEXPECTED_VALUETYPE);
3013 if (defaultBasetype == SMI_BASETYPE_OBJECTIDENTIFIER){
3014 $$ = smiMalloc(sizeof(SmiValue));
3015 $$->basetype = SMI_BASETYPE_OBJECTIDENTIFIER;
3017 $$->len = strlen($$->value.ptr);
3020 smiPrintError(thisParserPtr,
3021 ERR_UNEXPECTED_VALUETYPE);
3025 qOID: ucIdentifier COLON_COLON OID
3029 s = smiMalloc(strlen($1) +
3031 sprintf(s, "%s::%s", $1, $3);
3036 $$ = smiMalloc(strlen($1)+1);
3041 status: currentKeyword
3043 $$ = SMI_STATUS_CURRENT;
3047 $$ = SMI_STATUS_DEPRECATED;
3051 $$ = SMI_STATUS_OBSOLETE;
3055 number: hexadecimalNumber
3057 $$ = smiMalloc(sizeof(SmiValue));
3058 $$->basetype = SMI_BASETYPE_UNSIGNED64;
3059 $$->value.unsigned64 = strtoull($1, NULL, 16);
3063 $$ = smiMalloc(sizeof(SmiValue));
3064 $$->basetype = SMI_BASETYPE_UNSIGNED64;
3065 $$->value.unsigned64 = strtoull($1, NULL, 10);
3069 negativeNumber: '-' decimalNumber
3072 smiPrintError(thisParserPtr,
3073 ERR_BITS_NUMBER_NEGATIVE);
3076 $$ = smiMalloc(sizeof(SmiValue));
3077 $$->basetype = SMI_BASETYPE_INTEGER64;
3078 $$->value.integer64 = - strtoll($2, NULL, 10);
3082 signedNumber: number
3092 /* decimalNumber, hexadecimalNumber, floatValue */
3096 optsep_comma_01: /* empty */
3103 sep: /* empty, skipped by lexer */
3109 optsep: /* empty, skipped by lexer */
3115 stmtsep: /* empty, skipped by lexer */