/[bison]/bison/doc/bison.texinfo
ViewVC logotype

Diff of /bison/doc/bison.texinfo

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.75 by akim, Sun Nov 3 16:41:57 2002 UTC revision 1.76 by akim, Thu Nov 7 12:52:19 2002 UTC
# Line 1357  here is the definition we will use: Line 1357  here is the definition we will use:
1357  #include <stdio.h>  #include <stdio.h>
1358    
1359  void  void
1360  yyerror (const char *s)  /* called by yyparse on error */  yyerror (const char *s)  /* Called by yyparse on error.  */
1361  @{  @{
1362    printf ("%s\n", s);    printf ("%s\n", s);
1363  @}  @}
# Line 1973  main (void) Line 1973  main (void)
1973    
1974  @group  @group
1975  void  void
1976  yyerror (const char *s)  /* Called by yyparse on error */  yyerror (const char *s)  /* Called by yyparse on error.  */
1977  @{  @{
1978    printf ("%s\n", s);    printf ("%s\n", s);
1979  @}  @}
# Line 4050  The following definition suffices in sim Line 4050  The following definition suffices in sim
4050  @example  @example
4051  @group  @group
4052  void  void
4053  yyerror (char *s)  yyerror (const char *s)
4054  @{  @{
4055  @end group  @end group
4056  @group  @group
# Line 4064  error recovery if you have written suita Line 4064  error recovery if you have written suita
4064  (@pxref{Error Recovery}).  If recovery is impossible, @code{yyparse} will  (@pxref{Error Recovery}).  If recovery is impossible, @code{yyparse} will
4065  immediately return 1.  immediately return 1.
4066    
4067  Oviously, in location tracking pure parsers, @code{yyerror} should have  Obviously, in location tracking pure parsers, @code{yyerror} should have
4068  an access to the current location.  This is indeed the case for the GLR  an access to the current location.  This is indeed the case for the GLR
4069  parsers, but not for the Yacc parser, for historical reasons.  I.e., if  parsers, but not for the Yacc parser, for historical reasons.  I.e., if
4070  @samp{%locations %pure-parser} is passed then the prototypes for  @samp{%locations %pure-parser} is passed then the prototypes for
# Line 4072  parsers, but not for the Yacc parser, fo Line 4072  parsers, but not for the Yacc parser, fo
4072    
4073  @example  @example
4074  void yyerror (const char *msg);                 /* Yacc parsers.  */  void yyerror (const char *msg);                 /* Yacc parsers.  */
4075  void yyerror (const char *msg, YYLTYPE *locp);  /* GLR parsers.   */  void yyerror (YYLTYPE *locp, const char *msg);  /* GLR parsers.   */
4076  @end example  @end example
4077    
4078  If @samp{%parse-param "int *nastiness"  "nastiness"} is used, then:  If @samp{%parse-param "int *nastiness"  "nastiness"} is used, then:
4079    
4080  @example  @example
4081  void yyerror (int *randomness);  /* Yacc parsers.  */  void yyerror (int *randomness, const char *msg);  /* Yacc parsers.  */
4082  void yyerror (int *randomness);  /* GLR parsers.   */  void yyerror (int *randomness, const char *msg);  /* GLR parsers.   */
4083  @end example  @end example
4084    
4085  Finally, GLR and Yacc parsers share the same @code{yyerror} calling  Finally, GLR and Yacc parsers share the same @code{yyerror} calling
# Line 4104  results in the following signatures for Line 4104  results in the following signatures for
4104  @example  @example
4105  int yylex (YYSTYPE *lvalp, YYLTYPE *llocp, int *nastiness);  int yylex (YYSTYPE *lvalp, YYLTYPE *llocp, int *nastiness);
4106  int yyparse (int *nastiness, int *randomness);  int yyparse (int *nastiness, int *randomness);
4107  void yyerror (const char *msg, YYLTYPE *locp,  void yyerror (YYLTYPE *locp,
4108                int *nastiness, int *randomness);                int *nastiness, int *randomness,
4109                  const char *msg);
4110  @end example  @end example
4111    
4112    @noident
4113    Please, note that the prototypes are only indications of how the code
4114    produced by Bison will use @code{yyerror}, but you still have freedom
4115    and the exit value, and even on making @code{yyerror} a variadic
4116    function.  It is precisely to enable this that the message is passed
4117    last.
4118    
4119  @vindex yynerrs  @vindex yynerrs
4120  The variable @code{yynerrs} contains the number of syntax errors  The variable @code{yynerrs} contains the number of syntax errors
4121  encountered so far.  Normally this variable is global; but if you  encountered so far.  Normally this variable is global; but if you

Legend:
Removed from v.1.75  
changed lines
  Added in v.1.76

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26