Commit d471b20f authored by moh_lo's avatar moh_lo
Browse files

Revert "Revert "Compilable version""

This reverts commit 5e92cb68.
parent 5e92cb68
File mode changed from 100755 to 100644
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,6 +10,7 @@ Centre de Math ...@@ -10,6 +10,7 @@ Centre de Math
****************************************************************************/ ****************************************************************************/
#include "Easea.h" #include "Easea.h"
#include "debug.h"
// Globals // Globals
CSymbol *pCURRENT_CLASS; CSymbol *pCURRENT_CLASS;
...@@ -39,7 +40,7 @@ char sDISCARD_PRM[50]; ...@@ -39,7 +40,7 @@ char sDISCARD_PRM[50];
int nMINIMISE=2; int nMINIMISE=2;
int nELITE; int nELITE;
bool bELITISM=0; bool bELITISM=0;
bool bVERBOSE=0; bool bVERBOSE=1;
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;
...@@ -93,7 +94,7 @@ class CSymbol; ...@@ -93,7 +94,7 @@ class CSymbol;
%token USER_EVALUATOR %token USER_EVALUATOR
%token END_OF_FUNCTION %token END_OF_FUNCTION
//%token DELETE //%token DELETE
%token <szString> END_METHODS //%token <szString> WHATEVER_COMES_AFTER
%token <pSymbol> IDENTIFIER %token <pSymbol> IDENTIFIER
%token <pSymbol> IDENTIFIER2 %token <pSymbol> IDENTIFIER2
%token <pSymbol> BOOL %token <pSymbol> BOOL
...@@ -104,7 +105,6 @@ class CSymbol; ...@@ -104,7 +105,6 @@ 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,6 +136,7 @@ class CSymbol; ...@@ -136,6 +136,7 @@ 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
...@@ -152,6 +153,7 @@ public: ...@@ -152,6 +153,7 @@ 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
...@@ -198,14 +200,14 @@ EASEA : RunParameters GenomeAnalysis; ...@@ -198,14 +200,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.\n\n",sPROJECT_NAME); 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.\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);
} }
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.\n\n",sPROJECT_NAME); 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.\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);
} }
StandardFunctionsAnalysis StandardFunctionsAnalysis
; ;
...@@ -232,6 +234,12 @@ ClassDeclaration ...@@ -232,6 +234,12 @@ 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
...@@ -243,15 +251,6 @@ VariablesDeclarations ...@@ -243,15 +251,6 @@ 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
...@@ -365,14 +364,14 @@ BaseConstructorParameter ...@@ -365,14 +364,14 @@ BaseConstructorParameter
: NUMBER {} : NUMBER {}
; ;
//Methods Methods
// : Method : Method
// | Methods Method | Methods Method
// ; ;
//Method Method
// : NUMBER {} : NUMBER {}
// ; ;
GenomeDeclarationSection GenomeDeclarationSection
: GENOME { : GENOME {
...@@ -382,19 +381,11 @@ GenomeDeclarationSection ...@@ -382,19 +381,11 @@ 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
...@@ -489,8 +480,8 @@ StandardFunctionAnalysis ...@@ -489,8 +480,8 @@ StandardFunctionAnalysis
; ;
RunParameters RunParameters
: Parameter : Parameter { DEBUG_YACC("parameter has been reduce\n");}
| RunParameters Parameter | RunParameters Parameter { DEBUG_YACC("parameter has been reduce\n");}
; ;
Parameter Parameter
...@@ -1255,45 +1246,18 @@ Expr ...@@ -1255,45 +1246,18 @@ 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 *sTemp; char *psTemp;
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) {
sTemp=&(argv[nParamNb][0]); psTemp=&(argv[nParamNb][0]);
if ((argv[nParamNb][0]=='-')||(argv[nParamNb][0]=='/')) sTemp=&(argv[nParamNb][1]); if ((argv[nParamNb][0]=='-')||(argv[nParamNb][0]=='/')) psTemp=&(argv[nParamNb][1]);
if (!mystricmp(sTemp,"eo")) TARGET=EO; if (!mystricmp(psTemp,"eo")) TARGET=EO;
else if (!mystricmp(sTemp,"galib")) TARGET=GALIB; else if (!mystricmp(psTemp,"galib")) TARGET=GALIB;
else if (!mystricmp(sTemp,"dream")) TARGET=DREAM; else if (!mystricmp(psTemp,"dream")) TARGET=DREAM;
else if (!mystricmp(sTemp,"v")) bVERBOSE=true; else if (!mystricmp(psTemp,"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]);
} }
...@@ -1340,3 +1304,8 @@ double CEASEAParser::divide(double a, double b) ...@@ -1340,3 +1304,8 @@ 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 100755 to 100644
File mode changed from 100755 to 100644
...@@ -6,11 +6,9 @@ clex.h ...@@ -6,11 +6,9 @@ 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) 1997-99 P. D. Stearns Copyright (c) 1999-2001 Bumble-Bee Software Ltd.
************************************************************/ ************************************************************/
#define YY_ALEX
#include <stdio.h> #include <stdio.h>
#include <assert.h> #include <assert.h>
...@@ -22,6 +20,8 @@ Copyright (c) 1997-99 P. D. Stearns ...@@ -22,6 +20,8 @@ Copyright (c) 1997-99 P. D. Stearns
#include <yytudefs.h> #include <yytudefs.h>
#endif #endif
#define YY_ALEX
// modifiers // modifiers
#ifndef YYCDECL #ifndef YYCDECL
#define YYCDECL #define YYCDECL
......
...@@ -6,11 +6,9 @@ cyacc.h ...@@ -6,11 +6,9 @@ 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) 1997-99 P. D. Stearns Copyright (c) 1999-2001 Bumble-Bee Software Ltd.
************************************************************/ ************************************************************/
#define YY_AYACC
#include <stdio.h> #include <stdio.h>
#include <stddef.h> #include <stddef.h>
#include <assert.h> #include <assert.h>
...@@ -23,6 +21,8 @@ Copyright (c) 1997-99 P. D. Stearns ...@@ -23,6 +21,8 @@ Copyright (c) 1997-99 P. D. Stearns
#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 YYCNONTERMGOTO_T
#define YYCNONTERMGOTO_T
typedef short yycnontermgoto_t;
#endif
#ifndef YYCSTATEGOTO_T #ifndef YYCSTATEGOTO_T
#define YYCSTATEGOTO_T #define YYCSTATEGOTO_T
typedef struct yycstategoto { typedef short yycstategoto_t;
short current; // current state
short next; // next state
} yycstategoto_t;
#endif #endif
#ifndef YYNONTERMGOTO_T #ifndef YYCNONTERMGOTO_T
#define YYNONTERMGOTO_T #define YYCNONTERMGOTO_T
typedef struct yynontermgoto { typedef struct yycnontermgoto {
short base; // base short nonterm; // nonterminal
short def; // default state short next; // next state
} yynontermgoto_t; } yycnontermgoto_t;
#endif #endif
#ifndef YYSTATEGOTO_T #ifndef YYSTATEGOTO_T
#define YYSTATEGOTO_T #define YYSTATEGOTO_T
typedef struct yystategoto { typedef struct yystategoto {
short base; // base
short def; // default state
} yystategoto_t;
#endif
#ifndef YYNONTERMGOTO_T
#define YYNONTERMGOTO_T
typedef struct yynontermgoto {
short check; // check short check; // check
short next; // next state short next; // next state
} yystategoto_t; } yynontermgoto_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,39 +101,41 @@ typedef short yycstateaction_t; ...@@ -101,39 +101,41 @@ typedef short yycstateaction_t;
#ifndef YYCTOKENACTION_T #ifndef YYCTOKENACTION_T
#define YYCTOKENACTION_T #define YYCTOKENACTION_T
typedef struct yyctokenaction { typedef struct yyctokenaction {
int token; // lookahead token int token; // lookahead token
unsigned char type; // action to perform unsigned char type; // action to perform
short sr; // state to shift/production to reduce short sr; // state to shift/production to reduce
} yyctokenaction_t; } yyctokenaction_t;
#endif #endif
#ifndef YYSTATEACTION_T #ifndef YYSTATEACTION_T
#define YYSTATEACTION_T #define YYSTATEACTION_T
typedef struct yystateaction { typedef struct yystateaction {
short base; // base short base; // base
unsigned char lookahead; // lookahead needed