home *** CD-ROM | disk | FTP | other *** search
/ minnie.tuhs.org / unixen.tar / unixen / PDP-11 / Distributions / ucb / spencer_2bsd.tar.gz / 2bsd.tar / src / pxp / yyerror.c < prev    next >
C/C++ Source or Header  |  1980-02-17  |  2KB  |  108 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.  * pxp - Pascal execution profiler
  11.  *
  12.  * Bill Joy UCB
  13.  * Version 1.2 January 1979
  14.  */
  15.  
  16. #include "0.h"
  17. #include "yy.h"
  18.  
  19. /*
  20.  * Yerror prints an error
  21.  * message and then returns
  22.  * NIL for the tree if needed.
  23.  * The error is flagged on the
  24.  * current line which is printed
  25.  * if the listing is turned off.
  26. #ifdef PXP
  27.  *
  28.  * As is obvious from the fooling around
  29.  * with fout below, the Pascal system should
  30.  * be changed to use the new library "lS".
  31. #endif
  32.  */
  33. yerror(s, a1, a2, a3, a4, a5)
  34.     char *s;
  35. {
  36. #ifdef PI
  37.     char buf[256];
  38. #endif
  39.     register int i, j;
  40.     static yySerrs;
  41. #ifdef PXP
  42.     int ofout;
  43. #endif
  44.  
  45.     if (errpfx == 'w' && opt('w') != 0)
  46.         return;
  47. #ifdef PXP
  48.     flush();
  49.     ofout = fout[0];
  50.     fout[0] = errout;
  51. #endif
  52.     yyResume = 0;
  53. #ifdef PI
  54.     geterr(s, buf);
  55.     s = buf;
  56. #endif
  57.     yysync();
  58.     putchar(errpfx);
  59.     putchar(' ');
  60.     for (i = 3; i < yyecol; i++)
  61.         putchar('-');
  62.     printf("^--- ");
  63. /*
  64.     if (yyecol > 60)
  65.         printf("\n\t");
  66. */
  67.     printf(s, a1, a2, a3, a4, a5);
  68.     putchar('\n');
  69.     if (errpfx == 'E')
  70. #ifdef PI
  71.         eflg++, cgenflg++;
  72. #endif
  73. #ifdef PXP
  74.         eflg++;
  75. #endif
  76.     errpfx = 'E';
  77.     yySerrs++;
  78.     if (yySerrs >= MAXSYNERR) {
  79.         yySerrs = 0;
  80.         yerror("Too many syntax errors - QUIT");
  81.         pexit(ERRS);
  82.     }
  83. #ifdef PXP
  84.     flush();
  85.     fout[0] = ofout;
  86.     return (0);
  87. #endif
  88. }
  89.  
  90. /*
  91.  * A bracketing error message
  92.  */
  93. brerror(where, what)
  94.     int where;
  95.     char *what;
  96. {
  97.  
  98.     if (where == 0) {
  99.         line = yyeline;
  100.         setpfx(' ');
  101.         error("End matched %s on line %d", what, where);
  102.         return;
  103.     }
  104.     if (where < 0)
  105.         where = -where;
  106.     yerror("Inserted keyword end matching %s on line %d", what, where);
  107. }
  108.