main.c 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  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. #include <stdlib.h>
  6. #include <stdio.h>
  7. #include <unistd.h>
  8. #include "param.h"
  9. #include "varinfo.h"
  10. #include "error.h"
  11. #include "emlookup.h"
  12. #include "cvtkeywords.h"
  13. #include "expr.h"
  14. #include "output.h"
  15. #include "hall.h"
  16. #include <missing_proto.h>
  17. /* From YACC lexer */
  18. void yyparse(void);
  19. char *filename;
  20. void *beg_sbrk;
  21. int main(int argc, char *argv[])
  22. {
  23. extern int nerrors;
  24. extern int code_in_c;
  25. extern int tabledebug;
  26. extern int verbose;
  27. beg_sbrk = sbrk(0);
  28. while (argc >1 && argv[1][0]=='-') {
  29. switch(argv[1][1]) {
  30. case 'c':
  31. code_in_c = 0;
  32. break;
  33. case 'd':
  34. tabledebug++;
  35. break;
  36. case 'v':
  37. verbose++;
  38. break;
  39. default:
  40. error("Unknown flag -%c",argv[1][1]);
  41. }
  42. argc--; argv++;
  43. }
  44. if (argc==2) {
  45. if (freopen(argv[1],"r",stdin)==NULL) {
  46. error("Can't open %s",argv[1]);
  47. exit(-1);
  48. }
  49. filename = argv[1];
  50. }
  51. else if (argc == 1) {
  52. filename = "";
  53. } else
  54. error("Usage: %s [-c] [-d] [-v] [table]",argv[0]);
  55. initemhash();
  56. enterkeyw();
  57. initnodes();
  58. initio();
  59. yyparse();
  60. if (nerrors==0) {
  61. finishio();
  62. statistics();
  63. if (verbose)
  64. hallverbose();
  65. } else {
  66. errorexit();
  67. }
  68. exit(nerrors==0 ? 0 : -1);
  69. }