Stack Overflow
Previous: <Mystery Conflicts=>MysteryCon> * Next: <Error Recovery=>ErrorRecov> * Up: <Algorithm=>Algorithm>

#Wrap on
{fH3}Stack Overflow, and How to Avoid It{f}

The Bison parser stack can overflow if too many tokens are shifted and
not reduced.  When this happens, the parser function {fCode}yyparse{f}
returns a nonzero value, pausing only to call {fCode}yyerror{f} to report
the overflow.

By defining the macro {fCode}YYMAXDEPTH{f}, you can control how deep the
parser stack can become before a stack overflow occurs.  Define the
macro with a value that is an integer.  This value is the maximum number
of tokens that can be shifted (and not reduced) before overflow.
It must be a constant expression whose value is known at compile time.

The stack space allowed is not necessarily allocated.  If you specify a
large value for {fCode}YYMAXDEPTH{f}, the parser actually allocates a small
stack at first, and then makes it bigger by stages as needed.  This
increasing allocation happens automatically and silently.  Therefore,
you do not need to make {fCode}YYMAXDEPTH{f} painfully small merely to save
space for ordinary inputs that do not need much stack.

The default value of {fCode}YYMAXDEPTH{f}, if you do not define it, is
10000.

You can control how much stack is allocated initially by defining the
macro {fCode}YYINITDEPTH{f}.  This value too must be a compile-time
constant integer.  The default is 200.

