[antlr-interest] Grammar.createLookaheadDFA(): could not even do k=1 for decision 45;

Jim Idle jimi at temporal-wave.com
Wed Feb 6 08:08:04 PST 2008


You may well find that rather than using the existing grammar as your 
guide, it is easier to start with a blank screen and build up to the 
full grammar using 3.x constructs. As you add new productions, you will 
be able to see which of them are causing ambiguities and diagnose them 
as either grammar problems which you can refactor, or real language 
ambiguities which require a little more ingenuity.

Jim
> -----Original Message-----
> From: Erik Kratochvil [mailto:discontinuum at gmail.com]
> Sent: Wednesday, February 06, 2008 12:26 AM
> To: Jim Idle
> Cc: antlr-interest at antlr.org
> Subject: Re: [antlr-interest] Grammar.createLookaheadDFA(): could not
> even do k=1 for decision 45;
> 
> On 2/5/08, Jim Idle <jimi at temporal-wave.com> wrote:
> >
> > It means that your grammar is extremely ambiguous and the analysis 
of
> > that particular decision has timed out (1000ms is the default). You
> > could try to increase this timeout (see the wiki for the option), 
but
> it
> > is likely to just take longer to time out I am afraid.
> >
> > You could try backtracking (but this is quite a performance 
overhead,
> so
> > you should only really do it for prototyping or where you dont 
really
> > care about performance), or try using k=1 options in some of the
> > subrules and so on. However, your best bet is to step back in time
> with
> > your grammar and find out what you introduced to make it exhibit 
this
> > behavior, then re-specify the grammar in a less ambiguous fashion.
> >
> 
> Aha. The problem is that the grammar is not mine, I sort of inherited
> it. It was written for antlr 2.7 (and it worked well) and my task was
> to convert it so that it works with antlr 3. It is true that the
> grammar has some ambiguity issues, there are more than three dozens of
> syntactic and semantic predicates and the generated parser.java has
> more than 100MB while the size of the parser generated by antlr2.7 was
> only 2.3MB. I guess that conversion from 2.7 to 3.0 is not as easy as
> I thought :)
> 
> Thank you very much, I shall do as you suggest - I'll try to rewrite
> the problematic rules.
> 
> --
> Erik Kratochvíl




More information about the antlr-interest mailing list