Problem parsing Mib file using ANTLR.
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Jaykumar_Ahir
Posted On:   Friday, August 24, 2001 10:38 PM

Hi I am working on parsing Mib file using the ANTLR. The grammer I have been using is as follows // Parser Rules imports : "IMPORTS" (symbolsFromModule)* SEMI ; symbolsFromModule : symbolList "FROM" upperCaseIdentifier ; symbolList : symbol (COMMA symbol)* ; symbol : identifier ; snmpObjectTypeMacroType : identifier "OBJECT-TYPE" "SYNTAX" type snmpAccessPart snmpStatusPart (snmpDescrPart) (snmpReferPart) (snmpIndexPart) (snmpDefValPart) ; identifier : UPPERCASEIDENT    More>>

Hi I am working on parsing Mib file using the ANTLR. The grammer I have been using is as follows



			
// Parser Rules

imports :
"IMPORTS" (symbolsFromModule)* SEMI
;

symbolsFromModule :
symbolList "FROM" upperCaseIdentifier
;

symbolList :
symbol (COMMA symbol)*
;

symbol :
identifier
;


snmpObjectTypeMacroType :
identifier "OBJECT-TYPE" "SYNTAX" type
snmpAccessPart
snmpStatusPart
(snmpDescrPart)
(snmpReferPart)
(snmpIndexPart)
(snmpDefValPart)
;

identifier :
UPPERCASEIDENT
| LOWERCASEIDENT
;

// Lexer Rules

protected
IDENT
options {
testLiterals = true;
}
: ('a'..'z'|'A'..'Z'|'-'|'0'..'9')*
;

LOWERCASEIDENT
options {
// testLiterals = true;
paraphrase = "A Lower Case Identifer";
}
: ('a'..'z') IDENT
;

UPPERCASEIDENT
options {
// testLiterals = true;
paraphrase = "An Upper Case Identifer";
}
: ('A'..'Z') IDENT
;


Now when I try to parse the following content from a file



			
IMPORTS
mgmt, NetworkAddress, IpAddress, Counter, Gauge,
TimeTicks
FROM RFC1155-SMI
OBJECT-TYPE
FROM RFC-1212;

sysObjectID OBJECT-TYPE
SYNTAX OBJECT IDENTIFIER
ACCESS read-only
STATUS mandatory
DESCRIPTION
"The vendor's authoritative identification of the
network management subsystem contained in the
entity. This value is allocated within the SMI
enterprises subtree (1.3.6.1.4.1) and provides an
easy and unambiguous means for determining `what
kind of box' is being managed. For example, if
vendor `Flintstones, Inc.' was assigned the
subtree 1.3.6.1.4.1.4242, it could assign the
identifier 1.3.6.1.4.1.4242.1.1 to its `Fred
Router'."
::= { system 2 }


It gives a error something like following :
line 5: expecting A Semi-Colon, found 'OBJECT-TYPE'
How can I make antlr understand the OBJECT-TYPE in IMPORTS directive is not the one which is part of "snmpObjectTypeMacroType" parser rule. Since as soon as it finds "OBJECT-TYPE" in file it is trying to change the rule from imports to snmpObjectTypeMacroType.

Can anybody help out with this.
Thanks in advance.    <<Less

Re: Problem parsing Mib file using ANTLR.

Posted By:   Terence_Parr  
Posted On:   Saturday, September 1, 2001 11:43 AM

You told it to look for a SEMI in the grammar and you didn't pass one to the parser.
About | Sitemap | Contact