[antlr-interest] Compiler-exploding grammar
Harald Mueller
harald_m_mueller at gmx.de
Wed Nov 28 06:30:16 PST 2007
HI,
But isn't the problem with the com.sun(!).tools.javac???
It seems like a genuine compiler bug ... maybe if you send the code created around the empty -> rule to Sun (and also to the Antlr people - they might know how to avoid it ...).
Regards
Harald
-------- Original-Nachricht --------
> Datum: Wed, 28 Nov 2007 14:26:43 -0000
> Von: "Mark Edgeworth" <mark.edgeworth at scarletcode.co.uk>
> An: antlr-interest at antlr.org
> Betreff: Re: [antlr-interest] Compiler-exploding grammar
> Hi Steve,
>
> The last alternative in your rule is empty, and so need not contain a
> '->'.
> This looks like a corner case that might just create an invalid AST tree
> and
> an unconstrained recursion. Remove the '->' :-)
>
> 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
> |->;*/
>
> Hope this helps,
>
> Mark Edgeworth
>
> -----Original Message-----
> Message: 5
> Date: Wed, 28 Nov 2007 23:05:45 +1100
> From: "Steve Bennett" <stevagewp at gmail.com>
> Subject: [antlr-interest] Compiler-exploding grammar
>
> 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
--
Psssst! Schon vom neuen GMX MultiMessenger gehört?
Der kann`s mit allen: http://www.gmx.net/de/go/multimessenger
More information about the antlr-interest
mailing list