Commit 7ff04c0e authored by moh_lo's avatar moh_lo

Compilable version

parent bd18b1e4
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
****************************************************************************/
#include "Easea.h"
#include "debug.h"
// Globals
CSymbol *pCURRENT_CLASS;
......@@ -39,7 +40,7 @@ char sDISCARD_PRM[50];
int nMINIMISE=2;
int nELITE;
bool bELITISM=0;
bool bVERBOSE=0;
bool bVERBOSE=1;
int nPOP_SIZE, nOFF_SIZE, nSURV_PAR_SIZE, nSURV_OFF_SIZE;
int nNB_GEN;
int nNB_ISLANDS;
......@@ -93,7 +94,7 @@ class CSymbol;
%token USER_EVALUATOR
%token END_OF_FUNCTION
//%token DELETE
%token <szString> END_METHODS
//%token <szString> WHATEVER_COMES_AFTER
%token <pSymbol> IDENTIFIER
%token <pSymbol> IDENTIFIER2
%token <pSymbol> BOOL
......@@ -104,7 +105,6 @@ class CSymbol;
%token <pSymbol> POINTER
%token <dValue> NUMBER
%token <dValue> NUMBER2
%token METHODS
%token STATIC
%token NB_GEN
%token NB_ISLANDS
......@@ -136,6 +136,7 @@ class CSymbol;
%include {
#include "EaseaSym.h"
#include "EaseaLex.h"
#include <cyacc.h>
}
// parser name and class definition
......@@ -152,6 +153,7 @@ public:
double assign(CSymbol* pIdentifier, double dValue);
double divide(double dDividend, double dDivisor);
CSymbol* insert() const;
void yysyntaxerror();
}
// constructor
......@@ -198,14 +200,14 @@ EASEA : RunParameters GenomeAnalysis;
GenomeAnalysis
: ClassDeclarationsSection GenomeDeclarationSection {
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 C++ source file 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 : %s.cpp\n\n",sPROJECT_NAME,sPROJECT_NAME);
}
StandardFunctionsAnalysis
| GenomeDeclarationSection {
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 C++ source file 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 : %s.cpp\n\n",sPROJECT_NAME,sPROJECT_NAME);
}
StandardFunctionsAnalysis
;
......@@ -232,6 +234,12 @@ ClassDeclaration
'{' VariablesDeclarations '}' {
if (bVERBOSE) printf("Class %s declared for %d bytes.\n\n",$1->sName,$1->nSize);
}
MethodsDeclaration {}
;
MethodsDeclaration
: '[' Methods ']' {}
|
;
VariablesDeclarations
......@@ -243,15 +251,6 @@ VariablesDeclarations
VariablesDeclaration
: Qualifier BaseType {pCURRENT_TYPE=$2; pCURRENT_TYPE->ObjectQualifier=$1;} BaseObjects {}
| 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
......@@ -365,14 +364,14 @@ BaseConstructorParameter
: NUMBER {}
;
//Methods
// : Method
// | Methods Method
// ;
Methods
: Method
| Methods Method
;
//Method
// : NUMBER {}
// ;
Method
: NUMBER {}
;
GenomeDeclarationSection
: GENOME {
......@@ -382,19 +381,11 @@ GenomeDeclarationSection
pGENOME->pSymbolList=new CLList<CSymbol *>();
pGENOME->ObjectType=oUserClass;
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
: UserConstructorParameter
| UserConstructorParameters UserConstructorParameter
......@@ -489,8 +480,8 @@ StandardFunctionAnalysis
;
RunParameters
: Parameter
| RunParameters Parameter
: Parameter { DEBUG_YACC("parameter has been reduce\n");}
| RunParameters Parameter { DEBUG_YACC("parameter has been reduce\n");}
;
Parameter
......@@ -1255,45 +1246,18 @@ Expr
int main(int argc, char *argv[]){
int n = YYEXIT_FAILURE;
int nParamNb=0;
char *sTemp;
int i=0;
char *psTemp;
TARGET=bVERBOSE=0;
sRAW_PROJECT_NAME[0]=0; // used to ask for a filename if no filename is found on the command line.
while ((++nParamNb) < argc) {
sTemp=&(argv[nParamNb][0]);
if ((argv[nParamNb][0]=='-')||(argv[nParamNb][0]=='/')) sTemp=&(argv[nParamNb][1]);
if (!mystricmp(sTemp,"eo")) TARGET=EO;
else if (!mystricmp(sTemp,"galib")) TARGET=GALIB;
else if (!mystricmp(sTemp,"dream")) TARGET=DREAM;
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]);
}
}
psTemp=&(argv[nParamNb][0]);
if ((argv[nParamNb][0]=='-')||(argv[nParamNb][0]=='/')) psTemp=&(argv[nParamNb][1]);
if (!mystricmp(psTemp,"eo")) TARGET=EO;
else if (!mystricmp(psTemp,"galib")) TARGET=GALIB;
else if (!mystricmp(psTemp,"dream")) TARGET=DREAM;
else if (!mystricmp(psTemp,"v")) bVERBOSE=true;
else strcpy(sRAW_PROJECT_NAME,argv[nParamNb]);
}
......@@ -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
This file can be freely modified for the generation of
custom code.
Copyright (c) 1997-99 P. D. Stearns
Copyright (c) 1999-2001 Bumble-Bee Software Ltd.
************************************************************/
#define YY_ALEX
#include <stdio.h>
#include <assert.h>
......@@ -22,6 +20,8 @@ Copyright (c) 1997-99 P. D. Stearns
#include <yytudefs.h>
#endif
#define YY_ALEX
// modifiers
#ifndef YYCDECL
#define YYCDECL
......
......@@ -6,11 +6,9 @@ cyacc.h
This file can be freely modified for the generation of
custom code.
Copyright (c) 1997-99 P. D. Stearns
Copyright (c) 1999-2001 Bumble-Bee Software Ltd.
************************************************************/
#define YY_AYACC
#include <stdio.h>
#include <stddef.h>
#include <assert.h>
......@@ -23,6 +21,8 @@ Copyright (c) 1997-99 P. D. Stearns
#include <yytudefs.h>
#endif
#define YY_AYACC
// modifiers
#ifndef YYCDECL
#define YYCDECL
......@@ -57,41 +57,41 @@ typedef short yystack_t;
#define YYTK_END 0 // $end token
#define YYTK_ERROR 256 // error token
#ifndef YYCNONTERMGOTO_T
#define YYCNONTERMGOTO_T
typedef short yycnontermgoto_t;
#endif
#ifndef YYCSTATEGOTO_T
#define YYCSTATEGOTO_T
typedef struct yycstategoto {
short current; // current state
short next; // next state
} yycstategoto_t;
typedef short yycstategoto_t;
#endif
#ifndef YYNONTERMGOTO_T
#define YYNONTERMGOTO_T
typedef struct yynontermgoto {
short base; // base
short def; // default state
} yynontermgoto_t;
#ifndef YYCNONTERMGOTO_T
#define YYCNONTERMGOTO_T
typedef struct yycnontermgoto {
short nonterm; // nonterminal
short next; // next state
} yycnontermgoto_t;
#endif
#ifndef YYSTATEGOTO_T
#define YYSTATEGOTO_T
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 next; // next state
} yystategoto_t;
} yynontermgoto_t;
#endif
// action types
#define YYAT_SHIFT 0 // shift action
#define YYAT_REDUCE 1 // reduce action
#define YYAT_ERROR 2 // error
#define YYAT_ACCEPT 3 // accept
#define YYAT_DEFAULT 4 // default state
#define YYAT_SHIFT 0 // shift action
#define YYAT_REDUCE 1 // reduce action
#define YYAT_ERROR 2 // error
#define YYAT_ACCEPT 3 // accept
#define YYAT_DEFAULT 4 // default state
#ifndef YYCSTATEACTION_T
#define YYCSTATEACTION_T
......@@ -101,39 +101,41 @@ typedef short yycstateaction_t;
#ifndef YYCTOKENACTION_T
#define YYCTOKENACTION_T
typedef struct yyctokenaction {
int token; // lookahead token
unsigned char type; // action to perform
short sr; // state to shift/production to reduce
int token; // lookahead token
unsigned char type; // action to perform
short sr; // state to shift/production to reduce
} yyctokenaction_t;
#endif
#ifndef YYSTATEACTION_T
#define YYSTATEACTION_T
typedef struct yystateaction {
short base; // base
unsigned char lookahead; // lookahead needed
unsigned char type; // action to perform
short sr; // shift/reduce
short base; // base
unsigned char lookahead; // lookahead needed
unsigned char type; // action to perform
short sr; // shift/reduce
} yystateaction_t;
#endif
#ifndef YYTOKENACTION_T
#define YYTOKENACTION_T
typedef struct yytokenaction {
short check; // check
unsigned char type; // action type
short sr; // shift/reduce
short check; // check
unsigned char type; // action type
short sr; // shift/reduce
} yytokenaction_t;
#endif
// nonterminals
#define YYNT_ALL (-1) // match all nonterminals
// states
#define YYST_ALL (-1) // match all states
#define YYST_ERROR (-1) // goto error
#define YYST_ERROR (-1) // goto error
#ifndef YYREDUCTION_T
#define YYREDUCTION_T
typedef struct yyreduction {
short rule; // the rhs symbol
short nonterm; // the rhs symbol
short length; // number of symbols on lhs
short action; // the user action
} yyreduction_t;
......@@ -256,11 +258,11 @@ public:
void _yyerrok() { yysetskip(0); }
#endif
void yyexit(int exitcode) { yyexitflg = 1; yyexitcode = exitcode; }
void yyforceerror() { yythrowerror(0); }
void yyforceerror() { yythrowerror(); }
int yypopping() const { return yypopflg; }
int yyrecovering() const { return yyskip > 0; }
void yyretire(int retirecode) { yyretireflg = 1; yyretirecode = retirecode; }
void yythrowerror(int pop) { yyerrorflg = 1; yyerrorpop = pop; }
void yythrowerror(int pop = 0) { yyerrorflg = 1; yyerrorpop = pop; }
// compatibility
int yycparse() { return yyparse(); }
......@@ -306,7 +308,7 @@ protected:
void yydthrowerror(int errorpop) const;
void yydretire(int retirecode) const;
void yydattemptrecovery() const;
void yydebugoutput(const char *string) const;
void yydebugoutput(const char* string) const;
#endif
};
......@@ -324,9 +326,9 @@ protected:
const yystateaction_t YYNEARFAR* yystateaction;
const yytokenaction_t YYNEARFAR* yytokenaction;
int yytokenaction_size;
const yynontermgoto_t YYNEARFAR* yynontermgoto;
const yystategoto_t YYNEARFAR* yystategoto;
int yystategoto_size;
const yynontermgoto_t YYNEARFAR* yynontermgoto;
int yynontermgoto_size;
const yytokendest_t YYNEARFAR* yytokendestptr;
int yytokendest_size;
int yytokendestbase;
......@@ -345,8 +347,8 @@ public:
protected:
const yycstateaction_t YYNEARFAR* yycstateaction;
const yyctokenaction_t YYNEARFAR* yyctokenaction;
const yycnontermgoto_t YYNEARFAR* yycnontermgoto;
const yycstategoto_t YYNEARFAR* yycstategoto;
const yycnontermgoto_t YYNEARFAR* yycnontermgoto;
const yyctokendest_t YYNEARFAR* yyctokendestptr;
};
......
......@@ -6,15 +6,9 @@ lex.h
This file can be freely modified for the generation of
custom code.
Copyright (c) 1997-99 P. D. Stearns