net.percederberg.mib.asn1.parser
Class AsnParser

java.lang.Object
  |
  +--net.percederberg.mib.asn1.parser.AsnParser
All Implemented Interfaces:
AsnParserConstants

public class AsnParser
extends java.lang.Object
implements AsnParserConstants

An ASN.1 parser class. The parser is generated to be static, and only the method parse() should be called, which returns the parse tree.

The grammar used is derived in part from the yacc and lex sources of 'snacc' - a GNU ASN.1 to C or C++ compiler. Other parts of the grammar comes from RFC 1155, 1212, 1215, 1902, 1903, and 1904 in order to be able to correctly parse Internet MIBs.

The parser was originally written by Helena Sarin (hsarin@lucent.com). Modifications have been made by Per Cederberg (per@percederberg.net). The changes includes removing parts of the constraint mechanism, fixing some inefficient rules, and adding new productions for parsing Internet MIBs. Some unnecessary productions have been removed and others have been brought closer to the original 'snacc' grammar. Tokens and productions have also been reordered and renamed.

Version:
1.1
Author:
Helena Sarin, hsarin@lucent.com, Per Cederberg, per@percederberg.net
See Also:
"ISO 8824 - ASN.1 Syntax", "RFC 1155 - SNMPv1 Macros", "RFC 1212 - SNMPv1 Extended OBJECT-TYPE Macro", "RFC 1215 - SNMPv1 TRAP-TYPE Macro", "RFC 1902 - SNMPv2 Base Macros", "RFC 1903 - SNMPv2 TEXTUAL-CONVENTION Macro", "RFC 1904 - SNMPv2 Extended Macros"

Field Summary
static Token jj_nt
           
static boolean lookingAhead
           
static Token token
           
static AsnParserTokenManager token_source
           
 
Fields inherited from interface net.percederberg.mib.asn1.parser.AsnParserConstants
COMMENT, DEFAULT, EOF, TABSENT, TACCESS, TAGENT_CAPABILITIES, TANY, TAPPLICATION, TASSIGN, TAUGMENTS, TBAR, TBEGIN, TBINSTRING, TBIT, TBITS, TBOOLEAN, TBY, TCHOICE, TCOMMA, TCOMPONENT, TCOMPONENTS, TCONTACT_INFO, TCREATION_REQUIRES, TCSTRING, TDEFAULT, TDEFINED, TDEFINITIONS, TDEFVAL, TDESCRIPTION, TDISPLAY_HINT, TDOT, TEND, TENTERPRISE, TENUMERATED, TEXPLICIT, TEXPORTS, TFALSE, TFROM, TGROUP, THEXSTRING, TIDENT, TIDENTIFIER, TIMPLICIT, TIMPLIED, TIMPORTS, TINCLUDES, TINDEX, TINTEGER, TLAST_UPDATED, TLEFTBRACE, TLEFTBRACKET, TLEFTPAREN, TLESSTHAN, TMACRO, TMANDATORY_GROUPS, TMAX, TMAX_ACCESS, TMIN, TMIN_ACCESS, TMINUS, TMINUS_INFINITY, TMODULE, TMODULE_COMPLIANCE, TMODULE_IDENTITY, TNOTIFICATION_GROUP, TNOTIFICATION_TYPE, TNOTIFICATIONS, TNULL, TNUMBER, TOBJECT, TOBJECT_GROUP, TOBJECT_IDENTITY, TOBJECT_TYPE, TOBJECTS, TOCTET, TOF, tokenImage, TOPTIONAL, TORGANIZATION, TPLUS_INFINITY, TPRESENT, TPRIVATE, TPRODUCT_RELEASE, TREAL, TREFERENCE, TREVISION, TRIGHTBRACE, TRIGHTBRACKET, TRIGHTPAREN, TSEMI_COLON, TSEQUENCE, TSET, TSIZE, TSTATUS, TSTRING, TSUPPORTS, TSYNTAX, TTAGS, TTEXTUAL_CONVENTION, TTRAP_TYPE, TTRUE, TUNITS, TUNIVERSAL, TVARIABLES, TVARIATION, TWITH, TWRITE_SYNTAX
 
Constructor Summary
AsnParser(AsnParserTokenManager tm)
           
AsnParser(java.io.InputStream stream)
           
AsnParser(java.io.Reader stream)
           
 
Method Summary
static void AlphabetConstraint()
           
static void AnyType()
           
static void Assignment()
           
static void AssignmentList()
           
static void BinaryString()
           
static void BitStringType()
           
static void BooleanValue()
           
static void BuiltinType()
           
static void BuiltinValue()
           
static void CharString()
           
static void ChoiceType()
           
static void Class()
           
static void ClassNumber()
           
static void ComplianceGroup()
           
static void ComplianceObject()
           
static void Constraint()
           
static void ConstraintList()
           
static void DefinedMacroName()
           
static void DefinedMacroType()
           
static void DefinedType()
           
static void DefinedValue()
           
static void disable_tracing()
           
static void ElementType()
           
static void ElementTypeList()
           
static void enable_tracing()
           
static void EnumeratedType()
           
static void Exports()
           
static ParseException generateParseException()
           
static Token getNextToken()
           
static Token getToken(int index)
           
static void HexString()
           
static void Identifier()
           
static void Imports()
           
static void IntegerType()
           
static void LowerEndPoint()
           
static void MacroBody()
           
static void MacroDefinition()
           
static void MacroReference()
           
static void ModuleBody()
           
static void ModuleDefinition()
           
static void ModuleIdentifier()
           
static void ModuleReference()
           
static void NameAndNumberForm()
           
static void NamedBit()
           
static void NamedBits()
           
static void NamedNumber()
           
static void NamedNumberList()
           
static void NamedType()
           
static void NamedValue()
           
static void NullValue()
           
static void Number()
           
static void ObjectIdentifierValue()
           
static void ObjIdComponent()
           
static void ObjIdComponentList()
           
static Node parse(java.io.InputStream in)
          Parses an input stream and returns a ParseTree object.
static Node parse(java.io.Reader in)
          Parses an input stream and returns a ParseTree object.
 void ReInit(AsnParserTokenManager tm)
           
static void ReInit(java.io.InputStream stream)
           
static void ReInit(java.io.Reader stream)
           
static void SelectionType()
           
static void SequenceOfType()
           
static void SequenceType()
           
static void SetOfType()
           
static void SetType()
           
static void SignedNumber()
           
static void SizeConstraint()
           
static void SnmpAccessPart()
           
static void SnmpAgentCapabilitiesMacroType()
           
static void SnmpCompliancePart()
           
static void SnmpContactPart()
           
static void SnmpCreationPart()
           
static void SnmpDefValPart()
           
static void SnmpDescrPart()
           
static void SnmpDisplayPart()
           
static void SnmpEnterprisePart()
           
static void SnmpIndexPart()
           
static void SnmpMandatoryPart()
           
static void SnmpModuleComplianceMacroType()
           
static void SnmpModuleIdentityMacroType()
           
static void SnmpModulePart()
           
static void SnmpModuleSupportPart()
           
static void SnmpNotificationGroupMacroType()
           
static void SnmpNotificationsPart()
           
static void SnmpNotificationTypeMacroType()
           
static void SnmpObjectGroupMacroType()
           
static void SnmpObjectIdentityMacroType()
           
static void SnmpObjectsPart()
           
static void SnmpObjectTypeMacroType()
           
static void SnmpOrganizationPart()
           
static void SnmpProductReleasePart()
           
static void SnmpReferPart()
           
static void SnmpRevisionPart()
           
static void SnmpStatusPart()
           
static void SnmpSyntaxPart()
           
static void SnmpTextualConventionMacroType()
           
static void SnmpTrapTypeMacroType()
           
static void SnmpUnitsPart()
           
static void SnmpUpdatePart()
           
static void SnmpVariationPart()
           
static void SnmpVarPart()
           
static void SnmpWriteSyntaxPart()
           
static void SpecialRealValue()
           
static void Start()
           
static void StringType()
           
static void Symbol()
           
static void SymbolList()
           
static void SymbolsFromModule()
           
static void SymbolsFromModuleList()
           
static void Tag()
           
static void TagDefault()
           
static void TaggedType()
           
static void Type()
           
static void TypeAssignment()
           
static void TypeOrBits()
           
static void TypeOrValue()
           
static void TypeOrValueList()
           
static void TypeReference()
           
static void UpperEndPoint()
           
static void Value()
           
static void ValueAssignment()
           
static void ValueConstraint()
           
static void ValueList()
           
static void ValueRange()
           
static void VarTypes()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

token_source

public static AsnParserTokenManager token_source

token

public static Token token

jj_nt

public static Token jj_nt

lookingAhead

public static boolean lookingAhead
Constructor Detail

AsnParser

public AsnParser(java.io.InputStream stream)

AsnParser

public AsnParser(java.io.Reader stream)

AsnParser

public AsnParser(AsnParserTokenManager tm)
Method Detail

parse

public static Node parse(java.io.InputStream in)
                  throws ParseException
Parses an input stream and returns a ParseTree object. This method can be called any number of times, as it automatically reinitializes the parser.
Parameters:
in - an input character stream
Returns:
the top node of the parse tree
Throws:
ParseException - if the input stream couldn't be parsed correctly

parse

public static Node parse(java.io.Reader in)
                  throws ParseException
Parses an input stream and returns a ParseTree object. This method can be called any number of times, as it automatically reinitializes the parser.
Parameters:
in - an input stream reader
Returns:
the top node of the parse tree
Throws:
ParseException - if the input stream couldn't be parsed correctly

Start

public static final void Start()
                        throws ParseException

ModuleDefinition

public static final void ModuleDefinition()
                                   throws ParseException

TagDefault

public static final void TagDefault()
                             throws ParseException

ModuleIdentifier

public static final void ModuleIdentifier()
                                   throws ParseException

ModuleBody

public static final void ModuleBody()
                             throws ParseException

Exports

public static final void Exports()
                          throws ParseException

Imports

public static final void Imports()
                          throws ParseException

SymbolsFromModuleList

public static final void SymbolsFromModuleList()
                                        throws ParseException

SymbolsFromModule

public static final void SymbolsFromModule()
                                    throws ParseException

SymbolList

public static final void SymbolList()
                             throws ParseException

Symbol

public static final void Symbol()
                         throws ParseException

AssignmentList

public static final void AssignmentList()
                                 throws ParseException

Assignment

public static final void Assignment()
                             throws ParseException

MacroDefinition

public static final void MacroDefinition()
                                  throws ParseException

MacroBody

public static final void MacroBody()
                            throws ParseException

MacroReference

public static final void MacroReference()
                                 throws ParseException

TypeAssignment

public static final void TypeAssignment()
                                 throws ParseException

Type

public static final void Type()
                       throws ParseException

BuiltinType

public static final void BuiltinType()
                              throws ParseException

IntegerType

public static final void IntegerType()
                              throws ParseException

NamedNumberList

public static final void NamedNumberList()
                                  throws ParseException

NamedNumber

public static final void NamedNumber()
                              throws ParseException

SignedNumber

public static final void SignedNumber()
                               throws ParseException

StringType

public static final void StringType()
                             throws ParseException

BitStringType

public static final void BitStringType()
                                throws ParseException

SequenceType

public static final void SequenceType()
                               throws ParseException

SequenceOfType

public static final void SequenceOfType()
                                 throws ParseException

SetType

public static final void SetType()
                          throws ParseException

SetOfType

public static final void SetOfType()
                            throws ParseException

ElementTypeList

public static final void ElementTypeList()
                                  throws ParseException

ElementType

public static final void ElementType()
                              throws ParseException

NamedType

public static final void NamedType()
                            throws ParseException

ChoiceType

public static final void ChoiceType()
                             throws ParseException

EnumeratedType

public static final void EnumeratedType()
                                 throws ParseException

SelectionType

public static final void SelectionType()
                                throws ParseException

TaggedType

public static final void TaggedType()
                             throws ParseException

Tag

public static final void Tag()
                      throws ParseException

ClassNumber

public static final void ClassNumber()
                              throws ParseException

Class

public static final void Class()
                        throws ParseException

AnyType

public static final void AnyType()
                          throws ParseException

DefinedType

public static final void DefinedType()
                              throws ParseException

ConstraintList

public static final void ConstraintList()
                                 throws ParseException

Constraint

public static final void Constraint()
                             throws ParseException

ValueConstraint

public static final void ValueConstraint()
                                  throws ParseException

ValueRange

public static final void ValueRange()
                             throws ParseException

LowerEndPoint

public static final void LowerEndPoint()
                                throws ParseException

UpperEndPoint

public static final void UpperEndPoint()
                                throws ParseException

SizeConstraint

public static final void SizeConstraint()
                                 throws ParseException

AlphabetConstraint

public static final void AlphabetConstraint()
                                     throws ParseException

ValueAssignment

public static final void ValueAssignment()
                                  throws ParseException

Value

public static final void Value()
                        throws ParseException

DefinedValue

public static final void DefinedValue()
                               throws ParseException

BuiltinValue

public static final void BuiltinValue()
                               throws ParseException

BooleanValue

public static final void BooleanValue()
                               throws ParseException

SpecialRealValue

public static final void SpecialRealValue()
                                   throws ParseException

NullValue

public static final void NullValue()
                            throws ParseException

NamedValue

public static final void NamedValue()
                             throws ParseException

ObjectIdentifierValue

public static final void ObjectIdentifierValue()
                                        throws ParseException

ObjIdComponentList

public static final void ObjIdComponentList()
                                     throws ParseException

ObjIdComponent

public static final void ObjIdComponent()
                                 throws ParseException

NameAndNumberForm

public static final void NameAndNumberForm()
                                    throws ParseException

BinaryString

public static final void BinaryString()
                               throws ParseException

HexString

public static final void HexString()
                            throws ParseException

CharString

public static final void CharString()
                             throws ParseException

Number

public static final void Number()
                         throws ParseException

Identifier

public static final void Identifier()
                             throws ParseException

ModuleReference

public static final void ModuleReference()
                                  throws ParseException

TypeReference

public static final void TypeReference()
                                throws ParseException

DefinedMacroType

public static final void DefinedMacroType()
                                   throws ParseException

DefinedMacroName

public static final void DefinedMacroName()
                                   throws ParseException

SnmpModuleIdentityMacroType

public static final void SnmpModuleIdentityMacroType()
                                              throws ParseException

SnmpObjectIdentityMacroType

public static final void SnmpObjectIdentityMacroType()
                                              throws ParseException

SnmpObjectTypeMacroType

public static final void SnmpObjectTypeMacroType()
                                          throws ParseException

SnmpNotificationTypeMacroType

public static final void SnmpNotificationTypeMacroType()
                                                throws ParseException

SnmpTrapTypeMacroType

public static final void SnmpTrapTypeMacroType()
                                        throws ParseException

SnmpTextualConventionMacroType

public static final void SnmpTextualConventionMacroType()
                                                 throws ParseException

SnmpObjectGroupMacroType

public static final void SnmpObjectGroupMacroType()
                                           throws ParseException

SnmpNotificationGroupMacroType

public static final void SnmpNotificationGroupMacroType()
                                                 throws ParseException

SnmpModuleComplianceMacroType

public static final void SnmpModuleComplianceMacroType()
                                                throws ParseException

SnmpAgentCapabilitiesMacroType

public static final void SnmpAgentCapabilitiesMacroType()
                                                 throws ParseException

SnmpUpdatePart

public static final void SnmpUpdatePart()
                                 throws ParseException

SnmpOrganizationPart

public static final void SnmpOrganizationPart()
                                       throws ParseException

SnmpContactPart

public static final void SnmpContactPart()
                                  throws ParseException

SnmpDescrPart

public static final void SnmpDescrPart()
                                throws ParseException

SnmpRevisionPart

public static final void SnmpRevisionPart()
                                   throws ParseException

SnmpStatusPart

public static final void SnmpStatusPart()
                                 throws ParseException

SnmpReferPart

public static final void SnmpReferPart()
                                throws ParseException

SnmpSyntaxPart

public static final void SnmpSyntaxPart()
                                 throws ParseException

TypeOrBits

public static final void TypeOrBits()
                             throws ParseException

NamedBits

public static final void NamedBits()
                            throws ParseException

NamedBit

public static final void NamedBit()
                           throws ParseException

SnmpUnitsPart

public static final void SnmpUnitsPart()
                                throws ParseException

SnmpAccessPart

public static final void SnmpAccessPart()
                                 throws ParseException

SnmpIndexPart

public static final void SnmpIndexPart()
                                throws ParseException

TypeOrValueList

public static final void TypeOrValueList()
                                  throws ParseException

TypeOrValue

public static final void TypeOrValue()
                              throws ParseException

SnmpDefValPart

public static final void SnmpDefValPart()
                                 throws ParseException

SnmpObjectsPart

public static final void SnmpObjectsPart()
                                  throws ParseException

ValueList

public static final void ValueList()
                            throws ParseException

SnmpEnterprisePart

public static final void SnmpEnterprisePart()
                                     throws ParseException

SnmpVarPart

public static final void SnmpVarPart()
                              throws ParseException

VarTypes

public static final void VarTypes()
                           throws ParseException

SnmpDisplayPart

public static final void SnmpDisplayPart()
                                  throws ParseException

SnmpNotificationsPart

public static final void SnmpNotificationsPart()
                                        throws ParseException

SnmpModulePart

public static final void SnmpModulePart()
                                 throws ParseException

SnmpMandatoryPart

public static final void SnmpMandatoryPart()
                                    throws ParseException

SnmpCompliancePart

public static final void SnmpCompliancePart()
                                     throws ParseException

ComplianceGroup

public static final void ComplianceGroup()
                                  throws ParseException

ComplianceObject

public static final void ComplianceObject()
                                   throws ParseException

SnmpWriteSyntaxPart

public static final void SnmpWriteSyntaxPart()
                                      throws ParseException

SnmpProductReleasePart

public static final void SnmpProductReleasePart()
                                         throws ParseException

SnmpModuleSupportPart

public static final void SnmpModuleSupportPart()
                                        throws ParseException

SnmpVariationPart

public static final void SnmpVariationPart()
                                    throws ParseException

SnmpCreationPart

public static final void SnmpCreationPart()
                                   throws ParseException

ReInit

public static void ReInit(java.io.InputStream stream)

ReInit

public static void ReInit(java.io.Reader stream)

ReInit

public void ReInit(AsnParserTokenManager tm)

getNextToken

public static final Token getNextToken()

getToken

public static final Token getToken(int index)

generateParseException

public static final ParseException generateParseException()

enable_tracing

public static final void enable_tracing()

disable_tracing

public static final void disable_tracing()