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
ParseException

ModuleDefinition

public static final void ModuleDefinition()
                                   throws ParseException
ParseException

TagDefault

public static final void TagDefault()
                             throws ParseException
ParseException

ModuleIdentifier

public static final void ModuleIdentifier()
                                   throws ParseException
ParseException

ModuleBody

public static final void ModuleBody()
                             throws ParseException
ParseException

Exports

public static final void Exports()
                          throws ParseException
ParseException

Imports

public static final void Imports()
                          throws ParseException
ParseException

SymbolsFromModuleList

public static final void SymbolsFromModuleList()
                                        throws ParseException
ParseException

SymbolsFromModule

public static final void SymbolsFromModule()
                                    throws ParseException
ParseException

SymbolList

public static final void SymbolList()
                             throws ParseException
ParseException

Symbol

public static final void Symbol()
                         throws ParseException
ParseException

AssignmentList

public static final void AssignmentList()
                                 throws ParseException
ParseException

Assignment

public static final void Assignment()
                             throws ParseException
ParseException

MacroDefinition

public static final void MacroDefinition()
                                  throws ParseException
ParseException

MacroBody

public static final void MacroBody()
                            throws ParseException
ParseException

MacroReference

public static final void MacroReference()
                                 throws ParseException
ParseException

TypeAssignment

public static final void TypeAssignment()
                                 throws ParseException
ParseException

Type

public static final void Type()
                       throws ParseException
ParseException

BuiltinType

public static final void BuiltinType()
                              throws ParseException
ParseException

IntegerType

public static final void IntegerType()
                              throws ParseException
ParseException

NamedNumberList

public static final void NamedNumberList()
                                  throws ParseException
ParseException

NamedNumber

public static final void NamedNumber()
                              throws ParseException
ParseException

SignedNumber

public static final void SignedNumber()
                               throws ParseException
ParseException

StringType

public static final void StringType()
                             throws ParseException
ParseException

BitStringType

public static final void BitStringType()
                                throws ParseException
ParseException

SequenceType

public static final void SequenceType()
                               throws ParseException
ParseException

SequenceOfType

public static final void SequenceOfType()
                                 throws ParseException
ParseException

SetType

public static final void SetType()
                          throws ParseException
ParseException

SetOfType

public static final void SetOfType()
                            throws ParseException
ParseException

ElementTypeList

public static final void ElementTypeList()
                                  throws ParseException
ParseException

ElementType

public static final void ElementType()
                              throws ParseException
ParseException

NamedType

public static final void NamedType()
                            throws ParseException
ParseException

ChoiceType

public static final void ChoiceType()
                             throws ParseException
ParseException

EnumeratedType

public static final void EnumeratedType()
                                 throws ParseException
ParseException

SelectionType

public static final void SelectionType()
                                throws ParseException
ParseException

TaggedType

public static final void TaggedType()
                             throws ParseException
ParseException

Tag

public static final void Tag()
                      throws ParseException
ParseException

ClassNumber

public static final void ClassNumber()
                              throws ParseException
ParseException

Class

public static final void Class()
                        throws ParseException
ParseException

AnyType

public static final void AnyType()
                          throws ParseException
ParseException

DefinedType

public static final void DefinedType()
                              throws ParseException
ParseException

ConstraintList

public static final void ConstraintList()
                                 throws ParseException
ParseException

Constraint

public static final void Constraint()
                             throws ParseException
ParseException

ValueConstraint

public static final void ValueConstraint()
                                  throws ParseException
ParseException

ValueRange

public static final void ValueRange()
                             throws ParseException
ParseException

LowerEndPoint

public static final void LowerEndPoint()
                                throws ParseException
ParseException

UpperEndPoint

public static final void UpperEndPoint()
                                throws ParseException
ParseException

SizeConstraint

public static final void SizeConstraint()
                                 throws ParseException
ParseException

AlphabetConstraint

public static final void AlphabetConstraint()
                                     throws ParseException
ParseException

ValueAssignment

public static final void ValueAssignment()
                                  throws ParseException
ParseException

Value

public static final void Value()
                        throws ParseException
ParseException

DefinedValue

public static final void DefinedValue()
                               throws ParseException
ParseException

BuiltinValue

public static final void BuiltinValue()
                               throws ParseException
ParseException

BooleanValue

public static final void BooleanValue()
                               throws ParseException
ParseException

SpecialRealValue

public static final void SpecialRealValue()
                                   throws ParseException
ParseException

NullValue

public static final void NullValue()
                            throws ParseException
ParseException

NamedValue

public static final void NamedValue()
                             throws ParseException
ParseException

ObjectIdentifierValue

public static final void ObjectIdentifierValue()
                                        throws ParseException
ParseException

ObjIdComponentList

public static final void ObjIdComponentList()
                                     throws ParseException
ParseException

ObjIdComponent

public static final void ObjIdComponent()
                                 throws ParseException
ParseException

NameAndNumberForm

public static final void NameAndNumberForm()
                                    throws ParseException
ParseException

BinaryString

public static final void BinaryString()
                               throws ParseException
ParseException

HexString

public static final void HexString()
                            throws ParseException
ParseException

CharString

public static final void CharString()
                             throws ParseException
ParseException

Number

public static final void Number()
                         throws ParseException
ParseException

Identifier

public static final void Identifier()
                             throws ParseException
ParseException

ModuleReference

public static final void ModuleReference()
                                  throws ParseException
ParseException

TypeReference

public static final void TypeReference()
                                throws ParseException
ParseException

DefinedMacroType

public static final void DefinedMacroType()
                                   throws ParseException
ParseException

DefinedMacroName

public static final void DefinedMacroName()
                                   throws ParseException
ParseException

SnmpModuleIdentityMacroType

public static final void SnmpModuleIdentityMacroType()
                                              throws ParseException
ParseException

SnmpObjectIdentityMacroType

public static final void SnmpObjectIdentityMacroType()
                                              throws ParseException
ParseException

SnmpObjectTypeMacroType

public static final void SnmpObjectTypeMacroType()
                                          throws ParseException
ParseException

SnmpNotificationTypeMacroType

public static final void SnmpNotificationTypeMacroType()
                                                throws ParseException
ParseException

SnmpTrapTypeMacroType

public static final void SnmpTrapTypeMacroType()
                                        throws ParseException
ParseException

SnmpTextualConventionMacroType

public static final void SnmpTextualConventionMacroType()
                                                 throws ParseException
ParseException

SnmpObjectGroupMacroType

public static final void SnmpObjectGroupMacroType()
                                           throws ParseException
ParseException

SnmpNotificationGroupMacroType

public static final void SnmpNotificationGroupMacroType()
                                                 throws ParseException
ParseException

SnmpModuleComplianceMacroType

public static final void SnmpModuleComplianceMacroType()
                                                throws ParseException
ParseException

SnmpAgentCapabilitiesMacroType

public static final void SnmpAgentCapabilitiesMacroType()
                                                 throws ParseException
ParseException

SnmpUpdatePart

public static final void SnmpUpdatePart()
                                 throws ParseException
ParseException

SnmpOrganizationPart

public static final void SnmpOrganizationPart()
                                       throws ParseException
ParseException

SnmpContactPart

public static final void SnmpContactPart()
                                  throws ParseException
ParseException

SnmpDescrPart

public static final void SnmpDescrPart()
                                throws ParseException
ParseException

SnmpRevisionPart

public static final void SnmpRevisionPart()
                                   throws ParseException
ParseException

SnmpStatusPart

public static final void SnmpStatusPart()
                                 throws ParseException
ParseException

SnmpReferPart

public static final void SnmpReferPart()
                                throws ParseException
ParseException

SnmpSyntaxPart

public static final void SnmpSyntaxPart()
                                 throws ParseException
ParseException

TypeOrBits

public static final void TypeOrBits()
                             throws ParseException
ParseException

NamedBits

public static final void NamedBits()
                            throws ParseException
ParseException

NamedBit

public static final void NamedBit()
                           throws ParseException
ParseException

SnmpUnitsPart

public static final void SnmpUnitsPart()
                                throws ParseException
ParseException

SnmpAccessPart

public static final void SnmpAccessPart()
                                 throws ParseException
ParseException

SnmpIndexPart

public static final void SnmpIndexPart()
                                throws ParseException
ParseException

TypeOrValueList

public static final void TypeOrValueList()
                                  throws ParseException
ParseException

TypeOrValue

public static final void TypeOrValue()
                              throws ParseException
ParseException

SnmpDefValPart

public static final void SnmpDefValPart()
                                 throws ParseException
ParseException

SnmpObjectsPart

public static final void SnmpObjectsPart()
                                  throws ParseException
ParseException

ValueList

public static final void ValueList()
                            throws ParseException
ParseException

SnmpEnterprisePart

public static final void SnmpEnterprisePart()
                                     throws ParseException
ParseException

SnmpVarPart

public static final void SnmpVarPart()
                              throws ParseException
ParseException

VarTypes

public static final void VarTypes()
                           throws ParseException
ParseException

SnmpDisplayPart

public static final void SnmpDisplayPart()
                                  throws ParseException
ParseException

SnmpNotificationsPart

public static final void SnmpNotificationsPart()
                                        throws ParseException
ParseException

SnmpModulePart

public static final void SnmpModulePart()
                                 throws ParseException
ParseException

SnmpMandatoryPart

public static final void SnmpMandatoryPart()
                                    throws ParseException
ParseException

SnmpCompliancePart

public static final void SnmpCompliancePart()
                                     throws ParseException
ParseException

ComplianceGroup

public static final void ComplianceGroup()
                                  throws ParseException
ParseException

ComplianceObject

public static final void ComplianceObject()
                                   throws ParseException
ParseException

SnmpWriteSyntaxPart

public static final void SnmpWriteSyntaxPart()
                                      throws ParseException
ParseException

SnmpProductReleasePart

public static final void SnmpProductReleasePart()
                                         throws ParseException
ParseException

SnmpModuleSupportPart

public static final void SnmpModuleSupportPart()
                                        throws ParseException
ParseException

SnmpVariationPart

public static final void SnmpVariationPart()
                                    throws ParseException
ParseException

SnmpCreationPart

public static final void SnmpCreationPart()
                                   throws ParseException
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()