error.c 776 B

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