Mike Lischke | 3 Apr 2012 17:35
Picon
Favicon

C and C++ targets in ANTLR

Hi,

after long absence I am trying again to create new parsers. The last one was with ANTLR 2.7 several years ago, now I go with 3.4.

My problem is that both the C and the C++ target crash with a stack overflow error with a large grammar (MySQL 5.1 language). I can easily create parsers and lexers for C# and Java. I tried increasing the VM memory to 8GB, and antlr happily consumes it but still it crashes after about 15 minutes.

So, what strategy would be appropriate now to get this working? Since the grammar works with the other targets and I actually need the full language stripping down the grammar is not really an option. ANTLR.works gives me green on the grammar (but doesn't generate the compiler either, however it also has problems with the java target, so I better leave it out for tasks other than editing and syntax checking).

Thanks for any help,
<div>Hi,<div><br></div>
<div>after long absence I am trying again to create new parsers. The last one was with ANTLR 2.7 several years ago, now I go&nbsp;with 3.4.</div>
<div><br></div>
<div>My problem is that both the C and the C++ target crash with a stack overflow error with a large grammar (MySQL 5.1 language). I can easily create parsers and lexers for C# and Java. I tried increasing the VM memory to 8GB, and antlr happily consumes it but still it crashes after about 15 minutes.</div>
<div><br></div>
<div>So, what strategy would be appropriate now to get this working? Since the grammar works with the other targets and I actually need the full language stripping down the grammar is not really an option. ANTLR.works gives me green on the grammar (but doesn't generate the compiler either, however it also has problems with the java target, so I better leave it out for tasks other than editing and syntax checking).</div>
<div><br></div>
<div>Thanks for any help,</div>
<div>
<br><div apple-content-edited="true">
<span class="Apple-style-span">Mike<br>--&nbsp;<br><a href="http://www.soft-gems.net">www.soft-gems.net</a><br></span>
</div>
<br>
</div>
</div>
Jim Idle | 3 Apr 2012 20:55

Re: C and C++ targets in ANTLR

Without the grammar, or a stack trace or some indication of whether you mean that the 3.4 tool crashes when generating C, there is nothing I can do to help you here. I imagine that there is something wrong with the grammar that happens to be OK with the other targets and is not in the C target code generating templates (which were changed between 3.3 and 3.4). However you will need to experiment commenting out rules until you find the rule that causes ANTLR to break. Also, did you try 3.3 instead of 3.4?

 

I am sorry but I can’t work out what you mean by “ANTLR.works gives me green on the grammar (but doesn't generate the compiler either, however it also has problems with the java target, so I better leave it out for tasks other than editing and syntax checking).” In the first paragraph you said that the Java target works, but here you seem to be saying that it does not, or perhaps just does not with ANTLR Works?

 

Jim

 

From: antlr-dev-bounces-ErkRXerACLvYtjvyW6yDsg@public.gmane.org [mailto:antlr-dev-bounces-ErkRXerACLvYtjvyW6yDsg@public.gmane.org] On Behalf Of Mike Lischke
Sent: Tuesday, April 03, 2012 8:35 AM
To: antlr-dev-ErkRXerACLvYtjvyW6yDsg@public.gmane.org
Subject: [antlr-dev] C and C++ targets in ANTLR

 

Hi,

 

after long absence I am trying again to create new parsers. The last one was with ANTLR 2.7 several years ago, now I go with 3.4.

 

My problem is that both the C and the C++ target crash with a stack overflow error with a large grammar (MySQL 5.1 language). I can easily create parsers and lexers for C# and Java. I tried increasing the VM memory to 8GB, and antlr happily consumes it but still it crashes after about 15 minutes.

 

So, what strategy would be appropriate now to get this working? Since the grammar works with the other targets and I actually need the full language stripping down the grammar is not really an option. ANTLR.works gives me green on the grammar (but doesn't generate the compiler either, however it also has problems with the java target, so I better leave it out for tasks other than editing and syntax checking).

 

Thanks for any help,

 

 

<div><div class="WordSection1">
<p class="MsoNormal"><span>Without the grammar, or a stack trace or some indication of whether you mean that the 3.4 tool crashes when generating C, there is nothing I can do to help you here. I imagine that there is something wrong with the grammar that happens to be OK with the other targets and is not in the C target code generating templates (which were changed between 3.3 and 3.4). However you will need to experiment commenting out rules until you find the rule that causes ANTLR to break. Also, did you try 3.3 instead of 3.4?</span></p>
<p class="MsoNormal"><span>&nbsp;</span></p>
<p class="MsoNormal"><span>I am sorry but I can&rsquo;t work out what you mean by &ldquo;ANTLR.works gives me green on the grammar (but doesn't generate the compiler either, however it also has problems with the java target, so I better leave it out for tasks other than editing and syntax checking).&rdquo; In the first paragraph you said that the Java target works, but here you seem to be saying that it does not, or perhaps just does not with ANTLR Works?</span></p>
<p class="MsoNormal">&nbsp;</p>
<p class="MsoNormal">Jim<span></span></p>
<p class="MsoNormal"><a name="_MailEndCompose"><span>&nbsp;</span></a></p>
<div>
<div><div><p class="MsoNormal"><span>From:</span><span> <a href="mailto:antlr-dev-bounces@...">antlr-dev-bounces@...</a> [mailto:<a href="mailto:antlr-dev-bounces@...">antlr-dev-bounces@...</a>] On Behalf Of Mike Lischke<br>Sent: Tuesday, April 03, 2012 8:35 AM<br>To: <a href="mailto:antlr-dev@...">antlr-dev@...</a><br>Subject: [antlr-dev] C and C++ targets in ANTLR</span></p></div></div>
<p class="MsoNormal">
&nbsp;</p>
<p class="MsoNormal">Hi,</p>
<div><p class="MsoNormal">&nbsp;</p></div>
<div>
<p class="MsoNormal">after long absence I am trying again to create new parsers. The last one was with ANTLR 2.7 several years ago, now I go&nbsp;with 3.4.</p>
</div>
<div><p class="MsoNormal">&nbsp;</p></div>
<div>
<p class="MsoNormal">My problem is that both the C and the C++ target crash with a stack overflow error with a large grammar (MySQL 5.1 language). I can easily create parsers and lexers for C# and Java. I tried increasing the VM memory to 8GB, and antlr happily consumes it but still it crashes after about 15 minutes.</p>
</div>
<div><p class="MsoNormal">&nbsp;</p></div>
<div>
<p class="MsoNormal">So, what strategy would be appropriate now to get this working? Since the grammar works with the other targets and I actually need the full language stripping down the grammar is not really an option. ANTLR.works gives me green on the grammar (but doesn't generate the compiler either, however it also has problems with the java target, so I better leave it out for tasks other than editing and syntax checking).</p>
</div>
<div><p class="MsoNormal">&nbsp;</p></div>
<div><p class="MsoNormal">Thanks for any help,</p></div>
<div>
<p class="MsoNormal">&nbsp;</p>
<div><p class="MsoNormal"><span class="apple-style-span"><span>Mike</span></span><span><br><span class="apple-style-span">--&nbsp;</span><br><span class="apple-style-span"><a href="http://www.soft-gems.net">www.soft-gems.net</a></span><br><br></span></p></div>
<p class="MsoNormal">&nbsp;</p>
</div>
</div>
</div></div>

Gmane