[antlr-interest] ANTLRWorks and separate lexer/parser grammars - pleading?
r.mark.volkmann at gmail.com
Fri Jan 18 13:30:26 PST 2008
I figured out the issue. In my Java code that uses the generated
classes I was creating my parser and tree parser objects by passing
null to the constructor and then later calling setTokenStream on the
parser and setTreeNodeStream on the tree parser. You can't do that
when you compile with debug because the generated constructor for the
parser class will do this.
That means null is passed to the DebugTokenStream constructor which is
why I was getting the NullPointerException.
I can work around this for now by not creating my parser and tree
parser objects until I know what stream I want them to use.
I've got it working now. Thanks!
On Jan 18, 2008 3:18 PM, Terence Parr <parrt at cs.usfca.edu> wrote:
> On Jan 18, 2008, at 12:55 PM, Mark Volkmann wrote:
> > On Jan 18, 2008 2:29 PM, Terence Parr <parrt at cs.usfca.edu> wrote:
> >> run -debug on the parser grammar from command line.
> > Okay, I added the "-debug" option when running org.antlr.Tool on my
> > grammar files.
> only run it on the one grammar you want to debug.
> >> compile. start
> > The code generated with -debug compiles fine, but when I run it I get
> > Exception in thread "main" java.lang.NullPointerException at
> > org
> > .antlr.runtime.debug.DebugTokenStream.<init>(DebugTokenStream.java:45)
> > Do I have to do something different in my code that uses the
> > generated classes?
> Hm.... This doesn't happen for me. Try again only using -debug on the
> parser grammar.
R. Mark Volkmann
Object Computing, Inc.
More information about the antlr-interest