error.c 956 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  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 <stdlib.h>
  9. #include <stdio.h>
  10. int nerrors=0;
  11. yyerror(s) char *s; {
  12. error("Parser gives %s",s);
  13. }
  14. goodbye() {
  15. error("This was fatal, goodbye!");
  16. #ifndef NDEBUG
  17. abort();
  18. #endif
  19. }
  20. /*VARARGS1*/
  21. fatal(s,a,b,c,d) char *s; {
  22. error(s,a,b,c,d);
  23. errorexit();
  24. goodbye();
  25. exit(-1);
  26. }
  27. /*VARARGS1*/
  28. error(s,a,b,c,d) char *s; {
  29. extern int lineno;
  30. extern char *filename;
  31. fprintf(stderr,"\"%s\", line %d:",filename,lineno);
  32. fprintf(stderr,s,a,b,c,d);
  33. fprintf(stderr,"\n");
  34. nerrors++;
  35. }
  36. #ifndef NDEBUG
  37. badassertion(string,file,line) char *string,*file; {
  38. fprintf(stderr,"\"%s\", line %d: Assertion failed \"%s\"\n",
  39. file,line,string);
  40. goodbye();
  41. }
  42. #endif
  43. tabovf(string) char *string; {
  44. fatal("%s overflow",string);
  45. }