]> git.saurik.com Git - bison.git/blobdiff - doc/bison.texinfo
* data/glr.c (b4_shared_declarations): Put start-header first,
[bison.git] / doc / bison.texinfo
index 94a384e04f83ed823de14dbeeb87128293343c88..013847b5d884e5d9ea3a854f4d8fd79762417868 100644 (file)
@@ -2649,6 +2649,7 @@ can be done with two @var{Prologue} blocks, one before and one after the
 
 @smallexample
 %@{
+  #define _GNU_SOURCE
   #include <stdio.h>
   #include "ptypes.h"
 %@}
@@ -2666,6 +2667,13 @@ can be done with two @var{Prologue} blocks, one before and one after the
 @dots{}
 @end smallexample
 
+When in doubt, it is usually safer to put prologue code before all
+Bison declarations, rather than after.  For example, any definitions
+of feature test macros like @code{_GNU_SOURCE} or
+@code{_POSIX_C_SOURCE} should appear before all Bison declarations, as
+feature test macros can affect the behavior of Bison-generated
+@code{#include} directives.
+
 @findex %before-header
 @findex %start-header
 @findex %after-header
@@ -7423,8 +7431,8 @@ factor both as follows.
 
 @comment file: calc++-driver.hh
 @example
-// Announce to Flex the prototype we want for lexing function, ...
-# define YY_DECL                                       \
+// Tell Flex the lexer's prototype ...
+# define YY_DECL                                        \
   yy::calcxx_parser::token_type                         \
   yylex (yy::calcxx_parser::semantic_type* yylval,      \
          yy::calcxx_parser::location_type* yylloc,      \
@@ -7675,7 +7683,9 @@ unit: assignments exp  @{ driver.result = $2; @};
 assignments: assignments assignment @{@}
            | /* Nothing.  */        @{@};
 
-assignment: "identifier" ":=" exp @{ driver.variables[*$1] = $3; @};
+assignment:
+     "identifier" ":=" exp
+       @{ driver.variables[*$1] = $3; delete $1; @};
 
 %left '+' '-';
 %left '*' '/';
@@ -7683,7 +7693,7 @@ exp: exp '+' exp   @{ $$ = $1 + $3; @}
    | exp '-' exp   @{ $$ = $1 - $3; @}
    | exp '*' exp   @{ $$ = $1 * $3; @}
    | exp '/' exp   @{ $$ = $1 / $3; @}
-   | "identifier"  @{ $$ = driver.variables[*$1]; @}
+   | "identifier"  @{ $$ = driver.variables[*$1]; delete $1; @}
    | "number"      @{ $$ = $1; @};
 %%
 @end example
@@ -7844,8 +7854,8 @@ main (int argc, char *argv[])
       driver.trace_scanning = true;
     else
       @{
-       driver.parse (*argv);
-       std::cout << driver.result << std::endl;
+        driver.parse (*argv);
+        std::cout << driver.result << std::endl;
       @}
 @}
 @end example