mirror of
https://git.savannah.gnu.org/git/bison.git
synced 2026-03-10 12:53:03 +00:00
Use "look-ahead" instead of "lookahead", consistently.
This commit is contained in:
@@ -5187,13 +5187,13 @@ return_spec:
|
||||
|
||||
Bison produces @emph{deterministic} parsers that choose uniquely
|
||||
when to reduce and which reduction to apply
|
||||
based on a summary of the preceding input and on one extra token of lookahead.
|
||||
based on a summary of the preceding input and on one extra token of look-ahead.
|
||||
As a result, normal Bison handles a proper subset of the family of
|
||||
context-free languages.
|
||||
Ambiguous grammars, since they have strings with more than one possible
|
||||
sequence of reductions cannot have deterministic parsers in this sense.
|
||||
The same is true of languages that require more than one symbol of
|
||||
lookahead, since the parser lacks the information necessary to make a
|
||||
look-ahead, since the parser lacks the information necessary to make a
|
||||
decision at the point it must be made in a shift-reduce parser.
|
||||
Finally, as previously mentioned (@pxref{Mystery Conflicts}),
|
||||
there are languages where Bison's particular choice of how to
|
||||
@@ -5805,16 +5805,16 @@ beginning of the parsing, in the initial rule, right before the start
|
||||
symbol (here, @code{exp}). When the parser returns to this state right
|
||||
after having reduced a rule that produced an @code{exp}, the control
|
||||
flow jumps to state 2. If there is no such transition on a nonterminal
|
||||
symbol, and the lookahead is a @code{NUM}, then this token is shifted on
|
||||
symbol, and the look-ahead is a @code{NUM}, then this token is shifted on
|
||||
the parse stack, and the control flow jumps to state 1. Any other
|
||||
lookahead triggers a syntax error.''
|
||||
look-ahead triggers a syntax error.''
|
||||
|
||||
@cindex core, item set
|
||||
@cindex item set core
|
||||
@cindex kernel, item set
|
||||
@cindex item set core
|
||||
Even though the only active rule in state 0 seems to be rule 0, the
|
||||
report lists @code{NUM} as a lookahead symbol because @code{NUM} can be
|
||||
report lists @code{NUM} as a look-ahead token because @code{NUM} can be
|
||||
at the beginning of any rule deriving an @code{exp}. By default Bison
|
||||
reports the so-called @dfn{core} or @dfn{kernel} of the item set, but if
|
||||
you want to see more detail you can invoke @command{bison} with
|
||||
@@ -5848,7 +5848,7 @@ state 1
|
||||
@end example
|
||||
|
||||
@noindent
|
||||
the rule 5, @samp{exp: NUM;}, is completed. Whatever the lookahead
|
||||
the rule 5, @samp{exp: NUM;}, is completed. Whatever the look-ahead token
|
||||
(@samp{$default}), the parser will reduce it. If it was coming from
|
||||
state 0, then, after this reduction it will return to state 0, and will
|
||||
jump to state 2 (@samp{exp: go to state 2}).
|
||||
@@ -5871,7 +5871,7 @@ state 2
|
||||
|
||||
@noindent
|
||||
In state 2, the automaton can only shift a symbol. For instance,
|
||||
because of the item @samp{exp -> exp . '+' exp}, if the lookahead if
|
||||
because of the item @samp{exp -> exp . '+' exp}, if the look-ahead if
|
||||
@samp{+}, it will be shifted on the parse stack, and the automaton
|
||||
control will jump to state 4, corresponding to the item @samp{exp -> exp
|
||||
'+' . exp}. Since there is no default action, any other token than
|
||||
@@ -5948,7 +5948,7 @@ state 8
|
||||
$default reduce using rule 1 (exp)
|
||||
@end example
|
||||
|
||||
Indeed, there are two actions associated to the lookahead @samp{/}:
|
||||
Indeed, there are two actions associated to the look-ahead @samp{/}:
|
||||
either shifting (and going to state 7), or reducing rule 1. The
|
||||
conflict means that either the grammar is ambiguous, or the parser lacks
|
||||
information to make the right decision. Indeed the grammar is
|
||||
@@ -5966,14 +5966,14 @@ Note that all the previous states had a single possible action: either
|
||||
shifting the next token and going to the corresponding state, or
|
||||
reducing a single rule. In the other cases, i.e., when shifting
|
||||
@emph{and} reducing is possible or when @emph{several} reductions are
|
||||
possible, the lookahead is required to select the action. State 8 is
|
||||
one such state: if the lookahead is @samp{*} or @samp{/} then the action
|
||||
possible, the look-ahead is required to select the action. State 8 is
|
||||
one such state: if the look-ahead is @samp{*} or @samp{/} then the action
|
||||
is shifting, otherwise the action is reducing rule 1. In other words,
|
||||
the first two items, corresponding to rule 1, are not eligible when the
|
||||
lookahead is @samp{*}, since we specified that @samp{*} has higher
|
||||
precedence that @samp{+}. More generally, some items are eligible only
|
||||
with some set of possible lookaheads. When run with
|
||||
@option{--report=lookahead}, Bison specifies these lookaheads:
|
||||
look-ahead token is @samp{*}, since we specified that @samp{*} has higher
|
||||
precedence than @samp{+}. More generally, some items are eligible only
|
||||
with some set of possible look-ahead tokens. When run with
|
||||
@option{--report=look-ahead}, Bison specifies these look-ahead tokens:
|
||||
|
||||
@example
|
||||
state 8
|
||||
@@ -6319,9 +6319,9 @@ separated list of @var{things} among:
|
||||
Description of the grammar, conflicts (resolved and unresolved), and
|
||||
@acronym{LALR} automaton.
|
||||
|
||||
@item lookahead
|
||||
@item look-ahead
|
||||
Implies @code{state} and augments the description of the automaton with
|
||||
each rule's lookahead set.
|
||||
each rule's look-ahead set.
|
||||
|
||||
@item itemset
|
||||
Implies @code{state} and augments the description of the automaton with
|
||||
|
||||
Reference in New Issue
Block a user