o
    JPZ                  
   @   s^  d dl Z d dlZd dlmZ d dlmZ d dlmZ d dlm	Z	 d dlm
Z
 dd ejdD ZG d	d
 d
eZG dd deZG dd deZG dd deZG dd deZG dd deZG dd deZG dd deZG dd deZG dd deZejejejejgejejgejgej gej!gej"gej#gej$ej%gej&gd	Z'dd Z(dS )     N)lexerFactory)AbstractParser)error)debugc                 C   s   g | ]}t |qS  )int).0xr   r   2/usr/lib/python3/dist-packages/pysmi/parser/smi.py
<listcomp>   s    r   .c                   @   s  e Zd Ze Zd*ddZdd Zdd Zd	d
 Zdd Z	dd Z
dd Zdd Zdd Zdd Zdd Zdd Zdd Zdd Zdd  Zd!d" Zd#d$ Zd%d& Zd'd( Zd)d* Zd+d, Zd-d. Zd/d0 Zd1d2 Zd3d4 Zd5d6 Zd7d8 Zd9d: Z d;d< Z!d=d> Z"d?d@ Z#dAdB Z$dCdD Z%dEdF Z&dGdH Z'dIdJ Z(dKdL Z)dMdN Z*dOdP Z+dQdR Z,dSdT Z-dUdV Z.dWdX Z/dYdZ Z0d[d\ Z1d]d^ Z2d_d` Z3dadb Z4dcdd Z5dedf Z6dgdh Z7didj Z8dkdl Z9dmdn Z:dodp Z;dqdr Z<dsdt Z=dudv Z>dwdx Z?dydz Z@d{d| ZAd}d~ ZBdd ZCdd ZDdd ZEdd ZFdd ZGdd ZHdd ZIdd ZJdd ZKdd ZLdd ZMdd ZNdd ZOdd ZPdd ZQdd ZRdd ZSdd ZTdd ZUdd ZVdd ZWdd ZXdd ZYdd ZZdd Z[dd Z\dd Z]dd Z^dd Z_dd Z`dd Zadd Zbdd Zcdd ZdddĄ ZeddƄ ZfddȄ Zgddʄ Zhdd̄ Zidd΄ ZjddЄ Zkdd҄ ZlddԄ Zmddք Zndd؄ Zoddڄ Zpdd܄ Zqddބ Zrdd Zsdd Ztdd Zudd Zvdd Zwdd Zxdd Zydd Zzdd Z{dd Z|dd Z}dd Z~dd Zdd Zdd Zdd Zdd  Zdd Zdd Zdd Zdd Zd	d
 Zdd Zdd Zdd Zdd Zdd Zdd Zdd Zdd Zdd Zdd Zdd  Zd!d" Zd#d$ Zd%d& Zd'd( Zd)S (+  SmiV2ParsermibFile c              	   C   s   |r0t j||}zt | W n ty/   t d jdkr-t	d|t d f Y nw | j
|d| _| jj| _tddgk rQtj| |t|d|d| _d S tjtj@ r]tj }nt }tjtj@ rmtj }nd }tj| |t|d|||d	| _d S )
N      z'Failed to create cache directory %s: %s)tempdir   r   F)modulestartwrite_tablesr   	outputdir)r   r   r   r   r   ZdebuglogZerrorlog)ospathjoinmakedirsOSErrorsysexc_infoerrnor   
PySmiErrordefaultLexerlexertokensYACC_VERSIONyaccboolparserr   logger
flagParserZgetCurrentLoggerZ
NullLoggerZflagGrammar)selfZstartSymr   r(   Zdebugloggerr   r   r
   __init__   s@   
zSmiV2Parser.__init__c                 C   s   | j   d S )N)r"   reset)r*   r   r   r
   r,   =   s   zSmiV2Parser.resetc                 K   sj   t jt j@ ot dt||d d f  | jj|| jjd}|   |r3|d dkr3|d r3|d S g S )NzAsource MIB size is %s characters, first 50 characters are "%s..."2   )r"   r   r   r   )r   r(   r)   lenr'   parser"   r,   )r*   datakwargsastr   r   r
   r/   A   s   zSmiV2Parser.parsec                 C      d|d f|d< dS )z,mibFile : modules
                   | emptyr   r   r   Nr   r*   pr   r   r
   	p_mibFileR      zSmiV2Parser.p_mibFilec                 C   H   t |}|dkr|d |d g |d< dS |dkr"|d g|d< dS dS )z4modules : modules module
                   | moduler   r      r   Nr.   r*   r5   nr   r   r
   	p_modulesW      zSmiV2Parser.p_modulesc                 C   s$   |d |d |d |d f|d< dS )zomodule : moduleName moduleOid DEFINITIONS COLON_COLON_EQUAL BEGIN exportsClause linkagePart declarationPart ENDr   r9         r   Nr   r4   r   r   r
   p_module`   s
   zSmiV2Parser.p_modulec                 C   s$   t |}|dkr|d |d< dS dS )zAmoduleOid : '{' objectIdentifier '}'
                     | empty   r9   r   Nr:   r;   r   r   r
   p_moduleOidg   s   zSmiV2Parser.p_moduleOidc                 C      |d r|d |d< dS dS )z:linkagePart : linkageClause
                       | emptyr   r   Nr   r4   r   r   r
   p_linkagePartn      zSmiV2Parser.p_linkagePartc                 C      |d |d< dS )z&linkageClause : IMPORTS importPart ';'r9   r   Nr   r4   r   r   r
   p_linkageClauset      zSmiV2Parser.p_linkageClausec                 C      dS )z8exportsClause : EXPORTS
                         | emptyNr   r4   r   r   r
   p_exportsClausex       zSmiV2Parser.p_exportsClausec                 C   sT   |d r(i }|d D ]}|\}}||v r||  |7  < q
|||< q
||d< dS dS )z2importPart : imports
                      | emptyr   r   Nr   )r*   r5   Z
importDictimpZ
fromModulesymbolsr   r   r
   p_importPart|   s   
zSmiV2Parser.p_importPartc                 C   r8   )z4imports : imports import
                   | importr   r   r9   r   Nr:   r;   r   r   r
   	p_imports   r>   zSmiV2Parser.p_importsc                 C      |d |d f|d< dS )z*import : importIdentifiers FROM moduleNamer   r   r   Nr   r4   r   r   r
   p_import   s   zSmiV2Parser.p_importc                 C   H   t |}|dkr|d |d g |d< dS |dkr"|d g|d< dS dS )zjimportIdentifiers : importIdentifiers ',' importIdentifier
                             | importIdentifierrB   r   r   r   r9   Nr:   r;   r   r   r
   p_importIdentifiers   r>   zSmiV2Parser.p_importIdentifiersc                 C   rG   )zimportIdentifier : LOWERCASE_IDENTIFIER
                            | UPPERCASE_IDENTIFIER
                            | importedKeywordr   r   Nr   r4   r   r   r
   p_importIdentifier      zSmiV2Parser.p_importIdentifierc                 C   rG   )aA  importedKeyword : importedSMIKeyword
                           | BITS
                           | INTEGER32
                           | IPADDRESS
                           | MANDATORY_GROUPS
                           | MODULE_COMPLIANCE
                           | MODULE_IDENTITY
                           | OBJECT_GROUP
                           | OBJECT_IDENTITY
                           | OBJECT_TYPE
                           | OPAQUE
                           | TEXTUAL_CONVENTION
                           | TIMETICKS
                           | UNSIGNED32r   r   Nr   r4   r   r   r
   p_importedKeyword   s   zSmiV2Parser.p_importedKeywordc                 C   rG   )a2  importedSMIKeyword : AGENT_CAPABILITIES
                              | COUNTER32
                              | COUNTER64
                              | GAUGE32
                              | NOTIFICATION_GROUP
                              | NOTIFICATION_TYPE
                              | TRAP_TYPEr   r   Nr   r4   r   r   r
   p_importedSMIKeyword      z SmiV2Parser.p_importedSMIKeywordc                 C   rG   )z!moduleName : UPPERCASE_IDENTIFIERr   r   Nr   r4   r   r   r
   p_moduleName   rI   zSmiV2Parser.p_moduleNamec                 C   rD   )zAdeclarationPart : declarations
                           | emptyr   r   Nr   r4   r   r   r
   p_declarationPart   rF   zSmiV2Parser.p_declarationPartc                 C   r8   )zMdeclarations : declarations declaration
                        | declarationr   r   r9   r   Nr:   r;   r   r   r
   p_declarations   r>   zSmiV2Parser.p_declarationsc                 C   rD   )a  declaration : typeDeclaration
                       | valueDeclaration
                       | objectIdentityClause
                       | objectTypeClause
                       | trapTypeClause
                       | notificationTypeClause
                       | moduleIdentityClause
                       | moduleComplianceClause
                       | objectGroupClause
                       | notificationGroupClause
                       | agentCapabilitiesClause
                       | macroClauser   r   Nr   r4   r   r   r
   p_declaration   s   zSmiV2Parser.p_declarationc                 C   rJ   )z!macroClause : macroName MACRO ENDNr   r4   r   r   r
   p_macroClause   rL   zSmiV2Parser.p_macroClausec                 C   rJ   )az  macroName : MODULE_IDENTITY
                     | OBJECT_TYPE
                     | TRAP_TYPE
                     | NOTIFICATION_TYPE
                     | OBJECT_IDENTITY
                     | TEXTUAL_CONVENTION
                     | OBJECT_GROUP
                     | NOTIFICATION_GROUP
                     | MODULE_COMPLIANCE
                     | AGENT_CAPABILITIESNr   r4   r   r   r
   p_macroName   rL   zSmiV2Parser.p_macroNamec                 C   rJ   )zchoiceClause : CHOICE Nr   r4   r   r   r
   p_choiceClause   rL   zSmiV2Parser.p_choiceClausec                 C   rG   )znfuzzy_lowercase_identifier : LOWERCASE_IDENTIFIER
                                      | UPPERCASE_IDENTIFIERr   r   Nr   r4   r   r   r
   p_fuzzy_lowercase_identifier      z(SmiV2Parser.p_fuzzy_lowercase_identifierc                 C      d|d |d f|d< dS )zjvalueDeclaration : fuzzy_lowercase_identifier OBJECT IDENTIFIER COLON_COLON_EQUAL '{' objectIdentifier '}'ZvalueDeclarationr      r   Nr   r4   r   r   r
   p_valueDeclaration     zSmiV2Parser.p_valueDeclarationc                 C   rc   )z?typeDeclaration : typeName COLON_COLON_EQUAL typeDeclarationRHSZtypeDeclarationr   r   r   Nr   r4   r   r   r
   p_typeDeclaration  rf   zSmiV2Parser.p_typeDeclarationc                 C   rG   )z=typeName : UPPERCASE_IDENTIFIER
                    | typeSMIr   r   Nr   r4   r   r   r
   
p_typeName  rb   zSmiV2Parser.p_typeNamec                 C   rG   )z9typeSMI : typeSMIandSPPI
                   | typeSMIonlyr   r   Nr   r4   r   r   r
   	p_typeSMI  rb   zSmiV2Parser.p_typeSMIc                 C   rG   )ztypeSMIandSPPI : IPADDRESS
                          | TIMETICKS
                          | OPAQUE
                          | INTEGER32
                          | UNSIGNED32r   r   Nr   r4   r   r   r
   p_typeSMIandSPPI  s   zSmiV2Parser.p_typeSMIandSPPIc                 C   rG   )z[typeSMIonly : COUNTER32
                       | GAUGE32
                       | COUNTER64r   r   Nr   r4   r   r   r
   p_typeSMIonly  rV   zSmiV2Parser.p_typeSMIonlyc                 C   s`   |d r.|d dkr$d|d |d |d |d f|d |d	 f|d
< dS d|d f|d
< dS dS )ztypeDeclarationRHS : Syntax
                              | TEXTUAL_CONVENTION DisplayPart STATUS Status DESCRIPTION Text ReferPart SYNTAX Syntax
                              | choiceClauser   zTEXTUAL-CONVENTIONZtypeDeclarationRHSr9   rB      rd   r?   	   r   Nr   r4   r   r   r
   p_typeDeclarationRHS#  s   z SmiV2Parser.p_typeDeclarationRHSc                 C   r3   )z!conceptualTable : SEQUENCE OF rowZconceptualTabler   r   Nr   r4   r   r   r
   p_conceptualTable2     zSmiV2Parser.p_conceptualTablec                 C   r3   )zrow : UPPERCASE_IDENTIFIERrowr   r   Nr   r4   r   r   r
   p_row6  r7   zSmiV2Parser.p_rowc                 C   rQ   )z*entryType : SEQUENCE '{' sequenceItems '}'r   r   r   Nr   r4   r   r   r
   p_entryType;     zSmiV2Parser.p_entryTypec                 C   rS   )zVsequenceItems : sequenceItems ',' sequenceItem
                         | sequenceItemrB   r   r   r   r9   Nr:   r;   r   r   r
   p_sequenceItems?  s   zSmiV2Parser.p_sequenceItemsc                 C   rQ   )z2sequenceItem : LOWERCASE_IDENTIFIER sequenceSyntaxr   r9   r   Nr   r4   r   r   r
   p_sequenceItemI  rt   zSmiV2Parser.p_sequenceItemc                 C   D   t |}|dkr|d |d< dS |dkr |d |d f|d< dS dS )z@Syntax : ObjectSyntax
                  | BITS '{' NamedBits '}'r9   r   r   rl   r   Nr:   r;   r   r   r
   p_SyntaxM  s   zSmiV2Parser.p_Syntaxc                 C   rG   )zsequenceSyntax : BITS
                          | UPPERCASE_IDENTIFIER anySubType
                          | sequenceObjectSyntaxr   r   Nr   r4   r   r   r
   p_sequenceSyntaxX  rV   zSmiV2Parser.p_sequenceSyntaxc                 C   rS   )zBNamedBits : NamedBits ',' NamedBit
                     | NamedBitrB   r   r   r   r9   Nr:   r;   r   r   r
   p_NamedBits^  r>   zSmiV2Parser.p_NamedBitsc                 C   rQ   )z.NamedBit : LOWERCASE_IDENTIFIER '(' NUMBER ')'r   r   r   Nr   r4   r   r   r
   
p_NamedBitg  rt   zSmiV2Parser.p_NamedBitc                 C   s4   d|d |d |d |d f|d |d f|d< d	S )
zobjectIdentityClause : LOWERCASE_IDENTIFIER OBJECT_IDENTITY STATUS Status DESCRIPTION Text ReferPart COLON_COLON_EQUAL '{' objectIdentifier '}'ZobjectIdentityClauser   rB   rl   rd   r?   
   r   Nr   r4   r   r   r
   p_objectIdentityClausek  s   z"SmiV2Parser.p_objectIdentityClausec                 C   sP   d|d |d |d |d |d |d |d |d	 |d
 |d |d f|d< dS )zobjectTypeClause : LOWERCASE_IDENTIFIER OBJECT_TYPE SYNTAX Syntax UnitsPart MaxOrPIBAccessPart STATUS Status descriptionClause ReferPart IndexPart MibIndex DefValPart COLON_COLON_EQUAL '{' ObjectName '}'ZobjectTypeClauser   rB   rl   rd   r@   rm   r|               r   Nr   r4   r   r   r
   p_objectTypeClauset  s   zSmiV2Parser.p_objectTypeClausec                 C   $   |d r|d |d f|d< dS dS )zIdescriptionClause : DESCRIPTION Text
                             | emptyr   r9   r   Nr   r4   r   r   r
   p_descriptionClause     zSmiV2Parser.p_descriptionClausec                 C   2   d|d |d |d |d |d |d f|d< d	S )
ztrapTypeClause : fuzzy_lowercase_identifier TRAP_TYPE ENTERPRISE objectIdentifier VarPart DescrPart ReferPart COLON_COLON_EQUAL NUMBERtrapTypeClauser   rB   rl   rd   r?   rm   r   Nr   r4   r   r   r
   p_trapTypeClause  s   zSmiV2Parser.p_trapTypeClausec                 C      |d r|d p	g |d< dS )z?VarPart : VARIABLES '{' VarTypes '}'
                   | emptyr   r   r   Nr   r4   r   r   r
   	p_VarPart     zSmiV2Parser.p_VarPartc                 C   T   t |}|dkrd|d d |d g f|d< dS |dkr(d|d gf|d< dS dS )z=VarTypes : VarTypes ',' VarType
                    | VarTyperB   ZVarTypesr   r   r   r9   Nr:   r;   r   r   r
   
p_VarTypes     "zSmiV2Parser.p_VarTypesc                 C      |d d d |d< dS )zVarType : ObjectNamer   r   Nr   r4   r   r   r
   	p_VarType  rt   zSmiV2Parser.p_VarTypec                 C   r   )z9DescrPart : DESCRIPTION Text
                     | emptyr   r9   r   Nr   r4   r   r   r
   p_DescrPart  r   zSmiV2Parser.p_DescrPartc                 C   rD   )zHMaxOrPIBAccessPart : MaxAccessPart
                              | emptyr   r   Nr   r4   r   r   r
   p_MaxOrPIBAccessPart  rF   z SmiV2Parser.p_MaxOrPIBAccessPartc                 C   r3   )zJMaxAccessPart : MAX_ACCESS Access
                         | ACCESS AccessZMaxAccessPartr9   r   Nr   r4   r   r   r
   p_MaxAccessPart  r7   zSmiV2Parser.p_MaxAccessPartc                 C   :   d|d |d |d |d |d f|d |d f|d	< d
S )znotificationTypeClause : LOWERCASE_IDENTIFIER NOTIFICATION_TYPE NotificationObjectsPart STATUS Status DESCRIPTION Text ReferPart COLON_COLON_EQUAL '{' NotificationName '}'notificationTypeClauser   r   rl   rd   r?   r@   r~   r   Nr   r4   r   r   r
   p_notificationTypeClause  s   z$SmiV2Parser.p_notificationTypeClausec              	   C   sX   d|d |d |d f|d |d f|d |d f|d	 |d
 f|d |d f|d< dS )zmoduleIdentityClause : LOWERCASE_IDENTIFIER MODULE_IDENTITY SubjectCategoriesPart LAST_UPDATED ExtUTCTime ORGANIZATION Text CONTACT_INFO Text DESCRIPTION Text RevisionPart COLON_COLON_EQUAL '{' objectIdentifier '}'ZmoduleIdentityClauser   rB   rl   rd   r?   r@   rm   r|   r~   r      r   Nr   r4   r   r   r
   p_moduleIdentityClause  s   z"SmiV2Parser.p_moduleIdentityClausec                 C   rJ   )zmSubjectCategoriesPart : SUBJECT_CATEGORIES '{' SubjectCategories '}'
                                 | emptyNr   r4   r   r   r
   p_SubjectCategoriesPart  rL   z#SmiV2Parser.p_SubjectCategoriesPartc                 C   rJ   )zSubjectCategories : CategoryIDsNr   r4   r   r   r
   p_SubjectCategories  rL   zSmiV2Parser.p_SubjectCategoriesc                 C   rJ   )zLCategoryIDs : CategoryIDs ',' CategoryID
                       | CategoryIDNr   r4   r   r   r
   p_CategoryIDs  rL   zSmiV2Parser.p_CategoryIDsc                 C   rJ   )z]CategoryID : LOWERCASE_IDENTIFIER '(' NUMBER ')'
                      | LOWERCASE_IDENTIFIERNr   r4   r   r   r
   p_CategoryID  rL   zSmiV2Parser.p_CategoryIDc                 C   <   t |}|dkr|d |d< dS |dkr|d |d< dS dS )zObjectSyntax : SimpleSyntax
                        | conceptualTable
                        | row
                        | entryType
                        | ApplicationSyntax
                        | typeTag SimpleSyntaxr9   r   r   r   Nr:   r;   r   r   r
   p_ObjectSyntax  s   zSmiV2Parser.p_ObjectSyntaxc                 C   rJ   )zdtypeTag : '[' APPLICATION NUMBER ']' IMPLICIT
                   | '[' UNIVERSAL NUMBER ']' IMPLICITNr   r4   r   r   r
   	p_typeTag  rL   zSmiV2Parser.p_typeTagc                 C   rG   )zgsequenceObjectSyntax : sequenceSimpleSyntax
                                | sequenceApplicationSyntaxr   r   Nr   r4   r   r   r
   p_sequenceObjectSyntax  rV   z"SmiV2Parser.p_sequenceObjectSyntaxc                 C   rG   )z)valueofObjectSyntax : valueofSimpleSyntaxr   r   Nr   r4   r   r   r
   p_valueofObjectSyntax  rI   z!SmiV2Parser.p_valueofObjectSyntaxc                 C   s   t |}|dkrd|d f|d< d	S |dkr9|d dkr,d|d d |d  f|d< d	S d|d |d f|d< d	S |dkrPd|d d |d  |d f|d< d	S d	S )
a  SimpleSyntax : INTEGER
                        | INTEGER integerSubType
                        | INTEGER enumSpec
                        | INTEGER32
                        | INTEGER32 integerSubType
                        | UPPERCASE_IDENTIFIER enumSpec
                        | UPPERCASE_IDENTIFIER integerSubType
                        | OCTET STRING
                        | OCTET STRING octetStringSubType
                        | UPPERCASE_IDENTIFIER octetStringSubType
                        | OBJECT IDENTIFIER anySubTyper9   ZSimpleSyntaxr   r   r   ZOCTET rB   Nr:   r;   r   r   r
   p_SimpleSyntax	  s    &zSmiV2Parser.p_SimpleSyntaxc                 C   s2   t |}|dkr|d |d< dS |dkr	 dS dS )a  valueofSimpleSyntax : NUMBER
                               | NEGATIVENUMBER
                               | NUMBER64
                               | NEGATIVENUMBER64
                               | HEX_STRING
                               | BIN_STRING
                               | LOWERCASE_IDENTIFIER
                               | QUOTED_STRING
                               | '{' objectIdentifier_defval '}'r9   r   r   rB   Nr:   r;   r   r   r
   p_valueofSimpleSyntax"  s   z!SmiV2Parser.p_valueofSimpleSyntaxc                 C   sH   t |}|dkr|d |d< dS |dkr"|d d |d  |d< dS dS )zsequenceSimpleSyntax : INTEGER anySubType
                                | INTEGER32 anySubType
                                | OCTET STRING anySubType
                                | OBJECT IDENTIFIER anySubTyper   r   r   rB   r   r9   Nr:   r;   r   r   r
   p_sequenceSimpleSyntax7  s   z"SmiV2Parser.p_sequenceSimpleSyntaxc                 C   J   t |}|dkrd|d f|d< dS |dkr#d|d |d f|d< dS dS )a=  ApplicationSyntax : IPADDRESS anySubType
                             | COUNTER32
                             | COUNTER32 integerSubType
                             | GAUGE32
                             | GAUGE32 integerSubType
                             | UNSIGNED32
                             | UNSIGNED32 integerSubType
                             | TIMETICKS anySubType
                             | OPAQUE
                             | OPAQUE octetStringSubType
                             | COUNTER64
                             | COUNTER64 integerSubTyper9   ApplicationSyntaxr   r   r   Nr:   r;   r   r   r
   p_ApplicationSyntaxB  s   zSmiV2Parser.p_ApplicationSyntaxc                 C   <   t |}|dkr|d |d< dS |dkr|d |d< dS dS )a  sequenceApplicationSyntax : IPADDRESS anySubType
                                     | COUNTER32 anySubType
                                     | GAUGE32 anySubType
                                     | UNSIGNED32 anySubType
                                     | TIMETICKS anySubType
                                     | OPAQUE
                                     | COUNTER64 anySubTyper9   r   r   r   Nr:   r;   r   r   r
   p_sequenceApplicationSyntaxV  s   z'SmiV2Parser.p_sequenceApplicationSyntaxc                 C   rD   )zanySubType : integerSubType
                      | octetStringSubType
                      | enumSpec
                      | emptyr   r   Nr   r4   r   r   r
   p_anySubTyped  s   zSmiV2Parser.p_anySubTypec                 C   r3   )zintegerSubType : '(' ranges ')'ZintegerSubTyper9   r   Nr   r4   r   r   r
   p_integerSubTypel  rp   zSmiV2Parser.p_integerSubTypec                 C   r3   )z0octetStringSubType : '(' SIZE '(' ranges ')' ')'ZoctetStringSubTyperB   r   Nr   r4   r   r   r
   p_octetStringSubTypep  rp   z SmiV2Parser.p_octetStringSubTypec                 C   rS   )z3ranges : ranges '|' range
                  | rangerB   r   r   r   r9   Nr:   r;   r   r   r
   p_rangest  r>   zSmiV2Parser.p_rangesc                 C   sF   t |}|dkr|d f|d< dS |dkr!|d |d f|d< dS dS )z4range : value DOT_DOT value
                 | valuer9   r   r   rB   r   Nr:   r;   r   r   r
   p_range}  s   zSmiV2Parser.p_rangec                 C   rG   )zvalue : NEGATIVENUMBER
                 | NUMBER
                 | NEGATIVENUMBER64
                 | NUMBER64
                 | HEX_STRING
                 | BIN_STRINGr   r   Nr   r4   r   r   r
   p_value  s   zSmiV2Parser.p_valuec                 C   r3   )zenumSpec : '{' enumItems '}'ZenumSpecr9   r   Nr   r4   r   r   r
   
p_enumSpec  rp   zSmiV2Parser.p_enumSpecc                 C   rS   )zBenumItems : enumItems ',' enumItem
                     | enumItemrB   r   r   r   r9   Nr:   r;   r   r   r
   p_enumItems  r>   zSmiV2Parser.p_enumItemsc                 C   rQ   )z2enumItem : LOWERCASE_IDENTIFIER '(' enumNumber ')'r   r   r   Nr   r4   r   r   r
   
p_enumItem  rt   zSmiV2Parser.p_enumItemc                 C   rG   )z:enumNumber : NUMBER
                      | NEGATIVENUMBERr   r   Nr   r4   r   r   r
   p_enumNumber  rV   zSmiV2Parser.p_enumNumberc                 C   r3   )zStatus : LOWERCASE_IDENTIFIERZStatusr   r   Nr   r4   r   r   r
   p_Status  rp   zSmiV2Parser.p_Statusc                 C   r   )z>DisplayPart : DISPLAY_HINT Text
                       | emptyr   r9   r   Nr   r4   r   r   r
   p_DisplayPart  r   zSmiV2Parser.p_DisplayPartc                 C   r   )z3UnitsPart : UNITS Text
                     | emptyr   r9   r   Nr   r4   r   r   r
   p_UnitsPart  r   zSmiV2Parser.p_UnitsPartc                 C   rG   )zAccess : LOWERCASE_IDENTIFIERr   r   Nr   r4   r   r   r
   p_Access  rI   zSmiV2Parser.p_Accessc                 C      |d r|d |d< dS dS )z?IndexPart : AUGMENTS '{' Entry '}'
                     | emptyr   r   r   Nr   r4   r   r   r
   p_IndexPart  rF   zSmiV2Parser.p_IndexPartc                 C   r   )z?MibIndex : INDEX '{' IndexTypes '}'
                    | emptyr   r   r   Nr   r4   r   r   r
   
p_MibIndex  r   zSmiV2Parser.p_MibIndexc                 C   rS   )zGIndexTypes : IndexTypes ',' IndexType
                      | IndexTyperB   r   r   r   r9   Nr:   r;   r   r   r
   p_IndexTypes  r>   zSmiV2Parser.p_IndexTypesc                 C   sD   t |}|dkrd|d f|d< dS |dkr d|d f|d< dS dS )z6IndexType : IMPLIED Index
                     | Indexr9   r   r   r   Nr:   r;   r   r   r
   p_IndexType  s   zSmiV2Parser.p_IndexTypec                 C   r   )zIndex : ObjectNamer   r   Nr   r4   r   r   r
   p_Index     zSmiV2Parser.p_Indexc                 C   r   )zEntry : ObjectNamer   r   Nr   r4   r   r   r
   p_Entry  rt   zSmiV2Parser.p_Entryc                 C   s0   |d r|d r|d |d f|d< dS dS dS )z?DefValPart : DEFVAL '{' Value '}'
                      | emptyr   r   r   Nr   r4   r   r   r
   p_DefValPart  s   zSmiV2Parser.p_DefValPartc                 C   r   )z@Value : valueofObjectSyntax
                 | '{' BitsValue '}'r9   r   r   rB   Nr:   r;   r   r   r
   p_Value  s   zSmiV2Parser.p_Valuec                 C   rD   )z1BitsValue : BitNames
                     | emptyr   r   Nr   r4   r   r   r
   p_BitsValue  rF   zSmiV2Parser.p_BitsValuec                 C   r   )zWBitNames : BitNames ',' LOWERCASE_IDENTIFIER
                    | LOWERCASE_IDENTIFIERrB   ZBitNamesr   r   r   r9   Nr:   r;   r   r   r
   
p_BitNames  r   zSmiV2Parser.p_BitNamesc                 C   rG   )zObjectName : objectIdentifierr   r   Nr   r4   r   r   r
   p_ObjectName   rI   zSmiV2Parser.p_ObjectNamec                 C   rG   )z#NotificationName : objectIdentifierr   r   Nr   r4   r   r   r
   p_NotificationName  rI   zSmiV2Parser.p_NotificationNamec                 C   r   )z7ReferPart : REFERENCE Text
                     | emptyr   r9   r   Nr   r4   r   r   r
   p_ReferPart  r   zSmiV2Parser.p_ReferPartc                 C   rD   )z8RevisionPart : Revisions
                        | emptyr   r   Nr   r4   r   r   r
   p_RevisionPart  rF   zSmiV2Parser.p_RevisionPartc                 C   T   t |}|dkrd|d d |d g f|d< dS |dkr(d|d gf|d< dS dS )z>Revisions : Revisions Revision
                     | Revisionr   Z	Revisionsr   r9   r   Nr:   r;   r   r   r
   p_Revisions  r   zSmiV2Parser.p_Revisionsc                 C   s    |d |d |d ff|d< dS )z/Revision : REVISION ExtUTCTime DESCRIPTION Textr9   r   rB   r   Nr   r4   r   r   r
   
p_Revision  s   zSmiV2Parser.p_Revisionc                 C   r   )z\NotificationObjectsPart : OBJECTS '{' Objects '}'
                                   | emptyr   r   r   Nr   r4   r   r   r
   p_NotificationObjectsPart"  r   z%SmiV2Parser.p_NotificationObjectsPartc                 C   rG   )z0ObjectGroupObjectsPart : OBJECTS '{' Objects '}'r   r   Nr   r4   r   r   r
   p_ObjectGroupObjectsPart'  rI   z$SmiV2Parser.p_ObjectGroupObjectsPartc                 C   r   )z8Objects : Objects ',' Object
                   | ObjectrB   ZObjectsr   r   r   r9   Nr:   r;   r   r   r
   	p_Objects+  r   zSmiV2Parser.p_Objectsc                 C   r   )zObject : ObjectNamer   r   Nr   r4   r   r   r
   p_Object4  rt   zSmiV2Parser.p_Objectc                 C   rG   )z7NotificationsPart : NOTIFICATIONS '{' Notifications '}'r   r   Nr   r4   r   r   r
   p_NotificationsPart8  rI   zSmiV2Parser.p_NotificationsPartc                 C   r   )zVNotifications : Notifications ',' Notification
                         | NotificationrB   ZNotificationsr   r   r   r9   Nr:   r;   r   r   r
   p_Notifications<  r   zSmiV2Parser.p_Notificationsc                 C   r   )zNotification : NotificationNamer   r   Nr   r4   r   r   r
   p_NotificationE  rt   zSmiV2Parser.p_Notificationc                 C      |d dd |d< dS )zText : QUOTED_STRINGr   r   Nr   r4   r   r   r
   p_TextI  rt   zSmiV2Parser.p_Textc                 C   r   )zExtUTCTime : QUOTED_STRINGr   r   r   Nr   r4   r   r   r
   p_ExtUTCTimeM  rt   zSmiV2Parser.p_ExtUTCTimec                 C   r3   )z!objectIdentifier : subidentifiersZobjectIdentifierr   r   Nr   r4   r   r   r
   p_objectIdentifierQ  rp   zSmiV2Parser.p_objectIdentifierc                 C   r8   )zWsubidentifiers : subidentifiers subidentifier
                          | subidentifierr   r   r9   r   Nr:   r;   r   r   r
   p_subidentifiersU  r>   zSmiV2Parser.p_subidentifiersc                 C   rw   )zsubidentifier : fuzzy_lowercase_identifier
                         | NUMBER
                         | LOWERCASE_IDENTIFIER '(' NUMBER ')'r9   r   r   rl   r   Nr:   r;   r   r   r
   p_subidentifier^  s   zSmiV2Parser.p_subidentifierc                 C   r3   )z/objectIdentifier_defval : subidentifiers_defvalZobjectIdentifier_defvalr   r   Nr   r4   r   r   r
   p_objectIdentifier_defvalj  rp   z%SmiV2Parser.p_objectIdentifier_defvalc                 C   r   )zzsubidentifiers_defval : subidentifiers_defval subidentifier_defval
                                 | subidentifier_defvalr   Zsubidentifiers_defvalr   r9   r   Nr:   r;   r   r   r
   p_subidentifiers_defvaln  r   z#SmiV2Parser.p_subidentifiers_defvalc                 C   sJ   t |}|dkrd|d f|d< dS |dkr#d|d |d f|d< dS dS )zcsubidentifier_defval : LOWERCASE_IDENTIFIER '(' NUMBER ')'
                                | NUMBERr9   Zsubidentifier_defvalr   r   rl   r   Nr:   r;   r   r   r
   p_subidentifier_defvalw  s   z"SmiV2Parser.p_subidentifier_defvalc                 C   r   )zobjectGroupClause : LOWERCASE_IDENTIFIER OBJECT_GROUP ObjectGroupObjectsPart STATUS Status DESCRIPTION Text ReferPart COLON_COLON_EQUAL '{' objectIdentifier '}'ZobjectGroupClauser   r   rl   rd   r?   r@   r~   r   Nr   r4   r   r   r
   p_objectGroupClause     zSmiV2Parser.p_objectGroupClausec                 C   r   )znotificationGroupClause : LOWERCASE_IDENTIFIER NOTIFICATION_GROUP NotificationsPart STATUS Status DESCRIPTION Text ReferPart COLON_COLON_EQUAL '{' objectIdentifier '}'ZnotificationGroupClauser   r   rl   rd   r?   r@   r~   r   Nr   r4   r   r   r
   p_notificationGroupClause  r   z%SmiV2Parser.p_notificationGroupClausec                 C   s:   d|d |d |d |d f|d |d |d f|d	< d
S )zmoduleComplianceClause : LOWERCASE_IDENTIFIER MODULE_COMPLIANCE STATUS Status DESCRIPTION Text ReferPart ComplianceModulePart COLON_COLON_EQUAL '{' objectIdentifier '}'ZmoduleComplianceClauser   rB   rl   rd   r?   r@   r~   r   Nr   r4   r   r   r
   p_moduleComplianceClause  s   z$SmiV2Parser.p_moduleComplianceClausec                 C   rG   )z(ComplianceModulePart : ComplianceModulesr   r   Nr   r4   r   r   r
   p_ComplianceModulePart  rI   z"SmiV2Parser.p_ComplianceModulePartc                 C   r   )zfComplianceModules : ComplianceModules ComplianceModule
                             | ComplianceModuler   ZComplianceModulesr   r9   r   Nr:   r;   r   r   r
   p_ComplianceModules  r   zSmiV2Parser.p_ComplianceModulesc                 C   sH   |d r
|d d pg }||d r|d d pg 7 }|d |f|d< dS )zKComplianceModule : MODULE ComplianceModuleName MandatoryPart CompliancePartr   r   rB   r9   r   Nr   )r*   r5   Zobjectsr   r   r
   p_ComplianceModule  s
   zSmiV2Parser.p_ComplianceModulec                 C   rG   )zSComplianceModuleName : UPPERCASE_IDENTIFIER
                                | emptyr   r   Nr   r4   r   r   r
   p_ComplianceModuleName  rV   z"SmiV2Parser.p_ComplianceModuleNamec                 C   r   )zYMandatoryPart : MANDATORY_GROUPS '{' MandatoryGroups '}'
                         | emptyr   r   r   Nr   r4   r   r   r
   p_MandatoryPart  rF   zSmiV2Parser.p_MandatoryPartc                 C   r   )z`MandatoryGroups : MandatoryGroups ',' MandatoryGroup
                           | MandatoryGrouprB   ZMandatoryGroupsr   r   r   r9   Nr:   r;   r   r   r
   p_MandatoryGroups  r   zSmiV2Parser.p_MandatoryGroupsc                 C   r   )z!MandatoryGroup : objectIdentifierr   r   Nr   r4   r   r   r
   p_MandatoryGroup  rt   zSmiV2Parser.p_MandatoryGroupc                 C   rD   )z>CompliancePart : Compliances
                          | emptyr   r   Nr   r4   r   r   r
   p_CompliancePart  rF   zSmiV2Parser.p_CompliancePartc                 C   sx   t |}|dkr%|d r|d rd|d d |d g fp |d |d< dS |dkr:|d r4d|d gfp5d|d< dS dS )zHCompliances : Compliances Compliance
                       | Compliancer   r   r9   ZCompliancesr   Nr:   r;   r   r   r
   p_Compliances  s   :"zSmiV2Parser.p_Compliancesc                 C   rD   )zECompliance : ComplianceGroup
                      | ComplianceObjectr   r   Nr   r4   r   r   r
   p_Compliance  rF   zSmiV2Parser.p_Compliancec                 C   s   |d d d |d< dS )z9ComplianceGroup : GROUP objectIdentifier DESCRIPTION Textr9   r   r   Nr   r4   r   r   r
   p_ComplianceGroup  rt   zSmiV2Parser.p_ComplianceGroupc                 C   rJ   )z[ComplianceObject : OBJECT ObjectName SyntaxPart WriteSyntaxPart AccessPart DESCRIPTION TextNr   r4   r   r   r
   p_ComplianceObject  rL   zSmiV2Parser.p_ComplianceObjectc                 C   r   )z8SyntaxPart : SYNTAX Syntax
                      | emptyr   r9   r   Nr   r4   r   r   r
   p_SyntaxPart  rF   zSmiV2Parser.p_SyntaxPartc                 C   r   )zMWriteSyntaxPart : WRITE_SYNTAX WriteSyntax
                           | emptyr   r9   r   Nr   r4   r   r   r
   p_WriteSyntaxPart  rF   zSmiV2Parser.p_WriteSyntaxPartc                 C   r3   )zWriteSyntax : SyntaxZWriteSyntaxr   r   Nr   r4   r   r   r
   p_WriteSyntax  rp   zSmiV2Parser.p_WriteSyntaxc                 C   r   )z<AccessPart : MIN_ACCESS Access
                      | emptyr   r9   r   Nr   r4   r   r   r
   p_AccessPart   r   zSmiV2Parser.p_AccessPartc                 C   sB   d|d |d |d f|d |d |d f|d |d	 f|d
< dS )zagentCapabilitiesClause : LOWERCASE_IDENTIFIER AGENT_CAPABILITIES PRODUCT_RELEASE Text STATUS Status DESCRIPTION Text ReferPart ModulePart_Capabilities COLON_COLON_EQUAL '{' objectIdentifier '}'ZagentCapabilitiesClauser   r   rB   rd   r?   r@   rm   r   r   Nr   r4   r   r   r
   p_agentCapabilitiesClause  s   z%SmiV2Parser.p_agentCapabilitiesClausec                 C   rJ   )zYModulePart_Capabilities : Modules_Capabilities
                                   | emptyNr   r4   r   r   r
   p_ModulePart_Capabilities  rL   z%SmiV2Parser.p_ModulePart_Capabilitiesc                 C   rJ   )zuModules_Capabilities : Modules_Capabilities Module_Capabilities
                                | Module_CapabilitiesNr   r4   r   r   r
   p_Modules_Capabilities  rL   z"SmiV2Parser.p_Modules_Capabilitiesc                 C   rJ   )zhModule_Capabilities : SUPPORTS ModuleName_Capabilities INCLUDES '{' CapabilitiesGroups '}' VariationPartNr   r4   r   r   r
   p_Module_Capabilities   rL   z!SmiV2Parser.p_Module_Capabilitiesc                 C   rJ   )zoCapabilitiesGroups : CapabilitiesGroups ',' CapabilitiesGroup
                              | CapabilitiesGroupNr   r4   r   r   r
   p_CapabilitiesGroups&  rL   z SmiV2Parser.p_CapabilitiesGroupsc                 C   rJ   )z$CapabilitiesGroup : objectIdentifierNr   r4   r   r   r
   p_CapabilitiesGroup/  rL   zSmiV2Parser.p_CapabilitiesGroupc                 C   rJ   )zyModuleName_Capabilities : UPPERCASE_IDENTIFIER objectIdentifier
                                   | UPPERCASE_IDENTIFIERNr   r4   r   r   r
   p_ModuleName_Capabilities3  rL   z%SmiV2Parser.p_ModuleName_Capabilitiesc                 C   rJ   )z;VariationPart : Variations
                         | emptyNr   r4   r   r   r
   p_VariationPart<  rL   zSmiV2Parser.p_VariationPartc                 C   rJ   )zCVariations : Variations Variation
                      | VariationNr   r4   r   r   r
   p_VariationsB  rL   zSmiV2Parser.p_Variationsc                 C   rJ   )zxVariation : VARIATION ObjectName SyntaxPart WriteSyntaxPart VariationAccessPart CreationPart DefValPart DESCRIPTION TextNr   r4   r   r   r
   p_VariationK  rL   zSmiV2Parser.p_Variationc                 C   rJ   )zSVariationAccessPart : ACCESS VariationAccess
                               | emptyNr   r4   r   r   r
   p_VariationAccessPartV  rL   z!SmiV2Parser.p_VariationAccessPartc                 C   rJ   )z&VariationAccess : LOWERCASE_IDENTIFIERNr   r4   r   r   r
   p_VariationAccess\  rL   zSmiV2Parser.p_VariationAccessc                 C   r   )zNCreationPart : CREATION_REQUIRES '{' Cells '}'
                        | emptyr   r   r   Nr   r4   r   r   r
   p_CreationPart`  r   zSmiV2Parser.p_CreationPartc                 C   r   )z.Cells : Cells ',' Cell
                 | CellrB   ZCellsr   r   r   r9   Nr:   r;   r   r   r
   p_Cellsf  r   zSmiV2Parser.p_Cellsc                 C   r3   )zCell : ObjectNameZCellr   r   Nr   r4   r   r   r
   p_Cello  rp   zSmiV2Parser.p_Cellc                 C   rJ   )zempty :Nr   r4   r   r   r
   p_emptys  rL   zSmiV2Parser.p_emptyc                 C   s$   |rt jd|j|jf |jdd S )Nz(Bad grammar near token type %s, value %s)lineno)r   ZPySmiParserErrortypevaluer  r4   r   r   r
   p_errorw  s
   zSmiV2Parser.p_errorN)r   r   )__name__
__module____qualname__r   r!   r+   r,   r/   r6   r=   rA   rC   rE   rH   rK   rO   rP   rR   rT   rU   rW   rX   rZ   r[   r\   r]   r^   r_   r`   ra   re   rg   rh   ri   rj   rk   rn   ro   rr   rs   ru   rv   rx   ry   rz   r{   r}   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r  r   r   r   r
   r      s*   '		

	
																		

			
						r   c                   @   s<   e Zd Zedd Zedd Zedd Zedd Zd	S )
SupportSmiV1Keywordsc                 C   rG   )am  importedKeyword : importedSMIKeyword
                           | BITS
                           | INTEGER32
                           | IPADDRESS
                           | NETWORKADDRESS
                           | MANDATORY_GROUPS
                           | MODULE_COMPLIANCE
                           | MODULE_IDENTITY
                           | OBJECT_GROUP
                           | OBJECT_IDENTITY
                           | OBJECT_TYPE
                           | OPAQUE
                           | TEXTUAL_CONVENTION
                           | TIMETICKS
                           | UNSIGNED32r   r   Nr   r4   r   r   r
   rW     s   z&SupportSmiV1Keywords.p_importedKeywordc                 C   rG   )ztypeSMIandSPPI : IPADDRESS
                          | NETWORKADDRESS
                          | TIMETICKS
                          | OPAQUE
                          | INTEGER32
                          | UNSIGNED32r   r   Nr   r4   r   r   r
   rj     rY   z%SupportSmiV1Keywords.p_typeSMIandSPPIc                 C   r   )av  ApplicationSyntax : IPADDRESS anySubType
                             | NETWORKADDRESS anySubType
                             | COUNTER32
                             | COUNTER32 integerSubType
                             | GAUGE32
                             | GAUGE32 integerSubType
                             | UNSIGNED32
                             | UNSIGNED32 integerSubType
                             | TIMETICKS anySubType
                             | OPAQUE
                             | OPAQUE octetStringSubType
                             | COUNTER64
                             | COUNTER64 integerSubTyper9   r   r   r   r   Nr:   r;   r   r   r
   r     s   z(SupportSmiV1Keywords.p_ApplicationSyntaxc                 C   r   )a  sequenceApplicationSyntax : IPADDRESS anySubType
                                     | NETWORKADDRESS anySubType
                                     | COUNTER32 anySubType
                                     | GAUGE32 anySubType
                                     | UNSIGNED32 anySubType
                                     | TIMETICKS anySubType
                                     | OPAQUE
                                     | COUNTER64 anySubTyper9   r   r   r   Nr:   r;   r   r   r
   r     s   
z0SupportSmiV1Keywords.p_sequenceApplicationSyntaxN)r  r  r  staticmethodrW   rj   r   r   r   r   r   r
   r    s    



r  c                   @   $   e Zd Zedd Zedd ZdS )SupportIndexc                 C   s.   t |d tr|d d d p|d |d< dS )z/Index : ObjectName
                 | typeSMIv1r   r   N)
isinstancetupler4   r   r   r
   r     s   .zSupportIndex.p_Indexc                 C   s8   t |}|dkr|d d |d  p|d }||d< dS )z~typeSMIv1 : INTEGER
                     | OCTET STRING
                     | IPADDRESS
                     | NETWORKADDRESSr   r   r   r9   r   Nr:   )r*   r5   r<   Z	indextyper   r   r
   p_typeSMIv1  s   $zSupportIndex.p_typeSMIv1N)r  r  r  r	  r   r  r   r   r   r
   r    s
    
	r  c                   @      e Zd Zedd ZdS )CommaInImportc                 C   `   t |}|dkr|d |d g |d< dS |dkr"|d g|d< dS |dkr.|d |d< dS dS )zimportIdentifiers : importIdentifiers ',' importIdentifier
                             | importIdentifier
                             | importIdentifiers ','rB   r   r   r   r9   Nr:   r;   r   r   r
   rT     s   z!CommaInImport.p_importIdentifiersN)r  r  r  r	  rT   r   r   r   r
   r        r  c                   @   r  )CommaInSequencec                 C   r  )zsequenceItems : sequenceItems ',' sequenceItem
                         | sequenceItem
                         | sequenceItems ','rB   r   r   r   r9   Nr:   r;   r   r   r
   ru     s   zCommaInSequence.p_sequenceItemsN)r  r  r  r	  ru   r   r   r   r
   r    r  r  c                   @   r  )CommaAndSpacesc                 C   s   t |}|dkr|d |d g |d< dS |dkr"|d g|d< dS |dkrA|d dkr4|d |d< dS |d |d g |d< dS dS )zenumItems : enumItems ',' enumItem
                     | enumItem
                     | enumItems enumItem
                     | enumItems ','rB   r   r   r   r9   ,Nr:   r;   r   r   r
   r     s   zCommaAndSpaces.p_enumItemsN)r  r  r  r	  r   r   r   r   r
   r    r  r  c                   @   r  )UppercaseIdentifierc                 C   rQ   )zpenumItem : LOWERCASE_IDENTIFIER '(' enumNumber ')'
                    | UPPERCASE_IDENTIFIER '(' enumNumber ')'r   r   r   Nr   r4   r   r   r
   r   *  r   zUppercaseIdentifier.p_enumItemN)r  r  r  r	  r   r   r   r   r
   r  (  r  r  c                   @   r  )LowcaseIdentifierc                 C   r   )znotificationTypeClause : fuzzy_lowercase_identifier NOTIFICATION_TYPE NotificationObjectsPart STATUS Status DESCRIPTION Text ReferPart COLON_COLON_EQUAL '{' NotificationName '}'r   r   r   rl   rd   r?   r@   r~   r   Nr   r4   r   r   r
   r   4  s   z*LowcaseIdentifier.p_notificationTypeClauseN)r  r  r  r	  r   r   r   r   r
   r  2  r  r  c                   @   r
  )CurlyBracesInEnterprisesc                 C   r   )
zytrapTypeClause : fuzzy_lowercase_identifier TRAP_TYPE EnterprisePart VarPart DescrPart ReferPart COLON_COLON_EQUAL NUMBERr   r   r   rB   rl   rd   r@   r   Nr   r4   r   r   r
   r   C  s   z)CurlyBracesInEnterprises.p_trapTypeClausec                 C   r   )zlEnterprisePart : ENTERPRISE objectIdentifier
                          | ENTERPRISE '{' objectIdentifier '}'r   r9   r   rl   Nr:   r;   r   r   r
   p_EnterprisePartO  s   z)CurlyBracesInEnterprises.p_EnterprisePartN)r  r  r  r	  r   r  r   r   r   r
   r  A  s
    
r  c                   @   r  )NoCellsc                 C   s,   t |}|dkr|d |d f|d< dS dS )zCreationPart : CREATION_REQUIRES '{' Cells '}'
                        | CREATION_REQUIRES '{' '}'
                        | emptyrl   r   r   r   Nr:   r;   r   r   r
   r   ]  s   zNoCells.p_CreationPartN)r  r  r  r	  r   r   r   r   r
   r  [  r  r  )	ZsupportSmiV1KeywordsZsupportIndexZcommaAtTheEndOfImportZcommaAtTheEndOfSequenceZmixOfCommasAndSpacesZuppercaseIdentifierZlowcaseIdentifierZ!curlyBracesAroundEnterpriseInTrapZnoCellsc                  K   s~   i }| D ]*}| | r.|t vrtd| t | D ]}tjd dkr(|||j< q|||j< qqtdi | |d< tdt	f|S )a  Factory function producing custom specializations of base *SmiV2Parser*
       class.

       Keyword Args:
           grammarOptions: a list of (bool) typed optional keyword parameters
                           enabling particular set of SMIv2 grammar relaxations.

       Returns:
           Specialized copy of *SmiV2Parser* class.

       Notes:
           The following SMIv2 grammar relaxation parameters are defined:

           * supportSmiV1Keywords - parses SMIv1 grammar
           * supportIndex - tolerates ASN.1 types in INDEX clause
           * commaAtTheEndOfImport - tolerates stray comma at the end of IMPORT section
           * commaAtTheEndOfSequence - tolerates stray comma at the end of sequence of elements in MIB
           * mixOfCommasAndSpaces - tolerate a mix of comma and spaces in MIB enumerations
           * uppercaseIdentifier - tolerate uppercased MIB identifiers
           * lowcaseIdentifier - tolerate lowercase MIB identifiers
           * curlyBracesAroundEnterpriseInTrap - tolerate curly braces around enterprise ID in TRAP MACRO
           * noCells - tolerate missing cells (XXX)

       Examples:

       >>> from pysmi.parser import smi
       >>> SmiV1Parser = smi.parserFactory(supportSmiV1Keywords=True, supportIndex=True)

    z$Unknown parser relaxation option: %sr   r9   r!   Z	SmiParserNr   )
relaxedGrammarr   r    r   version_infor  Z	func_namer   r  r   )ZgrammarOptionsZ	classAttroptionfuncr   r   r
   parserFactory  s   r  ))r   r   Zply.yaccr%   Zpysmi.lexer.smir   Zpysmi.parser.baser   Zpysmir   r   __version__splitr$   r   objectr  r  r  r  r  r  r  r  r  rW   rj   r   r   r   r  rT   ru   r   r   r   r   r  r   r  r  r   r   r   r
   <module>   s\            I
