X-Git-Url: https://git.saurik.com/bison.git/blobdiff_plain/f28ac696ee611702d0f2c4883822956dd73e0acd..a61e1620e7656f5bbb04b7e72a332d741062bb81:/doc/bison.texinfo diff --git a/doc/bison.texinfo b/doc/bison.texinfo index 1a1f3417..6d7a81ec 100644 --- a/doc/bison.texinfo +++ b/doc/bison.texinfo @@ -44,12 +44,12 @@ This manual is for @acronym{GNU} Bison (version @value{VERSION}, @value{UPDATED}), the @acronym{GNU} parser generator. Copyright @copyright{} 1988, 1989, 1990, 1991, 1992, 1993, 1995, 1998, -1999, 2000, 2001, 2002, 2003, 2004 Free Software Foundation, Inc. +1999, 2000, 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc. @quotation Permission is granted to copy, distribute and/or modify this document under the terms of the @acronym{GNU} Free Documentation License, -Version 1.1 or any later version published by the Free Software +Version 1.2 or any later version published by the Free Software Foundation; with no Invariant Sections, with the Front-Cover texts being ``A @acronym{GNU} Manual,'' and with the Back-Cover Texts as in (a) below. A copy of the license is included in the section entitled @@ -62,7 +62,7 @@ Copies published by the Free Software Foundation raise funds for @end quotation @end copying -@dircategory GNU programming tools +@dircategory Software development @direntry * bison: (bison). @acronym{GNU} parser generator (Yacc replacement). @end direntry @@ -444,7 +444,7 @@ roughly that the next grammar rule to apply at any point in the input is uniquely determined by the preceding input and a fixed, finite portion (called a @dfn{look-ahead}) of the remaining input. A context-free grammar can be @dfn{ambiguous}, meaning that there are multiple ways to -apply the grammar rules to get the some inputs. Even unambiguous +apply the grammar rules to get the same inputs. Even unambiguous grammars can be @dfn{non-deterministic}, meaning that no fixed look-ahead always suffices to determine the next grammar rule to apply. With the proper declarations, Bison is also able to parse these more @@ -2627,7 +2627,7 @@ not come before the definition of @code{yyparse}. For example, the definitions of @code{yylex} and @code{yyerror} often go here. Because C requires functions to be declared before being used, you often need to declare functions like @code{yylex} and @code{yyerror} in the Prologue, -even if you define them int he Epilogue. +even if you define them in the Epilogue. @xref{Interface, ,Parser C-Language Interface}. If the last section is empty, you may omit the @samp{%%} that separates it @@ -5574,7 +5574,6 @@ By defining the macro @code{YYMAXDEPTH}, 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 @code{YYMAXDEPTH}, the parser actually allocates a small @@ -5583,14 +5582,26 @@ increasing allocation happens automatically and silently. Therefore, you do not need to make @code{YYMAXDEPTH} painfully small merely to save space for ordinary inputs that do not need much stack. +However, do not allow @code{YYMAXDEPTH} to be a value so large that +arithmetic overflow could occur when calculating the size of the stack +space. Also, do not allow @code{YYMAXDEPTH} to be less than +@code{YYINITDEPTH}. + @cindex default stack limit The default value of @code{YYMAXDEPTH}, if you do not define it, is 10000. @vindex YYINITDEPTH You can control how much stack is allocated initially by defining the -macro @code{YYINITDEPTH}. This value too must be a compile-time -constant integer. The default is 200. +macro @code{YYINITDEPTH} to a positive integer. For the C +@acronym{LALR}(1) parser, this value must be a compile-time constant +unless you are assuming C99 or some other target language or compiler +that allows variable-length arrays. The default is 200. + +Do not allow @code{YYINITDEPTH} to be a value so large that arithmetic +overflow would occur when calculating the size of the stack space. +Also, do not allow @code{YYINITDEPTH} to be greater than +@code{YYMAXDEPTH}. @c FIXME: C++ output. Because of semantical differences between C and C++, the @@ -7306,10 +7317,23 @@ syntax error. @xref{Action Features, ,Special Features for Use in Actions}. @end deffn @deffn {Macro} YYSTACK_USE_ALLOCA -Macro used to control the use of @code{alloca}. If defined to @samp{0}, -the parser will not use @code{alloca} but @code{malloc} when trying to -grow its internal stacks. Do @emph{not} define @code{YYSTACK_USE_ALLOCA} -to anything else. +Macro used to control the use of @code{alloca} when the C +@acronym{LALR}(1) parser needs to extend its stacks. If defined to 0, +the parser will use @code{malloc} to extend its stacks. If defined to +1, the parser will use @code{alloca}. Values other than 0 and 1 are +reserved for future Bison extensions. If not defined, +@code{YYSTACK_USE_ALLOCA} defaults to 0. + +If you define @code{YYSTACK_USE_ALLOCA} to 1, it is your +responsibility to make sure that @code{alloca} is visible, e.g., by +using @acronym{GCC} or by including @code{}. Furthermore, +in the all-too-common case where your code may run on a host with a +limited stack and with unreliable stack-overflow checking, you should +set @code{YYMAXDEPTH} to a value that cannot possibly result in +unchecked stack overflow on any of your target hosts when +@code{alloca} is called. You can inspect the code that Bison +generates in order to determine the proper numeric values. This will +require some expertise in low-level implementation details. @end deffn @deffn {Type} YYSTYPE