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
This diff is collapsed.
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 ...@@ -10,7 +10,6 @@ Centre de Math
****************************************************************************/ ****************************************************************************/
#include "Easea.h" #include "Easea.h"
#include "debug.h"
// Globals // Globals
CSymbol *pCURRENT_CLASS; CSymbol *pCURRENT_CLASS;
...@@ -40,7 +39,7 @@ char sDISCARD_PRM[50]; ...@@ -40,7 +39,7 @@ char sDISCARD_PRM[50];
int nMINIMISE=2; int nMINIMISE=2;
int nELITE; int nELITE;
bool bELITISM=0; bool bELITISM=0;
bool bVERBOSE=1; bool bVERBOSE=0;
int nPOP_SIZE, nOFF_SIZE, nSURV_PAR_SIZE, nSURV_OFF_SIZE; int nPOP_SIZE, nOFF_SIZE, nSURV_PAR_SIZE, nSURV_OFF_SIZE;
int nNB_GEN; int nNB_GEN;
int nNB_ISLANDS; int nNB_ISLANDS;
...@@ -94,7 +93,7 @@ class CSymbol; ...@@ -94,7 +93,7 @@ class CSymbol;
%token USER_EVALUATOR %token USER_EVALUATOR
%token END_OF_FUNCTION %token END_OF_FUNCTION
//%token DELETE //%token DELETE
//%token <szString> WHATEVER_COMES_AFTER %token <szString> END_METHODS
%token <pSymbol> IDENTIFIER %token <pSymbol> IDENTIFIER
%token <pSymbol> IDENTIFIER2 %token <pSymbol> IDENTIFIER2
%token <pSymbol> BOOL %token <pSymbol> BOOL
...@@ -105,6 +104,7 @@ class CSymbol; ...@@ -105,6 +104,7 @@ class CSymbol;
%token <pSymbol> POINTER %token <pSymbol> POINTER
%token <dValue> NUMBER %token <dValue> NUMBER
%token <dValue> NUMBER2 %token <dValue> NUMBER2
%token METHODS
%token STATIC %token STATIC
%token NB_GEN %token NB_GEN
%token NB_ISLANDS %token NB_ISLANDS
...@@ -136,7 +136,6 @@ class CSymbol; ...@@ -136,7 +136,6 @@ class CSymbol;
%include { %include {
#include "EaseaSym.h" #include "EaseaSym.h"
#include "EaseaLex.h" #include "EaseaLex.h"
#include <cyacc.h>
} }
// parser name and class definition // parser name and class definition
...@@ -153,7 +152,6 @@ public: ...@@ -153,7 +152,6 @@ public:
double assign(CSymbol* pIdentifier, double dValue); double assign(CSymbol* pIdentifier, double dValue);
double divide(double dDividend, double dDivisor); double divide(double dDividend, double dDivisor);
CSymbol* insert() const; CSymbol* insert() const;
void yysyntaxerror();
} }
// constructor // constructor
...@@ -200,14 +198,14 @@ EASEA : RunParameters GenomeAnalysis; ...@@ -200,14 +198,14 @@ EASEA : RunParameters GenomeAnalysis;
GenomeAnalysis GenomeAnalysis
: ClassDeclarationsSection GenomeDeclarationSection { : ClassDeclarationsSection GenomeDeclarationSection {
if (bVERBOSE) printf(" _______________________________________\n"); 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 JAVA source files for %s.\n\n",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 C++ source file for %s.\n\n",sPROJECT_NAME);
} }
StandardFunctionsAnalysis StandardFunctionsAnalysis
| GenomeDeclarationSection { | GenomeDeclarationSection {
if (bVERBOSE) printf(" _______________________________________\n"); 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 JAVA source files for %s.\n\n",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 C++ source file for %s.\n\n",sPROJECT_NAME);
} }
StandardFunctionsAnalysis StandardFunctionsAnalysis
; ;
...@@ -234,12 +232,6 @@ ClassDeclaration ...@@ -234,12 +232,6 @@ ClassDeclaration
'{' 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);
} }
MethodsDeclaration {}
;
MethodsDeclaration
: '[' Methods ']' {}
|
; ;
VariablesDeclarations VariablesDeclarations
...@@ -251,6 +243,15 @@ VariablesDeclarations ...@@ -251,6 +243,15 @@ VariablesDeclarations
VariablesDeclaration VariablesDeclaration
: Qualifier BaseType {pCURRENT_TYPE=$2; pCURRENT_TYPE->ObjectQualifier=$1;} BaseObjects {} : Qualifier BaseType {pCURRENT_TYPE=$2; pCURRENT_TYPE->ObjectQualifier=$1;} BaseObjects {}
| Qualifier UserType {pCURRENT_TYPE=$2; pCURRENT_TYPE->ObjectQualifier=$1;} UserObjects {} | Qualifier UserType {pCURRENT_TYPE=$2; pCURRENT_TYPE->ObjectQualifier=$1;} UserObjects {}
| MethodsDeclaration
;
MethodsDeclaration
: METHODS END_METHODS{
pCURRENT_CLASS->sString = new char[strlen($2) + 1];
strcpy(pCURRENT_CLASS->sString, $2);
if (bVERBOSE) printf("\n The following methods have been declared:\n\n%s\n\n",pCURRENT_CLASS->sString);
}
; ;
Qualifier Qualifier
...@@ -364,14 +365,14 @@ BaseConstructorParameter ...@@ -364,14 +365,14 @@ BaseConstructorParameter
: NUMBER {} : NUMBER {}
; ;
Methods //Methods
: Method // : Method
| Methods Method // | Methods Method
; // ;
Method //Method
: NUMBER {} // : NUMBER {}
; // ;
GenomeDeclarationSection GenomeDeclarationSection
: GENOME { : GENOME {
...@@ -381,11 +382,19 @@ GenomeDeclarationSection ...@@ -381,11 +382,19 @@ GenomeDeclarationSection
pGENOME->pSymbolList=new CLList<CSymbol *>(); pGENOME->pSymbolList=new CLList<CSymbol *>();
pGENOME->ObjectType=oUserClass; pGENOME->ObjectType=oUserClass;
pGENOME->ObjectQualifier=0; pGENOME->ObjectQualifier=0;
pGENOME->sString=NULL;
} }
'{' VariablesDeclarations '}' { '{' VariablesDeclarations '}' {}
}
; ;
//GenomeMethodsDeclaration
// : GENOME_METHODS GENOME_END_METHODS{
// pCURRENT_CLASS->sString = new char[strlen($2) + 1];
// strcpy(pCURRENT_CLASS->sString, $2);
// }
// |
// ;
UserConstructorParameters UserConstructorParameters
: UserConstructorParameter : UserConstructorParameter
| UserConstructorParameters UserConstructorParameter | UserConstructorParameters UserConstructorParameter
...@@ -480,8 +489,8 @@ StandardFunctionAnalysis ...@@ -480,8 +489,8 @@ StandardFunctionAnalysis
; ;
RunParameters RunParameters
: Parameter { DEBUG_YACC("parameter has been reduce\n");} : Parameter
| RunParameters Parameter { DEBUG_YACC("parameter has been reduce\n");} | RunParameters Parameter
; ;
Parameter Parameter
...@@ -1246,18 +1255,45 @@ Expr ...@@ -1246,18 +1255,45 @@ Expr
int main(int argc, char *argv[]){ int main(int argc, char *argv[]){
int n = YYEXIT_FAILURE; int n = YYEXIT_FAILURE;
int nParamNb=0; int nParamNb=0;
char *psTemp; char *sTemp;
int i=0;
TARGET=bVERBOSE=0; TARGET=bVERBOSE=0;
sRAW_PROJECT_NAME[0]=0; // used to ask for a filename if no filename is found on the command line. sRAW_PROJECT_NAME[0]=0; // used to ask for a filename if no filename is found on the command line.
while ((++nParamNb) < argc) { while ((++nParamNb) < argc) {
psTemp=&(argv[nParamNb][0]); sTemp=&(argv[nParamNb][0]);
if ((argv[nParamNb][0]=='-')||(argv[nParamNb][0]=='/')) psTemp=&(argv[nParamNb][1]); if ((argv[nParamNb][0]=='-')||(argv[nParamNb][0]=='/')) sTemp=&(argv[nParamNb][1]);
if (!mystricmp(psTemp,"eo")) TARGET=EO; if (!mystricmp(sTemp,"eo")) TARGET=EO;
else if (!mystricmp(psTemp,"galib")) TARGET=GALIB; else if (!mystricmp(sTemp,"galib")) TARGET=GALIB;
else if (!mystricmp(psTemp,"dream")) TARGET=DREAM; else if (!mystricmp(sTemp,"dream")) TARGET=DREAM;
else if (!mystricmp(psTemp,"v")) bVERBOSE=true; else if (!mystricmp(sTemp,"v")) bVERBOSE=true;
else if (!mystricmp(sTemp,"path")) {
if (argv[++nParamNb][0]=='"') {
strcpy(sEZ_PATH,&(argv[nParamNb][1]));
while (argv[++nParamNb][strlen(argv[nParamNb])]!='"')
strcat(sEZ_PATH,argv[nParamNb]);
argv[nParamNb][strlen(argv[nParamNb])]=0;
strcat(sEZ_PATH,argv[nParamNb]);
}
else {
if (argv[nParamNb][strlen(argv[nParamNb])-1]=='"') argv[nParamNb][strlen(argv[nParamNb])-1]=0;
strcpy(sEZ_PATH,argv[nParamNb]);
}
}
else if (!mystricmp(sTemp,"eo_dir")) {
if (argv[++nParamNb][0]=='"') {
strcpy(sEO_DIR,&(argv[nParamNb][1]));
while (argv[++nParamNb][strlen(argv[nParamNb])]!='"')
strcat(sEO_DIR,argv[nParamNb]);
argv[nParamNb][strlen(argv[nParamNb])]=0;
strcat(sEO_DIR,argv[nParamNb]);
}
else {
if (argv[nParamNb][strlen(argv[nParamNb])-1]=='"') argv[nParamNb][strlen(argv[nParamNb])-1]=0;
strcpy(sEO_DIR,argv[nParamNb]);
}
}
else strcpy(sRAW_PROJECT_NAME,argv[nParamNb]); else strcpy(sRAW_PROJECT_NAME,argv[nParamNb]);
} }
...@@ -1304,8 +1340,3 @@ double CEASEAParser::divide(double a, double b) ...@@ -1304,8 +1340,3 @@ double CEASEAParser::divide(double a, double b)
} }
} }
void CEASEAParser::yysyntaxerror(){
fprintf(stderr,"%s\t Error at line %d\n",sEZ_FILE_NAME,EASEALexer.yylineno);
exit(-1);
}
File mode changed from 100644 to 100755
File mode changed from 100644 to 100755
...@@ -6,9 +6,11 @@ clex.h ...@@ -6,9 +6,11 @@ clex.h
This file can be freely modified for the generation of This file can be freely modified for the generation of
custom code. custom code.
Copyright (c) 1999-2001 Bumble-Bee Software Ltd. Copyright (c) 1997-99 P. D. Stearns
************************************************************/ ************************************************************/
#define YY_ALEX
#include <stdio.h> #include <stdio.h>
#include <assert.h> #include <assert.h>
...@@ -20,8 +22,6 @@ Copyright (c) 1999-2001 Bumble-Bee Software Ltd. ...@@ -20,8 +22,6 @@ Copyright (c) 1999-2001 Bumble-Bee Software Ltd.
#include <yytudefs.h> #include <yytudefs.h>
#endif #endif
#define YY_ALEX
// modifiers // modifiers
#ifndef YYCDECL #ifndef YYCDECL
#define YYCDECL #define YYCDECL
......
...@@ -6,9 +6,11 @@ cyacc.h ...@@ -6,9 +6,11 @@ cyacc.h
This file can be freely modified for the generation of This file can be freely modified for the generation of
custom code. custom code.
Copyright (c) 1999-2001 Bumble-Bee Software Ltd. Copyright (c) 1997-99 P. D. Stearns
************************************************************/ ************************************************************/
#define YY_AYACC
#include <stdio.h> #include <stdio.h>
#include <stddef.h> #include <stddef.h>
#include <assert.h> #include <assert.h>
...@@ -21,8 +23,6 @@ Copyright (c) 1999-2001 Bumble-Bee Software Ltd. ...@@ -21,8 +23,6 @@ Copyright (c) 1999-2001 Bumble-Bee Software Ltd.
#include <yytudefs.h> #include <yytudefs.h>
#endif #endif
#define YY_AYACC
// modifiers // modifiers
#ifndef YYCDECL #ifndef YYCDECL
#define YYCDECL #define YYCDECL
...@@ -57,41 +57,41 @@ typedef short yystack_t; ...@@ -57,41 +57,41 @@ typedef short yystack_t;
#define YYTK_END 0 // $end token #define YYTK_END 0 // $end token
#define YYTK_ERROR 256 // error token #define YYTK_ERROR 256 // error token
#ifndef YYCSTATEGOTO_T
#define YYCSTATEGOTO_T
typedef short yycstategoto_t;
#endif
#ifndef YYCNONTERMGOTO_T #ifndef YYCNONTERMGOTO_T
#define YYCNONTERMGOTO_T #define YYCNONTERMGOTO_T
typedef struct yycnontermgoto { typedef short yycnontermgoto_t;
short nonterm; // nonterminal
short next; // next state
} yycnontermgoto_t;
#endif #endif
#ifndef YYSTATEGOTO_T #ifndef YYCSTATEGOTO_T
#define YYSTATEGOTO_T #define YYCSTATEGOTO_T
typedef struct yystategoto { typedef struct yycstategoto {
short base; // base short current; // current state
short def; // default state short next; // next state
} yystategoto_t; } yycstategoto_t;
#endif #endif
#ifndef YYNONTERMGOTO_T #ifndef YYNONTERMGOTO_T
#define YYNONTERMGOTO_T #define YYNONTERMGOTO_T
typedef struct yynontermgoto { typedef struct yynontermgoto {
short base; // base
short def; // default state
} yynontermgoto_t;
#endif
#ifndef YYSTATEGOTO_T
#define YYSTATEGOTO_T
typedef struct yystategoto {
short check; // check short check; // check
short next; // next state short next; // next state
} yynontermgoto_t; } yystategoto_t;
#endif #endif
// action types // action types
#define YYAT_SHIFT 0 // shift action #define YYAT_SHIFT 0 // shift action
#define YYAT_REDUCE 1 // reduce action #define YYAT_REDUCE 1 // reduce action
#define YYAT_ERROR 2 // error #define YYAT_ERROR 2 // error
#define YYAT_ACCEPT 3 // accept #define YYAT_ACCEPT 3 // accept
#define YYAT_DEFAULT 4 // default state #define YYAT_DEFAULT 4 // default state
#ifndef YYCSTATEACTION_T #ifndef YYCSTATEACTION_T
#define YYCSTATEACTION_T #define YYCSTATEACTION_T
...@@ -101,41 +101,39 @@ typedef short yycstateaction_t; ...@@ -101,41 +101,39 @@ typedef short yycstateaction_t;
#ifndef YYCTOKENACTION_T #ifndef YYCTOKENACTION_T
#define YYCTOKENACTION_T #define YYCTOKENACTION_T
typedef struct yyctokenaction {