[antlr-interest] Java Tree Parser: NPE: rulememo == null??

Randall R Schulz rschulz at sonic.net
Fri Jul 13 16:23:19 PDT 2007


Hi,

After a recent round of changes to my tree grammar, most of them in
parser class methods and other related classes, not the grammar itself,
the resulting parser is now crashing with an NPE in (org.antlr.runtime)
BaseRecognizer.memoize(IntStream, int, int). This line of code is:

    if ( ruleMemo[ruleIndex]!=null ) { ... }

Exception in thread "main" java.lang.NullPointerException
        at org.antlr.runtime.BaseRecognizer.memoize(BaseRecognizer.java:740)


What's even more perplexing, when I run this under the (Java) debugger
in IDEA the NPE occurs in a different place. In this case, the crash
occurs in BaseRecognizer.getRuleMemoization(int, int) at line 696.
Still, it is the ruleMemo field (an array) that is null:

   if ( ruleMemo[ruleIndex]==null ) { ... }


When I build the parser with "-debug" this is the NPE I see:

Exception in thread "main" java.lang.NullPointerException
        at org.antlr.runtime.debug.DebugEventSocketProxy.transmit(DebugEventSocketProxy.java:108)
        at org.antlr.runtime.debug.DebugEventSocketProxy.exitRule(DebugEventSocketProxy.java:122)


I'm at a loss to explain this crash or to even hypothesize causes for
it, especially given its shifting nature. Can anybody suggest what I
might have mucked up?


Thanks.

Randall Schulz


More information about the antlr-interest mailing list