[antlr-interest] Compiler-exploding grammar

Steve Bennett stevagewp at gmail.com
Wed Nov 28 04:05:45 PST 2007


I have a grammar, which when generated, causes the java compiler to
explode with an out of stack space message:

The system is out of resources.
Consult the following stack trace for details.
java.lang.StackOverflowError
at com.sun.tools.javac.comp.Attr.attribExpr(Attr.java:297)
at com.sun.tools.javac.comp.Attr.visitBinary(Attr.java:1518)
at com.sun.tools.javac.tree.Tree$Binary.accept(Tree.java:926)
at com.sun.tools.javac.comp.Attr.attribTree(Attr.java:275)
at com.sun.tools.javac.comp.Attr.attribExpr(Attr.java:297)
at com.sun.tools.javac.comp.Attr.visitBinary(Attr.java:1518)
at com.sun.tools.javac.tree.Tree$Binary.accept(Tree.java:926)
at com.sun.tools.javac.comp.Attr.attribTree(Attr.java:275)
at com.sun.tools.javac.comp.Attr.attribExpr(Attr.java:297)
at com.sun.tools.javac.comp.Attr.visitBinary(Attr.java:1518)
...
(hundreds of lines)

Is there a developer I should send this to? It's pretty big. I tried
trimming it down to the relevant bit, but strangely enough, that
compiled fine, and even stranger, ran as expected.

That is, the code that makes it explode is commented out in the
following snippet. But that snippet alone isn't enough to make the
compiler explode, I think.

close_bold_italics
@after {text_bold=false; text_italics = false;}
: ;
/*        {text_bold==true && text_italics==true}? =>  -> B_OFF I_OFF
       |{text_bold==false && text_italics==true}? => -> I_OFF
       |{text_bold==true && text_italics==false}? => -> B_OFF
       |->;*/


Steve


More information about the antlr-interest mailing list