]> git.saurik.com Git - bison.git/commitdiff
Merge remote-tracking branch 'origin/branch-2.6' into maint
authorAkim Demaille <akim@lrde.epita.fr>
Mon, 26 Nov 2012 08:05:28 +0000 (09:05 +0100)
committerAkim Demaille <akim@lrde.epita.fr>
Mon, 26 Nov 2012 08:05:28 +0000 (09:05 +0100)
* origin/branch-2.6:
  yacc.c: always initialize yylloc
  doc: one of the fixes for an ambiguous grammar was ambiguous too
  doc: fix the dangling else with precedence directives
  doc: prefer "token" to TOKEN
  doc: formatting changes

Conflicts:
NEWS
doc/bison.texi

1  2 
NEWS
THANKS
doc/bison.texi

diff --combined NEWS
index 46d614cfbff7718beabd45213f78d153a4759221,393b892414934f76aa4f95d8b7739542e3784dd8..3789e92d017ed67d695659500a7e1ecade131fe3
--- 1/NEWS
--- 2/NEWS
+++ b/NEWS
@@@ -2,60 -2,15 +2,71 @@@ GNU Bison NEW
  
  * Noteworthy changes in release ?.? (????-??-??) [?]
  
 +** Changes in the format of error messages
 +
 +  This used to be the format of many error reports:
 +
 +    foo.y:5.10-24: result type clash on merge function 'merge': <t3> != <t2>
 +    foo.y:4.13-27: previous declaration
 +
 +  It is now:
 +
 +    foo.y:5.10-25: result type clash on merge function 'merge': <t3> != <t2>
 +    foo.y:4.13-27:     previous declaration
 +
 +** Exception safety (lalr1.cc)
 +
 +  The parse function now catches exceptions, uses the %destructors to
 +  release memory (the lookahead symbol and the symbols pushed on the stack)
 +  before re-throwing the exception.
 +
 +  This feature is somewhat experimental.  User feedback would be
 +  appreciated.
 +
 +** New %define variable: api.location.type (glr.cc, lalr1.cc, lalr1.java)
 +
 +  The %define variable api.location.type defines the name of the type to use
 +  for locations.  When defined, Bison no longer generates the position.hh
 +  and location.hh files, nor does the parser will include them: the user is
 +  then responsible to define her type.
 +
 +  This can be used in programs with several parsers to factor their location
 +  and position files: let one of them generate them, and the others just use
 +  them.
 +
 +  This feature was actually introduced, but not documented, in Bison 2.5,
 +  under the name "location_type" (which is maintained for backward
 +  compatibility).
 +
 +  For consistency, lalr1.java's %define variables location_type and
 +  position_type are deprecated in favor of api.location.type and
 +  api.position.type.
 +
 +** Graph improvements in DOT and XSLT
 +
 +  The graphical presentation of the states is more readable: their shape is
 +  now rectangular, the state number is clearly displayed, and the items are
 +  numbered and left-justified.
 +
 +  The reductions are now explicitly represented as transitions to other
 +  diamond shaped nodes.
 +
 +  These changes are present in both --graph output and xml2dot.xsl XSLT
 +  processing, with minor (documented) differences.
 +
 +  Two nodes were added to the documentation: Xml and Graphviz.
 +
++* Noteworthy changes in release ?.? (????-??-??) [?]
++
+ ** Bug fixes
+   Warnings about uninitialized yylloc in yyparse have been fixed.
+ ** Documentation
+   The sections about shift/reduce and reduce/reduce conflicts resolution
+   have been fixed and extended.
  * Noteworthy changes in release 2.6.5 (2012-11-07) [stable]
  
    We consider compiler warnings about Bison generated parsers to be bugs.
  
  * Noteworthy changes in release 2.6.1 (2012-07-30) [stable]
  
 - Bison no longer executes user-specified M4 code when processing a grammar.
 +  Bison no longer executes user-specified M4 code when processing a grammar.
  
  ** Future Changes
  
@@@ -1980,8 -1935,7 +1991,8 @@@ along with this program.  If not, see <
   LocalWords:  namespaces strerror const autoconfiguration Dconst Autoconf's FDL
   LocalWords:  Automake TMPDIR LESSEQ ylwrap endif yydebug YYTOKEN YYLSP ival hh
   LocalWords:  extern YYTOKENTYPE TOKENTYPE yytokentype tokentype STYPE lval pdf
 - LocalWords:  lang yyoutput dvi html ps POSIX lvalp llocp calc yyo fval
 + LocalWords:  lang yyoutput dvi html ps POSIX lvalp llocp calc yyo fval Wmaybe
 + LocalWords:  yyvsp pragmas noreturn java's
  
  Local Variables:
  mode: outline
diff --combined THANKS
index ecdd1a8a158abb4d6851bd115e8780e5ab1c2097,e87568d5dddbbe4a8c59b3167f7d880e8a0e1ee5..8ae024fb26e86f695e70ba6ffa9976ba718cf162
--- 1/THANKS
--- 2/THANKS
+++ b/THANKS
@@@ -1,8 -1,9 +1,9 @@@
  Bison was originally written by Robert Corbett.  It would not be what
  it is today without the invaluable help of these people:
  
+ Аскар Сафин              safinaskar@mail.ru
  Airy Andre                Airy.Andre@edf.fr
- Akim Demaille             akim@freefriends.org
+ Akim Demaille             akim@lrde.epita.fr
  Albert Chin-A-Young       china@thewrittenword.com
  Alexander Belopolsky      alexb@rentec.com
  Alexandre Duret-Lutz      adl@lrde.epita.fr
@@@ -82,12 -83,12 +83,13 @@@ Nicolas Tisserand         nicolas.tisse
  Noah Friedman             friedman@gnu.org
  Odd Arild Olsen           oao@fibula.no
  Oleg Smolsky              oleg.smolsky@pacific-simulators.co.nz
 +Oleksii Taran             oleksii.taran@gmail.com
  Paolo Bonzini             bonzini@gnu.org
  Pascal Bart               pascal.bart@epita.fr
  Paul Eggert               eggert@cs.ucla.edu
  Paul Hilfinger            Hilfinger@CS.Berkeley.EDU
  Per Allansson             per@appgate.com
+ Peter Eisentraut          peter_e@gmx.net
  Peter Fales               psfales@lucent.com
  Peter Hamorsky            hamo@upjs.sk
  Peter Simons              simons@cryp.to
@@@ -131,7 -132,6 +133,7 @@@ thank them!  Please, help us keeping th
  
  Local Variables:
  mode: text
 +coding: utf-8
  End:
  
  -----
diff --combined doc/bison.texi
index 7bb41460f8f44bcad7807a7fa287139cd2e13ebc,8e257a607af95960cb274bcafe39013c96bd2da7..f2d3dbc52dcffd3e2a275e7b3f5fad582ee89bfb
@@@ -276,6 -276,7 +276,7 @@@ Operator Precedenc
  * Using Precedence::  How to specify precedence in Bison grammars.
  * Precedence Examples::  How these features are used in the previous example.
  * How Precedence::    How they work.
+ * Non Operators::     Using precedence for general conflicts.
  
  Tuning LR
  
@@@ -294,8 -295,6 +295,8 @@@ Handling Context Dependencie
  Debugging Your Parser
  
  * Understanding::     Understanding the structure of your parser.
 +* Graphviz::          Getting a visual representation of the parser.
 +* Xml::               Getting a markup representation of the parser.
  * Tracing::           Tracing the execution of your parser.
  
  Tracing Your Parser
@@@ -329,7 -328,6 +330,7 @@@ C++ Location Value
  
  * C++ position::                One point in the source file
  * C++ location::                Two points in the source file
 +* User Defined Location Type::  Required interface for locations
  
  A Complete C++ Example
  
@@@ -4704,10 -4702,6 +4705,10 @@@ incoming terminals during the second ph
  the current lookahead and the entire stack (except the current
  right-hand side symbols) when the parser returns immediately, and
  @item
 +the current lookahead and the entire stack (including the current right-hand
 +side symbols) when the C++ parser (@file{lalr1.cc}) catches an exception in
 +@code{parse},
 +@item
  the start symbol, when the parser succeeds.
  @end itemize
  
@@@ -5328,23 -5322,6 +5329,23 @@@ Unaccepted @var{variable}s produce an e
  Some of the accepted @var{variable}s are:
  
  @itemize @bullet
 +@c ================================================== api.location.type
 +@item @code{api.location.type}
 +@findex %define api.location.type
 +
 +@itemize @bullet
 +@item Language(s): C++, Java
 +
 +@item Purpose: Define the location type.
 +@xref{User Defined Location Type}.
 +
 +@item Accepted Values: String
 +
 +@item Default Value: none
 +
 +@item History: introduced in Bison 2.7
 +@end itemize
 +
  @c ================================================== api.prefix
  @item @code{api.prefix}
  @findex %define api.prefix
  @itemize @bullet
  @item Language(s): All
  
 -@item Purpose: Rename exported symbols
 +@item Purpose: Rename exported symbols.
  @xref{Multiple Parsers, ,Multiple Parsers in the Same Program}.
  
  @item Accepted Values: String
@@@ -6598,7 -6575,7 +6599,7 @@@ expr
  term:
    '(' expr ')'
  | term '!'
- | NUMBER
+ | "number"
  ;
  @end group
  @end example
@@@ -6637,20 -6614,20 +6638,20 @@@ statements, with a pair of rules like t
  @example
  @group
  if_stmt:
-   IF expr THEN stmt
- | IF expr THEN stmt ELSE stmt
+   "if" expr "then" stmt
+ | "if" expr "then" stmt "else" stmt
  ;
  @end group
  @end example
  
  @noindent
- Here we assume that @code{IF}, @code{THEN} and @code{ELSE} are
terminal symbols for specific keyword tokens.
+ Here @code{"if"}, @code{"then"} and @code{"else"} are terminal symbols for
+ specific keyword tokens.
  
- When the @code{ELSE} token is read and becomes the lookahead token, the
+ When the @code{"else"} token is read and becomes the lookahead token, the
  contents of the stack (assuming the input is valid) are just right for
  reduction by the first rule.  But it is also legitimate to shift the
- @code{ELSE}, because that would lead to eventual reduction by the second
+ @code{"else"}, because that would lead to eventual reduction by the second
  rule.
  
  This situation, where either a shift or a reduction would be valid, is
@@@ -6659,14 -6636,14 +6660,14 @@@ these conflicts by choosing to shift, u
  operator precedence declarations.  To see the reason for this, let's
  contrast it with the other alternative.
  
- Since the parser prefers to shift the @code{ELSE}, the result is to attach
+ Since the parser prefers to shift the @code{"else"}, the result is to attach
  the else-clause to the innermost if-statement, making these two inputs
  equivalent:
  
  @example
- if x then if y then win (); else lose;
+ if x then if y then win; else lose;
  
- if x then do; if y then win (); else lose; end;
+ if x then do; if y then win; else lose; end;
  @end example
  
  But if the parser chose to reduce when possible rather than shift, the
@@@ -6674,9 -6651,9 +6675,9 @@@ result would be to attach the else-clau
  making these two inputs equivalent:
  
  @example
- if x then if y then win (); else lose;
+ if x then if y then win; else lose;
  
- if x then do; if y then win (); end; else lose;
+ if x then do; if y then win; end; else lose;
  @end example
  
  The conflict exists because the grammar as written is ambiguous: either
@@@ -6689,11 -6666,16 +6690,16 @@@ This particular ambiguity was first enc
  Algol 60 and is called the ``dangling @code{else}'' ambiguity.
  
  To avoid warnings from Bison about predictable, legitimate shift/reduce
- conflicts, use the @code{%expect @var{n}} declaration.
+ conflicts, you can use the @code{%expect @var{n}} declaration.
  There will be no warning as long as the number of shift/reduce conflicts
  is exactly @var{n}, and Bison will report an error if there is a
  different number.
- @xref{Expect Decl, ,Suppressing Conflict Warnings}.
+ @xref{Expect Decl, ,Suppressing Conflict Warnings}.  However, we don't
+ recommend the use of @code{%expect} (except @samp{%expect 0}!), as an equal
+ number of conflicts does not mean that they are the @emph{same}.  When
+ possible, you should rather use precedence directives to @emph{fix} the
+ conflicts explicitly (@pxref{Non Operators,, Using Precedence For Non
+ Operators}).
  
  The definition of @code{if_stmt} above is solely to blame for the
  conflict, but the conflict does not actually appear without additional
@@@ -6702,7 -6684,6 +6708,6 @@@ the conflict
  
  @example
  @group
- %token IF THEN ELSE variable
  %%
  @end group
  @group
@@@ -6714,13 -6695,13 +6719,13 @@@ stmt
  
  @group
  if_stmt:
-   IF expr THEN stmt
- | IF expr THEN stmt ELSE stmt
+   "if" expr "then" stmt
+ | "if" expr "then" stmt "else" stmt
  ;
  @end group
  
  expr:
-   variable
+   "identifier"
  ;
  @end example
  
@@@ -6739,6 -6720,7 +6744,7 @@@ shift and when to reduce
  * Using Precedence::  How to specify precedence in Bison grammars.
  * Precedence Examples::  How these features are used in the previous example.
  * How Precedence::    How they work.
+ * Non Operators::     Using precedence for general conflicts.
  @end menu
  
  @node Why Precedence
@@@ -6826,16 -6808,11 +6832,11 @@@ would declare them in groups of equal p
  declared with @code{'-'}:
  
  @example
- %left '<' '>' '=' NE LE GE
+ %left '<' '>' '=' "!=" "<=" ">="
  %left '+' '-'
  %left '*' '/'
  @end example
  
- @noindent
- (Here @code{NE} and so on stand for the operators for ``not equal''
- and so on.  We assume that these tokens are more than one character long
- and therefore are represented by names, not character literals.)
  @node How Precedence
  @subsection How Precedence Works
  
@@@ -6858,6 -6835,44 +6859,44 @@@ resolved
  Not all rules and not all tokens have precedence.  If either the rule or
  the lookahead token has no precedence, then the default is to shift.
  
+ @node Non Operators
+ @subsection Using Precedence For Non Operators
+ Using properly precedence and associativity directives can help fixing
+ shift/reduce conflicts that do not involve arithmetics-like operators.  For
+ instance, the ``dangling @code{else}'' problem (@pxref{Shift/Reduce, ,
+ Shift/Reduce Conflicts}) can be solved elegantly in two different ways.
+ In the present case, the conflict is between the token @code{"else"} willing
+ to be shifted, and the rule @samp{if_stmt: "if" expr "then" stmt}, asking
+ for reduction.  By default, the precedence of a rule is that of its last
+ token, here @code{"then"}, so the conflict will be solved appropriately
+ by giving @code{"else"} a precedence higher than that of @code{"then"}, for
+ instance as follows:
+ @example
+ @group
+ %nonassoc "then"
+ %nonassoc "else"
+ @end group
+ @end example
+ Alternatively, you may give both tokens the same precedence, in which case
+ associativity is used to solve the conflict.  To preserve the shift action,
+ use right associativity:
+ @example
+ %right "then" "else"
+ @end example
+ Neither solution is perfect however.  Since Bison does not provide, so far,
+ support for ``scoped'' precedence, both force you to declare the precedence
+ of these keywords with respect to the other operators your grammar.
+ Therefore, instead of being warned about new conflicts you would be unaware
+ of (e.g., a shift/reduce conflict due to @samp{if test then 1 else 2 + 3}
+ being ambiguous: @samp{if test then 1 else (2 + 3)} or @samp{(if test then 1
+ else 2) + 3}?), the conflict will be already ``fixed''.
  @node Contextual Precedence
  @section Context-Dependent Precedence
  @cindex context-dependent precedence
@@@ -7018,30 -7033,38 +7057,38 @@@ reduce/reduce conflict must be studied 
  proper way to define @code{sequence}:
  
  @example
+ @group
  sequence:
    /* empty */    @{ printf ("empty sequence\n"); @}
  | sequence word  @{ printf ("added word %s\n", $2); @}
  ;
+ @end group
  @end example
  
  Here is another common error that yields a reduce/reduce conflict:
  
  @example
  sequence:
+ @group
    /* empty */
  | sequence words
  | sequence redirects
  ;
+ @end group
  
+ @group
  words:
    /* empty */
  | words word
  ;
+ @end group
  
+ @group
  redirects:
    /* empty */
  | redirects redirect
  ;
+ @end group
  @end example
  
  @noindent
@@@ -7094,6 -7117,58 +7141,58 @@@ redirects
  @end group
  @end example
  
+ Yet this proposal introduces another kind of ambiguity!  The input
+ @samp{word word} can be parsed as a single @code{words} composed of two
+ @samp{word}s, or as two one-@code{word} @code{words} (and likewise for
+ @code{redirect}/@code{redirects}).  However this ambiguity is now a
+ shift/reduce conflict, and therefore it can now be addressed with precedence
+ directives.
+ To simplify the matter, we will proceed with @code{word} and @code{redirect}
+ being tokens: @code{"word"} and @code{"redirect"}.
+ To prefer the longest @code{words}, the conflict between the token
+ @code{"word"} and the rule @samp{sequence: sequence words} must be resolved
+ as a shift.  To this end, we use the same techniques as exposed above, see
+ @ref{Non Operators,, Using Precedence For Non Operators}.  One solution
+ relies on precedences: use @code{%prec} to give a lower precedence to the
+ rule:
+ @example
+ %nonassoc "word"
+ %nonassoc "sequence"
+ %%
+ @group
+ sequence:
+   /* empty */
+ | sequence word      %prec "sequence"
+ | sequence redirect  %prec "sequence"
+ ;
+ @end group
+ @group
+ words:
+   word
+ | words "word"
+ ;
+ @end group
+ @end example
+ Another solution relies on associativity: provide both the token and the
+ rule with the same precedence, but make them right-associative:
+ @example
+ %right "word" "redirect"
+ %%
+ @group
+ sequence:
+   /* empty */
+ | sequence word      %prec "word"
+ | sequence redirect  %prec "redirect"
+ ;
+ @end group
+ @end example
  @node Mysterious Conflicts
  @section Mysterious Conflicts
  @cindex Mysterious Conflicts
@@@ -7103,8 -7178,6 +7202,6 @@@ Here is an example
  
  @example
  @group
- %token ID
  %%
  def: param_spec return_spec ',';
  param_spec:
@@@ -7119,10 -7192,10 +7216,10 @@@ return_spec
  ;
  @end group
  @group
- type: ID;
+ type: "id";
  @end group
  @group
- name: ID;
+ name: "id";
  name_list:
    name
  | name ',' name_list
  @end group
  @end example
  
- It would seem that this grammar can be parsed with only a single token
- of lookahead: when a @code{param_spec} is being read, an @code{ID} is
@code{name} if a comma or colon follows, or a @code{type} if another
- @code{ID} follows.  In other words, this grammar is LR(1).
+ It would seem that this grammar can be parsed with only a single token of
+ lookahead: when a @code{param_spec} is being read, an @code{"id"} is a
+ @code{name} if a comma or colon follows, or a @code{type} if another
+ @code{"id"} follows.  In other words, this grammar is LR(1).
  
  @cindex LR
  @cindex LALR
  However, for historical reasons, Bison cannot by default handle all
  LR(1) grammars.
- In this grammar, two contexts, that after an @code{ID} at the beginning
+ In this grammar, two contexts, that after an @code{"id"} at the beginning
  of a @code{param_spec} and likewise at the beginning of a
  @code{return_spec}, are similar enough that Bison assumes they are the
  same.
@@@ -7170,27 -7243,24 +7267,24 @@@ distinct.  In the above example, addin
  
  @example
  @group
- %token BOGUS
- @dots{}
- %%
  @dots{}
  return_spec:
    type
  | name ':' type
- | ID BOGUS       /* This rule is never used.  */
+ | "id" "bogus"       /* This rule is never used.  */
  ;
  @end group
  @end example
  
  This corrects the problem because it introduces the possibility of an
- additional active rule in the context after the @code{ID} at the beginning of
+ additional active rule in the context after the @code{"id"} at the beginning of
  @code{return_spec}.  This rule is not active in the corresponding context
  in a @code{param_spec}, so the two contexts receive distinct parser states.
- As long as the token @code{BOGUS} is never generated by @code{yylex},
+ As long as the token @code{"bogus"} is never generated by @code{yylex},
  the added rule cannot alter the way actual input is parsed.
  
  In this particular example, there is another way to solve the problem:
- rewrite the rule for @code{return_spec} to use @code{ID} directly
+ rewrite the rule for @code{return_spec} to use @code{"id"} directly
  instead of via @code{name}.  This also causes the two confusing
  contexts to have different sets of active rules, because the one for
  @code{return_spec} activates the altered rule for @code{return_spec}
@@@ -7203,7 -7273,7 +7297,7 @@@ param_spec
  ;
  return_spec:
    type
- | ID ':' type
+ | "id" ':' type
  ;
  @end example
  
@@@ -8095,8 -8165,6 +8189,8 @@@ automaton, and how to enable and unders
  
  @menu
  * Understanding::     Understanding the structure of your parser.
 +* Graphviz::          Getting a visual representation of the parser.
 +* Xml::               Getting a markup representation of the parser.
  * Tracing::           Tracing the execution of your parser.
  @end menu
  
@@@ -8513,165 -8581,6 +8607,165 @@@ precedence of @samp{/} with respect to 
  @samp{*}, but also because the
  associativity of @samp{/} is not specified.
  
 +Note that Bison may also produce an HTML version of this output, via an XML
 +file and XSLT processing (@pxref{Xml}).
 +
 +@c ================================================= Graphical Representation
 +
 +@node Graphviz
 +@section Visualizing Your Parser
 +@cindex dot
 +
 +As another means to gain better understanding of the shift/reduce
 +automaton corresponding to the Bison parser, a DOT file can be generated. Note
 +that debugging a real grammar with this is tedious at best, and impractical
 +most of the times, because the generated files are huge (the generation of
 +a PDF or PNG file from it will take very long, and more often than not it will
 +fail due to memory exhaustion). This option was rather designed for beginners,
 +to help them understand LR parsers.
 +
 +This file is generated when the @option{--graph} option is specified
 +(@pxref{Invocation, , Invoking Bison}).  Its name is made by removing
 +@samp{.tab.c} or @samp{.c} from the parser implementation file name, and
 +adding @samp{.dot} instead.  If the grammar file is @file{foo.y}, the
 +Graphviz output file is called @file{foo.dot}.
 +
 +The following grammar file, @file{rr.y}, will be used in the sequel:
 +
 +@example
 +%%
 +@group
 +exp: a ";" | b ".";
 +a: "0";
 +b: "0";
 +@end group
 +@end example
 +
 +The graphical output is very similar to the textual one, and as such it is
 +easier understood by making direct comparisons between them. See
 +@ref{Debugging, , Debugging Your Parser} for a detailled analysis of the
 +textual report.
 +
 +@subheading Graphical Representation of States
 +
 +The items (pointed rules) for each state are grouped together in graph nodes.
 +Their numbering is the same as in the verbose file. See the following points,
 +about transitions, for examples
 +
 +When invoked with @option{--report=lookaheads}, the lookahead tokens, when
 +needed, are shown next to the relevant rule between square brackets as a
 +comma separated list. This is the case in the figure for the representation of
 +reductions, below.
 +
 +@sp 1
 +
 +The transitions are represented as directed edges between the current and
 +the target states.
 +
 +@subheading Graphical Representation of Shifts
 +
 +Shifts are shown as solid arrows, labelled with the lookahead token for that
 +shift. The following describes a reduction in the @file{rr.output} file:
 +
 +@example
 +@group
 +state 3
 +
 +    1 exp: a . ";"
 +
 +    ";"  shift, and go to state 6
 +@end group
 +@end example
 +
 +A Graphviz rendering of this portion of the graph could be:
 +
 +@center @image{figs/example-shift, 100pt}
 +
 +@subheading Graphical Representation of Reductions
 +
 +Reductions are shown as solid arrows, leading to a diamond-shaped node
 +bearing the number of the reduction rule. The arrow is labelled with the
 +appropriate comma separated lookahead tokens. If the reduction is the default
 +action for the given state, there is no such label.
 +
 +This is how reductions are represented in the verbose file @file{rr.output}:
 +@example
 +state 1
 +
 +    3 a: "0" .  [";"]
 +    4 b: "0" .  ["."]
 +
 +    "."       reduce using rule 4 (b)
 +    $default  reduce using rule 3 (a)
 +@end example
 +
 +A Graphviz rendering of this portion of the graph could be:
 +
 +@center @image{figs/example-reduce, 120pt}
 +
 +When unresolved conflicts are present, because in deterministic parsing
 +a single decision can be made, Bison can arbitrarily choose to disable a
 +reduction, see @ref{Shift/Reduce, , Shift/Reduce Conflicts}.  Discarded actions
 +are distinguished by a red filling color on these nodes, just like how they are
 +reported between square brackets in the verbose file.
 +
 +The reduction corresponding to the rule number 0 is the acceptation state. It
 +is shown as a blue diamond, labelled "Acc".
 +
 +@subheading Graphical representation of go tos
 +
 +The @samp{go to} jump transitions are represented as dotted lines bearing
 +the name of the rule being jumped to.
 +
 +Note that a DOT file may also be produced via an XML file and XSLT
 +processing (@pxref{Xml}).
 +
 +@c ================================================= XML
 +
 +@node Xml
 +@section Visualizing your parser in multiple formats
 +@cindex xml
 +
 +Bison supports two major report formats: textual output
 +(@pxref{Understanding}) when invoked with option @option{--verbose}, and DOT
 +(@pxref{Graphviz}) when invoked with option @option{--graph}. However,
 +another alternative is to output an XML file that may then be, with
 +@command{xsltproc}, rendered as either a raw text format equivalent to the
 +verbose file, or as an HTML version of the same file, with clickable
 +transitions, or even as a DOT. The @file{.output} and DOT files obtained via
 +XSLT have no difference whatsoever with those obtained by invoking
 +@command{bison} with options @option{--verbose} or @option{--graph}.
 +
 +The textual file is generated when the options @option{-x} or
 +@option{--xml[=FILE]} are specified, see @ref{Invocation,,Invoking Bison}.
 +If not specified, its name is made by removing @samp{.tab.c} or @samp{.c}
 +from the parser implementation file name, and adding @samp{.xml} instead.
 +For instance, if the grammar file is @file{foo.y}, the default XML output
 +file is @file{foo.xml}.
 +
 +Bison ships with a @file{data/xslt} directory, containing XSL Transformation
 +files to apply to the XML file. Their names are non-ambiguous:
 +
 +@table @file
 +@item xml2dot.xsl
 +Used to output a copy of the DOT visualization of the automaton.
 +@item xml2text.xsl
 +Used to output a copy of the .output file.
 +@item xml2xhtml.xsl
 +Used to output an xhtml enhancement of the .output file.
 +@end table
 +
 +Sample usage (requires @code{xsltproc}):
 +@example
 +$ bison -x input.y
 +@group
 +$ bison --print-datadir
 +/usr/local/share/bison
 +@end group
 +$ xsltproc /usr/local/share/bison/xslt/xml2xhtml.xsl input.xml > input.html
 +@end example
 +
 +@c ================================================= Tracing
  
  @node Tracing
  @section Tracing Your Parser
@@@ -9391,9 -9300,8 +9485,9 @@@ generated in the following files
  @table @file
  @item position.hh
  @itemx location.hh
 -The definition of the classes @code{position} and @code{location},
 -used for location tracking.  @xref{C++ Location Values}.
 +The definition of the classes @code{position} and @code{location}, used for
 +location tracking.  These files are not generated if the @code{%define}
 +variable @code{api.location.type} is defined.  @xref{C++ Location Values}.
  
  @item stack.hh
  An auxiliary class @code{stack} used by the parser.
@@@ -9449,22 -9357,18 +9543,22 @@@ Symbols}
  @c - %define filename_type "const symbol::Symbol"
  
  When the directive @code{%locations} is used, the C++ parser supports
 -location tracking, see @ref{Tracking Locations}.  Two auxiliary classes
 -define a @code{position}, a single point in a file, and a @code{location}, a
 -range composed of a pair of @code{position}s (possibly spanning several
 -files).
 +location tracking, see @ref{Tracking Locations}.
 +
 +By default, two auxiliary classes define a @code{position}, a single point
 +in a file, and a @code{location}, a range composed of a pair of
 +@code{position}s (possibly spanning several files).  But if the
 +@code{%define} variable @code{api.location.type} is defined, then these
 +classes will not be generated, and the user defined type will be used.
  
  @tindex uint
  In this section @code{uint} is an abbreviation for @code{unsigned int}: in
  genuine code only the latter is used.
  
  @menu
 -* C++ position::         One point in the source file
 -* C++ location::         Two points in the source file
 +* C++ position::                One point in the source file
 +* C++ location::                Two points in the source file
 +* User Defined Location Type::  Required interface for locations
  @end menu
  
  @node C++ position
@@@ -9568,63 -9472,6 +9662,63 @@@ Report @var{p} on @var{o}, taking care 
  @code{filename} defined, or equal filename/line or column.
  @end deftypefun
  
 +@node User Defined Location Type
 +@subsubsection User Defined Location Type
 +@findex %define api.location.type
 +
 +Instead of using the built-in types you may use the @code{%define} variable
 +@code{api.location.type} to specify your own type:
 +
 +@example
 +%define api.location.type @var{LocationType}
 +@end example
 +
 +The requirements over your @var{LocationType} are:
 +@itemize
 +@item
 +it must be copyable;
 +
 +@item
 +in order to compute the (default) value of @code{@@$} in a reduction, the
 +parser basically runs
 +@example
 +@@$.begin = @@$1.begin;
 +@@$.end   = @@$@var{N}.end; // The location of last right-hand side symbol.
 +@end example
 +@noindent
 +so there must be copyable @code{begin} and @code{end} members;
 +
 +@item
 +alternatively you may redefine the computation of the default location, in
 +which case these members are not required (@pxref{Location Default Action});
 +
 +@item
 +if traces are enabled, then there must exist an @samp{std::ostream&
 +  operator<< (std::ostream& o, const @var{LocationType}& s)} function.
 +@end itemize
 +
 +@sp 1
 +
 +In programs with several C++ parsers, you may also use the @code{%define}
 +variable @code{api.location.type} to share a common set of built-in
 +definitions for @code{position} and @code{location}.  For instance, one
 +parser @file{master/parser.yy} might use:
 +
 +@example
 +%defines
 +%locations
 +%define namespace "master::"
 +@end example
 +
 +@noindent
 +to generate the @file{master/position.hh} and @file{master/location.hh}
 +files, reused by other parsers as follows:
 +
 +@example
 +%define api.location.type "master::location"
 +%code requires @{ #include <master/location.hh> @}
 +@end example
 +
  @node C++ Parser Interface
  @subsection C++ Parser Interface
  @c - define parser_class_name
@@@ -9662,11 -9509,6 +9756,11 @@@ Build a new parser object.  There are n
  
  @deftypemethod {parser} {int} parse ()
  Run the syntactic analysis, and return 0 on success, 1 otherwise.
 +
 +@cindex exceptions
 +The whole function is wrapped in a @code{try}/@code{catch} block, so that
 +when an exception is thrown, the @code{%destructor}s are called to release
 +the lookahead symbol, and the symbols pushed on the stack.
  @end deftypemethod
  
  @deftypemethod {parser} {std::ostream&} debug_stream ()
@@@ -9780,8 -9622,8 +9874,8 @@@ factor both as follows
  // 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,      \
 +  yylex (yy::calcxx_parser::semantic_typeyylval,      \
 +         yy::calcxx_parser::location_typeyylloc,      \
           calcxx_driver& driver)
  // ... and declare it for the parser's sake.
  YY_DECL;
@@@ -10338,11 -10180,11 +10432,11 @@@ class defines a @dfn{position}, a singl
  defines a class representing a @dfn{location}, a range composed of a pair of
  positions (possibly spanning several files).  The location class is an inner
  class of the parser; the name is @code{Location} by default, and may also be
 -renamed using @code{%define location_type "@var{class-name}"}.
 +renamed using @code{%define api.location.type "@var{class-name}"}.
  
  The location class treats the position as a completely opaque value.
  By default, the class name is @code{Position}, but this can be changed
 -with @code{%define position_type "@var{class-name}"}.  This class must
 +with @code{%define api.position.type "@var{class-name}"}.  This class must
  be supplied by the user.
  
  
@@@ -10477,7 -10319,7 +10571,7 @@@ In both cases, the scanner has to imple
  @deftypemethod {Lexer} {void} yyerror (Location @var{loc}, String @var{msg})
  This method is defined by the user to emit an error message.  The first
  parameter is omitted if location tracking is not active.  Its type can be
 -changed using @code{%define location_type "@var{class-name}".}
 +changed using @code{%define api.location.type "@var{class-name}".}
  @end deftypemethod
  
  @deftypemethod {Lexer} {int} yylex ()
@@@ -10495,7 -10337,7 +10589,7 @@@ Return respectively the first position 
  @code{yylex} returned, and the first position beyond it.  These
  methods are not needed unless location tracking is active.
  
 -The return type can be changed using @code{%define position_type
 +The return type can be changed using @code{%define api.position.type
  "@var{class-name}".}
  @end deftypemethod
  
@@@ -10740,11 -10582,10 +10834,11 @@@ comma-separated list.  Default is @code
  @xref{Java Scanner Interface}.
  @end deffn
  
 -@deffn {Directive} {%define location_type} "@var{class}"
 +@deffn {Directive} {%define api.location.type} "@var{class}"
  The name of the class used for locations (a range between two
  positions).  This class is generated as an inner class of the parser
  class by @command{bison}.  Default is @code{Location}.
 +Formerly named @code{location_type}.
  @xref{Java Location Values}.
  @end deffn
  
@@@ -10759,10 -10600,9 +10853,10 @@@ The name of the parser class.  Default 
  @xref{Java Bison Interface}.
  @end deffn
  
 -@deffn {Directive} {%define position_type} "@var{class}"
 +@deffn {Directive} {%define api.position.type} "@var{class}"
  The name of the class used for positions. This class must be supplied by
  the user.  Default is @code{Position}.
 +Formerly named @code{position_type}.
  @xref{Java Location Values}.
  @end deffn
  
@@@ -12046,8 -11886,11 +12140,11 @@@ London, Department of Computer Science
  @c LocalWords: getLVal defvar deftypefn deftypefnx gotos msgfmt Corbett LALR's
  @c LocalWords: subdirectory Solaris nonassociativity perror schemas Malloy ints
  @c LocalWords: Scannerless ispell american ChangeLog smallexample CSTYPE CLTYPE
 -@c LocalWords: clval CDEBUG cdebug deftypeopx yyterminate
 +@c LocalWords: clval CDEBUG cdebug deftypeopx yyterminate LocationType
- @c LocalWords: errorVerbose
+ @c LocalWords: parsers parser's
+ @c LocalWords: associativity subclasses precedences unresolvable runnable
+ @c LocalWords: allocators subunit initializations unreferenced untyped
+ @c LocalWords: errorVerbose subtype subtypes
  
  @c Local Variables:
  @c ispell-dictionary: "american"