📄 parsemib.java
字号:
// This file is part of the OpenNMS(R) MIB Parser.//// Copyright (C) 2002-2003 John Rodriguez//// OpenNMS(R) is a registered trademark of The OpenNMS Group, Inc.//// This library is free software; you can redistribute it and/or// modify it under the terms of the GNU Lesser General Public// License as published by the Free Software Foundation; either// version 2.1 of the License, or (at your option) any later version.// // This library is distributed in the hope that it will be useful,// but WITHOUT ANY WARRANTY; without even the implied warranty of// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU// Lesser General Public License for more details.// // You should have received a copy of the GNU Lesser General Public// License along with this library; if not, write to the Free Software// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA//// See: http://www.fsf.org/copyleft/lesser.html///* Generated By:JJTree&JavaCC: Do not edit this line. ParseMib.java */import java.util.Vector;class ParseMib/*@bgen(jjtree)*/implements ParseMibTreeConstants, ParseMibConstants {/*@bgen(jjtree)*/ protected static JJTParseMibState jjtree = new JJTParseMibState(); protected static Token lastObjectIdentifierToken = null; public static void main(String args[]) { try { if (args.length == 0) { System.out.println("usage: ParseMib [-debug] files"); System.out.println("version: " + Version.versionString); System.exit(0); } boolean setDebug = false; Vector argsList = new Vector(); String arg = null; for (int i = 0; i < args.length; i++) { arg = args[i]; // System.out.println("arg=#" + args[i] + "#"); if (arg.equalsIgnoreCase("-debug")) setDebug = true; else if (arg.equalsIgnoreCase("")) { // artifact from shell, ant or error, ignore } else argsList.addElement(arg); } SimpleNode.setDebug(setDebug); SimpleNode n = null; boolean firstFile = true; ParseMib parser = null; for (int i = 0; i < argsList.size(); i++) { arg = (String)argsList.elementAt(i); if (setDebug) System.out.println("JavaCC Parser: Reading from file " + arg + " . . ."); try { if (firstFile) parser = new ParseMib(new java.io.FileInputStream(arg)); else parser.ReInit(new java.io.FileInputStream(arg)); } catch (java.io.FileNotFoundException fnf) { System.err.println("ERROR: the file '" + arg + "' was not found or is mis-spelled"); System.exit(Errors.FILE_NOT_FOUND); } n = parser.Start(); if (setDebug) n.dump(""); firstFile = false; // must be called in this order because the ast is // decorated on each walk // 1) collectTableInfo // 2) collectTableIndexInfo // 3) collectSequenceInfo // 4) collectOids // 5) collectTextualConventionsInfo if (setDebug) System.out.println("collect table information"); n.markNotVisited(); // mark the abstract syntax tree as not visited n.collectTableInfo(); if (setDebug) System.out.println("collect table index information"); n.markNotVisited(); // mark the abstract syntax tree as not visited n.collectTableIndexInfo(); if (setDebug) System.out.println("collect sequence info information"); n.markNotVisited(); // mark the abstract syntax tree as not visited n.collectSequenceInfo(); if (setDebug) System.out.println("collect oids"); n.markNotVisited(); // mark the abstract syntax tree as not visited n.collectOids(); if (setDebug) System.out.println("collect type information"); n.markNotVisited(); // mark the abstract syntax tree as not visited n.collectTextualConventionsInfo(); // System.out.println("Dumping SymbolTables"); // n.dumpSymbolTables(); n.writeOids(); } if (setDebug) System.out.println("Thank you."); } catch (Throwable e) { System.err.println("Oops."); System.err.println(e.getMessage()); e.printStackTrace(); System.exit(Errors.UNKNOWN_FATAL); } } static final public SimpleNode Start() throws ParseException { /*@bgen(jjtree) Start */ SimpleNode jjtn000 = new SimpleNode(JJTSTART); boolean jjtc000 = true; jjtree.openNodeScope(jjtn000); try { MibBegin(); label_1: while (true) { if (jj_2_1(3)) { ; } else { break label_1; } Imports(); } label_2: while (true) { if (jj_2_2(3)) { ; } else { break label_2; } if (jj_2_3(3)) { Declaration(); } else if (jj_2_4(3)) { SequenceOfVarsOrTextConvention(); } else if (jj_2_5(3)) { Events(); } else if (jj_2_6(3)) { TrapType(); } else if (jj_2_7(3)) { Assignment(); } else if (jj_2_8(3)) { ModuleIdentity(); } else { jj_consume_token(-1); throw new ParseException(); } } End(); jjtree.closeNodeScope(jjtn000, true); jjtc000 = false; {if (true) return jjtn000;} } catch (Throwable jjte000) { if (jjtc000) { jjtree.clearNodeScope(jjtn000); jjtc000 = false; } else { jjtree.popNode(); } if (jjte000 instanceof RuntimeException) { {if (true) throw (RuntimeException)jjte000;} } if (jjte000 instanceof ParseException) { {if (true) throw (ParseException)jjte000;} } {if (true) throw (Error)jjte000;} } finally { if (jjtc000) { jjtree.closeNodeScope(jjtn000, true); } } throw new Error("Missing return statement in function"); } static final public void MibBegin() throws ParseException { /*@bgen(jjtree) MibBegin */ SimpleNode jjtn000 = new SimpleNode(JJTMIBBEGIN); boolean jjtc000 = true; jjtree.openNodeScope(jjtn000); try { Expression(); jj_consume_token(IDENTIFIER); jj_consume_token(ASSIGN); jj_consume_token(BEGIN); } catch (Throwable jjte000) { if (jjtc000) { jjtree.clearNodeScope(jjtn000); jjtc000 = false; } else { jjtree.popNode(); } if (jjte000 instanceof RuntimeException) { {if (true) throw (RuntimeException)jjte000;} } if (jjte000 instanceof ParseException) { {if (true) throw (ParseException)jjte000;} } {if (true) throw (Error)jjte000;} } finally { if (jjtc000) { jjtree.closeNodeScope(jjtn000, true); } } } static final public void Imports() throws ParseException { /*@bgen(jjtree) Imports */ SimpleNode jjtn000 = new SimpleNode(JJTIMPORTS); boolean jjtc000 = true; jjtree.openNodeScope(jjtn000); try { jj_consume_token(IMPORTS); label_3: while (true) { label_4: while (true) { if (jj_2_9(3)) { jj_consume_token(IDENTIFIER); } else if (jj_2_10(3)) { jj_consume_token(OBJECT_TYPE); } else if (jj_2_11(3)) { jj_consume_token(NOTIFICATION_TYPE_TOKEN); } else if (jj_2_12(3)) { jj_consume_token(MODULE_IDENTITY_TOKEN); } else if (jj_2_13(3)) { jj_consume_token(MODULE_COMPLIANCE_TOKEN); } else if (jj_2_14(3)) { jj_consume_token(OBJECT_GROUP_TOKEN); } else if (jj_2_15(3)) { jj_consume_token(NOTIFICATION_GROUP_TOKEN); } else if (jj_2_16(3)) { jj_consume_token(TRAP_TYPE_TOKEN); } else if (jj_2_17(3)) { jj_consume_token(TEXTUAL_CONVENTION_TOKEN); } else if (jj_2_18(3)) { jj_consume_token(OBJECT_IDENTITY); } else { jj_consume_token(-1); throw new ParseException(); } label_5: while (true) { if (jj_2_19(3)) { ; } else { break label_5; } jj_consume_token(COMMA); } if (jj_2_20(3)) { ; } else { break label_4; } } jj_consume_token(FROM); jj_consume_token(IDENTIFIER); if (jj_2_21(3)) { ; } else { break label_3; } } jj_consume_token(SEMICOLON); } finally { if (jjtc000) { jjtree.closeNodeScope(jjtn000, true); } } } static final public void ModuleIdentity() throws ParseException { /*@bgen(jjtree) ModuleIdentity */ SimpleNode jjtn000 = new SimpleNode(JJTMODULEIDENTITY); boolean jjtc000 = true; jjtree.openNodeScope(jjtn000); try { ObjectIdentifier(); jj_consume_token(MODULE_IDENTITY_TOKEN); label_6: while (true) { if (jj_2_22(3)) { jj_consume_token(LAST_UPDATED_TOKEN); jj_consume_token(DESCRIPTOR_LITERAL); } else if (jj_2_23(3)) { jj_consume_token(ORGANIZATION_TOKEN); jj_consume_token(DESCRIPTOR_LITERAL); } else if (jj_2_24(3)) { jj_consume_token(DESCRIPTION); jj_consume_token(DESCRIPTOR_LITERAL); } else if (jj_2_25(3)) { jj_consume_token(CONTACT_INFO_TOKEN); jj_consume_token(DESCRIPTOR_LITERAL); } else if (jj_2_26(3)) { jj_consume_token(REVISION_TOKEN); jj_consume_token(DESCRIPTOR_LITERAL); } else { jj_consume_token(-1); throw new ParseException(); } if (jj_2_27(3)) { ; } else { break label_6; } } jj_consume_token(ASSIGN); jj_consume_token(LBRACE); ParentObjectIdentifier(); IntegerOID(); jj_consume_token(RBRACE); } catch (Throwable jjte000) { if (jjtc000) { jjtree.clearNodeScope(jjtn000); jjtc000 = false; } else { jjtree.popNode(); } if (jjte000 instanceof RuntimeException) { {if (true) throw (RuntimeException)jjte000;} } if (jjte000 instanceof ParseException) { {if (true) throw (ParseException)jjte000;} } {if (true) throw (Error)jjte000;} } finally { if (jjtc000) { jjtree.closeNodeScope(jjtn000, true); } } } static final public void Declaration() throws ParseException { /*@bgen(jjtree) DeclOID */ SimpleNode jjtn000 = new SimpleNode(JJTDECLOID); boolean jjtc000 = true; jjtree.openNodeScope(jjtn000); try { ObjectIdentifier(); if (jj_2_75(3)) { if (jj_2_28(3)) { jj_consume_token(OBJECT_IDENTITY); } else if (jj_2_29(3)) { jj_consume_token(OBJECT_TYPE); } else if (jj_2_30(3)) { jj_consume_token(MODULE_COMPLIANCE_TOKEN); } else if (jj_2_31(3)) { jj_consume_token(OBJECT_GROUP_TOKEN); } else { jj_consume_token(-1); throw new ParseException(); } label_7: while (true) { if (jj_2_32(3)) { ; } else { break label_7; } if (jj_2_61(3)) { jj_consume_token(STATUS); jj_consume_token(IDENTIFIER); } else if (jj_2_62(3)) { if (jj_2_33(3)) { jj_consume_token(DESCRIPTION); } else if (jj_2_34(3)) { jj_consume_token(REFERENCE_TOKEN); } else if (jj_2_35(3)) { jj_consume_token(UNITS_TOKEN); } else { jj_consume_token(-1); throw new ParseException(); } jj_consume_token(DESCRIPTOR_LITERAL); } else if (jj_2_63(3)) { jj_consume_token(DEFVAL_TOKEN); if (jj_2_41(3)) { jj_consume_token(DESCRIPTOR_LITERAL); } else if (jj_2_42(3)) { jj_consume_token(LBRACE); if (jj_2_36(3)) { jj_consume_token(LBRACE); } else { ; } label_8: while (true) { if (jj_2_37(3)) { jj_consume_token(IDENTIFIER); } else if (jj_2_38(3)) { jj_consume_token(INTEGER_LITERAL); } else { jj_consume_token(-1); throw new ParseException(); } if (jj_2_39(3)) { ; } else { break label_8; } } jj_consume_token(RBRACE); if (jj_2_40(3)) { jj_consume_token(RBRACE); } else { ; } } else if (jj_2_43(3)) { jj_consume_token(INTEGER_LITERAL); } else { jj_consume_token(-1); throw new ParseException(); } } else if (jj_2_64(3)) { jj_consume_token(MODULE_TOKEN); jj_consume_token(MANDATORY_GROUPS_TOKEN); jj_consume_token(LBRACE); label_9: while (true) { jj_consume_token(IDENTIFIER); if (jj_2_44(3)) { jj_consume_token(COMMA);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -