1*22204Sdist /* 2*22204Sdist * Copyright (c) 1980 Regents of the University of California. 3*22204Sdist * All rights reserved. The Berkeley software License Agreement 4*22204Sdist * specifies the terms and conditions for redistribution. 5*22204Sdist */ 6784Speter 714747Sthien #ifndef lint 8*22204Sdist static char sccsid[] = "@(#)yyerror.c 5.1 (Berkeley) 06/05/85"; 9*22204Sdist #endif not lint 10784Speter 11784Speter #include "whoami.h" 12784Speter #include "0.h" 1314747Sthien #include "tree_ty.h" /* must be included for yy.h */ 14784Speter #include "yy.h" 15784Speter 16784Speter /* 17784Speter * Yerror prints an error 18784Speter * message and then returns 19784Speter * NIL for the tree if needed. 20784Speter * The error is flagged on the 21784Speter * current line which is printed 22784Speter * if the listing is turned off. 23784Speter #ifdef PXP 24784Speter * 25784Speter * As is obvious from the fooling around 26784Speter * with fout below, the Pascal system should 27784Speter * be changed to use the new library "lS". 28784Speter #endif 29784Speter */ 3014747Sthien /*VARARGS*/ 31784Speter yerror(s, a1, a2, a3, a4, a5) 32784Speter char *s; 3314747Sthien char *a1, *a2, *a3, *a4, *a5; 34784Speter { 35784Speter #ifdef PI 36784Speter char buf[256]; 37784Speter #endif 3814747Sthien register int i; 39784Speter static yySerrs; 40784Speter #ifdef PXP 41784Speter int ofout; 42784Speter #endif 43784Speter 44784Speter if (errpfx == 'w' && opt('w') != 0) { 45784Speter errpfx = 'E'; 46784Speter return; 47784Speter } 48784Speter #ifdef PXP 49784Speter flush(); 50784Speter ofout = fout[0]; 51784Speter fout[0] = errout; 52784Speter #endif 53784Speter yyResume = 0; 54784Speter #ifdef PI 5514747Sthien geterr((int) s, buf); 56784Speter s = buf; 57784Speter #endif 58784Speter yysync(); 59784Speter pchr(errpfx); 60784Speter pchr(' '); 61784Speter for (i = 3; i < yyecol; i++) 62784Speter pchr('-'); 63784Speter printf("^--- "); 64784Speter /* 65784Speter if (yyecol > 60) 66784Speter printf("\n\t"); 67784Speter */ 68784Speter printf(s, a1, a2, a3, a4, a5); 69784Speter pchr('\n'); 70784Speter if (errpfx == 'E') 71784Speter #ifdef PI 723085Smckusic eflg = TRUE, codeoff(); 73784Speter #endif 74784Speter #ifdef PXP 753085Smckusic eflg = TRUE; 76784Speter #endif 77784Speter errpfx = 'E'; 78784Speter yySerrs++; 79784Speter if (yySerrs >= MAXSYNERR) { 80784Speter yySerrs = 0; 81784Speter yerror("Too many syntax errors - QUIT"); 82784Speter pexit(ERRS); 83784Speter } 84784Speter #ifdef PXP 85784Speter flush(); 86784Speter fout[0] = ofout; 87784Speter return (0); 88784Speter #endif 89784Speter } 90784Speter 91784Speter /* 92784Speter * A bracketing error message 93784Speter */ 94784Speter brerror(where, what) 95784Speter int where; 96784Speter char *what; 97784Speter { 98784Speter 99784Speter if (where == 0) { 100784Speter line = yyeline; 101784Speter setpfx(' '); 10214747Sthien error("End matched %s on line %d", what, (char *) where); 103784Speter return; 104784Speter } 105784Speter if (where < 0) 106784Speter where = -where; 10714747Sthien yerror("Inserted keyword end matching %s on line %d", what, (char *) where); 108784Speter } 109