/* Pascal 1990 (ISO 7185) Compiler */
/* MAIN ENTRY POINT                */
/* (c) 2003 john weber             */

#include <stdio.h>
#include <sys/stat.h>
#include <sys/mman.h>
#include <sys/types.h>
#include <fcntl.h>
#include "globals.h"
#include "scanner.h"
#include "pool.h"
#include "table.h"
#include "types.h"
#include "jvm.h"
#include "tdrd.h"

pool constant_pool;
table symboltable;
scanner scan;

int main(int argc, char** argv)
{
	if(argc != 2) {
		printf("Usage: pcompiler [file]\n");
		exit(-2);
	}

  constant_pool = cp_init();
	symboltable   = table_init(64);	
	scan          = scanner_init(argv[1]);
  parse();
  
#ifdef DEBUG
   if(constant_pool->size != 0) cp_print(constant_pool);

   printf("\nSymbol Table\n------------\n");
	 table_print(symboltable);
#endif

	
	/* Clean up resources */
	scan->destroy();
  cp_destroy(constant_pool);
	table_destroy(symboltable);
	
#ifdef DEBUG
	 jterminate();
#endif
	return 0;
}
