help-bison
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Can one prune the parse stack?


From: Hans Aberg
Subject: Re: Can one prune the parse stack?
Date: Thu, 26 Aug 2010 23:43:25 +0200

On 26 Aug 2010, at 23:08, Christoph Lechner wrote:

Mike Aubury wrote:
I'm thinking your grammar is probably wrong - there shouldn't be any
problem with having lots of packets like that - so long and they are
not very recursive (packet within packet within packet .....)
What does your grammar look like ?
@Mike: Sorry for sending my first reply to you and not to the list. So
here is my mail to the list.

Hi,

thank you for your fast reply. I think I found the mistake now -- I
guess it's the 'stream' rule.

The beginning of my grammar is like:

stream:   /* empty line */
       | stmt stream
       | error stream
       ;

Make sure to use left recursion (see the Bison manual), as in the reply by Mike, with the recursion variable to the left, in order to avoid the parser stack building up. Like this:
  expseq1:
      exp
    | expseq1 ’,’ exp /* To the left here */
    ;
Your grammar may be written for LL, but Bison uses LALR(1).




reply via email to

[Prev in Thread] Current Thread [Next in Thread]