[antlr-interest] Parsing a grammar file 2.7.5

C T giarcmirt at gmail.com
Wed Mar 15 11:56:16 PST 2006


Hi,

Using 2.7.5.  I'm trying to parse a grammar file I created using the
following code:

 FileInputStream fos = new FileInputStream(new File(filename));
 ANTLRLexer lexer = new ANTLRLexer(fos);
 ANTLRParser parser = new ANTLRParser(lexer);
 parser.grammar();
 AST ast = parser.getAST();
 DumpASTVisitor visitor = new DumpASTVisitor();
 visitor.visit(ast);

When I do this I get a Null Pointer Exception.  Looks like this constructor:

 public ANTLRParser(
    TokenBuffer tokenBuf,
    ANTLRGrammarParseBehavior behavior_,

    Tool tool_
 )

 it not being instantiated, and so the ANTLRGrammarParseBehavior behavior
object remains null.  Should I construct the ANTLRParser class differently,
or am I doing something else wrong?

 Thanks in advance,
 Torrance
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/antlr-interest/attachments/20060315/d4b98224/attachment.html


More information about the antlr-interest mailing list