📄 asnparser.jj
字号:
/*@bgen(jjtree) Generated By:JJTree: Do not edit this line. AsnParser.jj *//*@egen*//* * * ASN.1 grammar for JavaCC * * Contributed by Helena Sarin (hsarin@lucent.com) * * Derived in part from the following work: snacc - a freeware ASN.1 to C or C++ compiler, v 1.3, * yacc/lex source code ( parse-asn1.y, lex-asn1.l), * the free software, which is covered by GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or later * * I tested it against several ASN.1 files used by CMIP; * Additional work is reguired to fully support SNMP MIBs parsing * * Please let me know if you use this grammar: i'm using it to develop ASN.1/IDL compiler * * SANITY_CHECK=true; * DEBUG_PARSER=false; * DEBUG_TOKEN_MANAGER=false; * */options {STATIC=false; }PARSER_BEGIN(AsnParser)//Title: //Version: $Id: AsnParser.jj,v 1.1.1.1 2000/12/21 06:33:42 ianibbo Exp $//Copyright: Copyright (C) 1999,2000 Knowledge Integration Ltd (See the file LICENSE for details.)//Author: Ian Ibbotson//Company: Knowledge Integration Ltd//Description: //package com.k_int.codec.comp;import java.util.*;import java.io.File;import java.io.FileInputStream;public class AsnParser/*@bgen(jjtree)*/implements AsnParserTreeConstants/*@egen*/ {/*@bgen(jjtree)*/ protected JJTAsnParserState jjtree = new JJTAsnParserState();/*@egen*/ // public static void main(String args[]) throws ParseException { // System.err.println("Args :"+args); // for ( int i=0; i<args.length; i++ ) // { // System.err.println("Processing asn source file : "+args[i]); // File next_asn_file = new File(args[i]); // if ( next_asn_file.exists() ) // { // parser = new AsnParser(System.in); // try // { // AsnParser parser = new AsnParser(new FileInputStream(next_asn_file)); // parser.Input(); // System.out.println("ASN.1 file parsed successfully... Calling pass1"); // parser.jjtree.rootNode().pass1(); // System.out.println("Calling outputJava"); // parser.jjtree.rootNode().outputJava(); // CodecBuilderInfo.getInfo().create(); // System.out.println("Done outputting java"); // } // catch(ParseException e) // { // System.out.println(e.toString()); // e.printStackTrace(); // } // catch(java.io.FileNotFoundException fnfe) // { // System.out.println(fnfe.toString()); // fnfe.printStackTrace(); // } // } // } // } public static String usefulTypes[] = { "GraphicString", "NumericString", "PrintableString", "TeletexString", "T61String", "VideotexString", "IA5String", "VisibleString", "ISO646String", "GeneralizedTime", "UniversalString", "BMPString", "EXTERNAL" }; public static String builtinTypes[] = { "Integer", "BitString", "SetOrSequenceType", "SetOrSequenceOfType", "ChoiceType", "SelectionType", "TaggedType", "Any", "Enumerated", "OctetString", "OID", "REAL", "BOOL", "NULL" };}PARSER_END(AsnParser)SKIP :{ " "| "\t"| "\n"| "\r"}SPECIAL_TOKEN :{ "--" : WithinASNComment}<WithinASNComment> SPECIAL_TOKEN :{ <("--" | "\n" | "\r" | "\r\n" )> : DEFAULT}<WithinASNComment> MORE :{ <~[]>}TOKEN : { <OBJECT_IDENTIFIER_TKN: "OBJECT" ([" ","\n","\t","\r"])? "IDENTIFIER">}TOKEN : { <BSTRING_TKN: "\'" (["0"-"1"])* "\'B">}TOKEN : { <HSTRING_TKN: "\'" (["0"-"9","A"-"F","a"-"f"])* "\'H">}TOKEN : { <CSTRING_TKN: "\"" ( ~["\""] )* "\"" >}TOKEN : { <NUMBER_ERANGE_TKN: ["1"-"9"](["0"-"9"])*>}TOKEN : { <NUMBER_TKN: "0">}TOKEN :{ <DOT_TKN: ".">| <COMMA_TKN: ",">| <LEFTBRACE_TKN: "{">| <RIGHTBRACE_TKN: "}">| <LEFTPAREN_TKN: "(">| <RIGHTPAREN_TKN: ")">| <LEFTBRACKET_TKN: "[">| <RIGHTBRACKET_TKN: "]">| <LESSTHAN_TKN: "<">| <MINUS_TKN: "-">| <GETS_TKN: "::=">| <BAR_TKN: "|">| <SEMI_COLON_TKN: ";">| <SELECTOR_TKN: ":">| <TAGS_TKN: "TAGS">| <BOOLEAN_TKN: "BOOLEAN">| <INTEGER_TKN: "INTEGER">| <BIT_TKN: "BIT">| <STRING_TKN: "STRING">| <OCTET_TKN: "OCTET">| <NULL_TKN: "NULL">| <SEQUENCE_TKN: "SEQUENCE">| <OF_TKN: "OF">| <SET_TKN: "SET">| <IMPLICIT_TKN: "IMPLICIT">| <CHOICE_TKN: "CHOICE">| <ANY_TKN: "ANY">| <OPTIONAL_TKN: "OPTIONAL">| <DEFAULT_TKN: "DEFAULT">| <COMPONENTS_TKN: "COMPONENTS">| <UNIVERSAL_TKN: "UNIVERSAL">| <APPLICATION_TKN: "APPLICATION">| <PRIVATE_TKN: "PRIVATE">| <TRUE_TKN: "TRUE">| <FALSE_TKN: "FALSE">| <BEGIN_TKN: "BEGIN">| <END_TKN: "END">| <DEFINITIONS_TKN: "DEFINITIONS">| <EXPLICIT_TKN: "EXPLICIT">| <ENUMERATED_TKN: "ENUMERATED">| <EXPORTS_TKN: "EXPORTS">| <IMPORTS_TKN: "IMPORTS">| <REAL_TKN: "REAL">| <INCLUDES_TKN: "INCLUDES">| <MIN_TKN: "MIN">| <MAX_TKN: "MAX">| <SIZE_TKN: "SIZE">| <FROM_TKN: "FROM">| <WITH_TKN: "WITH">| <COMPONENT_TKN: "COMPONENT">| <PRESENT_TKN: "PRESENT">| <ABSENT_TKN: "ABSENT">| <DEFINED_TKN: "DEFINED">| <BY_TKN: "BY">| <PLUS_INFINITY_TKN: "PLUS-INFINITY">| <MINUS_INFINITY_TKN: "MINUS-INFINITY">| <OBJECTTYPE_TKN: "OBJECT-TYPE">| <SYNTAX_TKN: "SYNTAX">| <ACCESS_TKN: "ACCESS">| <STATUS_TKN: "STATUS">| <DESCRIPTION_TKN: "DESCRIPTION">| <REFERENCE_TKN: "REFERENCE">| <INDEX_TKN: "INDEX">| <DEFVAL_TKN: "DEFVAL">| <DHINT: "DISPLAY-HINT">| <TC_TKN: "TEXTUAL-CONVENTION"> | <MACRO_TKN: "MACRO"> }TOKEN : { <LCASEFIRST_IDENT_TKN: ["a"-"z"] (("-"["a"-"z","A"-"Z","0"-"9"])|["a"-"z","A"-"Z","0"-"9"])*>}TOKEN : { <UCASEFIRST_IDENT_TKN: ["A"-"Z"](("-"["a"-"z","A"-"Z","0"-"9"])|["a"-"z","A"-"Z","0"-"9"])*>}void Input() : {/*@bgen(jjtree) Input */ ASTInput jjtn000 = new ASTInput(this, JJTINPUT); boolean jjtc000 = true; jjtree.openNodeScope(jjtn000);/*@egen*/} {/*@bgen(jjtree) Input */ try {/*@egen*/ (ModuleDefinition())*/*@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 ModuleDefinition() : {/*@bgen(jjtree) ModuleDefinition */ ASTModuleDefinition jjtn000 = new ASTModuleDefinition(this, JJTMODULEDEFINITION); boolean jjtc000 = true; jjtree.openNodeScope(jjtn000);/*@egen*/ Token t; } {/*@bgen(jjtree) ModuleDefinition */ try {/*@egen*/ ModuleIdentifier() <DEFINITIONS_TKN> [TagDefault()] <GETS_TKN> <BEGIN_TKN> ModuleBody() <END_TKN>/*@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 TagDefault() : {/*@bgen(jjtree) TagDefault */ ASTTagDefault jjtn000 = new ASTTagDefault(this, JJTTAGDEFAULT); boolean jjtc000 = true; jjtree.openNodeScope(jjtn000);/*@egen*/} {/*@bgen(jjtree) TagDefault */ try {/*@egen*/ (<EXPLICIT_TKN> { jjtn000.which = 1; } | <IMPLICIT_TKN> { jjtn000.which = 2; }) <TAGS_TKN>/*@bgen(jjtree)*/ } finally { if (jjtc000) { jjtree.closeNodeScope(jjtn000, true); } }/*@egen*/ }void ModuleIdentifier() : {/*@bgen(jjtree) ModuleIdentifier */ ASTModuleIdentifier jjtn000 = new ASTModuleIdentifier(this, JJTMODULEIDENTIFIER); boolean jjtc000 = true; jjtree.openNodeScope(jjtn000);/*@egen*/ } {/*@bgen(jjtree) ModuleIdentifier */ try {/*@egen*/ modulereference() [AssignedIdentifier()]/*@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 AssignedIdentifier() : {/*@bgen(jjtree) AssignedIdentifier */ ASTAssignedIdentifier jjtn000 = new ASTAssignedIdentifier(this, JJTASSIGNEDIDENTIFIER); boolean jjtc000 = true; jjtree.openNodeScope(jjtn000);/*@egen*/} {/*@bgen(jjtree) AssignedIdentifier */ try {/*@egen*/ ObjectIdentifierValue()/*@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 ModuleBody() : {/*@bgen(jjtree) ModuleBody */ ASTModuleBody jjtn000 = new ASTModuleBody(this, JJTMODULEBODY); boolean jjtc000 = true; jjtree.openNodeScope(jjtn000);/*@egen*/} {/*@bgen(jjtree) ModuleBody */ try {/*@egen*/ [Exports()] [Imports()] [AssignmentList()]/*@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 Exports() : {/*@bgen(jjtree) Exports */ ASTExports jjtn000 = new ASTExports(this, JJTEXPORTS); boolean jjtc000 = true; jjtree.openNodeScope(jjtn000);/*@egen*/} {/*@bgen(jjtree) Exports */ try {/*@egen*/ <EXPORTS_TKN> [SymbolsExported()] <SEMI_COLON_TKN>/*@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 SymbolsExported() : {/*@bgen(jjtree) SymbolsExported */ ASTSymbolsExported jjtn000 = new ASTSymbolsExported(this, JJTSYMBOLSEXPORTED); boolean jjtc000 = true; jjtree.openNodeScope(jjtn000);/*@egen*/} {/*@bgen(jjtree) SymbolsExported */ try {/*@egen*/ ExportSymbolList()/*@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 ExportSymbolList() : {/*@bgen(jjtree) ExportSymbolList */ ASTExportSymbolList jjtn000 = new ASTExportSymbolList(this, JJTEXPORTSYMBOLLIST); boolean jjtc000 = true; jjtree.openNodeScope(jjtn000);/*@egen*/} {/*@bgen(jjtree) ExportSymbolList */ try {/*@egen*/ Symbol() (<COMMA_TKN> Symbol())*/*@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*/}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -