error.c 936 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. /*
  2. * (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands.
  3. * See the copyright notice in the ACK home directory, in the file "Copyright".
  4. */
  5. #ifndef NORCSID
  6. static char rcsid[]= "$Id$";
  7. #endif
  8. #include <stdio.h>
  9. int nerrors=0;
  10. yyerror(s) char *s; {
  11. error("Parser gives %s",s);
  12. }
  13. goodbye() {
  14. error("This was fatal, goodbye!");
  15. #ifndef NDEBUG
  16. abort();
  17. #endif
  18. }
  19. /*VARARGS1*/
  20. fatal(s,a,b,c,d) char *s; {
  21. error(s,a,b,c,d);
  22. errorexit();
  23. goodbye();
  24. exit(-1);
  25. }
  26. /*VARARGS1*/
  27. error(s,a,b,c,d) char *s; {
  28. extern int lineno;
  29. extern char *filename;
  30. fprintf(stderr,"\"%s\", line %d:",filename,lineno);
  31. fprintf(stderr,s,a,b,c,d);
  32. fprintf(stderr,"\n");
  33. nerrors++;
  34. }
  35. #ifndef NDEBUG
  36. badassertion(string,file,line) char *string,*file; {
  37. fprintf(stderr,"\"%s\", line %d: Assertion failed \"%s\"\n",
  38. file,line,string);
  39. goodbye();
  40. }
  41. #endif
  42. tabovf(string) char *string; {
  43. fatal("%s overflow",string);
  44. }