122204Sdist /* 222204Sdist * Copyright (c) 1980 Regents of the University of California. 322204Sdist * All rights reserved. The Berkeley software License Agreement 422204Sdist * specifies the terms and conditions for redistribution. 522204Sdist */ 6784Speter 714747Sthien #ifndef lint 8*27739Smckusick static char sccsid[] = "@(#)yyerror.c 5.2 (Berkeley) 05/06/86"; 922204Sdist #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 } 48*27739Smckusick /* no continuations allowed here */ 49*27739Smckusick if (errpfx == ' ') 50*27739Smckusick errpfx = 'E'; 51784Speter #ifdef PXP 52784Speter flush(); 53784Speter ofout = fout[0]; 54784Speter fout[0] = errout; 55784Speter #endif 56784Speter yyResume = 0; 57784Speter #ifdef PI 5814747Sthien geterr((int) s, buf); 59784Speter s = buf; 60784Speter #endif 61784Speter yysync(); 62784Speter pchr(errpfx); 63784Speter pchr(' '); 64784Speter for (i = 3; i < yyecol; i++) 65784Speter pchr('-'); 66784Speter printf("^--- "); 67784Speter /* 68784Speter if (yyecol > 60) 69784Speter printf("\n\t"); 70784Speter */ 71784Speter printf(s, a1, a2, a3, a4, a5); 72784Speter pchr('\n'); 73784Speter if (errpfx == 'E') 74784Speter #ifdef PI 753085Smckusic eflg = TRUE, codeoff(); 76784Speter #endif 77784Speter #ifdef PXP 783085Smckusic eflg = TRUE; 79784Speter #endif 80784Speter errpfx = 'E'; 81784Speter yySerrs++; 82784Speter if (yySerrs >= MAXSYNERR) { 83784Speter yySerrs = 0; 84784Speter yerror("Too many syntax errors - QUIT"); 85784Speter pexit(ERRS); 86784Speter } 87784Speter #ifdef PXP 88784Speter flush(); 89784Speter fout[0] = ofout; 90784Speter return (0); 91784Speter #endif 92784Speter } 93784Speter 94784Speter /* 95784Speter * A bracketing error message 96784Speter */ 97784Speter brerror(where, what) 98784Speter int where; 99784Speter char *what; 100784Speter { 101784Speter 102784Speter if (where == 0) { 103784Speter line = yyeline; 104784Speter setpfx(' '); 10514747Sthien error("End matched %s on line %d", what, (char *) where); 106784Speter return; 107784Speter } 108784Speter if (where < 0) 109784Speter where = -where; 11014747Sthien yerror("Inserted keyword end matching %s on line %d", what, (char *) where); 111784Speter } 112