Commit 39b21c8d authored by kruger's avatar kruger
Browse files

Nouvelle Version avec lib

parent f1f92700
...@@ -41,7 +41,7 @@ extern CSymbol *pCURRENT_CLASS, *pCURRENT_TYPE, *pGENOME, *pCLASSES[128]; ...@@ -41,7 +41,7 @@ extern CSymbol *pCURRENT_CLASS, *pCURRENT_TYPE, *pGENOME, *pCLASSES[128];
extern int nClasses_nb; extern int nClasses_nb;
extern FILE *fpOutputFile, *fpTemplateFile, *fpGenomeFile, *fpExplodedGenomeFile; extern FILE *fpOutputFile, *fpTemplateFile, *fpGenomeFile, *fpExplodedGenomeFile;
extern char sRAW_PROJECT_NAME[], sPROJECT_NAME[], sEO_DIR[], sEZ_PATH[1000], sEZ_FILE_NAME[]; extern char sRAW_PROJECT_NAME[], sPROJECT_NAME[], sEO_DIR[], sEZ_PATH[1000], sTPL_DIR[1000], sEZ_FILE_NAME[];
extern char sLOWER_CASE_PROJECT_NAME[]; extern char sLOWER_CASE_PROJECT_NAME[];
extern char sREPLACEMENT[], sSELECTOR[], sSELECT_PRM[], sRED_PAR[], sRED_PAR_PRM[], sRED_FINAL[], sRED_FINAL_PRM[], sRED_OFF[], sRED_OFF_PRM[], sDISCARD[], sDISCARD_PRM[]; extern char sREPLACEMENT[], sSELECTOR[], sSELECT_PRM[], sRED_PAR[], sRED_PAR_PRM[], sRED_FINAL[], sRED_FINAL_PRM[], sRED_OFF[], sRED_OFF_PRM[], sDISCARD[], sDISCARD_PRM[];
extern int nMINIMISE,nELITE; extern int nMINIMISE,nELITE;
......
%{ %{
/**************************************************************************** /****************************************************************************
EaseaLex.l EaseaLex.l
Lexical analyser for the EASEA language (EAsy Specification for Evolutionary Algorithms) Lexical analyser for the EASEA language (EAsy Specification for Evolutionary Algorithms)
...@@ -9,10 +9,17 @@ Ecole Polytechnique ...@@ -9,10 +9,17 @@ Ecole Polytechnique
Centre de Mathmatiques Appliques Centre de Mathmatiques Appliques
91128 Palaiseau cedex 91128 Palaiseau cedex
****************************************************************************/ ****************************************************************************/
#ifdef WIN32
#define _CRT_SECURE_NO_WARNINGS
#pragma comment(lib, "libAlexYacc.lib")
#endif
#include "Easea.h" #include "Easea.h"
#include "EaseaParse.h" #include "EaseaParse.h"
#ifdef WIN32
#include <direct.h>
#else
#include <unistd.h> #include <unistd.h>
#endif
#include "debug.h" #include "debug.h"
size_t genomeSize; size_t genomeSize;
...@@ -41,7 +48,7 @@ Centre de Math ...@@ -41,7 +48,7 @@ Centre de Math
strcat(selectorName,"Roulette(globalRandomGenerator)"); strcat(selectorName,"Roulette(globalRandomGenerator)");
else{ else{
DEBUG_PRT("%s is not yet implemented",sSELECTOR); //DEBUG_PRT_PRT("%s is not yet implemented",sSELECTOR);
return NULL; return NULL;
} }
...@@ -135,6 +142,7 @@ exponent ([Ee][+-]?[0-9]+) ...@@ -135,6 +142,7 @@ exponent ([Ee][+-]?[0-9]+)
<TEMPLATE_ANALYSIS>"AESAE" {fprintf(fpOutputFile,"EASEA");} <TEMPLATE_ANALYSIS>"AESAE" {fprintf(fpOutputFile,"EASEA");}
<TEMPLATE_ANALYSIS>"EASEA" {fprintf(fpOutputFile,"%s",sPROJECT_NAME);} <TEMPLATE_ANALYSIS>"EASEA" {fprintf(fpOutputFile,"%s",sPROJECT_NAME);}
<TEMPLATE_ANALYSIS>"\\EZ_PATH" {fprintf(fpOutputFile,"%s",sEZ_PATH);} <TEMPLATE_ANALYSIS>"\\EZ_PATH" {fprintf(fpOutputFile,"%s",sEZ_PATH);}
<TEMPLATE_ANALYSIS>"\\TPL_DIR" {fprintf(fpOutputFile,"%s",sTPL_DIR);}
<TEMPLATE_ANALYSIS>"\\EO_DIR" {fprintf(fpOutputFile,"%s",sEO_DIR);} <TEMPLATE_ANALYSIS>"\\EO_DIR" {fprintf(fpOutputFile,"%s",sEO_DIR);}
<TEMPLATE_ANALYSIS>"LC_EASEA" {fprintf(fpOutputFile,"%s",sLOWER_CASE_PROJECT_NAME);} <TEMPLATE_ANALYSIS>"LC_EASEA" {fprintf(fpOutputFile,"%s",sLOWER_CASE_PROJECT_NAME);}
<TEMPLATE_ANALYSIS>"\\OPERATING_SYSTEM" {switch (OPERATING_SYSTEM) { <TEMPLATE_ANALYSIS>"\\OPERATING_SYSTEM" {switch (OPERATING_SYSTEM) {
...@@ -164,7 +172,7 @@ exponent ([Ee][+-]?[0-9]+) ...@@ -164,7 +172,7 @@ exponent ([Ee][+-]?[0-9]+)
<TEMPLATE_ANALYSIS>"\\INSERT_BEGIN_GENERATION_FUNCTION" { <TEMPLATE_ANALYSIS>"\\INSERT_BEGIN_GENERATION_FUNCTION" {
DEBUG_PRT("insert beg"); //DEBUG_PRT_PRT("insert beg");
if (bVERBOSE) printf ("Inserting at the begining of each generation function.\n"); if (bVERBOSE) printf ("Inserting at the begining of each generation function.\n");
yyreset(); yyreset();
yyin = fpGenomeFile; yyin = fpGenomeFile;
...@@ -175,7 +183,7 @@ exponent ([Ee][+-]?[0-9]+) ...@@ -175,7 +183,7 @@ exponent ([Ee][+-]?[0-9]+)
<TEMPLATE_ANALYSIS>"\\INSERT_END_GENERATION_FUNCTION" { <TEMPLATE_ANALYSIS>"\\INSERT_END_GENERATION_FUNCTION" {
DEBUG_PRT("insert end"); //DEBUG_PRT_PRT("insert end");
if (bVERBOSE) printf ("Inserting at the end of each generation function.\n"); if (bVERBOSE) printf ("Inserting at the end of each generation function.\n");
yyreset(); yyreset();
yyin = fpGenomeFile; yyin = fpGenomeFile;
...@@ -207,21 +215,21 @@ exponent ([Ee][+-]?[0-9]+) ...@@ -207,21 +215,21 @@ exponent ([Ee][+-]?[0-9]+)
pGENOME->pSymbolList->reset(); pGENOME->pSymbolList->reset();
while (pSym=pGENOME->pSymbolList->walkToNextItem()) while (pSym=pGENOME->pSymbolList->walkToNextItem())
if ((pSym->Object->pType->ObjectType==oUserClass)&&(!pSym->Object->pType->bAlreadyPrinted)){ if ((pSym->Object->pType->ObjectType==oUserClass)&&(!pSym->Object->pType->bAlreadyPrinted)){
DEBUG_PRT("%p",pSym->Object->pType); //DEBUG_PRT_PRT("%p",pSym->Object->pType);
pSym->Object->pType->printClasses(fpOutputFile); pSym->Object->pType->printClasses(fpOutputFile);
} }
if( TARGET == CUDA ){ if( TARGET == CUDA ){
DEBUG_PRT("User classes are :"); //DEBUG_PRT_PRT("User classes are :");
for( int i = nClasses_nb-1 ; i>=0 ; i-- ){ for( int i = nClasses_nb-1 ; i>=0 ; i-- ){
DEBUG_PRT(" %s, %p ,%d| ",pCLASSES[i]->sName,pCLASSES[i],pCLASSES[i]->bAlreadyPrinted); //DEBUG_PRT_PRT(" %s, %p ,%d| ",pCLASSES[i]->sName,pCLASSES[i],pCLASSES[i]->bAlreadyPrinted);
if( !pCLASSES[i]->bAlreadyPrinted ){ if( !pCLASSES[i]->bAlreadyPrinted ){
fprintf(fpOutputFile,"// User class not refereced by the Genome"); fprintf(fpOutputFile,"// User class not refereced by the Genome");
pCLASSES[i]->printClasses(fpOutputFile); pCLASSES[i]->printClasses(fpOutputFile);
} }
} }
DEBUG_PRT("\n"); //DEBUG_PRT_PRT("\n");
} }
} }
<TEMPLATE_ANALYSIS>"\\GENOME_CTOR" { <TEMPLATE_ANALYSIS>"\\GENOME_CTOR" {
...@@ -247,10 +255,10 @@ exponent ([Ee][+-]?[0-9]+) ...@@ -247,10 +255,10 @@ exponent ([Ee][+-]?[0-9]+)
CListItem<CSymbol*> *pSym; CListItem<CSymbol*> *pSym;
pGENOME->pSymbolList->reset(); pGENOME->pSymbolList->reset();
while (pSym=pGENOME->pSymbolList->walkToNextItem()){ while (pSym=pGENOME->pSymbolList->walkToNextItem()){
DEBUG_PRT("%s has size : %lu",pSym->Object->sName,pSym->Object->nSize); //DEBUG_PRT_PRT("%s has size : %lu",pSym->Object->sName,pSym->Object->nSize);
size_of_genome+=pSym->Object->nSize; size_of_genome+=pSym->Object->nSize;
} }
DEBUG_PRT("Total genome size is %lu",size_of_genome); //DEBUG_PRT_PRT("Total genome size is %lu",size_of_genome);
genomeSize = size_of_genome; genomeSize = size_of_genome;
genomeSizeValidity=true; genomeSizeValidity=true;
} }
...@@ -307,7 +315,7 @@ exponent ([Ee][+-]?[0-9]+) ...@@ -307,7 +315,7 @@ exponent ([Ee][+-]?[0-9]+)
if (bVERBOSE) printf ("Inserting default genome serializer.\n"); if (bVERBOSE) printf ("Inserting default genome serializer.\n");
pGENOME->pSymbolList->reset(); pGENOME->pSymbolList->reset();
while (pSym=pGENOME->pSymbolList->walkToNextItem()){ while (pSym=pGENOME->pSymbolList->walkToNextItem()){
DEBUG_PRT("found new symbol %s",pSym->Object->sName); //DEBUG_PRT_PRT("found new symbol %s",pSym->Object->sName);
fprintf(fpOutputFile," ar & %s;\n",pSym->Object->sName); fprintf(fpOutputFile," ar & %s;\n",pSym->Object->sName);
} }
} }
...@@ -652,19 +660,19 @@ exponent ([Ee][+-]?[0-9]+) ...@@ -652,19 +660,19 @@ exponent ([Ee][+-]?[0-9]+)
} }
<TEMPLATE_ANALYSIS>"\\INSERT_USER_CLASSES_DEFINITIONS" { <TEMPLATE_ANALYSIS>"\\INSERT_USER_CLASSES_DEFINITIONS" {
DEBUG_PRT("Inserting user classe definitions"); //DEBUG_PRT_PRT("Inserting user classe definitions");
pGENOME->printUserClasses(fpOutputFile); pGENOME->printUserClasses(fpOutputFile);
} }
<TEMPLATE_ANALYSIS>"\\SELECTOR" { <TEMPLATE_ANALYSIS>"\\SELECTOR" {
if( TARGET==CUDA || TARGET==STD){ if( TARGET==CUDA || TARGET==STD){
DEBUG_PRT("Selector is \"%s\" | Goal is %s",sSELECTOR,(nMINIMISE?"Minimize":"Maximize")); //DEBUG_PRT_PRT("Selector is \"%s\" | Goal is %s",sSELECTOR,(nMINIMISE?"Minimize":"Maximize"));
char* selectorClass = selectorDetermination(nMINIMISE,sSELECTOR); char* selectorClass = selectorDetermination(nMINIMISE,sSELECTOR);
if( !selectorClass ){ if( !selectorClass ){
fprintf(stderr,"Error %d : selection operator %s doesn't exist in CUDA/STD template\n",yylineno,sSELECTOR); fprintf(stderr,"Error %d : selection operator %s doesn't exist in CUDA/STD template\n",yylineno,sSELECTOR);
return -1; return -1;
} }
DEBUG_PRT("Created class is %s",selectorClass); //DEBUG_PRT_PRT("Created class is %s",selectorClass);
fprintf(fpOutputFile,"%s",selectorClass); fprintf(fpOutputFile,"%s",selectorClass);
} }
else fprintf(fpOutputFile,"%s",sSELECTOR); else fprintf(fpOutputFile,"%s",sSELECTOR);
...@@ -675,18 +683,18 @@ exponent ([Ee][+-]?[0-9]+) ...@@ -675,18 +683,18 @@ exponent ([Ee][+-]?[0-9]+)
<TEMPLATE_ANALYSIS>"\\OFF_SIZE" {fprintf(fpOutputFile,"%d",nOFF_SIZE);} <TEMPLATE_ANALYSIS>"\\OFF_SIZE" {fprintf(fpOutputFile,"%d",nOFF_SIZE);}
<TEMPLATE_ANALYSIS>"\\ELITE_SIZE" { <TEMPLATE_ANALYSIS>"\\ELITE_SIZE" {
fprintf(fpOutputFile,"%d",nELITE); fprintf(fpOutputFile,"%d",nELITE);
//DEBUG_PRT("elitism is %d, elite size is %d",bELITISM, nELITE); ////DEBUG_PRT_PRT("elitism is %d, elite size is %d",bELITISM, nELITE);
} }
<TEMPLATE_ANALYSIS>"\\RED_PAR" { <TEMPLATE_ANALYSIS>"\\RED_PAR" {
if( TARGET==CUDA || TARGET==STD){ if( TARGET==CUDA || TARGET==STD){
DEBUG_PRT("Parent reduction is \"%s\" | Goal is %s",sSELECTOR,(nMINIMISE?"Minimize":"Maximize")); //DEBUG_PRT_PRT("Parent reduction is \"%s\" | Goal is %s",sSELECTOR,(nMINIMISE?"Minimize":"Maximize"));
char* selectorClass = selectorDetermination(nMINIMISE,sSELECTOR); char* selectorClass = selectorDetermination(nMINIMISE,sSELECTOR);
if( !selectorClass ){ if( !selectorClass ){
fprintf(stderr,"Error %d : selection operator %s doesn't exist in CUDA/STD template\n",yylineno,sSELECTOR); fprintf(stderr,"Error %d : selection operator %s doesn't exist in CUDA/STD template\n",yylineno,sSELECTOR);
return -1; return -1;
} }
DEBUG_PRT("Created class is %s",selectorClass); //DEBUG_PRT_PRT("Created class is %s",selectorClass);
fprintf(fpOutputFile,"%s",selectorClass); fprintf(fpOutputFile,"%s",selectorClass);
} }
else fprintf(fpOutputFile,"%s",sRED_PAR); else fprintf(fpOutputFile,"%s",sRED_PAR);
...@@ -699,13 +707,13 @@ exponent ([Ee][+-]?[0-9]+) ...@@ -699,13 +707,13 @@ exponent ([Ee][+-]?[0-9]+)
} }
<TEMPLATE_ANALYSIS>"\\RED_OFF" { <TEMPLATE_ANALYSIS>"\\RED_OFF" {
if( TARGET==CUDA || TARGET==STD){ if( TARGET==CUDA || TARGET==STD){
DEBUG_PRT("Offspring reduction is \"%s\" | Goal is %s",sSELECTOR,(nMINIMISE?"Minimize":"Maximize")); //DEBUG_PRT_PRT("Offspring reduction is \"%s\" | Goal is %s",sSELECTOR,(nMINIMISE?"Minimize":"Maximize"));
char* selectorClass = selectorDetermination(nMINIMISE,sSELECTOR); char* selectorClass = selectorDetermination(nMINIMISE,sSELECTOR);
if( !selectorClass ){ if( !selectorClass ){
fprintf(stderr,"Error %d : selection operator %s doesn't exist in CUDA/STD template\n",yylineno,sSELECTOR); fprintf(stderr,"Error %d : selection operator %s doesn't exist in CUDA/STD template\n",yylineno,sSELECTOR);
return -1; return -1;
} }
DEBUG_PRT("Created class is %s",selectorClass); //DEBUG_PRT_PRT("Created class is %s",selectorClass);
fprintf(fpOutputFile,"%s",selectorClass); fprintf(fpOutputFile,"%s",selectorClass);
} }
else fprintf(fpOutputFile,"%s",sRED_OFF); else fprintf(fpOutputFile,"%s",sRED_OFF);
...@@ -717,17 +725,21 @@ exponent ([Ee][+-]?[0-9]+) ...@@ -717,17 +725,21 @@ exponent ([Ee][+-]?[0-9]+)
fprintf(fpOutputFile,"%s",sRED_OFF_PRM);} fprintf(fpOutputFile,"%s",sRED_OFF_PRM);}
<TEMPLATE_ANALYSIS>"\\RED_FINAL" { <TEMPLATE_ANALYSIS>"\\RED_FINAL" {
if( TARGET==CUDA || TARGET==STD){ if( TARGET==CUDA || TARGET==STD){
DEBUG_PRT("Replacement selector is \"%s\" | Goal is %s",sRED_FINAL,(nMINIMISE?"Minimize":"Maximize")); //DEBUG_PRT_PRT("Replacement selector is \"%s\" | Goal is %s",sRED_FINAL,(nMINIMISE?"Minimize":"Maximize"));
char* selectorClass = selectorDetermination(nMINIMISE,sRED_FINAL); char* selectorClass = selectorDetermination(nMINIMISE,sRED_FINAL);
if( !selectorClass ){ if( !selectorClass ){
fprintf(stderr,"Error %d : replacement operator %s doesn't exist in CUDA/TPL template\n",yylineno,sRED_FINAL); fprintf(stderr,"Error %d : replacement operator %s doesn't exist in CUDA/TPL template\n",yylineno,sRED_FINAL);
return -1; return -1;
} }
DEBUG_PRT("Created class is %s",selectorClass); //DEBUG_PRT_PRT("Created class is %s",selectorClass);
fprintf(fpOutputFile,"%s",selectorClass); fprintf(fpOutputFile,"%s",selectorClass);
} }
else fprintf(fpOutputFile,"%s",sRED_FINAL); else fprintf(fpOutputFile,"%s",sRED_FINAL);
} }
<TEMPLATE_ANALYSIS>"\\CUDA_RULE_DIR" {
if(OPERATING_SYSTEM=WINDOWS)
fprintf(fpOutputFile,"%s\\",getenv("NVSDKCUDA_ROOT"));
}
<TEMPLATE_ANALYSIS>"\\RED_FINAL_PRM" {fprintf(fpOutputFile,"%s",sRED_FINAL_PRM);} <TEMPLATE_ANALYSIS>"\\RED_FINAL_PRM" {fprintf(fpOutputFile,"%s",sRED_FINAL_PRM);}
<TEMPLATE_ANALYSIS>"\\SURV_PAR_SIZE" {fprintf(fpOutputFile,"%d",nSURV_PAR_SIZE);} <TEMPLATE_ANALYSIS>"\\SURV_PAR_SIZE" {fprintf(fpOutputFile,"%d",nSURV_PAR_SIZE);}
<TEMPLATE_ANALYSIS>"\\SURV_OFF_SIZE" {fprintf(fpOutputFile,"%d",nSURV_OFF_SIZE);} <TEMPLATE_ANALYSIS>"\\SURV_OFF_SIZE" {fprintf(fpOutputFile,"%d",nSURV_OFF_SIZE);}
...@@ -931,6 +943,15 @@ exponent ([Ee][+-]?[0-9]+) ...@@ -931,6 +943,15 @@ exponent ([Ee][+-]?[0-9]+)
fpOutputFile=fopen(sFileName,"w"); fpOutputFile=fopen(sFileName,"w");
} }
<TEMPLATE_ANALYSIS>"\\START_VISUAL_TPL" {
char sFileName[1000];
fclose(fpOutputFile);
strcpy(sFileName, sRAW_PROJECT_NAME);
strcat(sFileName,".vcproj");
if (bVERBOSE) printf("Creating %s...\n",sFileName);
fpOutputFile=fopen(sFileName,"w");
}
<TEMPLATE_ANALYSIS>"\\START_CUDA_MAKEFILE_TPL" { <TEMPLATE_ANALYSIS>"\\START_CUDA_MAKEFILE_TPL" {
char sFileName[1000]; char sFileName[1000];
char sPathName[1000]; char sPathName[1000];
...@@ -949,8 +970,12 @@ exponent ([Ee][+-]?[0-9]+) ...@@ -949,8 +970,12 @@ exponent ([Ee][+-]?[0-9]+)
if( fileNameLength != -1 ){ if( fileNameLength != -1 ){
// add "Makefile" at the end of path // add "Makefile" at the end of path
//char* cdn = get_current_dir_name(); //char* cdn = get_current_dir_name();
char cdn[4096]; char cdn[4096];
#ifdef WIN32
_getcwd(cdn,4096);
#else
getcwd(cdn,4096); getcwd(cdn,4096);
#endif
size_t cdnLength = strlen(cdn); size_t cdnLength = strlen(cdn);
strcpy(sFullFileName,cdn); strcpy(sFullFileName,cdn);
strcat(sFullFileName,"/\0"); strcat(sFullFileName,"/\0");
...@@ -959,17 +984,18 @@ exponent ([Ee][+-]?[0-9]+) ...@@ -959,17 +984,18 @@ exponent ([Ee][+-]?[0-9]+)
strncpy(sPathName,sRAW_PROJECT_NAME,fileNameLength); strncpy(sPathName,sRAW_PROJECT_NAME,fileNameLength);
strcpy(sPathName+fileNameLength,"/Makefile"); strcpy(sPathName+fileNameLength,"/Makefile");
DEBUG_PRT("PathName is %s",sPathName); //DEBUG_PRT_PRT("PathName is %s",sPathName);
DEBUG_PRT("FullFileName is %s",sFullFileName); //DEBUG_PRT_PRT("FullFileName is %s",sFullFileName);
// create a symbolic link from Makefile to EASEA.mak // create a symbolic link from Makefile to EASEA.mak
symlink(sFullFileName,sPathName); symlink(sFullFileName,sPathName);
} }
else{ else{
DEBUG_PRT("file name : %s",sFileName); //DEBUG_PRT_PRT("file name : %s",sFileName);
if( symlink(sFileName,"Makefile") ) perror("Symlink creation error "); if( symlink(sFileName,"Makefile") ) perror("Symlink creation error ");
} }
if (bVERBOSE){ if (bVERBOSE){
...@@ -981,7 +1007,7 @@ exponent ([Ee][+-]?[0-9]+) ...@@ -981,7 +1007,7 @@ exponent ([Ee][+-]?[0-9]+)
fprintf(stderr,"Error in %s creation\n",sFileName); fprintf(stderr,"Error in %s creation\n",sFileName);
exit(-1); exit(-1);
} }
} }
<TEMPLATE_ANALYSIS>"\\START_EVAL_TPL" { <TEMPLATE_ANALYSIS>"\\START_EVAL_TPL" {
...@@ -1147,7 +1173,7 @@ exponent ([Ee][+-]?[0-9]+) ...@@ -1147,7 +1173,7 @@ exponent ([Ee][+-]?[0-9]+)
break; break;
case STD: case STD:
case CUDA: case CUDA:
fprintf (fpOutputFile,"// Finalization function\nvoid EASEAFinalization(Population* population){"); fprintf (fpOutputFile,"// Finalization function\nvoid EASEAFinalization(CPopulation* population){");
break; break;
default: default:
fprintf (stderr," Error this template doesn't support finalization function "); fprintf (stderr," Error this template doesn't support finalization function ");
...@@ -1169,9 +1195,10 @@ exponent ([Ee][+-]?[0-9]+) ...@@ -1169,9 +1195,10 @@ exponent ([Ee][+-]?[0-9]+)
<COPY_END_GENERATION_FUNCTION>"\\At"[ \t\n]+"the"[ \t\n]+"end"[ \t\n]+"of"[ \t\n]+"each"[ \t\n]+"generation"[ \t\n]+"function"[ \t\n]*":" { <COPY_END_GENERATION_FUNCTION>"\\At"[ \t\n]+"the"[ \t\n]+"end"[ \t\n]+"of"[ \t\n]+"each"[ \t\n]+"generation"[ \t\n]+"function"[ \t\n]*":" {
DEBUG_PRT("at each end"); //DEBUG_PRT_PRT("at each end");
if( (TARGET==CUDA || TARGET==STD) ){ if( (TARGET==CUDA || TARGET==STD) ){
fprintf (fpOutputFile,"// Function called at each new generation\nvoid EASEAEndGenerationFunction(EvolutionaryAlgorithm* evolutionaryAlgorithm){\n"); fprintf (fpOutputFile,"{\n");
//fprintf (fpOutputFile,"// Function called at each new generation\nvoid EASEAEndGenerationFunction(EvolutionaryAlgorithm* evolutionaryAlgorithm){\n");
bFunction=1; bFunction=1;
bEndGenerationFunction = 1; bEndGenerationFunction = 1;
BEGIN COPY_USER_GENERATION; BEGIN COPY_USER_GENERATION;
...@@ -1192,9 +1219,9 @@ exponent ([Ee][+-]?[0-9]+) ...@@ -1192,9 +1219,9 @@ exponent ([Ee][+-]?[0-9]+)
<COPY_BEG_GENERATION_FUNCTION>"\\At"[ \t\n]+"the"[ \t\n]+"beginning"[ \t\n]+"of"[ \t\n]+"each"[ \t\n]+"generation"[ \t\n]+"function"[ \t\n]*":" { <COPY_BEG_GENERATION_FUNCTION>"\\At"[ \t\n]+"the"[ \t\n]+"beginning"[ \t\n]+"of"[ \t\n]+"each"[ \t\n]+"generation"[ \t\n]+"function"[ \t\n]*":" {
DEBUG_PRT("at each beg"); //DEBUG_PRT_PRT("at each beg");
if( (TARGET==CUDA || TARGET==STD)){ if( (TARGET==CUDA || TARGET==STD)){
fprintf (fpOutputFile,"// Function called at each new generation\nvoid EASEABeginningGenerationFunction(EvolutionaryAlgorithm* evolutionaryAlgorithm){\n"); fprintf (fpOutputFile,"{\n");
bFunction=1; bFunction=1;
bBeginGeneration = 0; bBeginGeneration = 0;
bBeginGenerationFunction = 1; bBeginGenerationFunction = 1;
...@@ -1217,7 +1244,7 @@ exponent ([Ee][+-]?[0-9]+) ...@@ -1217,7 +1244,7 @@ exponent ([Ee][+-]?[0-9]+)
<COPY_GENERATION_FUNCTION>"\\At"[ \t\n]+"each"[ \t\n]+"new"[ \t\n]+"generation"[ \t\n]*":" { <COPY_GENERATION_FUNCTION>"\\At"[ \t\n]+"each"[ \t\n]+"new"[ \t\n]+"generation"[ \t\n]*":" {
DEBUG_PRT("at each"); //DEBUG_PRT_PRT("at each");
if( TARGET==GALIB ){ if( TARGET==GALIB ){
fprintf (fpOutputFile,"// Function called at each new generation\n\nvoid EASEAGenerationFunction(GAGeneticAlgorithm & g){\n"); fprintf (fpOutputFile,"// Function called at each new generation\n\nvoid EASEAGenerationFunction(GAGeneticAlgorithm & g){\n");
fprintf(fpOutputFile," const GAPopulation *pPopulation;\n",sPROJECT_NAME); fprintf(fpOutputFile," const GAPopulation *pPopulation;\n",sPROJECT_NAME);
...@@ -1482,7 +1509,7 @@ exponent ([Ee][+-]?[0-9]+) ...@@ -1482,7 +1509,7 @@ exponent ([Ee][+-]?[0-9]+)
//**************************************** //****************************************
<COPY_DISPLAY>"\\GenomeClass::display"[ \t\n]*":" { <COPY_DISPLAY>"\\GenomeClass::display"[ \t\n]*":" {
/* DEBUG_PRT("Display function is at %d line in %s.ez",yylineno,sRAW_PROJECT_NAME); */ /* //DEBUG_PRT_PRT("Display function is at %d line in %s.ez",yylineno,sRAW_PROJECT_NAME); */
/* fprintf(fpOutputFile,"\n#line %d \"%s.ez\"\n",yylineno,sRAW_PROJECT_NAME); */ /* fprintf(fpOutputFile,"\n#line %d \"%s.ez\"\n",yylineno,sRAW_PROJECT_NAME); */
bDisplayFunction=bWithinDisplayFunction=1; bDisplayFunction=bWithinDisplayFunction=1;
BEGIN COPY_USER_FUNCTION; BEGIN COPY_USER_FUNCTION;
...@@ -1497,7 +1524,7 @@ exponent ([Ee][+-]?[0-9]+) ...@@ -1497,7 +1524,7 @@ exponent ([Ee][+-]?[0-9]+)
<COPY_DISPLAY>.|\n {} <COPY_DISPLAY>.|\n {}
<COPY_MAKEFILE_OPTION>"\\User"[ \t\n]+[Mm]"akefile"[ \t\n]+"options"[ \t\n]*":" { <COPY_MAKEFILE_OPTION>"\\User"[ \t\n]+[Mm]"akefile"[ \t\n]+"options"[ \t\n]*":" {
DEBUG_PRT("LDFLAGS is beg: %s",yytext); //DEBUG_PRT_PRT("LDFLAGS is beg: %s",yytext);
bWithinMAKEFILEOPTION=1; bWithinMAKEFILEOPTION=1;
return MAKEFILE_OPTION; return MAKEFILE_OPTION;
} }
...@@ -1509,7 +1536,7 @@ exponent ([Ee][+-]?[0-9]+) ...@@ -1509,7 +1536,7 @@ exponent ([Ee][+-]?[0-9]+)
//**************************************** //****************************************
<COPY_MAKEFILE_OPTION>"\\end" { <COPY_MAKEFILE_OPTION>"\\end" {
if( bWithinMAKEFILEOPTION ){ if( bWithinMAKEFILEOPTION ){
DEBUG_PRT("end of makefile options"); //DEBUG_PRT_PRT("end of makefile options");
yyin = fpTemplateFile; yyin = fpTemplateFile;
bWithinMAKEFILEOPTION = 0; bWithinMAKEFILEOPTION = 0;
BEGIN TEMPLATE_ANALYSIS; BEGIN TEMPLATE_ANALYSIS;
...@@ -1528,7 +1555,7 @@ exponent ([Ee][+-]?[0-9]+) ...@@ -1528,7 +1555,7 @@ exponent ([Ee][+-]?[0-9]+)
} }
<COPY_MAKEFILE_OPTION><<EOF>> { <COPY_MAKEFILE_OPTION><<EOF>> {
DEBUG_PRT("No makefile options defined."); //DEBUG_PRT_PRT("No makefile options defined.");
yyin = fpTemplateFile; yyin = fpTemplateFile;
bWithinMAKEFILEOPTION = 0; bWithinMAKEFILEOPTION = 0;
...@@ -1918,7 +1945,7 @@ exponent ([Ee][+-]?[0-9]+) ...@@ -1918,7 +1945,7 @@ exponent ([Ee][+-]?[0-9]+)
if (TARGET==DREAM) fprintf(fpOutputFile,"Math.random()<");} // local random name if (TARGET==DREAM) fprintf(fpOutputFile,"Math.random()<");} // local random name
<COPY_USER_FUNCTION>"random" { <COPY_USER_FUNCTION>"random" {
if (TARGET==DREAM) fprintf(fpOutputFile,"%s.random",sPROJECT_NAME); if (TARGET==DREAM) fprintf(fpOutputFile,"%s.random",sPROJECT_NAME);
else if( TARGET==CUDA || TARGET==STD) fprintf(fpOutputFile,"rg->random"); else if( TARGET==CUDA || TARGET==STD) fprintf(fpOutputFile,"globalRandomGenerator->random");
else fprintf(fpOutputFile,"random");} else fprintf(fpOutputFile,"random");}
<COPY_USER_FUNCTION>"child1" {if ((bWithinXover)&&(TARGET==GALIB)) fprintf(fpOutputFile, "(*pBro)"); <COPY_USER_FUNCTION>"child1" {if ((bWithinXover)&&(TARGET==GALIB)) fprintf(fpOutputFile, "(*pBro)");
else fprintf(fpOutputFile,"child1"); else fprintf(fpOutputFile,"child1");
...@@ -2092,10 +2119,10 @@ int CEASEALexer::create(CEASEAParser* pParser, CSymbolTable* pSymTable) ...@@ -2092,10 +2119,10 @@ int CEASEALexer::create(CEASEAParser* pParser, CSymbolTable* pSymTable)
char sTemp[1000]; char sTemp[1000];
#if defined UNIX_OS #if defined UNIX_OS
OPERATING_SYSTEM=UNIX; OPERATING_SYSTEM=UNIX;
#elif defined WINDOWS_OS #elif defined WIN32 //WINDOWS_OS
OPERATING_SYSTEM=WINDOWS; OPERATING_SYSTEM=WINDOWS;
#else //#else
OPERATING_SYSTEM=OTHER_SYSTEM; // OPERATING_SYSTEM=OTHER_SYSTEM;
#endif #endif
assert(pParser != NULL); assert(pParser != NULL);
assert(pSymTable != NULL); assert(pSymTable != NULL);
...@@ -2130,17 +2157,23 @@ int CEASEALexer::create(CEASEAParser* pParser, CSymbolTable* pSymTable) ...@@ -2130,17 +2157,23 @@ int CEASEALexer::create(CEASEAParser* pParser, CSymbolTable* pSymTable)
//strcpy(sTemp,"e:\\lutton\\easea\\debug");pour tester sous windows //strcpy(sTemp,"e:\\lutton\\easea\\debug");pour tester sous windows
if ((sEZ_PATH==NULL)||(sEZ_PATH[0]==0)) { if ((sEZ_PATH==NULL)||(sEZ_PATH[0]==0)) {
if (getenv("EZ_PATH")==NULL){ if (getenv("EZ_PATH")==NULL){
strcpy(sEZ_PATH,"./tpl/"); //strcpy(sEZ_PATH,"./tpl/");
strcpy(sEZ_PATH,"./");
}else }else
strcpy(sEZ_PATH,getenv("EZ_PATH")); strcpy(sEZ_PATH,getenv("EZ_PATH"));
} }
strcpy(sTPL_DIR,sEZ_PATH);
strcat(sTPL_DIR,"tpl/");
switch (OPERATING_SYSTEM) { switch (OPERATING_SYSTEM) {
case UNIX : if (sEZ_PATH[strlen(sEZ_PATH)-1] != '/') strcat (sEZ_PATH,"./"); break; case UNIX : if (sEZ_PATH[strlen(sEZ_PATH)-1] != '/') strcat (sEZ_PATH,"./"); break;
case WINDOWS : if (sEZ_PATH[strlen(sEZ_PATH)-1] != '\\') strcat (sEZ_PATH,"\\"); break; case WINDOWS : if (sEZ_PATH[strlen(sEZ_PATH)-1] != '\\') strcat (sEZ_PATH,"\\"); break;
case UNKNOWN_OS : fprintf(fpOutputFile,"UNKNOWN_OS"); break; case UNKNOWN_OS : fprintf(fpOutputFile,"UNKNOWN_OS"); break;
} }
strcpy(sTemp,sEZ_PATH); //strcpy(sTemp,sEZ_PATH);
strcpy(sTemp,sTPL_DIR);
if (TARGET==EO){ if (TARGET==EO){
strcat(sTemp,"EO.tpl"); strcat(sTemp,"EO.tpl");
if (!(yyin = fpTemplateFile = fopen(sTemp, "r"))){ if (!(yyin = fpTemplateFile = fopen(sTemp, "r"))){
......
...@@ -25,6 +25,7 @@ char sLOWER_CASE_PROJECT_NAME[1000]; ...@@ -25,6 +25,7 @@ char sLOWER_CASE_PROJECT_NAME[1000];
char sEZ_FILE_NAME[1000]; char sEZ_FILE_NAME[1000];
char sEO_DIR[1000]; char sEO_DIR[1000];
char sEZ_PATH[1000]; char sEZ_PATH[1000];
char sTPL_DIR[1000];
int TARGET,TARGET_FLAVOR; int TARGET,TARGET_FLAVOR;
int OPERATING_SYSTEM; int OPERATING_SYSTEM;
int nWARNINGS=0; int nWARNINGS=0;
...@@ -235,12 +236,12 @@ ClassDeclaration ...@@ -235,12 +236,12 @@ ClassDeclaration
pCURRENT_CLASS=SymbolTable.insert($1); pCURRENT_CLASS=SymbolTable.insert($1);
pCURRENT_CLASS->pSymbolList=new CLList<CSymbol *>(); pCURRENT_CLASS->pSymbolList=new CLList<CSymbol *>();
$1->ObjectType=oUserClass; $1->ObjectType=oUserClass;
DEBUG_PRT("Yacc Symbol declaration %s %d",$1->sName,$1->nSize); //DEBUG_PRT("Yacc Symbol declaration %s %d",$1->sName,$1->nSize);
pCLASSES[nClasses_nb++] = $1; pCLASSES[nClasses_nb++] = $1;
} }
'{' VariablesDeclarations '}' { '{' VariablesDeclarations '}' {
if (bVERBOSE) printf("Class %s declared for %d bytes.\n\n",$1->sName,$1->nSize); if (bVERBOSE) printf("Class %s declared for %d bytes.\n\n",$1->sName,$1->nSize);
DEBUG_PRT("Yacc variable declaration %s %d",$1->sName,$1->nSize); //DEBUG_PRT("Yacc variable declaration %s %d",$1->sName,$1->nSize);
} }
; ;
...@@ -387,7 +388,7 @@ BaseConstructorParameter ...@@ -387,7 +388,7 @@ BaseConstructorParameter
GenomeDeclarationSection GenomeDeclarationSection
: GENOME { : GENOME {
//DEBUG_PRT("Yacc genome decl %s",$1.pSymbol->sName); ////DEBUG_PRT("Yacc genome decl %s",$1.pSymbol->sName);
if (bVERBOSE) printf ("\nGenome declaration analysis :\n\n"); if (bVERBOSE) printf ("\nGenome declaration analysis :\n\n");
pGENOME=new CSymbol("Genome"); pGENOME=new CSymbol("Genome");
pCURRENT_CLASS=SymbolTable.insert(pGENOME); pCURRENT_CLASS=SymbolTable.insert(pGENOME);
...@@ -499,7 +500,7 @@ StandardFunctionAnalysis ...@@ -499,7 +500,7 @@ StandardFunctionAnalysis
if (TARGET!=EO && TARGET!=CUDA && TARGET!=STD) fprintf(fpOutputFile,"}\n"); if (TARGET!=EO && TARGET!=CUDA && TARGET!=STD) fprintf(fpOutputFile,"}\n");
} }
| MAKEFILE_OPTION END_OF_FUNCTION { | MAKEFILE_OPTION END_OF_FUNCTION {
DEBUG_PRT("User makefile options have been reduced"); //DEBUG_PRT("User makefile options have been reduced");
} }
| MAKEFILE_OPTION {} | MAKEFILE_OPTION {}
; ;
...@@ -993,7 +994,7 @@ Parameter ...@@ -993,7 +994,7 @@ Parameter
if (!mystricmp(sRED_FINAL,"Tournament")||!mystricmp(sRED_FINAL,"StochTrn")) { if (!mystricmp(sRED_FINAL,"Tournament")||!mystricmp(sRED_FINAL,"StochTrn")) {
if ($3>=2) { if ($3>=2) {
sprintf(sRED_FINAL,"DetTour");sprintf(sRED_FINAL_PRM,"(%d)",(int) $3); sprintf(sRED_FINAL,"DetTour");sprintf(sRED_FINAL_PRM,"(%d)",(int) $3);
DEBUG_PRT("tournament parameter is %s",sRED_FINAL_PRM); //DEBUG_PRT("tournament parameter is %s",sRED_FINAL_PRM);
} }
else if (($3>.5)&&($3<=1.0)) {sprintf(sRED_FINAL,"StochTour");sprintf(sRED_FINAL_PRM,"(%f)",(float) $3);} else if (($3>.5)&&($3<=1.0)) {sprintf(sRED_FINAL,"StochTour");sprintf(sRED_FINAL_PRM,"(%f)",(float) $3);}
else {fprintf(stderr,"\n%s - Error line %d: The parameter of the Tournament selector must be either >=2 or within ]0.5, 1].\n",sEZ_FILE_NAME,EASEALexer.yylineno); exit(1);} else {fprintf(stderr,"\n%s - Error line %d: The parameter of the Tournament selector must be either >=2 or within ]0.5, 1].\n",sEZ_FILE_NAME,EASEALexer.yylineno); exit(1);}
......
#ifdef WIN32
#define _CRT_SECURE_NO_WARNINGS
#endif
/**************************************************************************** /****************************************************************************
EaseaSym.cpp EaseaSym.cpp
Symbol table and other functions for the EASEA language (EAsy Specification for Evolutionary Algorithms) Symbol table and other functions for the EASEA language (EAsy Specification for Evolutionary Algorithms)
...@@ -97,7 +100,7 @@ void CSymbol::print(FILE *fp){ ...@@ -97,7 +100,7 @@ void CSymbol::print(FILE *fp){
bool isFlatClass = true; bool isFlatClass = true;
pSymbolList->reset(); pSymbolList->reset();
while (pSym=pSymbolList->walkToNextItem()){ while (pSym=pSymbolList->walkToNextItem()){
DEBUG_PRT("analyse flat %s",pSym->Object->pType->sName); //DEBUG_PRT("analyse flat %s",pSym->Object->pType->sName);
if( (pSym->Object->ObjectType == oPointer) ){ //|| (pSym->Object->pType->ObjectType == oObject) ){ if( (pSym->Object->ObjectType == oPointer) ){ //|| (pSym->Object->pType->ObjectType == oObject) ){