main.c 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. /* $Id$ */
  2. /*
  3. * (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands.
  4. * See the copyright notice in the ACK home directory, in the file "Copyright".
  5. */
  6. /* m a i n . c
  7. *
  8. * Contains the main program, the error reporting routine, and a routine
  9. * to check wether a constraint consists only of space
  10. */
  11. #include <stdlib.h>
  12. #include <stdio.h>
  13. extern int lineno, newline;
  14. FILE *genc, *genh, *input;
  15. static int nerrors;
  16. char *linedir = "#line %d \"%s\"\n"; /* format of line directive */
  17. char *inpfile;
  18. main(argc,argv) char *argv[]; {
  19. newline = 1;
  20. if (argc != 2) {
  21. fprintf(stderr,"Usage : %s targetoptimizerdescription\n",argv[0]);
  22. exit(1);
  23. }
  24. if ((input = fopen(argv[1],"r")) == NULL) {
  25. fprintf(stderr,"Fatal error : couldn't open %s\n",argv[1]);
  26. exit(1);
  27. }
  28. if ((genc = fopen("gen.c","w")) == NULL) {
  29. fputs("Fatal error : couldn't open gen.c\n",stderr);
  30. exit(1);
  31. }
  32. if ((genh = fopen("gen.h","w")) == NULL) {
  33. fputs("Fatal error : couldn't open gen.h\n",stderr);
  34. exit(1);
  35. }
  36. inpfile = argv[1]; /* needed for line directives and errors */
  37. LLparse();
  38. exit(nerrors);
  39. }
  40. /* VARARGS1 */
  41. error(s, s1) char *s, *s1; {
  42. nerrors++;
  43. fprintf(stderr,"\"%s\", line %d: ",inpfile,lineno);
  44. fprintf(stderr,s,s1);
  45. putc('\n',stderr);
  46. }
  47. onlyspace(s) register char *s; {
  48. while (*s) {
  49. if (*s != ' ' && *s != '\t' && *s != '\n') return 0;
  50. s++;
  51. }
  52. return 1;
  53. }