#include <iostream>
#include <fstream>
#include <sstream>
#include <string>
#include <ansi-c/ansi_c_language.h>
#include <util/cmdline.h>
#include <util/config.h>

int main(int argc, const char* argv[])
{
    // Command line: parse  -I incl_dir file1 ...
    cmdlinet cmdl;
    cmdl.parse(argc, argv, "I:");

    config.init();
    if(cmdl.isset('I'))	
	config.ansi_c.include_paths=cmdl.get_values('I');

    						// Set language to C
    std::auto_ptr<languaget> clang(new_ansi_c_language());
	
    contextt my_context;			// Symbol table

    cmdlinet::argst::iterator sit = cmdl.args.begin();
    for(;sit != cmdl.args.end();sit++)
    {
	std::ifstream in(sit->c_str());	        // Source code stream
	 
	                                        // Parse
        clang->parse(in,std::string(),std::cerr);

						// Typecheck
	clang->typecheck(my_context,sit->c_str(),std::cerr);
    }
						// Do some final adjustements
    clang->final(my_context,std::cerr);
	
    my_context.show(std::cout);

    return 0;
}
