main.c 1.1 KB

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