home *** CD-ROM | disk | FTP | other *** search
/ minnie.tuhs.org / unixen.tar / unixen / PDP-11 / Distributions / ucb / spencer_2bsd.tar.gz / 2bsd.tar / src / pi0 / yyerror.c < prev    next >
C/C++ Source or Header  |  1980-02-17  |  1KB  |  74 lines

  1. /* Copyright (c) 1979 Regents of the University of California */
  2. #
  3. /*
  4.  * pi - Pascal interpreter code translator
  5.  *
  6.  * Charles Haley, Bill Joy UCB
  7.  * Version 1.2 January 1979
  8.  */
  9.  
  10. #include "0.h"
  11. #include "yy.h"
  12.  
  13. /*
  14.  * Yerror prints an error
  15.  * message and then returns
  16.  * NIL for the tree if needed.
  17.  * The error is flagged on the
  18.  * current line which is printed
  19.  * if the listing is turned off.
  20.  */
  21. yerror(s, a1, a2, a3, a4, a5)
  22.     register char *s;
  23. {
  24.     char buf[256];
  25.     register int i, j;
  26.     static yySerrs;
  27.  
  28.     if (errpfx == 'w' && opt('w') != 0)
  29.         return;
  30.     yyResume = 0;
  31.     geterr(s, buf);
  32.     s = buf;
  33.     yysync();
  34.     putchar(errpfx);
  35.     putchar(' ');
  36.     for (i = 3; i < yyecol; i++)
  37.         putchar('-');
  38.     printf("^--- ");
  39. /*
  40.     if (yyecol > 60)
  41.         printf("\n\t");
  42. */
  43.     printf(s, a1, a2, a3, a4, a5);
  44.     putchar('\n');
  45.     if (errpfx == 'E')
  46.         eflg++;
  47.     errpfx = 'E';
  48.     yySerrs++;
  49.     if (yySerrs >= MAXSYNERR) {
  50.         yySerrs = 0;
  51.         yerror("Too many syntax errors - QUIT");
  52.         pexit(ERRS);
  53.     }
  54. }
  55.  
  56. /*
  57.  * A bracketing error message
  58.  */
  59. brerror(where, what)
  60.     register int where;
  61.     register char *what;
  62. {
  63.  
  64.     if (where == 0) {
  65.         line = yyeline;
  66.         setpfx(' ');
  67.         error("End matched %s on line %d", what, where);
  68.         return;
  69.     }
  70.     if (where < 0)
  71.         where = -where;
  72.     yerror("Inserted keyword end matching %s on line %d", what, where);
  73. }
  74.