|
|
|
#include <inttypes.h>
|
|
|
|
#include "init.h"
|
|
|
|
#include "debug.h"
|
|
|
|
#include "object.h"
|
|
|
|
#include "globals.h"
|
|
|
|
#include "arifmetic.h"
|
|
|
|
#include "parser/parser.h"
|
|
|
|
#include "parser/grammatical.h"
|
|
|
|
#include "parser/lexical.h"
|
|
|
|
|
|
|
|
int ParseConfigFile(char* config)
|
|
|
|
{
|
|
|
|
yyscan_t scanner;
|
|
|
|
struct lexical_extra extra;
|
|
|
|
FILE* conffd;
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
conffd=fopen(config,"r");
|
|
|
|
if(conffd==0)
|
|
|
|
{
|
|
|
|
COUT(ERROR)<<"Can't open file "<<config<<std::endl;
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
extra.filename=config;
|
|
|
|
extra.inclevel=0;
|
|
|
|
extra.maxinclevel=10;
|
|
|
|
extra.curline=1;
|
|
|
|
extra.curpos=extra.curoffset=0;
|
|
|
|
conflex_init_extra(&extra,&scanner);
|
|
|
|
confset_in(conffd,scanner);
|
|
|
|
// {YYSTYPE qqq; while(conflex(&qqq,scanner)>0);}
|
|
|
|
ret=confparse(scanner);
|
|
|
|
conflex_destroy(scanner);
|
|
|
|
fclose(conffd);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int RegisterArifmeticFunctions()
|
|
|
|
{
|
|
|
|
RegisterFunction("ADD",Arifm_Add);
|
|
|
|
RegisterFunction("SUB",Arifm_Sub);
|
|
|
|
RegisterFunction("MUL",Arifm_Mul);
|
|
|
|
RegisterFunction("DIV",Arifm_Div);
|
|
|
|
RegisterFunction("POW",Arifm_Pow);
|
|
|
|
RegisterFunction("POS",Arifm_Pos);
|
|
|
|
RegisterFunction("NEG",Arifm_Neg);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int BuildDepTree(DepTree* deptree,std::set<std::string>& used)
|
|
|
|
{
|
|
|
|
return deptree->CreateGlobalTree(used);
|
|
|
|
}
|