# 2.11BSD#431 - /usr/src/ucb/pascal/pi/error.c

##### Functions

    cerror            X
    derror            X
    error             X
    panic             X
    yysetfile         X

##### Variables

    errpfx            X
    hadsome           X
    lastname          X
    printed           X

       1: /*	@(#)error.c	2.3	SCCS id keyword	*/
       2: /* Copyright (c) 1979 Regents of the University of California */
       3: #
       4: /*
       5:  * pi - Pascal interpreter code translator
       6:  *
       7:  * Charles Haley, Bill Joy UCB
       8:  * Version 1.2 November 1978
       9:  */
      10:
      11: #include "whoami"
      12: #include "0.h"
      13: #ifndef PI1
      14: #include "yy.h"
      15: #endif
      16:
      17: char    errpfx  = 'E';
      18: extern  int yyline;
      19: /*
      20:  * Panic is called when impossible
      21:  * (supposedly, anyways) situations
      22:  * are encountered.
      23:  * Panic messages should be short
      24:  * as they do not go to the message
      25:  * file.
      26:  */
      27: panic(s)
      28:     char *s;
      29: {
      30:
      31: #ifdef DEBUG
      32: #ifdef PI1
      33:     printf("Snark (%s) line=%d\n", s, line);
      34:     abort();
      35: #else
      36:     printf("Snark (%s) line=%d, yyline=%d\n", s, line, yyline);
      37:     abort () ;  /* die horribly */
      38: #endif
      39: #endif
      40: #ifdef PI1
      41:     Perror( "Snark in pi1", s);
      42: #else
      43:     Perror( "Snark in pi", s);
      44: #endif
      45:     pexit(DIED);
      46: }
      47:
      48: extern  char *errfile;
      49: /*
      50:  * Error is called for
      51:  * semantic errors and
      52:  * prints the error and
      53:  * a line number.
      54:  */
      55:
      56: /*VARARGS*/
      57:
      58: error(a1, a2, a3, a4)
      59:     register char *a1;
      60: {
      61:     char errbuf[256];       /* was extern. why? ...pbk */
      62:     register int i;
      63:
      64:     if (errpfx == 'w' && opt('w') != 0) {
      65:         errpfx = 'E';
      66:         return;
      67:     }
      68:     Enocascade = 0;
      69:     geterr(a1, errbuf);
      70:     a1 = errbuf;
      71:     if (line < 0)
      72:         line = -line;
      73: #ifndef PI1
      74:     if (opt('l'))
      75:         yyoutline();
      76: #endif
      77:     yysetfile(filename);
      78:     if (errpfx == ' ') {
      79:         printf("  ");
      80:         for (i = line; i >= 10; i /= 10)
      81:             pchr( ' ' );
      82:         printf("... ");
      83:     } else if (Enoline)
      84:         printf("  %c - ", errpfx);
      85:     else
      86:         printf("%c %d - ", errpfx, line);
      87:     printf(a1, a2, a3, a4);
      88:     if (errpfx == 'E')
      89: #ifndef PI0
      90:         eflg++, codeoff();
      91: #else
      92:         eflg++;
      93: #endif
      94:     errpfx = 'E';
      95:     if (Eholdnl)
      96:         Eholdnl = 0;
      97:     else
      98:         pchr( '\n' );
      99: }
     100:
     101: /*VARAGRS*/
     102:
     103: cerror(a1, a2, a3, a4)
     104: {
     105:
     106:     if (Enocascade)
     107:         return;
     108:     setpfx(' ');
     109:     error(a1, a2, a3, a4);
     110: }
     111:
     112: #ifdef PI1
     113:
     114: /*VARARGS*/
     115:
     116: derror(a1, a2, a3, a4)
     117: {
     118:
     119:     if (!holdderr)
     120:         error(a1, a2, a3, a4);
     121:     errpfx = 'E';
     122: }
     123:
     124: char    *lastname, printed, hadsome;
     125:
     126: yysetfile(name)
     127:     char *name;
     128: {
     129:
     130:     if (lastname == name)
     131:         return;
     132:     printed |= 1;
     133:     printf("%s:\n", name);
     134:     lastname = name;
     135: }
     136: #endif

#### Defined functions

cerror defined in line 103; used 16 times

- in /usr/src/ucb/pascal/pi/call.c line 74
- in /usr/src/ucb/pascal/pi/case.c line 109
- in /usr/src/ucb/pascal/pi/conv.c line 90-91(2)
- in /usr/src/ucb/pascal/pi/cset.c line 116, 123, 131
- in /usr/src/ucb/pascal/pi/lval.c line 201, 260-262(2)
- in /usr/src/ucb/pascal/pi/proc.c line 286, 582
- in /usr/src/ucb/pascal/pi/rec.c line 198
- in /usr/src/ucb/pascal/pi/rval.c line 476
- in /usr/src/ucb/pascal/pi/stat.c line 276, 352

derror defined in line 116; never used
error defined in line 58; used 2 times

- in line 109, 120

panic defined in line 27; used 38 times

- in /usr/src/ucb/pascal/pi/call.c line 83
- in /usr/src/ucb/pascal/pi/clas.c line 81, 89
- in /usr/src/ucb/pascal/pi/const.c line 93, 129
- in /usr/src/ucb/pascal/pi/conv.c line 48, 209
- in /usr/src/ucb/pascal/pi/cset.c line 74
- in /usr/src/ucb/pascal/pi/fdec.c line 107, 157
- in /usr/src/ucb/pascal/pi/func.c line 247
- in /usr/src/ucb/pascal/pi/gen.c line 213
- in /usr/src/ucb/pascal/pi/lval.c line 192, 224
- in /usr/src/ucb/pascal/pi/nl.c line 358
- in /usr/src/ucb/pascal/pi/proc.c line 795
- in /usr/src/ucb/pascal/pi/put.c line 62, 318
- in /usr/src/ucb/pascal/pi/rval.c line 191, 213, 441, 492
- in /usr/src/ucb/pascal/pi/stat.c line 81
- in /usr/src/ucb/pascal/pi/string.c line 132, 143-150(3)
- in /usr/src/ucb/pascal/pi/tree.c line 166
- in /usr/src/ucb/pascal/pi/type.c line 85
- in /usr/src/ucb/pascal/pi/var.c line 123, 149, 167, 187, 210
- in /usr/src/ucb/pascal/pi/yylex.c line 35
- in /usr/src/ucb/pascal/pi/yymain.c line 162
- in /usr/src/ucb/pascal/pi/yyparse.c line 213
- in /usr/src/ucb/pascal/pi/yyrecover.c line 871

yysetfile defined in line 126; used 1 times

- in line 77

#### Defined variables

errpfx defined in line 17; used 8 times

- in line 64-65(2), 78, 84-88(3), 94, 121

hadsome defined in line 124; never used
lastname defined in line 124; used 2 times

- in line 130-134(2)

printed defined in line 124; used 1 times

- in line 132

Last modified: 1986-06-01 Generated: 2016-12-26 | Generated by src2html V0.67 page hit count: 626 |