GNU Info

Info Node: (bison.info)Rpcalc Error

(bison.info)Rpcalc Error


Next: Rpcalc Gen Prev: Rpcalc Main Up: RPN Calc
Enter node , (file) or (file)node

The Error Reporting Routine
---------------------------

   When `yyparse' detects a syntax error, it calls the error reporting
function `yyerror' to print an error message (usually but not always
`"parse error"').  It is up to the programmer to supply `yyerror'
(Note: Parser C-Language Interface.), so here is the
definition we will use:

     #include <stdio.h>
     
     void
     yyerror (const char *s)  /* Called by yyparse on error */
     {
       printf ("%s\n", s);
     }

   After `yyerror' returns, the Bison parser may recover from the error
and continue parsing if the grammar contains a suitable error rule
(Note: Error Recovery).  Otherwise, `yyparse' returns nonzero.  We
have not written any error rules in this example, so any invalid input
will cause the calculator program to exit.  This is not clean behavior
for a real calculator, but it is adequate for the first example.


automatically generated by info2www version 1.2.2.9