1: /*
   2:  * Copyright (c) 1980 Regents of the University of California.
   3:  * All rights reserved.  The Berkeley software License Agreement
   4:  * specifies the terms and conditions for redistribution.
   5:  */
   6: 
   7: #ifndef lint
   8: static char sccsid[] = "@(#)yyerror.c	5.2 (Berkeley) 5/6/86";
   9: #endif not lint
  10: 
  11: #include "whoami.h"
  12: #include "0.h"
  13: #include "tree_ty.h"    /* must be included for yy.h */
  14: #include "yy.h"
  15: 
  16: /*
  17:  * Yerror prints an error
  18:  * message and then returns
  19:  * NIL for the tree if needed.
  20:  * The error is flagged on the
  21:  * current line which is printed
  22:  * if the listing is turned off.
  23: #ifdef PXP
  24:  *
  25:  * As is obvious from the fooling around
  26:  * with fout below, the Pascal system should
  27:  * be changed to use the new library "lS".
  28: #endif
  29:  */
  30: /*VARARGS*/
  31: yerror(s, a1, a2, a3, a4, a5)
  32:     char *s;
  33:     char *a1, *a2, *a3, *a4, *a5;
  34: {
  35: #ifdef PI
  36:     char buf[256];
  37: #endif
  38:     register int i;
  39:     static yySerrs;
  40: #ifdef PXP
  41:     int ofout;
  42: #endif
  43: 
  44:     if (errpfx == 'w' && opt('w') != 0) {
  45:         errpfx = 'E';
  46:         return;
  47:     }
  48:     /* no continuations allowed here */
  49:     if (errpfx == ' ')
  50:         errpfx = 'E';
  51: #ifdef PXP
  52:     flush();
  53:     ofout = fout[0];
  54:     fout[0] = errout;
  55: #endif
  56:     yyResume = 0;
  57: #ifdef PI
  58:     geterr((int) s, buf);
  59:     s = buf;
  60: #endif
  61:     yysync();
  62:     pchr(errpfx);
  63:     pchr(' ');
  64:     for (i = 3; i < yyecol; i++)
  65:         pchr('-');
  66:     printf("^--- ");
  67: /*
  68: 	if (yyecol > 60)
  69: 		printf("\n\t");
  70: */
  71:     printf(s, a1, a2, a3, a4, a5);
  72:     pchr('\n');
  73:     if (errpfx == 'E')
  74: #ifdef PI
  75:         eflg = TRUE, codeoff();
  76: #endif
  77: #ifdef PXP
  78:         eflg = TRUE;
  79: #endif
  80:     errpfx = 'E';
  81:     yySerrs++;
  82:     if (yySerrs >= MAXSYNERR) {
  83:         yySerrs = 0;
  84:         yerror("Too many syntax errors - QUIT");
  85:         pexit(ERRS);
  86:     }
  87: #ifdef PXP
  88:     flush();
  89:     fout[0] = ofout;
  90:     return (0);
  91: #endif
  92: }
  93: 
  94: /*
  95:  * A bracketing error message
  96:  */
  97: brerror(where, what)
  98:     int where;
  99:     char *what;
 100: {
 101: 
 102:     if (where == 0) {
 103:         line = yyeline;
 104:         setpfx(' ');
 105:         error("End matched %s on line %d", what, (char *) where);
 106:         return;
 107:     }
 108:     if (where < 0)
 109:         where = -where;
 110:     yerror("Inserted keyword end matching %s on line %d", what, (char *) where);
 111: }
Last modified: 1986-05-07
Generated: 2016-12-26
Generated by src2html V0.67
page hit count: 2170
Valid CSS Valid XHTML 1.0 Strict