X-Git-Url: https://git.saurik.com/bison.git/blobdiff_plain/eda429346ae70445be1cffbe729c63fca7848ad6..6712933e0f2d2cbf43dc6b9bfe5c60b7d9941955:/doc/bison.texinfo diff --git a/doc/bison.texinfo b/doc/bison.texinfo index 8f35ac60..f01c638a 100644 --- a/doc/bison.texinfo +++ b/doc/bison.texinfo @@ -44,7 +44,7 @@ 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 Free Software Foundation, Inc. +1999, 2000, 2001, 2002, 2003, 2004 Free Software Foundation, Inc. @quotation Permission is granted to copy, distribute and/or modify this document @@ -223,7 +223,7 @@ Bison Declarations * Union Decl:: Declaring the set of all semantic value types. * Type Decl:: Declaring the choice of type for a nonterminal symbol. * Destructor Decl:: Declaring how symbols are freed. -* Expect Decl:: Suppressing warnings about shift/reduce conflicts. +* Expect Decl:: Suppressing warnings about parsing conflicts. * Start Decl:: Specifying the start symbol. * Pure Decl:: Requesting a reentrant parser. * Decl Summary:: Table of all Bison declarations. @@ -2338,7 +2338,7 @@ can be done with two @var{Prologue} blocks, one before and one after the %@} %union @{ - long n; + long int n; tree t; /* @r{@code{tree} is defined in @file{ptypes.h}.} */ @} @@ -2755,7 +2755,7 @@ This macro definition must go in the prologue of the grammar file In most programs, you will need different data types for different kinds of tokens and groupings. For example, a numeric constant may need type -@code{int} or @code{long}, while a string constant needs type @code{char *}, +@code{int} or @code{long int}, while a string constant needs type @code{char *}, and an identifier might need a pointer to an entry in the symbol table. To use more than one data type for semantic values in one parser, Bison @@ -3280,7 +3280,7 @@ Grammars}). * Union Decl:: Declaring the set of all semantic value types. * Type Decl:: Declaring the choice of type for a nonterminal symbol. * Destructor Decl:: Declaring how symbols are freed. -* Expect Decl:: Suppressing warnings about shift/reduce conflicts. +* Expect Decl:: Suppressing warnings about parsing conflicts. * Start Decl:: Specifying the start symbol. * Pure Decl:: Requesting a reentrant parser. * Decl Summary:: Table of all Bison declarations. @@ -3309,10 +3309,12 @@ associativity and precedence. @xref{Precedence Decl, ,Operator Precedence}. You can explicitly specify the numeric code for a token type by appending -an integer value in the field immediately following the token name: +a decimal or hexadecimal integer value in the field immediately +following the token name: @example %token NUM 300 +%token XNUM 0x12d // a GNU extension @end example @noindent @@ -3558,6 +3560,7 @@ typefull: string; // $$ = $1 applies, $1 is not destroyed. @cindex warnings, preventing @cindex conflicts, suppressing warnings of @findex %expect +@findex %expect-rr Bison normally warns if there are any conflicts in the grammar (@pxref{Shift/Reduce, ,Shift/Reduce Conflicts}), but most real grammars @@ -3578,6 +3581,18 @@ reduce/reduce conflicts. The usual warning is given if there are either more or fewer conflicts, or if there are any reduce/reduce conflicts. +For normal LALR(1) parsers, reduce/reduce conflicts are more serious, +and should be eliminated entirely. Bison will always report +reduce/reduce conflicts for these parsers. With GLR parsers, however, +both shift/reduce and reduce/reduce are routine (otherwise, there +would be no need to use GLR parsing). Therefore, it is also possible +to specify an expected number of reduce/reduce conflicts in GLR +parsers, using the declaration: + +@example +%expect-rr @var{n} +@end example + In general, using @code{%expect} involves these steps: @itemize @bullet @@ -6214,7 +6229,7 @@ compatibility with @acronym{POSIX}: @example #! /bin/sh -bison -y "$@" +bison -y "$@@" @end example @end table @@ -6508,6 +6523,11 @@ handle features like include files, you might consider using Flex functions like @samp{yy_switch_to_buffer} that manipulate multiple input buffers. +If your Flex-generated scanner uses start conditions (@pxref{Start +conditions, , Start conditions, flex, The Flex Manual}), you might +also want to reset the scanner's state, i.e., go back to the initial +start condition, through a call to @samp{BEGIN (0)}. + @node Strings are Destroyed @section Strings are Destroyed