Commit 5e92cb68 authored by moh_lo's avatar moh_lo

Revert "Compilable version"

This reverts commit 7ff04c0e.
parent 7ff04c0e
File mode changed from 100644 to 100755
This diff is collapsed.
#ifndef _EASEALEX_H
#define _EASEALEX_H
#include <clex.h>
#line 17 "C:\\repo\\src\\EaseaLex.l"
// forward references
class CEASEAParser;
class CSymbolTable;
#line 13 "C:\\repo\\src\\EaseaLex.h"
#define GENOME_ANALYSIS 2
#define TEMPLATE_ANALYSIS 4
#define MACRO_IDENTIFIER 6
#define MACRO_DEFINITION 8
#define COPY_USER_DECLARATIONS 10
#define COPY_INITIALISATION_FUNCTION 12
#define ANALYSE_USER_CLASSES 14
#define COPY_EO_INITIALISER 16
#define COPY 18
#define COPY_INITIALISER 20
#define COPY_CROSSOVER 22
#define COPY_MUTATOR 24
#define COPY_EVALUATOR 26
#define COPY_DISPLAY 28
#define COPY_USER_FUNCTION 30
#define COPY_USER_GENERATION 32
#define PARAMETERS_ANALYSIS 34
#define GET_PARAMETERS 36
#define COPY_USER_FUNCTIONS 38
#define COPY_GENERATION_FUNCTION 40
#define GET_METHODS 42
/////////////////////////////////////////////////////////////////////////////
// CEASEALexer
#ifndef YYDECLSPEC
#define YYDECLSPEC
#endif
class YYFAR YYDECLSPEC CEASEALexer : public yyflexer {
public:
CEASEALexer();
protected:
void yytables();
virtual int yyaction(int action);
public:
#line 31 "C:\\repo\\src\\EaseaLex.l"
protected:
CSymbolTable *pSymbolTable; // the symbol table
bool bSymbolInserted,bWithinEvaluator; // used to change evalutor type from double to float
bool bInitFunction,bDisplayFunction,bFunction, bNotFinishedYet, bWithinEO_Function;
bool bDoubleQuotes,bWithinDisplayFunction,bWithinInitialiser,bWithinMutator,bWithinXover;
bool bWaitingForSemiColon,bFinishNB_GEN,bFinishMINIMISE,bFinishMINIMIZE,bGenerationFunction;
bool bCatchNextSemiColon,bWaitingToClosePopulation, bMethodsInGenome;
CSymbol *pASymbol;
public:
int create(CEASEAParser* pParser, CSymbolTable* pSymbolTable);
int yywrap();
double myStrtod() const;
#line 67 "C:\\repo\\src\\EaseaLex.h"
};
#ifndef YYLEXNAME
#define YYLEXNAME CEASEALexer
#endif
#ifndef INITIAL
#define INITIAL 0
#endif
#endif
%{
/****************************************************************************
/****************************************************************************
EaseaLex.l
Lexical analyser for the EASEA language (EAsy Specification for Evolutionary Algorithms)
......@@ -7,49 +7,49 @@ Pierre COLLET (Pierre.Collet@polytechnique.fr)
Ecole Polytechnique
Centre de Mathmatiques Appliques
91128 Palaiseau cedex
****************************************************************************/
****************************************************************************/
#include "Easea.h"
#include "EaseaParse.h"
%}
%}
// include file
%include {
// forward references
class CEASEAParser;
class CSymbolTable;
}
// forward references
class CEASEAParser;
class CSymbolTable;
}
%start GENOME_ANALYSIS TEMPLATE_ANALYSIS MACRO_IDENTIFIER MACRO_DEFINITION
%start COPY_USER_DECLARATIONS COPY_INITIALISATION_FUNCTION ANALYSE_USER_CLASSES
%start COPY_EO_INITIALISER
%start COPY COPY_INITIALISER COPY_CROSSOVER COPY_MUTATOR COPY_EVALUATOR
%start COPY_DISPLAY COPY_USER_FUNCTION COPY_USER_GENERATION PARAMETERS_ANALYSIS GET_PARAMETERS
%start COPY_USER_FUNCTIONS COPY_GENERATION_FUNCTION
%start COPY_USER_FUNCTIONS COPY_GENERATION_FUNCTION GET_METHODS
// lexical analyser name and class definition
// lexical analyser name and class definition
%name CEASEALexer {
protected:
protected:
CSymbolTable *pSymbolTable; // the symbol table
bool bSymbolInserted,bWithinEvaluator; // used to change evalutor type from double to float
bool bInitFunction,bDisplayFunction,bFunction, bNotFinishedYet, bWithinEO_Function;
bool bDoubleQuotes,bWithinDisplayFunction,bWithinInitialiser,bWithinMutator,bWithinXover;
bool bWaitingForSemiColon,bFinishNB_GEN,bFinishMINIMISE,bFinishMINIMIZE,bGenerationFunction;
bool bCatchNextSemiColon,bWaitingToClosePopulation;
bool bCatchNextSemiColon,bWaitingToClosePopulation, bMethodsInGenome;
CSymbol *pASymbol;
public:
public:
int create(CEASEAParser* pParser, CSymbolTable* pSymbolTable);
int yywrap();
double myStrtod() const;
}
}
// constructor
{
bFunction=bWithinEvaluator=bDisplayFunction=bInitFunction=bNotFinishedYet=0;
bSymbolInserted=bDoubleQuotes=bWithinDisplayFunction=bWithinInitialiser=bWithinMutator=bWithinXover=0;
bWaitingForSemiColon=bFinishNB_GEN=bFinishMINIMISE=bFinishMINIMIZE=bGenerationFunction=0;
bCatchNextSemiColon,bWaitingToClosePopulation=0;
bFunction=bWithinEvaluator=bDisplayFunction=bInitFunction=bNotFinishedYet=0;
bSymbolInserted=bDoubleQuotes=bWithinDisplayFunction=bWithinInitialiser=bWithinMutator=bWithinXover=0;
bWaitingForSemiColon=bFinishNB_GEN=bFinishMINIMISE=bFinishMINIMIZE=bGenerationFunction=0;
bCatchNextSemiColon,bWaitingToClosePopulation=bMethodsInGenome=0;
}
// macros
......@@ -58,9 +58,9 @@ exponent ([Ee][+-]?[0-9]+)
%%
%{
// extract yylval for use later on in actions
YYSTYPE& yylval = *(YYSTYPE*)yyparserptr->yylvalptr;
%}
// extract yylval for use later on in actions
YYSTYPE& yylval = *(YYSTYPE*)yyparserptr->yylvalptr;
%}
// Gobbles up ^Ms, to be compatible with unix
\r {}
......@@ -142,6 +142,11 @@ YYSTYPE& yylval = *(YYSTYPE*)yyparserptr->yylvalptr;
}
}
<TEMPLATE_ANALYSIS>"\\INSERT_GENOME" {
if (pGENOME->sString) {
if (bVERBOSE) printf ("Inserting Methods into Genome Class.\n");
fprintf(fpOutputFile,"// User-defined methods:\n\n");
fprintf(fpOutputFile,"%s\n",pGENOME->sString);
}
if (bVERBOSE) printf ("Inserting genome.\n");
pGENOME->print(fpOutputFile);
}
......@@ -528,7 +533,7 @@ YYSTYPE& yylval = *(YYSTYPE*)yyparserptr->yylvalptr;
if (bVERBOSE) printf("Creating %s...\n",sFileName);
fpOutputFile=fopen(sFileName,"w");
}
<TEMPLATE_ANALYSIS>"\\START" {
<TEMPLATE_ANALYSIS>"\\START_EVAL_TPL" {
char sFileName[1000];
fclose(fpOutputFile);
strcpy(sFileName, sRAW_PROJECT_NAME);
......@@ -584,6 +589,14 @@ YYSTYPE& yylval = *(YYSTYPE*)yyparserptr->yylvalptr;
if (bVERBOSE) printf("Creating %s...\n",sFileName);
fpOutputFile=fopen(sFileName,"w");
}
<TEMPLATE_ANALYSIS>"\\START_ISLAND_TPL" {
char sFileName[1000];
fclose(fpOutputFile);
strcpy(sFileName, sRAW_PROJECT_NAME);
strcat(sFileName,"Island.java");
if (bVERBOSE) printf("Creating %s...\n",sFileName);
fpOutputFile=fopen(sFileName,"w");
}
<TEMPLATE_ANALYSIS>"\\TEMPLATE_END" {
if (nWARNINGS) printf ("\nWARNING !!!\nTarget file(s) generation went through WITH %d WARNING(S) !\n",nWARNINGS);
else printf ("\nCONGRATULATIONS !!!\nTarget file(s) generation succeeded with no warning.\n");
......@@ -752,6 +765,12 @@ YYSTYPE& yylval = *(YYSTYPE*)yyparserptr->yylvalptr;
else fprintf(fpOutputFile,"Genome");} // local genome name
<COPY>"identicalGenome" {fprintf(fpOutputFile,"genome._evaluated");} // local name
<COPY>"#define"[ \t]* {fprintf(fpOutputFile,"%s",yytext); BEGIN MACRO_IDENTIFIER;}
<COPY>[a-zA-Z0-9_]*[ \t]+"GenomeClass::" {
int i;
for (i=0;(yytext[i]!=' ')&&(yytext[i]!=' ');i++);
yytext[i]=0;
fprintf(fpOutputFile,"template <class fitT> %s %sGenome<fitT>::",yytext,sPROJECT_NAME);}
<COPY>"GenomeClass::" {fprintf(fpOutputFile,"template <class fitT> %sGenome<fitT>::",sPROJECT_NAME);}
<COPY>"GenomeClass" {if (TARGET==EO) fprintf(fpOutputFile,"Indi");
else fprintf(fpOutputFile,"%sGenome",sPROJECT_NAME);} // local name
<COPY>"\\end" {if (bFunction==1) {fprintf (fpOutputFile,"}\n"); bFunction=0;}
......@@ -802,6 +821,14 @@ YYSTYPE& yylval = *(YYSTYPE*)yyparserptr->yylvalptr;
<GENOME_ANALYSIS>"bool" {if (TARGET!=DREAM) yylval.pSymbol = pSymbolTable->find("bool");
else yylval.pSymbol = pSymbolTable->find("boolean");
return BOOL;}
<GENOME_ANALYSIS>"boolean" {if (TARGET==DREAM){
yylval.pSymbol = pSymbolTable->find("boolean");
return BOOL;
}
else {
yylval.pSymbol = new CSymbol(yytext);
return IDENTIFIER;
} }
<GENOME_ANALYSIS>"static" {return STATIC;}
<GENOME_ANALYSIS>"int" {yylval.pSymbol = pSymbolTable->find("int"); return INT;}
<GENOME_ANALYSIS>"double" {yylval.pSymbol = pSymbolTable->find("double"); return DOUBLE;}
......@@ -812,6 +839,10 @@ YYSTYPE& yylval = *(YYSTYPE*)yyparserptr->yylvalptr;
<GENOME_ANALYSIS>"GenomeClass" {return GENOME; }
<GENOME_ANALYSIS>"Methods:" {BEGIN GET_METHODS;
yylval.szString=yytext;
bMethodsInGenome=1;
return METHODS;}
// number
<GENOME_ANALYSIS>[0-9]+"."[0-9]*{exponent}? |
<GENOME_ANALYSIS>"."[0-9]+{exponent}? |
......@@ -821,6 +852,7 @@ YYSTYPE& yylval = *(YYSTYPE*)yyparserptr->yylvalptr;
// identifier
<GENOME_ANALYSIS>[a-zA-Z_][a-zA-Z0-9_]* { yylval.pSymbol = new CSymbol(yytext);
return IDENTIFIER; }
<GET_METHODS>[^\}]* {BEGIN GENOME_ANALYSIS; return END_METHODS;}
//****************************************
// Looking for a user-supplied display function.
......@@ -1133,7 +1165,7 @@ YYSTYPE& yylval = *(YYSTYPE*)yyparserptr->yylvalptr;
//****************************************
<PARAMETERS_ANALYSIS>"\\Default run"[ \t\n]+"parameters"[ \t\n]*":" {
if (bVERBOSE) printf ("Analysing parameters.\n");
if (bVERBOSE) printf ("Analysing parameters...\n");
BEGIN GET_PARAMETERS;
}
<PARAMETERS_ANALYSIS>.|\n {}
......@@ -1148,32 +1180,32 @@ YYSTYPE& yylval = *(YYSTYPE*)yyparserptr->yylvalptr;
<GET_PARAMETERS>^[ \t]*\n { /*return '\n';*/ }
<GET_PARAMETERS>\n { /*return '\n';*/ }
<GET_PARAMETERS>"Number"[ \t\n]+"of"[ \t\n]+"generations"[ \t\n]*":"[ \t\n]* {return NB_GEN;}
<GET_PARAMETERS>"Number"[ \t\n]+"of"[ \t\n]+"islands"[ \t\n]*":"[ \t\n]* {return NB_ISLANDS;}
<GET_PARAMETERS>"Operators"[ \t\n]+"are"[ \t\n]+"called"[ \t\n]*":"[ \t\n]* {return PROP_SEQ;}
<GET_PARAMETERS>"Evolutionary"[ \t\n]+"engine"[ \t\n]*":"[ \t\n]* {return REPLACEMENT;}
<GET_PARAMETERS>"Population"[ \t\n]+"size"[ \t\n]*":"[ \t\n]* {return POP_SIZE;}
<GET_PARAMETERS>"Elite"[ \t\n]*":"[ \t\n]* {return ELITE;}
<GET_PARAMETERS>"Fertility"[ \t\n]*":"[ \ta-zA-Z0-9_]* {}
<GET_PARAMETERS>"Genitors"[ \t\n]+"selector"[ \t\n]*":"[ \t\n]* {return SELECTOR;}
<GET_PARAMETERS>"Selected"[ \t\n]+"genitors"[ \t\n]*":"[ \ta-zA-Z0-9_]* {}
<GET_PARAMETERS>"Mutation"[ \t\n]+"probability"[ \t\n]*":"[ \t\n]* {return MUT_PROB;}
<GET_PARAMETERS>"Crossover"[ \t\n]+"probability"[ \t\n]*":"[ \t\n]* {return XOVER_PROB;}
<GET_PARAMETERS>"Offspring"[ \t\n]+"size"[ \t\n]*":"[ \t\n]* {return OFFSPRING;}
<GET_PARAMETERS>"Reduce"[ \t\n]+"parents"[ \t\n]*":"[ \t\n]* {return RED_PAR;}
<GET_PARAMETERS>"Surviving"[ \t\n]+"parents"[ \t\n]*":"[ \t\n]* {return SURVPAR;}
<GET_PARAMETERS>"Reduce"[ \t\n]+"offspring"[ \t\n]*":"[ \t\n]* {return RED_OFF;}
<GET_PARAMETERS>"Surviving"[ \t\n]+"offspring"[ \t\n]*":"[ \t\n]* {return SURVOFF;}
<GET_PARAMETERS>"Final"[ \t\n]+"reduce"[ \t\n]*":"[ \t\n]* {return RED_FINAL;}// DISCARD;}
<GET_PARAMETERS>"Elitism"[ \t\n]*":" {return ELITISM;}
<GET_PARAMETERS>"Evaluator"[ \t\n]+"goal"[ \t\n]*":"[ \t\n]* {return MINIMAXI;}
<GET_PARAMETERS>"Emigration"[ \t\n]+"policy"[ \t\n]*":"[ \t\n]* {return MIG_CLONE;}
<GET_PARAMETERS>"Migrants"[ \t\n]+"selector"[ \t\n]*":"[ \t\n]* {return MIG_SEL;}
<GET_PARAMETERS>"Migrants"[ \t\n]+"destination"[ \t\n]*":"[ \t\n]* {return MIGRATOR;}
<GET_PARAMETERS>"Migration"[ \t\n]+"frequency"[ \t\n]*":"[ \t\n]* {return MIG_FREQ;}
<GET_PARAMETERS>"Number"[ \t\n]+"of"[ \t\n]+"emigrants"[ \t\n]*":"[ \t\n]* {return NB_MIG;}
<GET_PARAMETERS>"Immigration"[ \t\n]+"replacement"[ \t\n]*":"[ \t\n]* {return IMMIG_SEL;}
<GET_PARAMETERS>"Immigration"[ \t\n]+"policy"[ \t\n]*":"[ \t\n]* {return IMMIG_REPL;}
<GET_PARAMETERS>"Number"[ \t\n]+"of"[ \t\n]+"generations"[ \t\n]*":"[ \t\n]* {if (bVERBOSE) printf ("\tNb of Gen...\n");return NB_GEN;}
<GET_PARAMETERS>"Number"[ \t\n]+"of"[ \t\n]+"islands"[ \t\n]*":"[ \t\n]* {if (bVERBOSE) printf ("\tNb of Isl...\n");return NB_ISLANDS;}
<GET_PARAMETERS>"Operators"[ \t\n]+"are"[ \t\n]+"called"[ \t\n]*":"[ \t\n]* {if (bVERBOSE) printf ("\tOp Seq...\n");return PROP_SEQ;}
<GET_PARAMETERS>"Evolutionary"[ \t\n]+"engine"[ \t\n]*":"[ \t\n]* {if (bVERBOSE) printf ("\tEvol Engine...\n");return REPLACEMENT;}
<GET_PARAMETERS>"Population"[ \t\n]+"size"[ \t\n]*":"[ \t\n]* {if (bVERBOSE) printf ("\tPop Size...\n");return POP_SIZE;}
<GET_PARAMETERS>"Elite"[ \t\n]*":"[ \t\n]* {if (bVERBOSE) printf ("\tElite Size...\n");return ELITE;}
<GET_PARAMETERS>"Fertility"[ \t\n]*":"[ \ta-zA-Z0-9_]* {if (bVERBOSE) printf ("\tFertil...\n");}
<GET_PARAMETERS>"Genitors"[ \t\n]+"selector"[ \t\n]*":"[ \t\n]* {if (bVERBOSE) printf ("\tGenitors Sel...\n");return SELECTOR;}
<GET_PARAMETERS>"Selected"[ \t\n]+"genitors"[ \t\n]*":"[ \ta-zA-Z0-9_]* {if (bVERBOSE) printf ("\tSel Genitors...\n");}
<GET_PARAMETERS>"Mutation"[ \t\n]+"probability"[ \t\n]*":"[ \t\n]* {if (bVERBOSE) printf ("\tMut Prob...\n");return MUT_PROB;}
<GET_PARAMETERS>"Crossover"[ \t\n]+"probability"[ \t\n]*":"[ \t\n]* {if (bVERBOSE) printf ("\tXov Prob...\n");return XOVER_PROB;}
<GET_PARAMETERS>"Offspring"[ \t\n]+"size"[ \t\n]*":"[ \t\n]* {if (bVERBOSE) printf ("\tOff Size...\n");return OFFSPRING;}
<GET_PARAMETERS>"Reduce"[ \t\n]+"parents"[ \t\n]*":"[ \t\n]* {if (bVERBOSE) printf ("\tReduce Par...\n");return RED_PAR;}
<GET_PARAMETERS>"Surviving"[ \t\n]+"parents"[ \t\n]*":"[ \t\n]* {if (bVERBOSE) printf ("\tSurv Par...\n");return SURVPAR;}
<GET_PARAMETERS>"Reduce"[ \t\n]+"offspring"[ \t\n]*":"[ \t\n]* {if (bVERBOSE) printf ("\tRed Off...\n");return RED_OFF;}
<GET_PARAMETERS>"Surviving"[ \t\n]+"offspring"[ \t\n]*":"[ \t\n]* {if (bVERBOSE) printf ("\tSurv Off...\n");return SURVOFF;}
<GET_PARAMETERS>"Final"[ \t\n]+"reduce"[ \t\n]*":"[ \t\n]* {if (bVERBOSE) printf ("\tFinal Red...\n");return RED_FINAL;}// DISCARD;}
<GET_PARAMETERS>"Elitism"[ \t\n]*":" {if (bVERBOSE) printf ("\tElitism...\n");return ELITISM;}
<GET_PARAMETERS>"Evaluator"[ \t\n]+"goal"[ \t\n]*":"[ \t\n]* {if (bVERBOSE) printf ("\tMinMax...\n");return MINIMAXI;}
<GET_PARAMETERS>"Emigration"[ \t\n]+"policy"[ \t\n]*":"[ \t\n]* {if (bVERBOSE) printf ("\tMig Policy...\n");return MIG_CLONE;}
<GET_PARAMETERS>"Migrants"[ \t\n]+"selector"[ \t\n]*":"[ \t\n]* {if (bVERBOSE) printf ("\tMig Sel...\n");return MIG_SEL;}
<GET_PARAMETERS>"Migrants"[ \t\n]+"destination"[ \t\n]*":"[ \t\n]* {if (bVERBOSE) printf ("\tMig Dest...\n");return MIGRATOR;}
<GET_PARAMETERS>"Migration"[ \t\n]+"frequency"[ \t\n]*":"[ \t\n]* {if (bVERBOSE) printf ("\tMig Freq...\n");return MIG_FREQ;}
<GET_PARAMETERS>"Number"[ \t\n]+"of"[ \t\n]+"emigrants"[ \t\n]*":"[ \t\n]* {if (bVERBOSE) printf ("\tNb Mig...\n");return NB_MIG;}
<GET_PARAMETERS>"Immigration"[ \t\n]+"replacement"[ \t\n]*":"[ \t\n]* {if (bVERBOSE) printf ("\tImmig Repl...\n");return IMMIG_SEL;}
<GET_PARAMETERS>"Immigration"[ \t\n]+"policy"[ \t\n]*":"[ \t\n]* {if (bVERBOSE) printf ("\tImmig Policy...\n");return IMMIG_REPL;}
// number
<GET_PARAMETERS>[0-9]+"."[0-9]*{exponent}? |
......@@ -1196,7 +1228,7 @@ YYSTYPE& yylval = *(YYSTYPE*)yyparserptr->yylvalptr;
%%
/////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////
inline char mytolower(char c) {
return ((c>=65)&&(c<=90)) ? c+=32:c;
......@@ -1214,14 +1246,14 @@ inline int mystricmp(char *string1, char *string2){
}
inline int isLetter(char c){
if (((c>=65)&&(c<=90))||((c>=97)&&(c<=122))) return 1;
if ((c==45)||(c==46)||(c==95)) return 1;
return 0;
if (((c>=65)&&(c<=90))||((c>=97)&&(c<=122))) return 1;
if ((c==45)||(c==46)||(c==95)) return 1;
return 0;
}
inline int isFigure(char c){
if ((c>=48)&&(c<=57)) return 1;
return 0;
if ((c>=48)&&(c<=57)) return 1;
return 0;
}
/////////////////////////////////////////////////////////////////////////////
......@@ -1233,7 +1265,7 @@ int CEASEALexer::yywrap(){
}
int CEASEALexer::create(CEASEAParser* pParser, CSymbolTable* pSymTable)
{
{
int i;
char sTemp[1000];
#if defined UNIX_OS
......@@ -1250,8 +1282,8 @@ int CEASEALexer::create(CEASEAParser* pParser, CSymbolTable* pSymTable)
if (!yycreate(pParser)) return 0;
if (bVERBOSE) printf("\n ");
if (bVERBOSE) printf("\n E A S E A (v0.7patch17)");
if (bVERBOSE) printf("\n ____________________ ");
if (bVERBOSE) printf("\n E A S E A (v0.7b)");
if (bVERBOSE) printf("\n ___________________ ");
if (bVERBOSE) printf("\n ");
if (sRAW_PROJECT_NAME[0]==0){
......@@ -1261,7 +1293,7 @@ int CEASEALexer::create(CEASEAParser* pParser, CSymbolTable* pSymTable)
if (bVERBOSE) printf("\n");
if (TARGET==0) {
printf("\nPlease select a target library (EO or GALib): ");
printf("\nPlease select a target library (DREAM, EO or GALib): ");
scanf("%s",sTemp);
if (!mystricmp(sTemp,"eo")) TARGET=EO;
else if (!mystricmp(sTemp,"galib")) TARGET=GALIB;
......@@ -1269,16 +1301,19 @@ int CEASEALexer::create(CEASEAParser* pParser, CSymbolTable* pSymTable)
else return 0;
}
/////////////////////////////////////////////////////////
//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 (getenv("EZ_PATH")==NULL){
printf("\n\nHmmm, it looks like you are running EASEA for the first time.\n");
printf("\n\nHmmm, it looks like you are running EASEA without GUIDE for the first time.\n");
printf("Please, add the path of the installation directory to the PATH variable and\n");
printf("into the \"EZ_PATH\" environment variable, so that EASEA knows where to look for\n");
printf("its template files.\n");
exit(0);
exit(1);
}
strcpy(sEZ_PATH,getenv("EZ_PATH"));
}
switch (OPERATING_SYSTEM) {
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;
......@@ -1308,19 +1343,24 @@ int CEASEALexer::create(CEASEAParser* pParser, CSymbolTable* pSymTable)
} }
if (TARGET==EO){
if ((sEO_DIR==NULL)||(sEO_DIR[0]==0)) {
if ((getenv("EO_DIR")==NULL)){
printf("\n\nHmmm, it looks like you are running EASEA millennium edition with EO for the\nfirst time.\n");
printf("Please, set the \"EO_DIR\" environment variable to the EO installation directory.\n");
exit(1);
}
else strcpy(sEO_DIR,getenv("EO_DIR"));
strcpy(sEO_DIR,getenv("EO_DIR"));
}
switch (OPERATING_SYSTEM) {
case UNIX : if (sEO_DIR[strlen(sEO_DIR)-1] != '/') strcat (sEO_DIR,"/"); break;
case WINDOWS : if (sEO_DIR[strlen(sEO_DIR)-1] != '\\') strcat (sEO_DIR,"\\"); break;
case UNKNOWN_OS : fprintf(fpOutputFile,"UNKNOWN_OS"); break;
}
}
if ((sRAW_PROJECT_NAME[0]=='"')&&(OPERATING_SYSTEM!=WINDOWS)){
strcpy(sRAW_PROJECT_NAME,&(sRAW_PROJECT_NAME[1]));
sRAW_PROJECT_NAME[strlen(sRAW_PROJECT_NAME)-1]=0;
}
if (strlen(sRAW_PROJECT_NAME)>3)
if (!mystricmp(".EZ",&(sRAW_PROJECT_NAME[strlen(sRAW_PROJECT_NAME)-3])))
sRAW_PROJECT_NAME[strlen(sRAW_PROJECT_NAME)-3]=0;
......@@ -1333,14 +1373,14 @@ int CEASEALexer::create(CEASEAParser* pParser, CSymbolTable* pSymTable)
for(i=0;i<(int)strlen(sPROJECT_NAME);i++) sLOWER_CASE_PROJECT_NAME[i]=mytolower(sPROJECT_NAME[i]);
if (!isLetter(sPROJECT_NAME[0])) {
if ((!isLetter(sPROJECT_NAME[0]))&&(sPROJECT_NAME[0]!='"')&&(sPROJECT_NAME[0]!='/')&&(sPROJECT_NAME[0]!='\\')) {
fprintf(stderr,"\n*** Project names starting with non-letters are invalid.\n*** Please choose another name.\n"); return 0;}
if (!(fpGenomeFile = fopen(sEZ_FILE_NAME, "r"))){
fprintf(stderr,"\n*** Could not open %s\n",sEZ_FILE_NAME); return 0;}
return 1;
}
}
/////////////////////////////////////////////////////////////////////////////
......
This diff is collapsed.
#ifndef _EASEAPARSE_H
#define _EASEAPARSE_H
#include <cyacc.h>
#line 58 "C:\\repo\\src\\EaseaParse.y"
// forward references
class CSymbol;
#line 12 "C:\\repo\\src\\EaseaParse.h"
#ifndef YYSTYPE
union tagYYSTYPE {
#line 64 "C:\\repo\\src\\EaseaParse.y"
CSymbol* pSymbol;
double dValue;
int ObjectQualifier;
int nValue;
char *szString;
#line 23 "C:\\repo\\src\\EaseaParse.h"
};
#define YYSTYPE union tagYYSTYPE
#endif
#define UMINUS 257
#define CLASSES 258
#define GENOME 259
#define USER_CTOR 260
#define USER_XOVER 261
#define USER_MUTATOR 262
#define USER_EVALUATOR 263
#define END_OF_FUNCTION 264
#define END_METHODS 265
#define IDENTIFIER 266
#define IDENTIFIER2 267
#define BOOL 268
#define INT 269
#define DOUBLE 270
#define FLOAT 271
#define CHAR 272
#define POINTER 273
#define NUMBER 274
#define NUMBER2 275
#define METHODS 276
#define STATIC 277
#define NB_GEN 278
#define NB_ISLANDS 279
#define PROP_SEQ 280
#define MUT_PROB 281
#define XOVER_PROB 282
#define POP_SIZE 283
#define SELECTOR 284
#define RED_PAR 285
#define RED_OFF 286
#define RED_FINAL 287
#define OFFSPRING 288
#define SURVPAR 289
#define SURVOFF 290
#define REPLACEMENT 291
#define DISCARD 292
#define MINIMAXI 293
#define ELITISM 294
#define ELITE 295
#define MIG_CLONE 296
#define MIG_SEL 297
#define MIGRATOR 298
#define MIG_FREQ 299
#define NB_MIG 300
#define IMMIG_SEL 301
#define IMMIG_REPL 302
#line 136 "C:\\repo\\src\\EaseaParse.y"
#include "EaseaSym.h"
#include "EaseaLex.h"
#line 80 "C:\\repo\\src\\EaseaParse.h"
/////////////////////////////////////////////////////////////////////////////
// CEASEAParser
#ifndef YYDECLSPEC
#define YYDECLSPEC
#endif
class YYFAR YYDECLSPEC CEASEAParser : public yyfparser {
public:
CEASEAParser();
protected:
void yytables();
virtual void yyaction(int action);
#ifdef YYDEBUG
void YYFAR* yyattribute1(int index) const;
void yyinitdebug(void YYFAR** p, int count) const;
#endif
public:
#line 143 "C:\\repo\\src\\EaseaParse.y"
protected:
CEASEALexer EASEALexer; // the lexical analyser
public:
CSymbolTable SymbolTable; // the symbol table
int create();
double assign(CSymbol* pIdentifier, double dValue);
double divide(double dDividend, double dDivisor);
void yysyntaxerror();
CSymbol* insert() const;
#line 115 "C:\\repo\\src\\EaseaParse.h"
};
#ifndef YYPARSENAME
#define YYPARSENAME CEASEAParser
#endif
#endif
......@@ -10,7 +10,6 @@ Centre de Math
****************************************************************************/
#include "Easea.h"
#include "debug.h"
// Globals
CSymbol *pCURRENT_CLASS;
......@@ -40,7 +39,7 @@ char sDISCARD_PRM[50];
int nMINIMISE=2;
int nELITE;
bool bELITISM=0;
bool bVERBOSE=1;
bool bVERBOSE=0;
int nPOP_SIZE, nOFF_SIZE, nSURV_PAR_SIZE, nSURV_OFF_SIZE;
int nNB_GEN;
int nNB_ISLANDS;
......@@ -94,7 +93,7 @@ class CSymbol;
%token USER_EVALUATOR
%token END_OF_FUNCTION
//%token DELETE
//%token <szString> WHATEVER_COMES_AFTER
%token <szString> END_METHODS
%token <pSymbol> IDENTIFIER
%token <pSymbol> IDENTIFIER2
%token <pSymbol> BOOL
......@@ -105,6 +104,7 @@ class CSymbol;
%token <pSymbol> POINTER
%token <dValue> NUMBER
%token <dValue> NUMBER2
%token METHODS
%token STATIC
%token NB_GEN
%token NB_ISLANDS
......@@ -136,7 +136,6 @@ class CSymbol;
%include {
#include "EaseaSym.h"
#include "EaseaLex.h"
#include <cyacc.h>
}
// parser name and class definition
......@@ -153,7 +152,6 @@ public:
double assign(CSymbol* pIdentifier, double dValue);
double divide(double dDividend, double dDivisor);
CSymbol* insert() const;
void yysyntaxerror();
}
// constructor
......@@ -200,14 +198,14 @@ EASEA : RunParameters GenomeAnalysis;
GenomeAnalysis
: ClassDeclarationsSection GenomeDeclarationSection {
if (bVERBOSE) printf(" _______________________________________\n");
if ((TARGET==DREAM)&& bVERBOSE) printf ("\nGeneration of the JAVA source files for %s : %s.cpp\n\n",sPROJECT_NAME,sPROJECT_NAME);
if ((TARGET!=DREAM)&& bVERBOSE) printf ("\nGeneration of the C++ source file for %s : %s.cpp\n\n",sPROJECT_NAME,sPROJECT_NAME);
if ((TARGET==DREAM)&& bVERBOSE) printf ("\nGeneration of the JAVA source files for %s.\n\n",sPROJECT_NAME);
if ((TARGET!=DREAM)&& bVERBOSE) printf ("\nGeneration of the C++ source file for %s.\n\n",sPROJECT_NAME);
}
StandardFunctionsAnalysis
| GenomeDeclarationSection {
if (bVERBOSE) printf(" _______________________________________\n");
if ((TARGET==DREAM)&& bVERBOSE) printf ("\nGeneration of the JAVA source files for %s : %s.cpp\n\n",sPROJECT_NAME,sPROJECT_NAME);
if ((TARGET!=DREAM)&& bVERBOSE) printf ("\nGeneration of the C++ source file for %s : %s.cpp\n\n",sPROJECT_NAME,sPROJECT_NAME);
if ((TARGET==DREAM)&& bVERBOSE) printf ("\nGeneration of the JAVA source files for %s.\n\n",sPROJECT_NAME);
if ((TARGET!=DREAM)&& bVERBOSE) printf ("\nGeneration of the C++ source file for %s.\n\n",sPROJECT_NAME);
}
StandardFunctionsAnalysis
;
......@@ -234,12 +232,6 @@ ClassDeclaration
'{' VariablesDeclarations '}' {
if (bVERBOSE) printf("Class %s declared for %d bytes.\n\n",$1->sName,$1->nSize);
}
MethodsDeclaration {}
;
MethodsDeclaration
: '[' Methods ']' {}
|
;