[antlr-interest] Compiling the Generated Code

Johannes Luber jaluber at gmx.de
Tue Apr 24 07:57:44 PDT 2007


Marc-André Laverdière wrote:
> Hello,
> 
> I generated the code from my grammar using ANTLRWorks 1.0b11 and I've
> imported the code in my Eclipse project. There are compiler errors that
> I don't understand.
> 
> They happen in the parser: one of my rules has {greedy=false;}, and this
> is put in the Java code, but the compiler complains that greedy doesn't
> exist. When I comment it out, it complains about a RecognitionException
> that can't be thrown, so I'd have to remove the try, catch and finally
> structure. Is it supposed to be like that?
> 
> Further, looking at that code, I don't see how it is supposed to act in
> a non-greedy manner! It is a (.)* rule, non-greedy, that should stop
> when a given token is read.
> 
> It works fine in AntlrWorks, btw (tested in 1.0b10). So, its a bit of a
> surprise here.

Can you post the relevant parts of the grammar? Makes it easier to see
if you have a syntax error, which is now discovered, or if ANTLRworks
got a new bug. Your rule should look like this: "( options
{greedy=false;} : . )*".

> Thanks a ton in advance. This is my first excursion in the field of
> programming language design, and I hope it won't be a too painful one!

Did you read this tutorial (and the others)
<http://www.antlr.org/wiki/display/ANTLR3/Quick+Starter+on+Parser+Grammars+-+No+Past+Experience+Required>
already?

Best regards,
Johannes Luber


More information about the antlr-interest mailing list