Expect Decl
Previous: <Type Decl=>TypeDecl> * Next: <Start Decl=>StartDecl> * Up: <Declarations=>Declaratio>

#Wrap on
{fH4}Suppressing Conflict Warnings{f}

Bison normally warns if there are any conflicts in the grammar
(\*Note <Shift\/Reduce=>ShiftRedud>: Shift\/Reduce Conflicts), but most real grammars have harmless shift\/reduce
conflicts which are resolved in a predictable way and would be difficult to
eliminate.  It is desirable to suppress the warning about these conflicts
unless the number of conflicts changes.  You can do this with the
{fCode}%expect{f} declaration.

The declaration looks like this:

#Wrap off
#fCode
%expect {fStrong}n{f}
#f
#Wrap on

Here {fStrong}n{f} is a decimal integer.  The declaration says there should be no
warning if there are {fStrong}n{f} shift\/reduce conflicts and no reduce\/reduce
conflicts.  The usual warning is given if there are either more or fewer
conflicts, or if there are any reduce\/reduce conflicts.

In general, using {fCode}%expect{f} involves these steps:

#Indent +4

  Compile your grammar without {fCode}%expect{f}.  Use the {fEmphasis}-v{f} option
to get a verbose list of where the conflicts occur.  Bison will also
print the number of conflicts.


  Check each of the conflicts to make sure that Bison's default
resolution is what you really want.  If not, rewrite the grammar and
go back to the beginning.


  Add an {fCode}%expect{f} declaration, copying the number {fStrong}n{f} from the
number which Bison printed.

#Indent

Now Bison will stop annoying you about the conflicts you have checked, but
it will warn you again if changes in the grammar result in additional
conflicts.

