help-bison
[Top][All Lists]
Advanced

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

Re: Query regarding Parser stack


From: Hans Aberg
Subject: Re: Query regarding Parser stack
Date: Fri, 29 Oct 2004 20:13:45 +0200
User-agent: Microsoft-Outlook-Express-Macintosh-Edition/5.0.6

At 17:33 +0530 2004/10/12, Rachna Khanna wrote:
>I am using Bison version 1.875.
>
>My project requires to be tested under environment where files having
>many source lines can be specified. But in such a situation, the parser
>stack overflow occurs and unintialized memory is being accessed which
>leads to the application getting terminated.
>
>Earlier I was using an older version of Bison i.e. version 1.24 and was
>facing the same problem. To rectify the problem, I changed the stack
>limits (YYINITDEPTH, YYMAXDEPTH). I had also raised this query in the
>Bison help mailing list and got the reply that in future versions a
>dynamic method of parser stack generation will be implemented. In the
>present version(1.875) also, I have had to change the stack size limits
>in the file "yacc.c". After changing the limits the application worked
>successfully.
>
>Can anybody please clarify that is there any other method to increase
>the stack size other than changing the static way?

The Bison C parser already creates a dynamically reallocating stack:
YYINITDEPTH creates an initial array in the parser function, used as a
static stack. When that becomes too small, it switches to a dynamic
allocation, where YYMAXDEPTH is the upper limit. The file yacc.c says:
/* YYMAXDEPTH -- maximum size the stacks can grow to (effective only
   if the built-in stack extension method is used).

   Do not make this value too large; the results are undefined if
   SIZE_MAX < YYSTACK_BYTES (YYMAXDEPTH)
   evaluated with infinite-precision integer arithmetic.  */

So, apart from making sure you get the left/right recursion correct (as
suggested in another letter), you already get your dynamic stack (thanks to
Paul Eggert, who wrote it). When setting YYMAXDEPTH, follow the instructions
in the comment above.

  Hans Aberg






reply via email to

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