You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

52 lines
1.3 KiB

9 years ago
#include "debug.h"
#include "init.h"
#include "globals.h"
9 years ago
int main(int argc, char** argv)
{
if(argc!=2) return 1;
int ret;
DepTree* DPTree;
9 years ago
SetDebugLevel(INFO);
9 years ago
COUT(INFO)<<"Parse config file "<<argv[1]<<" ";
ret=ParseConfigFile(argv[1]); if(ret!=0) { ClearGlobals(); return 1;}
COUT(INFO)<<"Ok"<<std::endl;
if(G_tosave.size()==0 && G_toprint.size()==0)
{
COUT(WARNING)<<"No actions needed, exiting"<<std::endl;
ClearGlobals();
return 0;
}
{
UsedType used, all;
for(auto& i:G_vars) all.insert(i.first);
unsigned int tot=G_vars.size();
DPTree=new DepTree;
COUT(INFO)<<"Building dependency tree ";
ret=BuildDepTree(DPTree,used); if(ret!=0) { ClearGlobals(); delete DPTree; return 1;}
COUT(INFO)<<"Ok"<<std::endl;
COUT(INFO)<<"Remove unneeded definitions: ";
for(auto& i:all) if(used.count(i)==0) { delete G_vars[i]; G_vars.erase(i);};
COUT(INFO)<<(tot-G_vars.size())<<" removed, "<<G_vars.size()<<" remains."<<std::endl;
}
RegisterArifmeticFunctions();
9 years ago
COUT(INFO)<<"Checking functions ";
ret=CheckFunctions(); if(ret!=0) { ClearGlobals(); delete DPTree; return 1;}
COUT(INFO)<<"Ok"<<std::endl;
COUT(INFO)<<"Evaluate tree ";
ret=DPTree->EvaluateTree(); if(ret!=0) { ClearGlobals(); delete DPTree; return 1;}
COUT(INFO)<<"Ok"<<std::endl;
ClearGlobals();
delete DPTree;
9 years ago
return 0;
}