main.c 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  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. char *filename;
  10. char *beg_sbrk;
  11. extern char *sbrk();
  12. main(argc,argv) char **argv; {
  13. extern int nerrors;
  14. extern int code_in_c;
  15. extern int tabledebug;
  16. extern int verbose;
  17. beg_sbrk = sbrk(0);
  18. while (argc >1 && argv[1][0]=='-') {
  19. switch(argv[1][1]) {
  20. case 'c':
  21. code_in_c = 0;
  22. break;
  23. case 'd':
  24. tabledebug++;
  25. break;
  26. case 'v':
  27. verbose++;
  28. break;
  29. default:
  30. error("Unknown flag -%c",argv[1][1]);
  31. }
  32. argc--; argv++;
  33. }
  34. if (argc==2) {
  35. if (freopen(argv[1],"r",stdin)==NULL) {
  36. error("Can't open %s",argv[1]);
  37. exit(-1);
  38. }
  39. filename = argv[1];
  40. }
  41. else if (argc == 1) {
  42. filename = "";
  43. } else
  44. error("Usage: %s [-c] [-d] [-v] [table]",argv[0]);
  45. initemhash();
  46. enterkeyw();
  47. initnodes();
  48. initio();
  49. yyparse();
  50. if (nerrors==0) {
  51. finishio();
  52. statistics();
  53. if (verbose)
  54. hallverbose();
  55. } else {
  56. errorexit();
  57. }
  58. exit(nerrors==0 ? 0 : -1);
  59. }