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 / error.c < prev    next >
C/C++ Source or Header  |  1980-02-17  |  2KB  |  127 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. #ifdef PXP
  20. extern    int yyline;
  21. extern    char errout;
  22. #endif
  23.  
  24. char    errpfx    'E';
  25. extern    int yyline;
  26. /*
  27.  * Panic is called when impossible
  28.  * (supposedly, anyways) situations
  29.  * are encountered.
  30. #ifdef PI
  31.  * Panic messages should be short
  32.  * as they do not go to the message
  33.  * file.
  34. #endif
  35.  */
  36. panic(s)
  37.     char *s;
  38. {
  39.  
  40. #ifdef DEBUG
  41.     printf("Snark (%s) line=%d yyline=%d\n", s, line, yyline);
  42. #endif
  43. #ifdef PXP
  44.     Perror( "Snark in pxp", s);
  45. #endif
  46. #ifdef PI
  47.     Perror( "Snark in pi", s);
  48. #endif
  49.     pexit(DIED);
  50. }
  51.  
  52. extern    char *errfile;
  53. /*
  54.  * Error is called for
  55.  * semantic errors and
  56.  * prints the error and
  57.  * a line number.
  58.  */
  59. error(a1, a2, a3, a4)
  60. {
  61. #ifdef PI
  62.     char buf[256];
  63.     register int i;
  64. #endif
  65. #ifdef PXP
  66.     int ofout;
  67. #endif
  68.  
  69.     if (errpfx == 'w' && opt('w') != 0)
  70.         return;
  71. #ifdef PXP
  72.     flush();
  73.     ofout = fout[0];
  74.     fout[0] = errout;
  75. #endif
  76. #ifdef PI
  77.     Enocascade = 0;
  78.     geterr(a1, buf);
  79.     a1 = buf;
  80. #endif
  81.     if (line < 0)
  82.         line = -line;
  83.     yySsync();
  84.     yysetfile(filename);
  85. #ifdef PI
  86.     if (errpfx == ' ') {
  87.         printf("  ");
  88.         for (i = line; i >= 10; i =/ 10)
  89.             putchar(' ');
  90.         printf("... ");
  91.     } else if (Enoline)
  92.         printf("  %c - ", errpfx);
  93.     else
  94. #endif
  95.         printf("%c %d - ", errpfx, line);
  96.     printf(a1, a2, a3, a4);
  97.     if (errpfx == 'E')
  98. #ifdef PI
  99.         eflg++, cgenflg++;
  100. #endif
  101. #ifdef PXP
  102.         eflg++;
  103. #endif
  104.     errpfx = 'E';
  105. #ifdef PI
  106.     if (Eholdnl)
  107.         Eholdnl = 0;
  108.     else
  109. #endif
  110.         putchar('\n');
  111. #ifdef PXP
  112.     flush();
  113.     fout[0] = ofout;
  114. #endif
  115. }
  116.  
  117. #ifdef PI
  118. cerror(a1, a2, a3, a4)
  119. {
  120.  
  121.     if (Enocascade)
  122.         return;
  123.     setpfx(' ');
  124.     error(a1, a2, a3, a4);
  125. }
  126. #endif
  127.