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 source diff could not be displayed because it is too large. You can view the blob instead.
#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
#ifndef CLEX_H
#define CLEX_H
/************************************************************
clex.h
This file can be freely modified for the generation of
custom code.
Copyright (c) 1997-99 P. D. Stearns
************************************************************/
#define YY_ALEX
#include <stdio.h>
#include <assert.h>
// defines
#include <yytdefs.h>
// user defines
#if defined(YYTUDEFS) || defined(YYUDEFS)
#include <yytudefs.h>
#endif
// modifiers
#ifndef YYCDECL
#define YYCDECL
#endif
#ifndef YYDCDECL
#define YYDCDECL
#endif
#ifndef YYNEAR
#define YYNEAR
#endif
#ifndef YYFAR
#define YYFAR
#endif
#ifndef YYNEARFAR
#define YYNEARFAR
#endif
#ifndef YYBASED_CODE
#define YYBASED_CODE
#endif
// forward references
class YYFAR yyparser;
// yylex return values
#define YYEOF 0 // end of file
#ifndef YYSTATE_T
#define YYSTATE_T
typedef struct yystate {
short def; // default state
short base; // base
short match; // action associated with state
} yystate_t;
#endif
#ifndef YYTRANSITION_T
#define YYTRANSITION_T
typedef struct yytransition {
short next; // next state on transition
short check; // check
} yytransition_t;
#endif
#ifndef YYCTRANSITION_T
#define YYCTRANSITION_T
typedef struct yyctransition {
unsigned char first; // first character in range
unsigned char last; // last character in range
short next; // next state on transition
} yyctransition_t;
#endif
typedef short yymatch_t;
typedef unsigned char yybackup_t;
class YYFAR yylexer {
public:
yylexer();
virtual ~yylexer();
// Attributes
protected:
// left context
int yystart; // current start state
unsigned char yyeol; // whether an end-of-line '\n' has been seen
unsigned char yyoldeol; // previous end-of-line value
// text buffer
int YYFAR* yystatebuf; // state buffer
int YYFAR* yysstatebuf; // initial (static) state buffer
char YYFAR* yystext; // initial (static) text buffer
int yytext_size; // text buffer size
int yystext_size; // initial (static) text buffer size
// unput buffer
int YYFAR* yyunputbufptr; // unput buffer
int YYFAR* yysunputbufptr; // initial (static) unput buffer
int yyunput_size; // unput buffer size
int yysunput_size; // initial (static) unput buffer size
int yyunputindex; // unput buffer position
// actions
unsigned char yymoreflg; // concatenate matched strings
unsigned char yyrejectflg; // yyreject called from an action
unsigned char yyreturnflg; // return from an action
public:
yyparser YYFAR* yyparserptr; // pointer to the attached parser
// buffer flags
unsigned char yytextgrow; // whether text buffer is allowed to grow
unsigned char yyunputgrow; // whether unput buffer is allowed to grow
// streams
FILE YYFAR* yyin; // input text stream
FILE YYFAR* yyout; // output text stream
FILE YYFAR* yyerr; // error stream
// matched string
char YYFAR* yytext; // text buffer
int yyleng; // matched string length
int yylineno; // current line number
// Operations
protected:
// helper functions
int yyback(const yymatch_t YYNEARFAR* p, int action) const;
public:
// instance functions
int yycreate(yyparser YYFAR* parserptr = NULL);
void yydestroy();
// general functions
void yycleanup();
virtual int yylex() = 0;
void yyreset();
int yysettextsize(int size);
int yysetunputsize(int size);
// service functions
virtual int yyinput();
virtual void yyoutput(int ch);
virtual void yyunput(int ch);
virtual int yywrap();
virtual int yygetchar();
virtual void yytextoverflow();
virtual void yyunputoverflow();
virtual int yyaction(int action) = 0;
// action functions
void yyecho();
void yyless(int length);
void yybegin(int state) { yystart = state; }
void yymore() { yymoreflg = 1; }
void yynewline(int newline) { newline ? yyeol = 1 : (yyeol = 0); }
void yyreject() { yyrejectflg = 1; }
int yyunputcount() const { return yyunputindex; }
// compatibility
int yyclex() { return yylex(); }
void yylexcleanup() { yycleanup(); }
void yylexinit() { /* do nothing */ }
#define BEGIN yystart =
#define ECHO yyecho()
#define REJECT yyreject()
#define YYSTATE yystart
#define YY_START yystart
// Tables
protected:
const yymatch_t YYNEARFAR* yymatch;
const yystate_t YYNEARFAR* yystate;
const yybackup_t YYNEARFAR* yybackup;
// Debugging
#ifdef YYDEBUG
public:
int yydebug; // whether debug information should be output
int yydebugflush; // whether debug output should be flushed
FILE YYFAR* yydebugout; // debug output file
protected:
void yydebugoutput(int ch) const;
void yydmatch(int expr) const;
void yydebugoutput(const char* string) const;
#endif
};
class YYFAR yyflexer : public yylexer {
public:
yyflexer() { /* do nothing */ }
// Operations
public:
virtual int yylex();
// Tables
protected:
const yytransition_t YYNEARFAR* yytransition;
int yytransitionmax;
};
class YYFAR yyclexer : public yylexer {
public:
yyclexer() { /* do nothing */ }
// Operations
public:
virtual int yylex();
// Tables
protected:
const yyctransition_t YYNEARFAR* yyctransition;
};
// helper functions
#ifndef yyassert
#define yyassert(expr) assert(expr)
#endif
// debugging variables
#ifdef YYDEBUG
extern "C" int YYNEAR YYDCDECL yydebug;
extern "C" int YYNEAR YYDCDECL yydebugflush;
#endif
// user defines
#if defined(YYBUDEFS) || defined(YYUDEFS)
#include <yybudefs.h>
#endif
// defines
#include <yybdefs.h>
#endif
#ifndef CYACC_H
#define CYACC_H
/************************************************************
cyacc.h
This file can be freely modified for the generation of
custom code.
Copyright (c) 1997-99 P. D. Stearns
************************************************************/
#define YY_AYACC
#include <stdio.h>
#include <stddef.h>
#include <assert.h>
// defines
#include <yytdefs.h>
// user defines
#if defined(YYTUDEFS) || defined(YYUDEFS)
#include <yytudefs.h>
#endif
// modifiers
#ifndef YYCDECL
#define YYCDECL
#endif
#ifndef YYDCDECL
#define YYDCDECL
#endif
#ifndef YYNEAR
#define YYNEAR
#endif
#ifndef YYFAR
#define YYFAR
#endif