Commit 6d388b3a authored by moh_lo's avatar moh_lo

Initial Import

parents
/****************************************************************************
Easea.h
General header for the EASEA language (EAsy Specification for Evolutionary Algorithms)
Pierre COLLET (Pierre.Collet@polytechnique.fr)
Ecole Polytechnique
Centre de Mathmatiques Appliques
91128 Palaiseau cedex
****************************************************************************/
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <assert.h>
#include <errno.h>
#define true 1
#define false 0
#define GALIB 1
#define EO 2
#define DREAM 3
#define UNIX 1
#define WINDOWS 2
#define UNKNOWN_OS 3
#define YYTEXT_SIZE 10000
class CSymbol;
extern CSymbol *pCURRENT_CLASS, *pCURRENT_TYPE, *pGENOME;
extern FILE *fpOutputFile, *fpTemplateFile, *fpGenomeFile, *fpExplodedGenomeFile;
extern char sRAW_PROJECT_NAME[], sPROJECT_NAME[], sEO_DIR[], sEZ_PATH[], sEZ_FILE_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 int nMINIMISE,nELITE;
extern bool bELITISM, bVERBOSE;
extern bool bPROP_SEQ;
extern int nPOP_SIZE, nNB_GEN, nNB_ISLANDS, nOFF_SIZE, nSURV_PAR_SIZE, nSURV_OFF_SIZE;
extern float fMUT_PROB, fXOVER_PROB, fREPL_PERC, fMIG_FREQ;
extern int nMIG_CLONE, nNB_MIG, nIMMIG_REPL;
extern char sMIG_SEL[], sMIGRATOR[], sIMMIG_SEL[],sMIG_TARGET_SELECTOR[];
extern int nWARNINGS, nERRORS;
extern int TARGET, OPERATING_SYSTEM;
// Prototypes
extern int mystricmp(char *, char *);
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);
CSymbol* insert() const;
#line 115 "C:\\repo\\src\\EaseaParse.h"
};
#ifndef YYPARSENAME
#define YYPARSENAME CEASEAParser
#endif
#endif
This diff is collapsed.
This diff is collapsed.
/****************************************************************************
EaseaSym.h
Symbol table and other functions for the EASEA language (EAsy Specification for Evolutionary Algorithms)
Pierre COLLET (Pierre.Collet@inria.fr)
Copyright EVOlutionary LABoratory
INRIA Rocquencourt, Projet FRACTALES
Domaine de Voluceau
Rocquencourt BP 105
78153 Le Chesnay CEDEX
****************************************************************************/
#ifndef SYMBOL_H
#define SYMBOL_H
#include "Easea.h"
extern void debug (char *);
enum EObjectType {oUserClass, oBaseClass, oObject, oPointer, oArray, oMacro, oUndefined};
/////////////////////////////////////////////////////////////////////////////
// Object
template <class T> class CLList;
template <class T> class CListItem {
friend class CLList<T>;
// Operations
public:
CListItem(const CListItem<T> *pOldObject, const T &NewObject)
:Object(NewObject), pNext((CListItem<T>*)pOldObject){}
~CListItem();
// Attributes
T Object; // The object
CListItem<T> *pNext; // pointer to the next object in the list
};
/////////////////////////////////////////////////////////////////////////////
// Linked List
template <class T> class CLList {
private :
CListItem<T> *pHead;
CListItem<T> *pCurrentObject;
CListItem<T> *pNextItem;
public :
CLList():pHead(NULL),pCurrentObject(NULL){}
~CLList();
void addLast(const T &p);
void addFirst(const T &NewObject) {pHead = new CListItem<T>(pHead, NewObject);}
void reset(){pCurrentObject=pNextItem=pHead;}
CListItem<T> * getHead(){return pHead;}
T CurrentObject(){return pCurrentObject?pCurrentObject->Object:NULL;}
T nextObject(){return pNextItem ?pNextItem->Object:NULL;}
CListItem<T> *walkToNextItem();
CListItem<T> *remove(T *p);
};
/////////////////////////////////////////////////////////////////////////////
// Symbol
class CSymbol {
public:
CSymbol(char *s);
virtual ~CSymbol();
// Attributes
public:
CSymbol* pNextInBucket; // next symbol in bucket list (hash code)
char *sName; // symbol name
double dValue; // value attached to symbol
char *sString; // attached string
int nSize; // size of the object represented by the symbol
bool bAlreadyPrinted; // no comment
EObjectType ObjectType; // variable, array, pointer, class,...
int ObjectQualifier; // 0=Normal, 1=Static, 2=oObservable, ...
CSymbol *pType; // pointer to the variable/array/.. type
CSymbol *pClass; // pointer to the variable class in which it is defined.
CLList<CSymbol *> *pSymbolList; // pointer on a list of class members (if the symbol is a class)
// pointer on the class (if the symbol is a variable)
// Operations
public:
void print(FILE *f);
void printClasses(FILE *f);
void printAllSymbols(FILE *f, char *, EObjectType, CListItem<CSymbol *> *pSym);
};
/////////////////////////////////////////////////////////////////////////////
// symboltable
#define BUCKET_SIZE 4093 // prime number
class CSymbolTable {
public:
CSymbolTable();
virtual ~CSymbolTable();
// Attributes
protected:
CSymbol* saBucket[BUCKET_SIZE]; // array of buckets
// Operations
protected:
int hash(const char* sName) const;
public:
CSymbol* insert(CSymbol *pSymbol);
CSymbol* find(const char* s);
};
#endif
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
#ifndef MILCONV_H
#define MILCONV_H
/************************************************************
milconv.h
This file can be freely modified for the generation of
custom code.
Copyright (c) 1997-99 P. D. Stearns
************************************************************/
/* variables */
#define yymoreflg (yy)->yymmoreflg
#define yyrejectflg (yy)->yymrejectflg
#define yyreturnflg (yy)->yymreturnflg
#define yytextgrow (yy)->yymtextgrow
#define yyunputgrow (yy)->yymunputgrow
#define yyeol (yy)->yymeol
#define yyoldeol (yy)->yymoldeol
#define yystart (yy)->yymstart
#define yyin (yy)->yymin
#define yyout (yy)->yymout
#define yylexerr (yy)->yymerr
#define yyleng (yy)->yymleng
#define yylineno (yy)->yymlineno
#define yyunputindex (yy)->yymunputindex
#define yytext (yy)->yymtext
#define yystext (yy)->yymstext
#define yytext_size (yy)->yymtext_size
#define yystext_size (yy)->yymstext_size
#define yystatebuf (yy)->yymstatebuf
#define yysstatebuf (yy)->yymsstatebuf
#define yyunputbufptr (yy)->yymunputbufptr
#define yysunputbufptr (yy)->yymsunputbufptr
#define yyunput_size (yy)->yymunputbufptr
#define yysunput_size (yy)->yymsunput_size
#define yylexdebug (yy)->yymdebug
#define yylexdebugflush (yy)->yymdebugflush
#define yylexdebugout (yy)->yymdebugout
/* general functions */
#define yylexinit() yymlexinit(yy)
#define yylex() yymlex(yy)
#define yyclex() yymclex(yy)
#define yyreset() yymreset(yy)
#define yylexcleanup() yymlexcleanup(yy)
#define yysettextsize(size) yymsettextsize(yy, (size))
#define yysetunputsize(size) yymsetunputsize(yy, (size))
/* service functions */
#define yyinput() (*yy->yyminput)(yy)
#define yyoutput(ch) (*yy->yymoutput)(yy, (ch))
#define yyunput(ch) (*yy->yymunput)(yy, (ch))
#define yywrap() (*yy->yymwrap)(yy)
#define yygetchar() (*yy->yymgetchar)(yy)
#define yytextoverflow() (*yy->yymtextoverflow)(yy)
#define yyunputoverflow() (*yy->yymunputoverflow)(yy)
/* action functions */
#define yybegin(state) yymbegin(yy, (state))
#define yyecho() yymecho(yy)
#define yyless(length) yymless(yy, (length))
#define yymore() yymmore(yy)
#define yynewline(newline) yymnewline(yy, (newline))
#define yyreject() yymreject(yy)
#define yyunputcount() yymunputcount(yy)
/* compatibility */
#define ECHO yyecho()
#define REJECT yyreject()
#define BEGIN (yy)->yymstart =
#define YYSTATE (yy)->yymstart
#define YY_START (yy)->yymstart
#ifndef input
#define input() (*yy->yyminput)(yy)
#define YY_INPUT
#endif
#ifndef output
#define output(ch) (*yy->yymoutput)(yy, (ch))
#define YY_OUTPUT
#endif
#ifdef unput
#define unput(ch) (*yy->yymunput)(yy, (ch))
#define YY_UNPUT
#endif
#endif
#ifndef MIYCONV_H
#define MIYCONV_H
/************************************************************
miyconv.h
This file can be freely modified for the generation of
custom code.
Copyright (c) 1997-99 P. D. Stearns
************************************************************/
/* variables */
#define yylookahead (yy)->yymlookahead
#define yystackgrow (yy)->yymstackgrow
#define yyexitflg (yy)->yymexitflg
#define yyretireflg (yy)->yymretireflg
#define yyerrorflg (yy)->yymerrorflg
#define yypopflg (yy)->yympopflg
#define yywipeflg (yy)->yymwipeflg
#define yytop (yy)->yymtop
#define yychar (yy)->yymchar
#define yyskip (yy)->yymskip
#define yyerrorcount (yy)->yymerrorcount
#define yyexitcode (yy)->yymexitcode
#define yyretirecode (yy)->yymretirecode
#define yyerrorpop (yy)->yymerrorpop
#define yyparseerr (yy)->yymerr
#define yystackptr (yy)->yymstackptr
#define yysstackptr (yy)->yymsstackptr
#define yystack_size (yy)->yymstack_size
#define yysstack_size (yy)->yymsstack_size
#define yyattribute_size (yy)->yymattribute_size
#define yyvalptr (yy)->yymvalptr
#define yylvalptr (yy)->yymlvalptr
#define yyattributestackptr (yy)->yymattributestackptr
#define yysattributestackptr (yy)->yymsattributestackptr
#define yyparsedebug (yy)->yymdebug
#define yyparsedebugstack (yy)->yymdebugstack
#define yyparsedebugflush (yy)->yymdebugflush
#define yyparsedebugout (yy)->yymdebugout
/* general functions */
#define yycparse() yymcparse(yy)
#define yycwipe() yymcwipe(yy)
#define yycwork() yymcwork(yy)
#define yydestructpop(num) yymdestructpop(yy, (pop))
#define yyparse() yymparse(yy)
#define yyparsecleanup() yymparsecleanup(yy)
#define yyparseinit() yymparseinit(yy)
#define yysetstacksize(size) yymsetstacksize(yy, (size))
#define yysetup() yymsetup(yy)
#define yywipe() yymwipe(yy)
#define yywork() yymwork(yy)
/* service functions */
#define yygettoken() (*yy->yymgettoken)(yy)
#define yystackoverflow() (*yy->yymstackoverflow)(yy)
#define yyerror(text) (*yy->yymerror)(yy, text)
#define yysyntaxerror() (*yy->yymsyntaxerror)(yy)
#define yydiscard() (*yy->yymdiscard)(yy)
/* action functions */
#define yycdestructclearin() yymcdestructclearin(yy)
#define yydestructclearin() yymdestructclearin(yy)
#define yysetin(token) yymsetin(yy, (token)
#define yyunclearin() yymunclearin(yy)
#define yyabort() yymabort(yy)
#define yyaccept() yymaccept(yy)
#define yyclearin() yymclearin(yy)
#define yydestructclearin() yymdestructclearin(yy)
#define yyerrok() yymerrok(yy)
#define yyexit(exitcode) yymexit(yy, (exitcode))
#define yyforceerror() yymforceerror(yy)
#define yypopping() yympopping(yy)
#define yyrecovering() yymrecovering(yy)
#define yyretire(retirecode) yymretire(yy, (retirecode))
#define yythrowerror(pop) yymthrowerror(yy, (pop))
#ifdef YY_COMPATIBLE
#undef yyerrok
#define yyerrok yymerrok(yy)
#undef yyclearin
#define yyclearin yymclearin(yy)
#endif
#define YYACCEPT yymaccept(yy)
#define YYABORT yymabort(yy)
#define YYERROR yymforceerror(yy)
#define YYRECOVERING yymrecovering(yy)
#endif
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
/************************************************************
yycecho.cpp
This file can be freely modified for the generation of
custom code.
Copyright (c) 1997-99 P. D. Stearns
************************************************************/
#include <stdio.h>
#include "clex.h"
void yylexer::yyecho()
{
for (int i = 0; i < yyleng; i++) {
yyoutput(yytext[i]);
}
}
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.