This file is indexed.

/usr/share/doc/bison-doc/html/LR-Table-Construction.html is in bison-doc 1:2.5-1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
<html lang="en">
<head>
<title>LR Table Construction - Bison 2.5</title>
<meta http-equiv="Content-Type" content="text/html">
<meta name="description" content="Bison 2.5">
<meta name="generator" content="makeinfo 4.13">
<link title="Top" rel="start" href="index.html#Top">
<link rel="up" href="Tuning-LR.html#Tuning-LR" title="Tuning LR">
<link rel="next" href="Default-Reductions.html#Default-Reductions" title="Default Reductions">
<link href="http://www.gnu.org/software/texinfo/" rel="generator-home" title="Texinfo Homepage">
<!--
This manual (14 May 2011) is for GNU Bison (version
2.5), the GNU parser generator.

Copyright (C) 1988-1993, 1995, 1998-2011 Free Software
Foundation, Inc.

     Permission is granted to copy, distribute and/or modify this
     document under the terms of the GNU Free Documentation License,
     Version 1.3 or any later version published by the Free Software
     Foundation; with no Invariant Sections, with the Front-Cover texts
     being ``A GNU Manual,'' and with the Back-Cover Texts as in (a)
     below.  A copy of the license is included in the section entitled
     ``GNU Free Documentation License.''

     (a) The FSF's Back-Cover Text is: ``You have the freedom to copy
     and modify this GNU manual.  Buying copies from the FSF supports
     it in developing GNU and promoting software freedom.''
   -->
<meta http-equiv="Content-Style-Type" content="text/css">
<style type="text/css"><!--
  pre.display { font-family:inherit }
  pre.format  { font-family:inherit }
  pre.smalldisplay { font-family:inherit; font-size:smaller }
  pre.smallformat  { font-family:inherit; font-size:smaller }
  pre.smallexample { font-size:smaller }
  pre.smalllisp    { font-size:smaller }
  span.sc    { font-variant:small-caps }
  span.roman { font-family:serif; font-weight:normal; } 
  span.sansserif { font-family:sans-serif; font-weight:normal; } 
--></style>
</head>
<body>
<div class="node">
<a name="LR-Table-Construction"></a>
<p>
Next:&nbsp;<a rel="next" accesskey="n" href="Default-Reductions.html#Default-Reductions">Default Reductions</a>,
Up:&nbsp;<a rel="up" accesskey="u" href="Tuning-LR.html#Tuning-LR">Tuning LR</a>
<hr>
</div>

<h4 class="subsection">5.8.1 LR Table Construction</h4>

<p><a name="index-Mysterious-Conflict-365"></a><a name="index-LALR-366"></a><a name="index-IELR-367"></a><a name="index-canonical-LR-368"></a><a name="index-g_t_0025define-lr_002etype-369"></a>
For historical reasons, Bison constructs LALR(1) parser tables by default. 
However, LALR does not possess the full language-recognition power of LR. 
As a result, the behavior of parsers employing LALR parser tables is often
mysterious.  We presented a simple example of this effect in <a href="Mysterious-Conflicts.html#Mysterious-Conflicts">Mysterious Conflicts</a>.

   <p>As we also demonstrated in that example, the traditional approach to
eliminating such mysterious behavior is to restructure the grammar. 
Unfortunately, doing so correctly is often difficult.  Moreover, merely
discovering that LALR causes mysterious behavior in your parser can be
difficult as well.

   <p>Fortunately, Bison provides an easy way to eliminate the possibility of such
mysterious behavior altogether.  You simply need to activate a more powerful
parser table construction algorithm by using the <code>%define lr.type</code>
directive.

<div class="defun">
&mdash; Directive: <b>%define lr.type </b><var>TYPE</var><var><a name="index-g_t_0025define-lr_002etype-_0040var_007bTYPE_007d-370"></a></var><br>
<blockquote><p>Specify the type of parser tables within the LR(1) family.  The accepted
values for <var>TYPE</var> are:

          <ul>
<li><code>lalr</code> (default)
<li><code>ielr</code>
<li><code>canonical-lr</code>
</ul>

        <p>(This feature is experimental. More user feedback will help to stabilize
it.) 
</p></blockquote></div>

   <p>For example, to activate IELR, you might add the following directive to you
grammar file:

<pre class="example">     %define lr.type ielr
</pre>
   <p class="noindent">For the example in <a href="Mysterious-Conflicts.html#Mysterious-Conflicts">Mysterious Conflicts</a>, the mysterious
conflict is then eliminated, so there is no need to invest time in
comprehending the conflict or restructuring the grammar to fix it.  If,
during future development, the grammar evolves such that all mysterious
behavior would have disappeared using just LALR, you need not fear that
continuing to use IELR will result in unnecessarily large parser tables. 
That is, IELR generates LALR tables when LALR (using a deterministic parsing
algorithm) is sufficient to support the full language-recognition power of
LR.  Thus, by enabling IELR at the start of grammar development, you can
safely and completely eliminate the need to consider LALR's shortcomings.

   <p>While IELR is almost always preferable, there are circumstances where LALR
or the canonical LR parser tables described by Knuth
(see <a href="Bibliography.html#Bibliography">Knuth 1965</a>) can be useful.  Here we summarize the
relative advantages of each parser table construction algorithm within
Bison:

     <ul>
<li>LALR

     <p>There are at least two scenarios where LALR can be worthwhile:

          <ul>
<li>GLR without static conflict resolution.

          <p><a name="index-GLR-with-LALR-371"></a>When employing GLR parsers (see <a href="GLR-Parsers.html#GLR-Parsers">GLR Parsers</a>), if you do not resolve any
conflicts statically (for example, with <code>%left</code> or <code>%prec</code>), then
the parser explores all potential parses of any given input.  In this case,
the choice of parser table construction algorithm is guaranteed not to alter
the language accepted by the parser.  LALR parser tables are the smallest
parser tables Bison can currently construct, so they may then be preferable. 
Nevertheless, once you begin to resolve conflicts statically, GLR behaves
more like a deterministic parser in the syntactic contexts where those
conflicts appear, and so either IELR or canonical LR can then be helpful to
avoid LALR's mysterious behavior.

          <li>Malformed grammars.

          <p>Occasionally during development, an especially malformed grammar with a
major recurring flaw may severely impede the IELR or canonical LR parser
table construction algorithm.  LALR can be a quick way to construct parser
tables in order to investigate such problems while ignoring the more subtle
differences from IELR and canonical LR. 
</ul>

     <li>IELR

     <p>IELR (Inadequacy Elimination LR) is a minimal LR algorithm.  That is, given
any grammar (LR or non-LR), parsers using IELR or canonical LR parser tables
always accept exactly the same set of sentences.  However, like LALR, IELR
merges parser states during parser table construction so that the number of
parser states is often an order of magnitude less than for canonical LR. 
More importantly, because canonical LR's extra parser states may contain
duplicate conflicts in the case of non-LR grammars, the number of conflicts
for IELR is often an order of magnitude less as well.  This effect can
significantly reduce the complexity of developing a grammar.

     <li>Canonical LR

     <p><a name="index-delayed-syntax-error-detection-372"></a><a name="index-LAC-373"></a><a name="index-g_t_0025nonassoc-374"></a>While inefficient, canonical LR parser tables can be an interesting means to
explore a grammar because they possess a property that IELR and LALR tables
do not.  That is, if <code>%nonassoc</code> is not used and default reductions are
left disabled (see <a href="Default-Reductions.html#Default-Reductions">Default Reductions</a>), then, for every left context of
every canonical LR state, the set of tokens accepted by that state is
guaranteed to be the exact set of tokens that is syntactically acceptable in
that left context.  It might then seem that an advantage of canonical LR
parsers in production is that, under the above constraints, they are
guaranteed to detect a syntax error as soon as possible without performing
any unnecessary reductions.  However, IELR parsers that use LAC are also
able to achieve this behavior without sacrificing <code>%nonassoc</code> or
default reductions.  For details and a few caveats of LAC, see <a href="LAC.html#LAC">LAC</a>. 
</ul>

   <p>For a more detailed exposition of the mysterious behavior in LALR parsers
and the benefits of IELR, see <a href="Bibliography.html#Bibliography">Denny 2008 March</a>, and
<a href="Bibliography.html#Bibliography">Denny 2010 November</a>.

   </body></html>