parsemib.jj

来自「opennms得相关源码 请大家看看」· JJ 代码 · 共 1,259 行 · 第 1/3 页

JJ
1,259
字号
}void Declaration()          : {/*@bgen(jjtree) DeclOID */  SimpleNode jjtn000 = new SimpleNode(JJTDECLOID);  boolean jjtc000 = true;  jjtree.openNodeScope(jjtn000);/*@egen*/}{/*@bgen(jjtree) DeclOID */  try {/*@egen*/  // lightsurf OBJECT-IDENTITY  //   STATUS current  //  	    DESCRIPTION  //  		"This describes the OID infrastructure for the mandated Lightsurf hierarchy"  //          ::=  {  enterprises  15420  }  //  //  // or there could be a different type of SYNTAX  //   SYNTAX Integer32(1..100)  // or the SYNTAX could be like:  //   SYNTAX      DisplayString (SIZE (0..255))  // or the SYNTAX could be a table decl like:  //   SYNTAX SEQUENCE OF varTpe  // or the SYNTAX could be like:  //   SYNTAX INTEGER { enabled(1), disabled(2) }  // or it could be declared like:  //   module OBJECT IDENTIFIER ::= { sprint 1 }  // or there could be:  //   MODULE  -- this module  //         MANDATORY-GROUPS { ifGeneralInformationGroup, ifStackGroup2 }  //  // this form makes building oids harder (multipleOids)  // mgmt OBJECT IDENTIFIER ::= { iso org(3) dod(6) internet(1) mgmt(2) }  // this is equivalent  // mgmt OBJECT IDENTIFIER ::= { internet 2 }  //  // DEFVAL can have some weird syntax (RFC1382-MIB as an example)  // DEFVAL { pvc }  // DEFVAL { {0 0} }  // DEFVAL { ''h }  // DEFVAL { 128 }  ObjectIdentifier()    (( (<OBJECT_IDENTITY> | <OBJECT_TYPE> | <MODULE_COMPLIANCE_TOKEN> | <OBJECT_GROUP_TOKEN> )    ( <STATUS> <IDENTIFIER> | (<DESCRIPTION> | <REFERENCE_TOKEN> | <UNITS_TOKEN>) <DESCRIPTOR_LITERAL> |      <DEFVAL_TOKEN> ( <DESCRIPTOR_LITERAL> | <LBRACE> [<LBRACE>] (<IDENTIFIER>|<INTEGER_LITERAL>)+ <RBRACE> [<RBRACE>] | <INTEGER_LITERAL> ) |      <MODULE_TOKEN> <MANDATORY_GROUPS_TOKEN> <LBRACE> (<IDENTIFIER> [<COMMA>])+ <RBRACE> |      <GROUP_TOKEN> <IDENTIFIER> | <AUGMENTS_TOKEN> <LBRACE> <IDENTIFIER> <RBRACE> |      <OBJECT_TOKEN> <IDENTIFIER> |      <OBJECTS_TOKEN> <LBRACE> (<IDENTIFIER> [<COMMA>])+ <RBRACE> |        <SYNTAX_TOKEN> (<OBJECT_TOKEN> <IDENTIFIER_TOKEN> | <OCTET_TOKEN> <STRING_TOKEN> [SizeDeclaration()] |        TableSequenceOf() |        GetTypeIdentifier() (SizeDeclaration() |        <LBRACE> (<IDENTIFIER> <LPAREN> <INTEGER_LITERAL> <RPAREN> [<COMMA>])+ <RBRACE> )* ) |      (<ACCESS_TOKEN> | <MAX_ACCESS_TOKEN> | <MIN_ACCESS_TOKEN>) GetAccessIdentifier() |      IndexOfTable() |     <ASSIGN> <LBRACE> ParentObjectIdentifier() IntegerOID() <RBRACE> )*)    | IndexOfTable() |    ( <OBJECT_TOKEN> <IDENTIFIER_TOKEN>    <ASSIGN> <LBRACE> ParentObjectIdentifier() (MultipleOids())* [IntegerOID()] <RBRACE>))/*@bgen(jjtree)*/  } catch (Throwable jjte000) {    if (jjtc000) {      jjtree.clearNodeScope(jjtn000);      jjtc000 = false;    } else {      jjtree.popNode();    }    if (jjte000 instanceof RuntimeException) {      throw (RuntimeException)jjte000;    }    if (jjte000 instanceof ParseException) {      throw (ParseException)jjte000;    }    throw (Error)jjte000;  } finally {    if (jjtc000) {      jjtree.closeNodeScope(jjtn000, true);    }  }/*@egen*/}// handle NOTIFICATION-TPYE// at this time it just mostly skips the info here// it would be easy to walk the trees later and output xml// for the trapsvoid Events() : {/*@bgen(jjtree) Events */  SimpleNode jjtn000 = new SimpleNode(JJTEVENTS);  boolean jjtc000 = true;  jjtree.openNodeScope(jjtn000);/*@egen*/}{/*@bgen(jjtree) Events */  try {/*@egen*/  //    overSmsQueueThreshold NOTIFICATION-TYPE  //      STATUS current  //      OBJECTS { smsInQueue }  //      DESCRIPTION "The SMS queue has more messages than the configurable threshold.  //      This event will be sent on every poll until the messages fall below the threshold.  //      The number of sms currently in the queue is sent with the trap."  //      ::= { events 1 }  //  // or there could be something like this:  //   NOTIFICATIONS { coldStart, authenticationFailure }  <IDENTIFIER> (<NOTIFICATION_TYPE_TOKEN> | <NOTIFICATION_GROUP_TOKEN>)  (<STATUS> <IDENTIFIER> | <DESCRIPTION> <DESCRIPTOR_LITERAL> |    <OBJECTS_TOKEN> <LBRACE> (<IDENTIFIER> [<COMMA>])+ <RBRACE> |    <NOTIFICATIONS_TOKEN> <LBRACE> (<IDENTIFIER> [<COMMA>])+ <RBRACE> |    <ASSIGN> <LBRACE> <IDENTIFIER> <INTEGER_LITERAL> <RBRACE>)*/*@bgen(jjtree)*/  } finally {    if (jjtc000) {      jjtree.closeNodeScope(jjtn000, true);    }  }/*@egen*/}// handle the TRAP-TYPE, this is just different enough from// NOTIFICATION-TYPE that I wanted to keep them separatevoid TrapType() : {/*@bgen(jjtree) TrapType */  SimpleNode jjtn000 = new SimpleNode(JJTTRAPTYPE);  boolean jjtc000 = true;  jjtree.openNodeScope(jjtn000);/*@egen*/}{/*@bgen(jjtree) TrapType */  try {/*@egen*///    egpNeighborLoss TRAP-TYPE//           ENTERPRISE  snmp//           VARIABLES   { egpNeighAddr }//           DESCRIPTION//                          "An egpNeighborLoss trap signifies that an EGP//                          neighbor for whom the sending protocol entity//                          was an EGP peer has been marked down and the//                          peer relationship no longer obtains."//           ::= 5  <IDENTIFIER> <TRAP_TYPE_TOKEN>  (<STATUS> <IDENTIFIER> | <DESCRIPTION> <DESCRIPTOR_LITERAL> |    <ENTERPRISE_TOKEN> <IDENTIFIER> |    <VARIABLES_TOKEN> <LBRACE> (<IDENTIFIER> [<COMMA>])+ <RBRACE> |    <ASSIGN> [<LBRACE> <IDENTIFIER>] <INTEGER_LITERAL> [<RBRACE>])*/*@bgen(jjtree)*/  } finally {    if (jjtc000) {      jjtree.closeNodeScope(jjtn000, true);    }  }/*@egen*/}void TableSequenceOf() :{/*@bgen(jjtree) TableSequenceOf */    SimpleNode jjtn000 = new SimpleNode(JJTTABLESEQUENCEOF);    boolean jjtc000 = true;    jjtree.openNodeScope(jjtn000);/*@egen*/    Token t;}{/*@bgen(jjtree) TableSequenceOf */  try {/*@egen*/    // The AST has to be marked with a table because the index    // could be anything from 1 to N, rather than just "0" as with    // other OIDS. So the index is saved symbolically.    // This means that we have to recognize the following    // in the MIB ASN.1 on 3 different declarations    // 1) "SEQUENCE OF varTpe" - from table OID    // 2) "INDEX      { sysORIndex }" from the index OID    // 3) "SEQUENCE {...} - has the OID with the index name first    // and then mark each one in the AST to retrieve later.    //    // sysORTable OBJECT-TYPE    // SYNTAX     SEQUENCE OF SysOREntry    // MAX-ACCESS not-accessible    // STATUS     current    // DESCRIPTION    //         "The (conceptual) table listing the capabilities of the    //         local SNMPv2 entity acting in an agent role with respect to    //         various MIB modules.  SNMPv2 entities having dynamically-    //         configurable support of MIB modules will have a    //         dynamically-varying number of conceptual rows."    // ::= { system 9 }    //    // sysOREntry OBJECT-TYPE    //     SYNTAX     SysOREntry    //     MAX-ACCESS not-accessible    //     STATUS     current    //    DESCRIPTION    //             "An entry (conceptual row) in the sysORTable."    //     INDEX      { sysORIndex }    //     ::= { sysORTable 1 }    //    // SysOREntry ::= SEQUENCE {    //     sysORIndex     INTEGER,    //     sysORID        OBJECT IDENTIFIER,    //     sysORDescr     DisplayString,    //     sysORUpTime    TimeStamp  <SEQUENCE_TOKEN> <OF_TOKEN> t=<IDENTIFIER>/*@bgen(jjtree)*/  {    jjtree.closeNodeScope(jjtn000, true);    jjtc000 = false;  }/*@egen*/  {    jjtn000.setName(t.image);  }/*@bgen(jjtree)*/  } finally {    if (jjtc000) {      jjtree.closeNodeScope(jjtn000, true);    }  }/*@egen*/}void IndexOfTable() :{/*@bgen(jjtree) IndexOfTable */    SimpleNode jjtn000 = new SimpleNode(JJTINDEXOFTABLE);    boolean jjtc000 = true;    jjtree.openNodeScope(jjtn000);/*@egen*/    Token t;}{/*@bgen(jjtree) IndexOfTable */    try {/*@egen*/    // Related to the table decl TableSequenceOf.    // This will be the index of a tabel.    //    INDEX      { sysORIndex }    //    INDEX   { atIfIndex, atNetAddress } 2nd index TBD not handled correctly?    <INDEX_TOKEN> <LBRACE> t=<IDENTIFIER> (<COMMA> <IDENTIFIER>)* <RBRACE>/*@bgen(jjtree)*/    } finally {      if (jjtc000) {        jjtree.closeNodeScope(jjtn000, true);      }    }/*@egen*/}// handle identifier :== identifiervoid Assignment() :{/*@bgen(jjtree) Assignment */    SimpleNode jjtn000 = new SimpleNode(JJTASSIGNMENT);    boolean jjtc000 = true;    jjtree.openNodeScope(jjtn000);/*@egen*/    Token t;}{/*@bgen(jjtree) Assignment */  try {/*@egen*/    // quite a few different kinds of identifiers    //    RouterID ::= IpAddress    //    AutonomousType    ::= OBJECT IDENTIFIER    //    Metric    ::= INTEGER (1..'FFFF'h)    //    TruthValue ::= INTEGER { true (1), false (2) }    //    Status ::= INTEGER { enabled (1), disabled (2) }  t=<IDENTIFIER> <ASSIGN> (GetTypeIdentifier() | <OBJECT_TOKEN> <IDENTIFIER_TOKEN>)    [(<LPAREN> <INTEGER_LITERAL> "." "." <INTEGER_LITERAL> <RPAREN> |     <LBRACE> (<IDENTIFIER> <LPAREN> <INTEGER_LITERAL> <RPAREN> [<COMMA>])+ <RBRACE>)]/*@bgen(jjtree)*/    {      jjtree.closeNodeScope(jjtn000, true);      jjtc000 = false;    }/*@egen*/    // save the subtype name from the first identifier just like    // TextConvention() did    // this makes a tree with the subtype in the parent and    // the base type in the child. These are put in symbol tables    // later so we can get to the right types and output base types    // to XML.    {        jjtn000.setName(t.image);    }/*@bgen(jjtree)*/  } catch (Throwable jjte000) {    if (jjtc000) {      jjtree.clearNodeScope(jjtn000);      jjtc000 = false;    } else {      jjtree.popNode();    }    if (jjte000 instanceof RuntimeException) {      throw (RuntimeException)jjte000;    }    if (jjte000 instanceof ParseException) {      throw (ParseException)jjte000;    }    throw (Error)jjte000;  } finally {    if (jjtc000) {      jjtree.closeNodeScope(jjtn000, true);    }  }/*@egen*/}void SequenceOfVarsOrTextConvention() : {/*@bgen(jjtree) SequenceOfVarsOrTextConvention */  SimpleNode jjtn000 = new SimpleNode(JJTSEQUENCEOFVARSORTEXTCONVENTION);  boolean jjtc000 = true;  jjtree.openNodeScope(jjtn000);/*@egen*/}{/*@bgen(jjtree) SequenceOfVarsOrTextConvention */    try {/*@egen*/    // both start with identifier :==    ObjectIdentifier() <ASSIGN> (SequenceOfVars() | TextConvention())/*@bgen(jjtree)*/    } catch (Throwable jjte000) {      if (jjtc000) {        jjtree.clearNodeScope(jjtn000);        jjtc000 = false;      } else {        jjtree.popNode();      }      if (jjte000 instanceof RuntimeException) {        throw (RuntimeException)jjte000;      }      if (jjte000 instanceof ParseException) {        throw (ParseException)jjte000;      }      throw (Error)jjte000;    } finally {      if (jjtc000) {        jjtree.closeNodeScope(jjtn000, true);      }    }/*@egen*/}void SequenceOfVars()               : {/*@bgen(jjtree) TableOidVars */  SimpleNode jjtn000 = new SimpleNode(JJTTABLEOIDVARS);  boolean jjtc000 = true;  jjtree.openNodeScope(jjtn000);/*@egen*/}{/*@bgen(jjtree) TableOidVars */    try {/*@egen*/    // SysOREntry ::= SEQUENCE {    // sysORIndex     INTEGER,    // sysORID        OBJECT IDENTIFIER,    // sysORDescr     DisplayString,    // sysORUpTime    TimeStamp,    // ifDescr        OCTET STRING,    // tcpConnLocalPort INTEGER (0..65535),    // ds1CircuitIdentifier DisplayString (SIZE (0..255))    //    (<SEQUENCE_TOKEN> <LBRACE>      (IdentifierInSequenceOfVars()      ( <IDENTIFIER> ( SizeDeclaration() | <LPAREN> <INTEGER_LITERAL> "." "." <INTEGER_LITERAL> <RPAREN>)* |      <OBJECT_IDENTITY> | <OBJECT_TYPE> |      <OBJECT_TOKEN> <IDENTIFIER_TOKEN> | <OCTET_TOKEN> <STRING_TOKEN> [SizeDeclaration()])      (<COMMA>)* )+ <RBRACE>)/*@bgen(jjtree)*/    {      jjtree.closeNodeScope(jjtn000, true);      jjtc000 = false;    }/*@egen*/    {        jjtn000.setName(lastObjectIdentifierToken.image);    }/*@bgen(jjtree)*/    } catch (Throwable jjte000) {      if (jjtc000) {        jjtree.clearNodeScope(jjtn000);        jjtc000 = false;      } else {        jjtree.popNode();      }      if (jjte000 instanceof RuntimeException) {        throw (RuntimeException)jjte000;      }      if (jjte000 instanceof ParseException) {        throw (ParseException)jjte000;      }      throw (Error)jjte000;    } finally {      if (jjtc000) {        jjtree.closeNodeScope(jjtn000, true);      }    }/*@egen*/}void TextConvention() : {/*@bgen(jjtree) TextConvention */  SimpleNode jjtn000 = new SimpleNode(JJTTEXTCONVENTION);  boolean jjtc000 = true;  jjtree.openNodeScope(jjtn000);/*@egen*/}{/*@bgen(jjtree) TextConvention */  try {/*@egen*/  // The TEXTUAL-CONVENTION is different enough from the other declarations  // that it merits it's own scanning, even though it does reuse tokens  // that other declarations catch. Also, the base type of the declaration  // must be saved in the AST and later in the symbol table. The base type  // in the example below would be Integer32 and it will be associated with  // QueueStates in the symbol table during AST walks.  //  // QueueStates ::= TEXTUAL-CONVENTION  // DISPLAY-HINT "d"  // SYNTAX Integer32 { pause(1), start(2) }  // STATUS current  // DESCRIPTION "The current state a queue is in."  //  // another way to declare a text convention is  // DisplayString ::= OCTET STRING (SIZE (0..255))  <TEXTUAL_CONVENTION_TOKEN>  ( <STATUS> <IDENTIFIER> |    (<DESCRIPTION> | <REFERENCE_TOKEN>) <DESCRIPTOR_LITERAL> |    <DISPLAY_HINT_TOKEN> <DESCRIPTOR_LITERAL> |    <OBJECTS_TOKEN> <LBRACE> (<IDENTIFIER> [<COMMA>])+ <RBRACE> |    <SYNTAX_TOKEN> (<OBJECT_TOKEN> <IDENTIFIER_TOKEN> | <OCTET_TOKEN> <STRING_TOKEN>  [SizeDeclaration()] |       GetTypeIdentifier() [( SizeDeclaration() |    <LBRACE> (<IDENTIFIER> <LPAREN> <INTEGER_LITERAL> <RPAREN> [<COMMA>])+ <RBRACE> )] )  )+ |   <OCTET_TOKEN> <STRING_TOKEN>  [SizeDeclaration() | <LBRACE> (<IDENTIFIER> <LPAREN> <INTEGER_LITERAL> <RPAREN> [<COMMA>])+ <RBRACE>]/*@bgen(jjtree)*/  {

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?