
//BEGIN ROMTEAM Cristi Petrescu 98-04-
#include "stdafx.h"
#include <afxtempl.h>
typedef enum {begin_french, begin_english, begin_dsgvar} tdeBegin;
// I made this a class just for using CList to build stacks.
class CPA_EdIR_DefineContext
{
public:
	char					*m_pcIndex;
	struct yy_buffer_state	*m_bufLexContext;
};
class CPA_EdIR_DefineContextStack : public CList <CPA_EdIR_DefineContext *, CPA_EdIR_DefineContext *>
{
public:
	void m_fn_vDestroyAndRemoveAllEntries (void);
};
//END ROMTEAM Cristi Petrescu 98-04-



#include <io.h>	//for read()

#include "EdIRbis.hpp"

#include "EdIRDVLs.hpp"
#include "EdIRMacL.hpp"
#include "EdIRFrm.hpp"
#include "EdIRIRD.hpp"
#include "EdIRBeEn.hpp"
#include "EdIRBeha.hpp"
#include "EdIR2Eng.hpp"
#include "EdIRGlob.hpp"
#include "EdIRDict.hpp"
#include "EdIRIAWd.hpp"
#include "EdIRStrg.hpp"

#include "ai_intf.hpp"	//for g_pclAIInterface

#include "CPA_NLL.hpp"

#include "EDACModl.hpp"

extern long gl_MacroAddress;

#include "GAM.h"
#if 0
///////////////////////////////////////////////////////////////////////////
//TEMPORAIRE A ENLEVER LE PLUS RAPIDEMENT POSSIBLE
//#include "GAM\GamInven.h"
#endif //0

#include "IPT.h"

#include "x:\cpa\main\inc\_EditID.h"
#include "TLS/LPSconst.hpp"

#include "GMT.h"

#include "TFA.h"

#include "incAI.h"

#include "_Actors.hpp"

#define YY_USE_CLASS

//ANNECY CB
CString	gcsGlob;
//END
//ROMTEAM Optimisation (Ionut Grozea 24/04/98)
CString cs_params;
int iCount;
long l_id;
//END ROMTEAM Optimisation (Ionut Grozea 24/04/98)

/**********/
/* Macros */
/**********/

#define M_COMPUTE_POSITION()			if(!m_bIsInMacro && !m_bIsInDefine)																							\
																	{																															\
																		m_lOldIndex=m_lIndexWithoutSpaceAndTab;											\
																		m_lIndex+=yyleng;																						\
																		m_lIndexWithoutSpaceAndTab=m_lIndex;												\
																	}

#define M_COMPUTE_ALL()						M_COMPUTE_POSITION();																					\
																	g_clParse.yylval.csInitial=yytext

#define M_COMPUTE_ALL_4_KW()			M_COMPUTE_ALL();																							\
																	long	lIndex=fn_lGetKeyWordIdFromEditorName(yytext);					\
																	fn_vInitNode(&(g_clParse.yylval),m_lIndex,eKeyWord,lIndex);		\
																	if(M_ID_IS_INVALID(lIndex))																			\
																	{																															\
																		g_clParse.m_csMsgError="Unknown KeyWord";										\
																		return CParse::SYNTAXERROR;																	\
																	}

#define M_COMPUTE_ALL_4_OP()			M_COMPUTE_ALL();																							\
																	long	lIndex=fn_lGetOperatorIdFromEditorName(yytext);					\
																	fn_vInitNode(&(g_clParse.yylval),m_lIndex,eOperator,lIndex);	\
																	if(M_ID_IS_INVALID(lIndex))																			\
																	{																															\
																		g_clParse.m_csMsgError="Unknown Operator";									\
																		return CParse::SYNTAXERROR;																	\
																	}

#define M_COMPUTE_ALL_4_OPC()			M_COMPUTE_ALL();																							\
																	long	lIndex=fn_lGetConditionIdFromEditorName(yytext);				\
																	fn_vInitNode(&(g_clParse.yylval),m_lIndex,eCondition,lIndex);	\
																	if(M_ID_IS_INVALID(lIndex))																			\
																	{																															\
																		g_clParse.m_csMsgError="Unknown Condition";									\
																		return CParse::SYNTAXERROR;																	\
																	}

#define M_COMPUTE_ALL_4_BOOL(a)		M_COMPUTE_ALL();																							\
																	fn_vInitNode(&(g_clParse.yylval),m_lIndex,eConstant,(long)(a))

#define M_COMPUTE_ALL_4_COND()		M_COMPUTE_ALL();																							\
																	if(!fn_bIsCondition(yytext,&(g_clParse.yylval)))							\
																	{																															\
																		g_clParse.m_csMsgError="Unknown Condition";									\
																		return CParse::SYNTAXERROR;																	\
																	}

//BEGIN ROMTEAM Cristi Petrescu 98-04-
#define M_EXPAND_DEFINE()											CString csDefineText;											\
																	if (m_clDefineList . Lookup (yytext, csDefineText))				\
																	{																\
																		m_bIsInDefine = TRUE;										\
																		m_fn_vEnterContext ((char *) (LPCSTR) (csDefineText));		\
																		return yylex ();											\
																	}
//END ROMTEAM Cristi Petrescu 98-04-

/*************/
/* Functions */
/*************/

//MetaAction
//ANNECY CB
BOOL fn_bIsMetaAction(CString&,stReturn *);
//BOOL fn_bIsMetaAction(CString,stReturn *);
BOOL fn_bIsMetaAction(char *,stReturn *);
//END

//Condition
//ANNECY CB
BOOL fn_bIsCondition(CString&,stReturn *);
//BOOL fn_bIsCondition(CString,stReturn *);
BOOL fn_bIsCondition(char *,stReturn *);
//END

//Designer Variable
//ANNECY CB
BOOL fn_bIsDesignerVariable(CString&,stReturn *);
//BOOL fn_bIsDesignerVariable(CString,stReturn *);
BOOL fn_bIsDesignerVariable(char *,stReturn *);
//END

//ConstantInt
//ANNECY CB
BOOL fn_bIsAConstantInt(CString&,stReturn *);
//BOOL fn_bIsAConstantInt(CString,stReturn *);
BOOL fn_bIsAConstantInt(char *,stReturn *);
//END

//ConstantReal
//ANNECY CB
BOOL fn_bIsAConstantReal(CString&,stReturn *);
//BOOL fn_bIsAConstantReal(CString,stReturn *);
BOOL fn_bIsAConstantReal(char *,stReturn *);
//END

//Type
//ANNECY CB
BOOL fn_bIsAType(CString&,stReturn *);
//BOOL fn_bIsAType(CString,stReturn *);
BOOL fn_bIsAType(char *,stReturn *);
//END

//Function
//ANNECY CB
BOOL fn_bIsFunction(CString&,stReturn *);
//BOOL fn_bIsFunction(CString,stReturn *);
BOOL fn_bIsFunction(char *,stReturn *);
//END

//Procedure
//ANNECY CB
BOOL fn_bIsProcedure(CString&,stReturn *);
//BOOL fn_bIsProcedure(CString,stReturn *);
BOOL fn_bIsProcedure(char *,stReturn *);
//END

//BEGIN ROMTEAM Cristi Petrescu 98-04-
//Subr
BOOL fn_bIsSubr(CString&,stReturn *);
BOOL fn_bIsSubr(char *,stReturn *);
//END ROMTEAM Cristi Petrescu 98-04-

//Field
//ANNECY CB
BOOL fn_bIsField(CString&,stReturn *);
//BOOL fn_bIsField(CString,stReturn *);
BOOL fn_bIsField(char *,stReturn *);
//END

//Perso (and Always)
//ANNECY CB
BOOL fn_bIsAPerso(CString&,stReturn *);
//BOOL fn_bIsAPerso(CString,stReturn *);
BOOL fn_bIsAPerso(char *,stReturn *);
//END

//ZDD
//ANNECY CB
long fn_lIsAZdd(CString&,stReturn *);
//long fn_lIsAZdd(CString,stReturn *);
long fn_lIsAZdd(char *,stReturn *);
//END

//ZDE
//ANNECY CB
long fn_lIsAZde(CString&,stReturn *);
//long fn_lIsAZde(CString,stReturn *);
long fn_lIsAZde(char *,stReturn *);
//END

//ZDM
//ANNECY CB
long fn_lIsAZdm(CString&,stReturn *);
//long fn_lIsAZdm(CString,stReturn *);
long fn_lIsAZdm(char *,stReturn *);
//END

//ZDR
//ANNECY CB
long fn_lIsAZdr(CString&,stReturn *);
//long fn_lIsAZdr(CString,stReturn *);
long fn_lIsAZdr(char *,stReturn *);
//END

//Action
//ANNECY CB
BOOL fn_bIsAnAction(CString&,stReturn *);
//BOOL fn_bIsAnAction(CString,stReturn *);
BOOL fn_bIsAnAction(char *,stReturn *);
//END

//WayPoint
//ANNECY CB
BOOL fn_bIsAWayPoint(CString&,stReturn *);
//BOOL fn_bIsAWayPoint(CString,stReturn *);
BOOL fn_bIsAWayPoint(char *,stReturn *);
//END

//Channel
//ANNECY CB
BOOL fn_bIsAChannel(CString&,stReturn *);
//BOOL fn_bIsAChannel(CString,stReturn *);
BOOL fn_bIsAChannel(char *,stReturn *);
//END

//Surface
//ANNECY CB
BOOL fn_bIsASurface(CString&,stReturn *);
//BOOL fn_bIsASurface(CString,stReturn *);
BOOL fn_bIsASurface(char *,stReturn *);
//END

//Environment
//ANNECY CB
BOOL fn_bIsAEnvironment(CString&,stReturn *);
//BOOL fn_bIsAEnvironment(CString,stReturn *);
BOOL fn_bIsAEnvironment(char *,stReturn *);
//END

//LipSynchro
//ANNECY CB
BOOL fn_bIsALipSynchro(CString&,stReturn *);
//BOOL fn_bIsALipSynchro(CString,stReturn *);
BOOL fn_bIsALipSynchro(char *,stReturn *);
//END

//Sector
//ANNECY CB
BOOL fn_bIsASector(CString&,stReturn *);
//BOOL fn_bIsASector(CString,stReturn *);
BOOL fn_bIsASector(char *,stReturn *);
//END

//SuperObject
//ANNECY CB
BOOL fn_bIsASuperObject(CString&,stReturn *);
//BOOL fn_bIsASuperObject(CString,stReturn *);
BOOL fn_bIsASuperObject(char *,stReturn *);
//END

//ObjectTable
//ANNECY CB
BOOL fn_bIsAObjectTable(CString&,stReturn *);
//BOOL fn_bIsAObjectTable(CString,stReturn *);
BOOL fn_bIsAObjectTable(char *,stReturn *);
//END

//Family
//ANNECY CB
BOOL fn_bIsAFamily(CString&,stReturn *);
//BOOL fn_bIsAFamily(CString,stReturn *);
BOOL fn_bIsAFamily(char *,stReturn *);
//END

//Model
//ANNECY CB
BOOL fn_bIsAModel(CString&,stReturn *);
//BOOL fn_bIsAModel(CString,stReturn *);
BOOL fn_bIsAModel(char *,stReturn *);
//END

//SoundEvent
//ANNECY CB
BOOL fn_bIsASoundEvent(CString&,stReturn *);
//BOOL fn_bIsASoundEvent(CString,stReturn *);
BOOL fn_bIsASoundEvent(char *,stReturn *);
//END

//GameMaterial
//ANNECY CB
BOOL fn_bIsAGameMaterial(CString&,stReturn *);
//BOOL fn_bIsAGameMaterial(CString,stReturn *);
BOOL fn_bIsAGameMaterial(char *,stReturn *);
//END

//Light
//ANNECY CB
BOOL fn_bIsALight(CString&,stReturn *);
//BOOL fn_bIsALight(CString,stReturn *);
BOOL fn_bIsALight(char *,stReturn *);
//END

//Capabilities
//ANNECY CB
BOOL fn_bIsACaps(CString&,stReturn *);
//BOOL fn_bIsACaps(CString,stReturn *);
BOOL fn_bIsACaps(char *,stReturn *);
//END
//Graph
//ANNECY CB
BOOL fn_bIsAGraph(CString&,stReturn *);
//BOOL fn_bIsAGraph(CString,stReturn *);
BOOL fn_bIsAGraph(char *,stReturn *);
//END

//Reflex Behaviour
//ANNECY CB
BOOL fn_bIsAReflexBehaviour(CString&,stReturn *);
//BOOL fn_bIsAReflexBehaviour(CString,stReturn *);
BOOL fn_bIsAReflexBehaviour(char *,stReturn *);
//END

//Intelligence Behaviour
//ANNECY CB
BOOL fn_bIsAIntelligenceBehaviour(CString&,stReturn *);
//BOOL fn_bIsAIntelligenceBehaviour(CString,stReturn *);
BOOL fn_bIsAIntelligenceBehaviour(char *,stReturn *);
//END

//Reflex Behaviour (for me)
//ANNECY CB
BOOL fn_bIsMyReflexBehaviour(CString&,stReturn *);
//BOOL fn_bIsMyReflexBehaviour(CString,stReturn *);
BOOL fn_bIsMyReflexBehaviour(char *,stReturn *);
//END

//Intelligence Behaviour (for me)
//ANNECY CB
BOOL fn_bIsMyIntelligenceBehaviour(CString&,stReturn *);
//BOOL fn_bIsMyIntelligenceBehaviour(CString,stReturn *);
BOOL fn_bIsMyIntelligenceBehaviour(char *,stReturn *);
//END 

//KeyButton
//ANNECY CB
BOOL fn_bIsAKeyButton(CString&,stReturn *);
//BOOL fn_bIsAKeyButton(CString,stReturn *);
BOOL fn_bIsAKeyButton(char *,stReturn *);
//END

//Mask Type
//ANNECY CB
BOOL fn_bIsAMaskType(CString&,stReturn *);
//BOOL fn_bIsAMaskType(CString,stReturn *);
BOOL fn_bIsAMaskType(char *,stReturn *);
//END

#if 0
//Power
//ANNECY CB
BOOL fn_bIsAPower(CString&,stReturn *);
//BOOL fn_bIsAPower(CString,stReturn *);
BOOL fn_bIsAPower(char *,stReturn *);
//END
#endif //0 car inutilise dans RM 2

//Text
//ANNECY CB
BOOL fn_bIsAText(CString&,stReturn *);
//BOOL fn_bIsAText(CString,stReturn *);
BOOL fn_bIsAText(char *,stReturn *);
//END

//ParticleGenerator
//ANNECY CB
BOOL fn_bIsAParticleGenerator(CString&,stReturn *);
//BOOL fn_bIsAParticleGenerator(CString,stReturn *);
BOOL fn_bIsAParticleGenerator(char *,stReturn *);
//END

//State
//ANNECY CB
BOOL fn_bIsAState(CString&,stReturn *);
//BOOL fn_bIsAState(CString,stReturn *);
BOOL fn_bIsAState(char *,stReturn *);
//END

//Init IntermediateCode Node
void fn_vInitNode(stReturn *,long,tdeNodeType,long,CPA_Actor *pclModel=NULL);
void fn_vInitNode(stReturn *,long,tdeNodeType,double);
void fn_vInitNode(stReturn *,long,tdeNodeType,CString);



define MEMBERS	~CLex();																								\
								void							yyinit(char *,enum tdeTypeText_);			\
								long							m_lOldIndex;													\
								long							m_lIndexWithoutSpaceAndTab;						\
								long							m_lIndex;															\
								long							m_lOldMacroIndex;											\
								BOOL							m_bIsInMacro;													\
								BOOL							m_bIsInDefine;													\
								char							*m_pcIndex;														\
								enum tdeTypeText_	m_eTypeText;		\
								tdeBegin						m_eBegin;	\
								CString							m_csDefineName;	\
								CMapStringToString				m_clDefineList;	\
								CPA_EdIR_DefineContextStack		m_clDefineContextStack;	\
								void m_fn_vEnterContext (char *szStringToParse);									\
								void m_fn_vExitContext (void);


%define INPUT_CODE	{																										\
											if(*m_pcIndex==0)																	\
												result=YY_NULL;																	\
											else																							\
											{																									\
												result=min((size_t)max_size,strlen(m_pcIndex));	\
												strncpy(buffer,m_pcIndex,result);								\
												m_pcIndex+=result;															\
											}																									\
											return result;																		\
										}
						
%define WRAP_CODE	{															\
						if (m_clDefineContextStack . IsEmpty ())				\
						{														\
							return 1;											\
						}														\
						else													\
						{														\
							m_fn_vExitContext ();								\
							if (m_clDefineContextStack . IsEmpty ())			\
								m_bIsInDefine = FALSE;							\
							return 0;											\
						}														\
					}
						
DIGIT		[0-9]
LETTER	[A-Za-z_]
ALNUM		[0-9A-Za-z_]

%s ENGLISH
%s FRENCH
%x DECL_DSG_VAR
//BEGIN ROMTEAM Cristi Petrescu 98-04-
%x DEFINE
%x DEFINE_TEXT
//END ROMTEAM Cristi Petrescu 98-04-

/*<ENGLISH>world												{M_COMPUTE_ALL_4_KW();return CParse::WORLD;}*/
/*<FRENCH>monde													{M_COMPUTE_ALL_4_KW();return CParse::WORLD;}*/

%%

<FRENCH,ENGLISH,DECL_DSG_VAR>";"			{
																				int	c;

																				//for ";" char
																				M_COMPUTE_ALL();

																				while((c=yyinput())!='\xd' && c!=EOF)
																				{
																					M_COMPUTE_ALL();
																				}

																				//for "enter" char
																				M_COMPUTE_ALL();
																			}

<ENGLISH>me														{M_COMPUTE_ALL_4_KW();return CParse::ME;}
<ENGLISH>mainactor										{M_COMPUTE_ALL_4_KW();return CParse::MAINACTOR;}
<ENGLISH,DECL_DSG_VAR>nobody					{M_COMPUTE_ALL_4_KW();return CParse::NOBODY;}
<ENGLISH,DECL_DSG_VAR>nosuperobject				{M_COMPUTE_ALL_4_KW();return CParse::NOSUPEROBJECT;}
<ENGLISH,DECL_DSG_VAR>emptytext				{M_COMPUTE_ALL_4_KW();return CParse::EMPTYTEXT;}
<ENGLISH,DECL_DSG_VAR>nowhere					{M_COMPUTE_ALL_4_KW();return CParse::NOWHERE;}
<ENGLISH,DECL_DSG_VAR>nocomport				{M_COMPUTE_ALL_4_KW();return CParse::NOCOMPORT;}
<ENGLISH,DECL_DSG_VAR>noaction				{M_COMPUTE_ALL_4_KW();return CParse::NOACTION;}
<ENGLISH,DECL_DSG_VAR>capanull				{
																				M_COMPUTE_ALL_4_KW();
																				return CParse::CAPSNULL;
																			}
<ENGLISH,DECL_DSG_VAR>nograph 				{
																				M_COMPUTE_ALL_4_KW();
																				return CParse::NOGRAPH;
																			}

<ENGLISH>or														{M_COMPUTE_ALL_4_COND();return CParse::OR;}
<ENGLISH>xor													{M_COMPUTE_ALL_4_COND();return CParse::XOR;}
<ENGLISH>and													{M_COMPUTE_ALL_4_COND();return CParse::AND;}
<ENGLISH>not													{M_COMPUTE_ALL_4_COND();return CParse::NOT;}
<ENGLISH,DECL_DSG_VAR>true						{M_COMPUTE_ALL_4_BOOL(1);return CParse::BOOLEAN;}
<ENGLISH,DECL_DSG_VAR>false						{M_COMPUTE_ALL_4_BOOL(0);return CParse::BOOLEAN;}
														
<ENGLISH>if														{M_COMPUTE_ALL_4_KW();return CParse::IF;}
<ENGLISH>if2													{M_COMPUTE_ALL_4_KW();return CParse::IF2;}
<ENGLISH>if4													{M_COMPUTE_ALL_4_KW();return CParse::IF4;}
<ENGLISH>if8													{M_COMPUTE_ALL_4_KW();return CParse::IF8;}
<ENGLISH>if16													{M_COMPUTE_ALL_4_KW();return CParse::IF16;}
<ENGLISH>ifdebug												{M_COMPUTE_ALL_4_KW();return CParse::IFDEBUG;}
<ENGLISH>ifnotu64												{M_COMPUTE_ALL_4_KW();return CParse::IFNOTU64;}
<ENGLISH>ifnot													{M_COMPUTE_ALL_4_KW();return CParse::IFNOT;}
<ENGLISH>then													{M_COMPUTE_ALL_4_KW();return CParse::THEN;}
<ENGLISH>else													{M_COMPUTE_ALL_4_KW();return CParse::ELSE;}
<ENGLISH>endif												{M_COMPUTE_ALL_4_KW();return CParse::ENDIF;}
														
<ENGLISH>schedule											{
																				if(m_eTypeText!=ReflexText)
																				{
																					M_COMPUTE_ALL_4_KW();
																					return CParse::SCHEDULE;
																				}
																				else
																					return CParse::SYNTAXERROR;
																			}
<ENGLISH>interruptrule								{M_COMPUTE_ALL_4_KW();return CParse::ITRULES;}
														
<ENGLISH>macro												{M_COMPUTE_ALL();return CParse::MACRO;}
<ENGLISH>subroutine											{M_COMPUTE_ALL();return CParse::SUBROUTINE;}

<ENGLISH>vector												{M_COMPUTE_ALL_4_KW();return CParse::VECTOR;}
<ENGLISH,DECL_DSG_VAR>constantvector	{M_COMPUTE_ALL_4_KW();return CParse::CONSTVECTOR;}

<ENGLISH>"[stopengine]"								{
																				M_COMPUTE_ALL();
																				fn_vInitNode(&(g_clParse.yylval),m_lIndex,eStopEngine,(long)C_ACTION_ENGINE_STOP);
																				
																				return CParse::STOPENGINE;
																			}

<ENGLISH>"[stoprule]"									{
																				M_COMPUTE_ALL();
																				fn_vInitNode(&(g_clParse.yylval),m_lIndex,eStopRule,(long)C_ACTION_ENGINE_STOP_RULE);
																				
																				return CParse::STOPRULE;
																			}

<ENGLISH>"[nonstop]"									{
																				M_COMPUTE_ALL();
																				fn_vInitNode(&(g_clParse.yylval),m_lIndex,eNonStop,(long)C_ACTION_ENGINE_CONTINUE);
																				
																				return CParse::NONSTOP;
																			}

<FRENCH>moi														{M_COMPUTE_ALL_4_KW();return CParse::ME;}
<FRENCH>acteurprincipal								{M_COMPUTE_ALL_4_KW();return CParse::MAINACTOR;}
<FRENCH,DECL_DSG_VAR>personne					{M_COMPUTE_ALL_4_KW();return CParse::NOBODY;}
<FRENCH,DECL_DSG_VAR>sanssuperobjet				{M_COMPUTE_ALL_4_KW();return CParse::NOSUPEROBJECT;}

<FRENCH,DECL_DSG_VAR>textevide				{M_COMPUTE_ALL_4_KW();return CParse::EMPTYTEXT;}
<FRENCH,DECL_DSG_VAR>nullepart				{M_COMPUTE_ALL_4_KW();return CParse::NOWHERE;}
<FRENCH,DECL_DSG_VAR>sanscomportement	{M_COMPUTE_ALL_4_KW();return CParse::NOCOMPORT;}
<FRENCH,DECL_DSG_VAR>sansaction				{M_COMPUTE_ALL_4_KW();return CParse::NOACTION;}
<FRENCH,DECL_DSG_VAR>capazero					{
																				M_COMPUTE_ALL_4_KW();
																				return CParse::CAPSNULL;
																			}
<FRENCH,DECL_DSG_VAR>sansgraph 				{
																				M_COMPUTE_ALL_4_KW();
																				return CParse::NOGRAPH;
																			}

<FRENCH>ou														{M_COMPUTE_ALL_4_COND();return CParse::OR;}
<FRENCH>ouexclusif										{M_COMPUTE_ALL_4_COND();return CParse::XOR;}
<FRENCH>et														{M_COMPUTE_ALL_4_COND();return CParse::AND;}
<FRENCH>non														{M_COMPUTE_ALL_4_COND();return CParse::NOT;}
<FRENCH,DECL_DSG_VAR>vrai							{M_COMPUTE_ALL_4_BOOL(1);return CParse::BOOLEAN;}
<FRENCH,DECL_DSG_VAR>faux							{M_COMPUTE_ALL_4_BOOL(0);return CParse::BOOLEAN;}
														
<FRENCH>si														{M_COMPUTE_ALL_4_KW();return CParse::IF;}
<FRENCH>si2														{M_COMPUTE_ALL_4_KW();return CParse::IF2;}
<FRENCH>si4														{M_COMPUTE_ALL_4_KW();return CParse::IF4;}
<FRENCH>si8														{M_COMPUTE_ALL_4_KW();return CParse::IF8;}
<FRENCH>si16													{M_COMPUTE_ALL_4_KW();return CParse::IF16;}
<FRENCH>sidebug													{M_COMPUTE_ALL_4_KW();return CParse::IFDEBUG;}
<FRENCH>sipasu64												{M_COMPUTE_ALL_4_KW();return CParse::IFNOTU64;}
<FRENCH>sipas													{M_COMPUTE_ALL_4_KW();return CParse::IFNOT;}
<FRENCH>alors													{M_COMPUTE_ALL_4_KW();return CParse::THEN;}
<FRENCH>sinon													{M_COMPUTE_ALL_4_KW();return CParse::ELSE;}
<FRENCH>finsi													{M_COMPUTE_ALL_4_KW();return CParse::ENDIF;}
														
<FRENCH>emploitemps										{
																				if(m_eTypeText!=ReflexText)
																				{
																					M_COMPUTE_ALL_4_KW();
																					return CParse::SCHEDULE;
																				}
																				else
																					return CParse::SYNTAXERROR;
																			}
<FRENCH>regleinterruption							{M_COMPUTE_ALL_4_KW();return CParse::ITRULES;}
														
<FRENCH>macro													{M_COMPUTE_ALL();return CParse::MACRO;}
<FRENCH>subroutine												{M_COMPUTE_ALL();return CParse::SUBROUTINE;}

<FRENCH>vecteur												{M_COMPUTE_ALL_4_KW();return CParse::VECTOR;}
<FRENCH,DECL_DSG_VAR>vecteurconstant	{M_COMPUTE_ALL_4_KW();return CParse::CONSTVECTOR;}

<FRENCH>"[bloquantmoteur]"						{
																				M_COMPUTE_ALL();
																				fn_vInitNode(&(g_clParse.yylval),m_lIndex,eStopEngine,(long)C_ACTION_ENGINE_STOP);
																				
																				return CParse::STOPENGINE;
																			}

<FRENCH>"[bloquantregle]"							{
																				M_COMPUTE_ALL();
																				fn_vInitNode(&(g_clParse.yylval),m_lIndex,eStopRule,(long)C_ACTION_ENGINE_STOP_RULE);
																				
																				return CParse::STOPRULE;
																			}

<FRENCH>"[nonbloquant]"								{
																				M_COMPUTE_ALL();
																				fn_vInitNode(&(g_clParse.yylval),m_lIndex,eNonStop,(long)C_ACTION_ENGINE_CONTINUE);
																				
																				return CParse::NONSTOP;
																			}

beginmacro														{
																				M_COMPUTE_ALL();
																				fn_vInitNode(&(g_clParse.yylval),m_lIndex,eBeginMacro,0L);
																				// BEGIN ROMTEAM Cristi Petrescu 98-08-
																				// see fn_vPostProcessIA
																				//m_bIsInMacro=TRUE;
																				// END ROMTEAM Cristi Petrescu 98-08-
																				return CParse::BEGINMACRO;
																			}
endmacro															{
																				M_COMPUTE_ALL();
																				fn_vInitNode(&(g_clParse.yylval),m_lIndex,eEndMacro,0L);

																				// BEGIN ROMTEAM Cristi Petrescu 98-08-
																				// see fn_vPostProcessIA
																				//m_lOldIndex=m_lOldMacroIndex;
																				//m_lIndexWithoutSpaceAndTab=m_lOldMacroIndex;
																				//m_lIndex=m_lOldMacroIndex;
																				//m_bIsInMacro=FALSE;
																				// END ROMTEAM Cristi Petrescu 98-08-

																				return CParse::ENDMACRO;
																			}
																	
<DECL_DSG_VAR>"private"						{
												//BEGIN ROMTEAM Cristi Petrescu 98-05-
												M_COMPUTE_ALL();
												return CParse::DVQUALIFIER;
												//END ROMTEAM Cristi Petrescu 98-05-
											}

<DECL_DSG_VAR>"public"						{
												//BEGIN ROMTEAM Cristi Petrescu 98-05-
												M_COMPUTE_ALL();
												return CParse::DVQUALIFIER;
												//END ROMTEAM Cristi Petrescu 98-05-
											}
																	
">"																		{M_COMPUTE_ALL_4_OPC();return CParse::OPCOND;}
"<"																		{M_COMPUTE_ALL_4_OPC();return CParse::OPCOND;}
">="																	{M_COMPUTE_ALL_4_OPC();return CParse::OPCOND;}
"<="																	{M_COMPUTE_ALL_4_OPC();return CParse::OPCOND;}
"="																		{M_COMPUTE_ALL_4_OPC();return CParse::OPCOND;}
"<>"																	{M_COMPUTE_ALL_4_OPC();return CParse::OPCOND;}
":="																	{M_COMPUTE_ALL_4_OP();return CParse::OPWITH2PARMS;}
"+="																	{M_COMPUTE_ALL_4_OP();return CParse::OPWITH2PARMS;}
"-="																	{M_COMPUTE_ALL_4_OP();return CParse::OPWITH2PARMS;}
"*="																	{M_COMPUTE_ALL_4_OP();return CParse::OPWITH2PARMS;}
"/="																	{M_COMPUTE_ALL_4_OP();return CParse::OPWITH2PARMS;}
".x:="																{M_COMPUTE_ALL_4_OP();return CParse::OPWITH2PARMS;}
".y:="																{M_COMPUTE_ALL_4_OP();return CParse::OPWITH2PARMS;}
".z:="																{M_COMPUTE_ALL_4_OP();return CParse::OPWITH2PARMS;}
"++"																	{M_COMPUTE_ALL_4_OP();return CParse::OPWITH1PARM;}
"--"																	{M_COMPUTE_ALL_4_OP();return CParse::OPWITH1PARM;}

"::"																	{}


".x"[^A-Za-z:]				{
	unput(yytext[yyleng-1]);
	M_COMPUTE_ALL_4_OP();
	return CParse::OPGETCOMPO;}
".y"[^A-Za-z:]				{
	unput(yytext[yyleng-1]);
	M_COMPUTE_ALL_4_OP();
	return CParse::OPGETCOMPO;}
".z"[^A-Za-z:]				{
	unput(yytext[yyleng-1]);
	M_COMPUTE_ALL_4_OP();
	return CParse::OPGETCOMPO;}
{LETTER}{ALNUM}*/::  {
																				l_id = fn_lGetProcedureIdFromEditorName(yytext);
																				cs_params = fn_csGetProcedureParams(l_id);
																				if (cs_params != "")
																				iCount = 0;
}
{LETTER}{ALNUM}*											{
//Stefan Dumitrean 20-05-98
																				M_COMPUTE_ALL();
//End Stefan Dumitrean																				
																				// before all, check for #defines...
																				//BEGIN ROMTEAM Cristi Petrescu 98-04-
																				M_EXPAND_DEFINE();
																				//END ROMTEAM Cristi Petrescu 98-04-
//Stefan Dumitrean 20-05-98
//																				M_COMPUTE_ALL();
//End Stefan Dumitrean																				
																				if(fn_bIsProcedure(yytext,&(g_clParse.yylval)))
																				{
//ROMTEAM Optimisation (Ionut Grozea 24/04/98)
																					l_id = fn_lGetProcedureIdFromEditorName(yytext);
																					cs_params = fn_csGetProcedureParams(l_id);
																					iCount = 0;
//END ROMTEAM Optimisation (Ionut Grozea 24/04/98)

																					return CParse::PROCEDURE;
																				}
//ROMTEAM Optimisation (Ionut Grozea 24/04/98)
if (cs_params.GetLength()!=0 && iCount< cs_params.GetLength())
{
	switch(cs_params[iCount])
	{
		case 'X':
			{
			iCount++;
			if(fn_bIsFunction(yytext,&(g_clParse.yylval)))
 				return CParse::FUNCTION;
			if(fn_bIsDesignerVariable(yytext,&(g_clParse.yylval)))
				return CParse::DESVAR;
			break;
			}
		case 'A':
			iCount++;
			if(fn_bIsMetaAction(yytext,&(g_clParse.yylval)))
				return CParse::METAACTION;
			break;
		case 'L':
			iCount++;
			if(fn_bIsDesignerVariable(yytext,&(g_clParse.yylval)))
				return CParse::DESVAR;
			break;
		case 'V':
			iCount++;
			if(fn_bIsDesignerVariable(yytext,&(g_clParse.yylval)))
				return CParse::DESVAR;
			break;
		case 'P':
			iCount++;
			if(fn_bIsAType(yytext,&(g_clParse.yylval)))
				return CParse::DVTYPE;
			break;
		default:
		//	iCount++;
			break;
	}

}
//END ROMTEAM Optimisation (Ionut Grozea 24/04/98)

																				if(fn_bIsFunction(yytext,&(g_clParse.yylval)))
 																						return CParse::FUNCTION;

																				if(fn_bIsCondition(yytext,&(g_clParse.yylval)))
																					return CParse::CONDITION;
//ANNECY CB																																			
//																				if(fn_bIsMetaAction(yytext,&(g_clParse.yylval)))
//																					return CParse::METAACTION;
//END
																				if(fn_bIsAType(yytext,&(g_clParse.yylval)))
																					return CParse::DVTYPE;
																				
																				if(fn_bIsField(yytext,&(g_clParse.yylval)))
																					return CParse::FIELD;

																				if(fn_bIsAConstantInt(yytext,&(g_clParse.yylval)))
																					return CParse::CONSTANTINT;

																				if(fn_bIsAConstantReal(yytext,&(g_clParse.yylval)))
																					return CParse::CONSTANTREAL;
																				
//ANNECY CB																																			
																				if(fn_bIsMetaAction(yytext,&(g_clParse.yylval)))
																					return CParse::METAACTION;

																				//BEGIN ROMTEAM Cristi Petrescu 98-04-
																				if (fn_bIsSubr (yytext, & (g_clParse.yylval)))
																					return CParse::SUBRREF;
																				//END ROMTEAM Cristi Petrescu 98-04-
//END
																				//YOU MUST CALL THIS FUNCTION AT THE END
																				if(fn_bIsDesignerVariable(yytext,&(g_clParse.yylval)))
																					return CParse::DESVAR;

																				fn_vInitNode(&(g_clParse.yylval),m_lIndex,eString,yytext);
																				return CParse::STRING;
																			}

<DECL_DSG_VAR>{LETTER}{ALNUM}*				{
//Stefan Dumitrean 20-05-98
																				M_COMPUTE_ALL();
//End Stefan Dumitrean

																				// before all, check for #defines...
																				//BEGIN ROMTEAM Cristi Petrescu 98-04-
																				M_EXPAND_DEFINE ();
																				//END ROMTEAM Cristi Petrescu 98-04-
//Stefan Dumitrean 20-05-98
//																				M_COMPUTE_ALL();
//End Stefan Dumitrean
																				if(fn_bIsAType(yytext,&(g_clParse.yylval)))
																					return CParse::DVTYPE;

																				fn_vInitNode(&(g_clParse.yylval),m_lIndex,eString,yytext);
																				return CParse::STRING;
																			}

\"[^\"]*\"														{
																				M_COMPUTE_ALL();

																				if(strcmp(yytext,"\"\"")==0)
																					return CParse::STRING;

																				//Skips first " and last "
																				yytext[strlen(yytext)-1]=0;
																				yytext++;
//ROMTEAM Optimisation (Ionut Grozea 24/04/98)
if (cs_params.GetLength()!=0 && iCount< cs_params.GetLength())
{
	switch(cs_params[iCount])
	{
		case 'X':
			iCount++;
			if(fn_bIsFunction(yytext,&(g_clParse.yylval)))
 				return CParse::FUNCTION;
			break;
		case 'A':
			iCount++;
			if(fn_bIsAnAction(yytext,&(g_clParse.yylval)))
				return CParse::ACTION;
			break;
		case '2':
			iCount++;
			if(fn_bIsMyIntelligenceBehaviour(yytext,&(g_clParse.yylval)))
				return CParse::MYBEHAV;
			break;
		case '1':
			iCount++;
			if(fn_bIsMyReflexBehaviour(yytext,&(g_clParse.yylval)))
				return CParse::MYREFLEX;
			break;
		case '6':
			iCount++;
			if(fn_bIsAKeyButton(yytext,&(g_clParse.yylval)))
				return CParse::KEYBUTTON;
			break;
		case 'P':
			iCount++;
			if(fn_bIsAPerso(yytext,&(g_clParse.yylval)))
				return CParse::PERSO;
			break;
		case '!':
			iCount++;
			if(fn_bIsAPerso(yytext,&(g_clParse.yylval)))
				return CParse::PERSO;
			break;
		case '4':
			{
			iCount++;
			if(fn_bIsAIntelligenceBehaviour(yytext,&(g_clParse.yylval)))
				return CParse::BEHAV;
			break;
			}
		case 'Z':
			{
			iCount++;
			long	lZdd=fn_lIsAZdd(yytext,&(g_clParse.yylval));
			if(lZdd==1)
				return CParse::ZDD;
			else
				if(lZdd>1)
					return CParse::SYNTAXERROR;
			break;
			}
		case 'E':
			{
			iCount++;
			long	lZde=fn_lIsAZde(yytext,&(g_clParse.yylval));
			if(lZde==1)
				return CParse::ZDE;
			else
				if(lZde>1)
					return CParse::SYNTAXERROR;
			break;
			}
		case 'U':
			{
			iCount++;
			long	lZdm=fn_lIsAZdm(yytext,&(g_clParse.yylval));
			if(lZdm==1)
				return CParse::ZDM;
			else
				if(lZdm>1)
					return CParse::SYNTAXERROR;
			break;
			}
		case 'W':
			iCount++;
			if(fn_bIsAWayPoint(yytext,&(g_clParse.yylval)))
				return CParse::WAYPOINT;
			break;
		case '3':
			iCount++;
			if(fn_bIsAReflexBehaviour(yytext,&(g_clParse.yylval)))
				return CParse::REFLEX;
			break;
		case 'M':
			iCount++;
			if(fn_bIsAChannel(yytext,&(g_clParse.yylval)))
				return CParse::CHANNEL;
			break;
		case 'R':
			iCount++;
			if(fn_bIsASector(yytext,&(g_clParse.yylval)))
				return CParse::SECTOR;
			break;
		case 'o':
			iCount++;
			if(fn_bIsALipSynchro(yytext,&(g_clParse.yylval)))
				return CParse::LIPSYNCHRO;
			break;
		case 'J':
			iCount++;
			if(fn_bIsAObjectTable(yytext,&(g_clParse.yylval)))
				return CParse::OBJECTTABLE;
			break;
		case 'G':
			iCount++;
			if(fn_bIsAFamily(yytext,&(g_clParse.yylval)))
				return CParse::FAMILY;
			break;
		case 'C':
			iCount++;
			if(fn_bIsAGameMaterial(yytext,&(g_clParse.yylval)))
				return CParse::GAMEMATERIAL;
			break;
//		case 'C':
//			iCount++;
//			if(fn_bIsALight(yytext,&(g_clParse.yylval)))
//				return CParse::LIGHT;
//			break;
		case '$':
			iCount++;
            if(fn_bIsAGraph(yytext,&(g_clParse.yylval)))
				return CParse::GRAPH;
			break;
		case '#':
			iCount++;
			if(fn_bIsACaps(yytext,&(g_clParse.yylval)))
				return CParse::CAPS;
			break;
#if 0
		case 'N':
			iCount++;
			if(fn_bIsAPower(yytext,&(g_clParse.yylval)))
				return CParse::POWER;
			break;
#endif //0 car inutilise dans RM 2
		case 'K':
			iCount++;
			if(fn_bIsAMaskType(yytext,&(g_clParse.yylval)))
				return CParse::MASKTYPE;
			break;
		case 'T':
			iCount++;
			if(fn_bIsAText(yytext,&(g_clParse.yylval)))
				return CParse::TEXT;
			break;
		case 'F':
			iCount++;
			if(fn_bIsASurface(yytext,&(g_clParse.yylval)))
				return CParse::SURFACE;
			break;
		case 'H':
			iCount++;
			if(fn_bIsAEnvironment(yytext,&(g_clParse.yylval)))
				return CParse::ENVIRONMENT;
			break;
		default:
			iCount++;
			break;
	}

}

//END ROMTEAM Optimisation (Ionut Grozea 24/04/98)
																				
																				if(fn_bIsAnAction(yytext,&(g_clParse.yylval)))
																					return CParse::ACTION;

//ANNECY CB
																				if(fn_bIsMyIntelligenceBehaviour(yytext,&(g_clParse.yylval)))
																					return CParse::MYBEHAV;
//END
																				if(fn_bIsMyReflexBehaviour(yytext,&(g_clParse.yylval)))
																					return CParse::MYREFLEX;
//ANNECY CB
																				if(fn_bIsAKeyButton(yytext,&(g_clParse.yylval)))
																					return CParse::KEYBUTTON;
//END
//ANNECY CB
//																				if(fn_bIsMyIntelligenceBehaviour(yytext,&(g_clParse.yylval)))
//																					return CParse::MYBEHAV;
//END
																				if(fn_bIsAPerso(yytext,&(g_clParse.yylval)))
																					return CParse::PERSO;

//ANNECY CB
																				if(fn_bIsAIntelligenceBehaviour(yytext,&(g_clParse.yylval)))
																					return CParse::BEHAV;
//END
//ANNECY CB
//																				if(fn_bIsAReflexBehaviour(yytext,&(g_clParse.yylval)))
//																					return CParse::REFLEX;
//END
//ANNECY CB
//																				if(fn_bIsAIntelligenceBehaviour(yytext,&(g_clParse.yylval)))
//																					return CParse::BEHAV;
//END
																				long	lZdd=fn_lIsAZdd(yytext,&(g_clParse.yylval));
																				if(lZdd==1)
																					return CParse::ZDD;
																				else
																				if(lZdd>1)
																					return CParse::SYNTAXERROR;

																				long	lZde=fn_lIsAZde(yytext,&(g_clParse.yylval));
																				if(lZde==1)
																					return CParse::ZDE;
																				else
																				if(lZde>1)
																					return CParse::SYNTAXERROR;

																				long	lZdm=fn_lIsAZdm(yytext,&(g_clParse.yylval));
																				if(lZdm==1)
																					return CParse::ZDM;
																				else
																				if(lZdm>1)
																					return CParse::SYNTAXERROR;

																				long	lZdr=fn_lIsAZdm(yytext,&(g_clParse.yylval));
																				if(lZdr==1)
																					return CParse::ZDR;
																				else
																				if(lZdr>1)
																					return CParse::SYNTAXERROR;
																				if(fn_bIsAWayPoint(yytext,&(g_clParse.yylval)))
																					return CParse::WAYPOINT;

//ANNECY CB
																				if(fn_bIsAReflexBehaviour(yytext,&(g_clParse.yylval)))
																					return CParse::REFLEX;
//END
																				if(fn_bIsAChannel(yytext,&(g_clParse.yylval)))
																					return CParse::CHANNEL;
//ANNECY CB
//																				if(fn_bIsASurface(yytext,&(g_clParse.yylval)))
//																					return CParse::SURFACE;
//																				if(fn_bIsAEnvironment(yytext,&(g_clParse.yylval)))
//																					return CParse::ENVIRONMENT;
//END
																				if(fn_bIsASector(yytext,&(g_clParse.yylval)))
																					return CParse::SECTOR;

																				if(fn_bIsASuperObject(yytext,&(g_clParse.yylval)))
																					return CParse::SUPEROBJECT;

																				if(fn_bIsALipSynchro(yytext,&(g_clParse.yylval)))
																					return CParse::LIPSYNCHRO;

																				if(fn_bIsAObjectTable(yytext,&(g_clParse.yylval)))
																					return CParse::OBJECTTABLE;

																				if(fn_bIsAFamily(yytext,&(g_clParse.yylval)))
																					return CParse::FAMILY;

																				if(fn_bIsAModel(yytext,&(g_clParse.yylval)))
																					return CParse::MODEL;

																				if(fn_bIsASoundEvent(yytext,&(g_clParse.yylval)))
																					return CParse::SOUNDEVENT;

																				if(fn_bIsAGameMaterial(yytext,&(g_clParse.yylval)))
																					return CParse::GAMEMATERIAL;

																				if(fn_bIsALight(yytext,&(g_clParse.yylval)))
																					return CParse::LIGHT;

																				if(fn_bIsACaps(yytext,&(g_clParse.yylval)))
																					return CParse::CAPS;

                                        if(fn_bIsAGraph(yytext,&(g_clParse.yylval)))
																					return CParse::GRAPH;
//ANNECY CB
//																				if(fn_bIsAKeyButton(yytext,&(g_clParse.yylval)))
//																					return CParse::KEYBUTTON;
//END
																				if(fn_bIsAMaskType(yytext,&(g_clParse.yylval)))
																					return CParse::MASKTYPE;

#if 0
																				if(fn_bIsAPower(yytext,&(g_clParse.yylval)))
																					return CParse::POWER;
#endif //0 car inutilise dans RM 2

																				if(fn_bIsAText(yytext,&(g_clParse.yylval)))
																					return CParse::TEXT;

																				if(fn_bIsAParticleGenerator(yytext,&(g_clParse.yylval)))
																					return CParse::PARTGEN;

																				if(fn_bIsAState(yytext,&(g_clParse.yylval)))
																					return CParse::STATE;


																				fn_vInitNode(&(g_clParse.yylval),m_lIndex,eString,yytext);
																				return CParse::STRING;
																			}

<DECL_DSG_VAR>\"[^\"]*\"							{
																				if(strcmp(yytext,"\"\"")==0)
																					return CParse::STRING;

																				M_COMPUTE_ALL();

																				//Skips first " and last "
																				yytext[strlen(yytext)-1]=0;
																				yytext++;

																				if(fn_bIsAnAction(yytext,&(g_clParse.yylval)))
																					return CParse::ACTION;

																				if(fn_bIsAPerso(yytext,&(g_clParse.yylval)))
																					return CParse::PERSO;

																				if(fn_bIsAWayPoint(yytext,&(g_clParse.yylval)))
																					return CParse::WAYPOINT;

																				if(fn_bIsACaps(yytext,&(g_clParse.yylval)))
																					return CParse::CAPS;

                                        if(fn_bIsAGraph(yytext,&(g_clParse.yylval)))
																					return CParse::GRAPH;

																				if(fn_bIsAText(yytext,&(g_clParse.yylval)))
																					return CParse::TEXT;

																				fn_vInitNode(&(g_clParse.yylval),m_lIndex,eString,yytext);
																				return CParse::STRING;
																			}

<FRENCH,ENGLISH,DECL_DSG_VAR>("-")?{DIGIT}+	{
																				M_COMPUTE_ALL();
																				fn_vInitNode(&(g_clParse.yylval),m_lIndex,eConstant,atol(yytext));

																				return CParse::INT;
																			}

<FRENCH,ENGLISH,DECL_DSG_VAR>("-")?{DIGIT}+"."{DIGIT}*	{
																				M_COMPUTE_ALL();
																				fn_vInitNode(&(g_clParse.yylval),m_lIndex,eReal,atof(yytext));

																				return CParse::REAL;
																			}
																			
<FRENCH,ENGLISH,DECL_DSG_VAR>[^ \t\n\xd]	{
																				M_COMPUTE_ALL();
																				return *yytext;
																			}
															
<FRENCH,ENGLISH,DECL_DSG_VAR>[ \t\n\xd]	{
																				m_lIndex+=yyleng;
																			}
															
<FRENCH,ENGLISH,DECL_DSG_VAR>.				{
																				/*printf("!! %s\n",yytext);*/
																				return *yytext;
																			}


<FRENCH>^"#define"							{
//BEGIN ROMTEAM Cristi Petrescu 98-04-
//Stefan Dumitrean 20-05-98
													M_COMPUTE_ALL();
//End Stefan Dumitrean
													// trick to remember the initial state
													m_eBegin = begin_french;
													//yy_start_old = yy_start;
													BEGIN (DEFINE);
//END ROMTEAM Cristi Petrescu 98-04-
											}

<ENGLISH>^"#define"							{
//BEGIN ROMTEAM Cristi Petrescu 98-04-
//Stefan Dumitrean 20-05-98
													M_COMPUTE_ALL();
//End Stefan Dumitrean
													// trick to remember the initial state
													m_eBegin = begin_english;
													//yy_start_old = yy_start;
													BEGIN (DEFINE);
//END ROMTEAM Cristi Petrescu 98-04-
											}

<DECL_DSG_VAR>^"#define"									{
//BEGIN ROMTEAM Cristi Petrescu 98-04-
//Stefan Dumitrean 20-05-98
													M_COMPUTE_ALL();
//End Stefan Dumitrean
													// trick to remember the initial state
													m_eBegin = begin_dsgvar;
													//yy_start_old = yy_start;
													BEGIN (DEFINE);
//END ROMTEAM Cristi Petrescu 98-04-
											}

<DEFINE>{LETTER}{ALNUM}*					{
//BEGIN ROMTEAM Cristi Petrescu 98-04-
//Stefan Dumitrean 20-05-98
													M_COMPUTE_ALL();
//End Stefan Dumitrean
													// get the definiton name
													m_csDefineName = yytext;
													// and get the text, too
													BEGIN (DEFINE_TEXT);
//END ROMTEAM Cristi Petrescu 98-04-
											}

<DEFINE_TEXT>[^\n]+							{
//BEGIN ROMTEAM Cristi Petrescu 98-04-
//Stefan Dumitrean 20-05-98
													M_COMPUTE_ALL();
//End Stefan Dumitrean
													// add the define into the table
													CString csDefineText = yytext;
													m_clDefineList . SetAt (m_csDefineName, csDefineText);
//END ROMTEAM Cristi Petrescu 98-04-
											}

<DEFINE_TEXT>[\n]							{
//BEGIN ROMTEAM Cristi Petrescu 98-04-
//Stefan Dumitrean 20-05-98
													m_lIndex+=yyleng;
//End Stefan Dumitrean
													// go back
													//yy_start = yy_start_old;
													switch (m_eBegin)
													{
													case begin_french: 
														BEGIN (FRENCH);
														break;
													case begin_english:
														BEGIN (ENGLISH);
														break;
													case begin_dsgvar:
														BEGIN (DECL_DSG_VAR);
														break;
													}
//END ROMTEAM Cristi Petrescu 98-04-
											}
<DEFINE,DEFINE_TEXT>[ \t\n\xd]              {
//Stefan Dumitrean 20-05-98

													m_lIndex+=yyleng;
//End Stefan Dumitrean

											}

%%

//Some useful macros
#define M_MAKECHAR(a)			((char *)(LPCTSTR(a)))

//ANNECY CB
#define CSTRING_EQ(cs, psz)\
{\
	cs= psz;\
}
//END

//MetaAction
/****************************************************************************/
//ANNECY CB
BOOL fn_bIsMetaAction(CString &csString,stReturn *pstReturn)
//BOOL fn_bIsMetaAction(CString csString,stReturn *pstReturn)
//END
{
	long	lIndex=fn_lGetMetaActionIdFromEditorName(csString);

	if(M_ID_IS_VALID(lIndex))
	{
		fn_vInitNode(pstReturn,g_clLex.m_lIndex,eMetaAction,lIndex);

		return TRUE;
	}
	else
		return FALSE;
}
//ANNECY CB
BOOL fn_bIsMetaAction(char *csString,stReturn *pstReturn)
{
	CSTRING_EQ(gcsGlob, csString);
	return fn_bIsMetaAction(gcsGlob,pstReturn);
}
//END

//Condition
/****************************************************************************/
//ANNECY CB
BOOL fn_bIsCondition(CString &csString,stReturn *pstReturn)
//BOOL fn_bIsCondition(CString csString,stReturn *pstReturn)
//END
{
	long	lIndex=fn_lGetConditionIdFromEditorName(csString);

	if(M_ID_IS_VALID(lIndex))
	{
		fn_vInitNode(pstReturn,g_clLex.m_lIndex,eCondition,lIndex);

		return TRUE;
	}
	else
		return FALSE;
}
//ANNECY CB
BOOL fn_bIsCondition(char *csString,stReturn *pstReturn)
{
	CSTRING_EQ(gcsGlob, csString);
	return fn_bIsCondition(gcsGlob,pstReturn);
}
//END

//Designer Variable
/****************************************************************************/
//ANNECY CB
BOOL fn_bIsDesignerVariable(CString &csString,stReturn *pstReturn)
//BOOL fn_bIsDesignerVariable(CString csString,stReturn *pstReturn)
//END
{
	//First looks in current dsg var list
//ANNECY CB
	long lIndex = g_clDsgVarList.m_fn_bIsADesignerVariable(csString) - 1;
	if(lIndex >= 0)
//	if(g_clDsgVarList.m_fn_bIsADesignerVariable(csString))
	{
//		long	lIndex=g_clDsgVarList.m_fn_lGetIndexOfADesignerVariable(csString);
//END

		fn_vInitNode(pstReturn,g_clLex.m_lIndex,eDsgVar,lIndex,g_pclCurrentModel);

		CPA_EdIR_IntermediateCode *pclIntermediateCode=pstReturn->clIntermediateCodeList.GetTail();

		pclIntermediateCode->m_fn_vSetString(csString);

		return TRUE;
	}
	else
	{
		//Looks in all models
		CPA_List<CPA_BaseObject> clModelsList;
		g_pclAIInterface->GetMainWorld()->fn_lFindObjects(&clModelsList,"",C_szActorModelTypeName,NO_CRITERIA);

		POSITION				pos=clModelsList.GetHeadPosition();
		BOOL						bFound=FALSE;
		long						lNoDsgVar=0;
		CPA_Actor	*pclModel=NULL;
		while(pos!=NULL && !bFound)
		{
			CPA_Actor	*pclActor=(CPA_Actor *)(clModelsList.GetNext(pos));

			if(pclActor->fn_bIsAvailable())
			{
				pclModel=pclActor;

				if(pclModel!=g_pclCurrentModel)
				{
					CPA_EdIR_Brain	*pclBrain=((EdActors_EditorActorModel *)pclModel->m_fn_pclGetEditorActor())->m_pclBrain;

					CString	csIn;

					if(!pclBrain->m_clListOfDeclarations.IsEmpty())
					{
						//Gets Designer Variable MainBehaviour (first element in the list)
						CPA_EdIR_MainBehaviour *pclMainBehaviour=pclBrain->m_clListOfDeclarations.GetHead();

						//Gets text declaraition
						if(pclMainBehaviour->m_pclBehaviour!=NULL)
							csIn=pclMainBehaviour->m_pclBehaviour->m_fn_csGetRules();
						else
							csIn=pclMainBehaviour->m_csText;

						csIn=fn_csGetCodeWithoutComments(csIn);

						//Looks for dsg var in this text
						long		lCurrentIndex=0;
						CString	csWord=fn_csGetNextWord(csIn,lCurrentIndex);
						lNoDsgVar=0;
						while(!csWord.IsEmpty() && !bFound)
						{
							BOOL bPublic = TRUE;
							
							// skip private & public
							if (fn_bIsDsgVarQualifier(csWord))
							{
								bPublic = csWord.CompareNoCase("private");
								csWord=fn_csGetNextWord(csIn,lCurrentIndex);
							}

							//Gets Type
							tdeDsgVarTypeId	eDsgVarTypeId=(tdeDsgVarTypeId)fn_lGetDsgVarTypeIdFromEditorName(csWord);

							//Gets Name
							csWord=fn_csGetNextWord(csIn,lCurrentIndex);

							if(csWord.CompareNoCase(csString)==0)
								bFound=TRUE;
							else
							{
								//Skips Value
								fn_csGetNextWord(csIn,lCurrentIndex);

								if(eDsgVarTypeId==eDsgVarType_Vector)
								{
									//Skips x,y,z components
									fn_csGetNextWord(csIn,lCurrentIndex);
									fn_csGetNextWord(csIn,lCurrentIndex);
									fn_csGetNextWord(csIn,lCurrentIndex);
								}

								//Skips type
								csWord=fn_csGetNextWord(csIn,lCurrentIndex);

								lNoDsgVar++;
							}
						}
					}
				}
			}
		}

		long	lIndex=lNoDsgVar;

		if(bFound)
		{
			fn_vInitNode(pstReturn,g_clLex.m_lIndex,eDsgVar,lIndex,pclModel);

			CPA_EdIR_IntermediateCode *pclIntermediateCode=pstReturn->clIntermediateCodeList.GetTail();

			pclIntermediateCode->m_fn_vSetString(csString);
		}

		return bFound;
	}
}
//ANNECY CB
BOOL fn_bIsDesignerVariable(char *csString,stReturn *pstReturn)
{
	CSTRING_EQ(gcsGlob, csString);
	return fn_bIsDesignerVariable(gcsGlob,pstReturn);
}
//END

//ConstantInt
/****************************************************************************/
//ANNECY CB
BOOL fn_bIsAConstantInt(CString &csString,stReturn *pstReturn)
//BOOL fn_bIsAConstantInt(CString csString,stReturn *pstReturn)
//END
{
	CPA_EdIR_Frame *pclMainFrame=g_pclAIInterface->m_pclIRMainFrame;

	if(pclMainFrame!=NULL)
	{
		if(pclMainFrame->m_clConstantList.m_fn_bIsAConstant(csString))
		{
			CString	csValue=pclMainFrame->m_clConstantList.m_fn_csGetValueOfAConstant(csString);

			if(pclMainFrame->m_clConstantList.m_fn_csGetTypeOfAConstant(csString)==g_c_csInteger)
			{
				long	lValue=atol(M_MAKECHAR(csValue));

				fn_vInitNode(pstReturn,g_clLex.m_lIndex,eConstantInt,lValue);

				CPA_EdIR_IntermediateCode *pclIntermediateCode=pstReturn->clIntermediateCodeList.GetTail();
				pclIntermediateCode->m_fn_vSetString(csString);

				return TRUE;
			}
			else
				return FALSE;
		}
		else
			return FALSE;
	}
	else
		return FALSE;
}
//ANNECY CB
BOOL fn_bIsAConstantInt(char *csString,stReturn *pstReturn)
{
	CSTRING_EQ(gcsGlob, csString);
	return fn_bIsAConstantInt(gcsGlob,pstReturn);
}
//END

//ConstantReal
/****************************************************************************/
//ANNECY CB
BOOL fn_bIsAConstantReal(CString &csString,stReturn *pstReturn)
//BOOL fn_bIsAConstantReal(CString csString,stReturn *pstReturn)
//END
{
	CPA_EdIR_Frame *pclMainFrame=g_pclAIInterface->m_pclIRMainFrame;

	if(pclMainFrame!=NULL)
	{
		if(pclMainFrame->m_clConstantList.m_fn_bIsAConstant(csString))
		{
			CString	csValue=pclMainFrame->m_clConstantList.m_fn_csGetValueOfAConstant(csString);

			if(pclMainFrame->m_clConstantList.m_fn_csGetTypeOfAConstant(csString)==g_c_csDecimal)
			{
				double	dfValue=atof(M_MAKECHAR(csValue));

				fn_vInitNode(pstReturn,g_clLex.m_lIndex,eConstantReal,dfValue);

				CPA_EdIR_IntermediateCode *pclIntermediateCode=pstReturn->clIntermediateCodeList.GetTail();
				pclIntermediateCode->m_fn_vSetString(csString);

				return TRUE;
			}
			else
				return FALSE;
		}
		else
			return FALSE;
	}
	else
		return FALSE;
}
//ANNECY CB
BOOL fn_bIsAConstantReal(char *csString,stReturn *pstReturn)
{
	CSTRING_EQ(gcsGlob, csString);
	return fn_bIsAConstantReal(gcsGlob,pstReturn);
}
//END

//Type
/****************************************************************************/
//ANNECY CB
BOOL fn_bIsAType(CString &csString,stReturn *pstReturn)
//BOOL fn_bIsAType(CString csString,stReturn *pstReturn)
//END
{
	long	lIndex=fn_lGetDsgVarTypeIdFromEditorName(csString);

	if(M_ID_IS_VALID(lIndex))
	{
		fn_vInitNode(pstReturn,g_clLex.m_lIndex,eCreateDsgVar,lIndex);

		return TRUE;
	}
	else
		return FALSE;
}
//ANNECY CB
BOOL fn_bIsAType(char *csString,stReturn *pstReturn)
{
	CSTRING_EQ(gcsGlob, csString);
	return fn_bIsAType(gcsGlob,pstReturn);
}
//END

//Function
/****************************************************************************/
//ANNECY CB
BOOL fn_bIsFunction(CString &csString,stReturn *pstReturn)
//BOOL fn_bIsFunction(CString csString,stReturn *pstReturn)
//END
{
	long	lIndex=fn_lGetFunctionIdFromEditorName(csString);

	if(M_ID_IS_VALID(lIndex))
	{
		fn_vInitNode(pstReturn,g_clLex.m_lIndex,eFunction,lIndex);

		return TRUE;
	}
	else
		return FALSE;
}
//ANNECY CB
BOOL fn_bIsFunction(char *csString,stReturn *pstReturn)
{
	CSTRING_EQ(gcsGlob, csString);
	return fn_bIsFunction(gcsGlob,pstReturn);
}
//END

//Procedure
/****************************************************************************/
//ANNECY CB
BOOL fn_bIsProcedure(CString &csString,stReturn *pstReturn)
//BOOL fn_bIsProcedure(CString csString,stReturn *pstReturn)
//END
{
	long	lIndex=fn_lGetProcedureIdFromEditorName(csString);

	if(M_ID_IS_VALID(lIndex))
	{
		fn_vInitNode(pstReturn,g_clLex.m_lIndex,eProcedure,lIndex);

		return TRUE;
	}
	else
		return FALSE;
}
//ANNECY CB
BOOL fn_bIsProcedure(char *csString,stReturn *pstReturn)
{
	CSTRING_EQ(gcsGlob, csString);
	return fn_bIsProcedure(gcsGlob,pstReturn);
}
//END

//BEGIN ROMTEAM Cristi Petrescu 98-04-
//Subr
/****************************************************************************/
BOOL fn_bIsSubr(CString &csString,stReturn *pstReturn)
{
	if (g_pclListOfSubrs -> m_fn_bIsInList (csString))
	{
		CPA_EdIR_MainBehaviour *pclMainBehaviour = g_pclListOfSubrs -> m_fn_pclGetMainBehaviour(csString);

		//Keeps the editor pointer
		//Converts it to a engine pointer before engine start
		long lIndex = (long) pclMainBehaviour;
		fn_vInitNode (pstReturn, g_clLex . m_lIndex, eSubrRef, lIndex);

		return TRUE;
	}

	return FALSE;
	//return g_pclListOfSubrs -> m_fn_bIsInList (csString);
}

BOOL fn_bIsSubr(char *csString,stReturn *pstReturn)
{
	CSTRING_EQ(gcsGlob, csString);
	return fn_bIsSubr(gcsGlob,pstReturn);
}
//END ROMTEAM Cristi Petrescu 98-04-

//Field
/****************************************************************************/
//ANNECY CB
BOOL fn_bIsField(CString &csString,stReturn *pstReturn)
//BOOL fn_bIsField(CString csString,stReturn *pstReturn)
//END
{
	long	lIndex=fn_lGetFieldIdFromEditorName(csString);	

	if(M_ID_IS_VALID(lIndex))
	{
		fn_vInitNode(pstReturn,g_clLex.m_lIndex,eField,lIndex);

		return TRUE;
	}
	else
		return FALSE;
}
//ANNECY CB
BOOL fn_bIsField(char *csString,stReturn *pstReturn)
{
	CSTRING_EQ(gcsGlob, csString);
	return fn_bIsField(gcsGlob,pstReturn);
}
//END

//Known editor object
/****************************************************************************/
//ANNECY CB
BOOL fn_bIsAKnownEditorObject(CString &csString,stReturn *pstReturn,char *csTypeName,tdeNodeType eNodeType)
//BOOL fn_bIsAKnownEditorObject(CString csString,stReturn *pstReturn,CString csTypeName,tdeNodeType eNodeType)
//END
{
	CPA_BaseObject	*pclBaseObject;
	pclBaseObject=g_pclAIInterface->GetMainWorld()->fn_p_oFindObject(M_MAKECHAR(csString),csTypeName);

	if(pclBaseObject!=NULL)
	{
		if(pclBaseObject->fn_bIsAvailable()==FALSE)
			pclBaseObject->GetEditor()->fn_bLoadBaseObject(pclBaseObject);

		long	lIndex=long(pclBaseObject->GetData());

		fn_vInitNode(pstReturn,g_clLex.m_lIndex,eNodeType,lIndex);
	}

	return (pclBaseObject!=NULL);
}

//Perso (and Always)
/****************************************************************************/
//ANNECY CB
BOOL fn_bIsAPerso(CString &csString,stReturn *pstReturn)
//BOOL fn_bIsAPerso(CString csString,stReturn *pstReturn)
//END
{
	return fn_bIsAKnownEditorObject(csString,pstReturn,C_szActorInstanceTypeName,ePerso);
}
//ANNECY CB
BOOL fn_bIsAPerso(char *csString,stReturn *pstReturn)
{
	CSTRING_EQ(gcsGlob, csString);
	return fn_bIsAPerso(gcsGlob,pstReturn);
}
//END

//For ZDD ZDM ZDE ZDR and WAY
/****************************************************************************/
//ANNECY CB
long fn_lIsAZdxOrAWay(CString &csString,long &lIndex,CString &csObjectType)
//long fn_lIsAZdxOrAWay(CString csString,long &lIndex,CString &csObjectType)
//END
{
	stIndexOfNameInfo	stInfo;
	stInfo.csNameOfObject=csString;

	CPA_DLLBase	*pclActorDLL=(CPA_DLLBase*)(g_pclAIInterface->GetMainWorld()->GetObjectDLLWithName(C_szDLLActorName));
	long				lResultIndex=pclActorDLL->OnQueryAction(g_pclAIInterface,C_uiActor_GetIndexOfName,(long)&stInfo);

	csObjectType=stInfo.csObjectType;
	CPA_Actor	*pclModel=stInfo.pclModel;

	switch (lResultIndex)
	{
		case C_wNoNameFound:
			return 0;

		case C_wMultipleNamesFound:
			AfxMessageBox("Conflict with "+csString+"\nTry to use ListName@ObjectName");
			return 2;

		case C_wNoNameListFound:
			return 0;

		case C_wMultipleNameListsFound:
			AfxMessageBox("Conflict with "+csString+"\nTry to use FamilyName@ListName@ObjectName");
			return 2;

		case C_wNoFamilyFound:
			return 0;

		case C_wMultipleFamiliesFound:
			AfxMessageBox("PB : FamilyName are not unique !!!");
			return 2;

		default:
			lIndex=lResultIndex;
			return 1;
	}
}

//ZDD
/****************************************************************************/
//ANNECY CB
long fn_lIsAZdd(CString &csString,stReturn *pstReturn)
//long fn_lIsAZdd(CString csString,stReturn *pstReturn)
//END
{
	CString	csObjectType;
	long		lIndex;
	long		lResult=fn_lIsAZdxOrAWay(csString,lIndex,csObjectType);

	if(lResult!=1)
		return lResult;
	else
	if(csObjectType==C_szZDdNameListType)
	{
		lIndex++;

		fn_vInitNode(pstReturn,g_clLex.m_lIndex,eZdd,lIndex);

		return 1;
	}
	else
		return 0;
}
//ANNECY CB
long fn_lIsAZdd(char *csString,stReturn *pstReturn)
{
	CSTRING_EQ(gcsGlob, csString);
	return fn_lIsAZdd(gcsGlob,pstReturn);
}
//END

//ZDE
/****************************************************************************/
//ANNECY CB
long fn_lIsAZde(CString &csString,stReturn *pstReturn)
//long fn_lIsAZde(CString csString,stReturn *pstReturn)
//END
{
	CString	csObjectType;
	long		lIndex;
	long		lResult=fn_lIsAZdxOrAWay(csString,lIndex,csObjectType);

	if(lResult!=1)
		return lResult;
	else
	if(csObjectType==C_szZDeNameListType)
	{
		lIndex++;

		fn_vInitNode(pstReturn,g_clLex.m_lIndex,eZde,lIndex);

		return 1;
	}
	else
		return 0;
}
//ANNECY CB
long fn_lIsAZde(char *csString,stReturn *pstReturn)
{
	CSTRING_EQ(gcsGlob, csString);
	return fn_lIsAZde(gcsGlob,pstReturn);
}
//END

//ZDM
/****************************************************************************/
//ANNECY CB
long fn_lIsAZdm(CString &csString,stReturn *pstReturn)
//long fn_lIsAZdm(CString csString,stReturn *pstReturn)
//END
{
	CString	csObjectType;
	long		lIndex;
	long		lResult=fn_lIsAZdxOrAWay(csString,lIndex,csObjectType);

	if(lResult!=1)
		return lResult;
	else
	if(csObjectType==C_szZDmNameListType)
	{
		lIndex++;

		fn_vInitNode(pstReturn,g_clLex.m_lIndex,eZdm,lIndex);

		return 1;
	}
	else
		return 0;
}
//ANNECY CB
long fn_lIsAZdm(char *csString,stReturn *pstReturn)
{
	CSTRING_EQ(gcsGlob, csString);
	return fn_lIsAZdm(gcsGlob,pstReturn);
}
//END

//ZDM
/****************************************************************************/
//ANNECY CB
long fn_lIsAZdr(CString &csString,stReturn *pstReturn)
//long fn_lIsAZdr(CString csString,stReturn *pstReturn)
//END
{
	CString	csObjectType;
	long		lIndex;
	long		lResult=fn_lIsAZdxOrAWay(csString,lIndex,csObjectType);

	if(lResult!=1)
		return lResult;
	else
	if(csObjectType==C_szZDrNameListType)
	{
		lIndex++;

		fn_vInitNode(pstReturn,g_clLex.m_lIndex,eZdr,lIndex);

		return 1;
	}
	else
		return 0;
}
//ANNECY CB
long fn_lIsAZdr(char *csString,stReturn *pstReturn)
{
	CSTRING_EQ(gcsGlob, csString);
	return fn_lIsAZdr(gcsGlob,pstReturn);
}
//END

//***********************************************************************
void fn_vSplitName(CString csName,CString &csOwner,CString &csObject)
{
	int	iPos;
	
	// extract object
	iPos = csName.ReverseFind('@');
	if (iPos != -1)
	{
		csObject = csName.Right(csName.GetLength()-iPos-1);
		csOwner = csName.Left(iPos);
	}
	else
	{
		csObject = csName;
	}
}

//Action
/****************************************************************************/
//ANNECY CB
BOOL fn_bIsAnAction(CString &csString,stReturn *pstReturn)
//BOOL fn_bIsAnAction(CString csString,stReturn *pstReturn)
//END
{
	//Looks if it is a action of the current family
	long	lIndex=long(((EdActors_EditorActorModel *)g_pclCurrentModel->m_fn_pclGetEditorActor())->m_pclBrain->m_fn_pvGetStateHandle(csString));

	if(lIndex!=NULL)
	{
		fn_vInitNode(pstReturn,g_clLex.m_lIndex,eAction,lIndex);

		return TRUE;
	}
	else
	{
		CPA_BaseObject *pclOwner=NO_CRITERIA;

		//Try to split action name
		CString	csFamily;
		CString	csAction;
		fn_vSplitName(csString,csFamily,csAction);

		if(!csFamily.IsEmpty())
			pclOwner=g_pclAIInterface->GetMainWorld()->fn_p_oFindObject(M_MAKECHAR(csFamily),C_szFamilyTypeName);

		//Looks in other family
		CPA_List<CPA_BaseObject> clObjectLists;
		long lNumActions=g_pclAIInterface->GetMainWorld()->fn_lFindObjects(&clObjectLists,M_MAKECHAR(csAction),C_szActionTypeName,pclOwner);

		CPA_BaseObject	*pclBaseObject=NULL;

		if(lNumActions==1)
		{
			pclBaseObject=clObjectLists.GetHead();

			if(pclBaseObject!=NULL)
			{
				if(pclBaseObject->fn_bIsAvailable()==FALSE)
					pclBaseObject->GetEditor()->fn_bLoadBaseObject(pclBaseObject);

				CPA_Action	*pclAction=(CPA_Action *)pclBaseObject;

				if(pclAction->mfn_p_oGetDefaultState()!=NULL)
				{
					lIndex=long(pclAction->mfn_p_oGetDefaultState()->GetData());
				}
				else
				{
					AfxMessageBox("The action \""+pclAction->GetName()+"\" has no Initial State !!!!");

					return FALSE;
				}

				fn_vInitNode(pstReturn,g_clLex.m_lIndex,eAction,lIndex);
			}
		}
		else
		if(lNumActions>1)
		{
			AfxMessageBox("Conflict with "+csString+"\nTry to use FamilyName@ActionName");
		}

		return (pclBaseObject!=NULL);
	}
}
//ANNECY CB
BOOL fn_bIsAnAction(char *csString,stReturn *pstReturn)
{
	CSTRING_EQ(gcsGlob, csString);
	return fn_bIsAnAction(gcsGlob,pstReturn);
}
//END

//WayPoint
/****************************************************************************/
//ANNECY CB
BOOL fn_bIsAWayPoint(CString &csString,stReturn *pstReturn)
//BOOL fn_bIsAWayPoint(CString csString,stReturn *pstReturn)
//END
{
	return fn_bIsAKnownEditorObject(csString,pstReturn,C_szWayPointTypeName,eWayPoint);
}
//ANNECY CB
BOOL fn_bIsAWayPoint(char *csString,stReturn *pstReturn)
{
	CSTRING_EQ(gcsGlob, csString);
	return fn_bIsAWayPoint(gcsGlob,pstReturn);
}
//END

//Channel
/****************************************************************************/
//ANNECY CB
BOOL fn_bIsAChannel(CString &csString,stReturn *pstReturn)
//BOOL fn_bIsAChannel(CString csString,stReturn *pstReturn)
//END
{
	CPA_DLLBase *pclFamilyDLL=(CPA_DLLBase*)(g_pclAIInterface->GetMainWorld()->GetToolDLLWithName(C_szDLLFamilyName));

	if(pclFamilyDLL!=NULL)
	{
		CString	csFamilyName;
		CString	csChannelName;
		fn_vSplitName(csString,csFamilyName,csChannelName);

		tdstChannelInfoSearch stChannelInfo;

		if(!csFamilyName.IsEmpty())
			stChannelInfo.p_oFamily=(CPA_Family *)g_pclAIInterface->GetMainWorld()->fn_p_oFindObject(M_MAKECHAR(csFamilyName),C_szFamilyTypeName);
		else
			stChannelInfo.p_oFamily=NULL;

		stChannelInfo.szChannel=(char *)LPCTSTR(csChannelName);
		stChannelInfo.lIndexOfChannel=0;

		if(pclFamilyDLL->OnQueryAction(g_pclAIInterface,C_uiGetChannel,(LPARAM)&stChannelInfo)==1)
		{
			long	lIndex=stChannelInfo.lIndexOfChannel;

			fn_vInitNode(pstReturn,g_clLex.m_lIndex,eModule,lIndex);

			return TRUE;
		}
		else
		if(pclFamilyDLL->OnQueryAction(g_pclAIInterface,C_uiGetChannel,(LPARAM)&stChannelInfo)==2)
		{
			AfxMessageBox("Conflict with "+csString+"\nTry to use FamilyName@ObjectName");
		}
		else
			return FALSE;
	}

	return FALSE;
}
//ANNECY CB
BOOL fn_bIsAChannel(char *csString,stReturn *pstReturn)
{
	CSTRING_EQ(gcsGlob, csString);
	return fn_bIsAChannel(gcsGlob,pstReturn);
}
//END

//Surface
/****************************************************************************/
//ANNECY CB
BOOL fn_bIsASurface(CString &csString,stReturn *pstReturn)
//BOOL fn_bIsASurface(CString csString,stReturn *pstReturn)
//END
{
	return fn_bIsAKnownEditorObject(csString,pstReturn,C_szSurfaceTypeName,eSurface);
}
//ANNECY CB
BOOL fn_bIsASurface(char *csString,stReturn *pstReturn)
{
	CSTRING_EQ(gcsGlob, csString);
	return fn_bIsASurface(gcsGlob,pstReturn);
}
//END

//Environment
/****************************************************************************/
//ANNECY CB
BOOL fn_bIsAEnvironment(CString &csString,stReturn *pstReturn)
//BOOL fn_bIsAEnvironment(CString csString,stReturn *pstReturn)
//END
{
	return fn_bIsAKnownEditorObject(csString,pstReturn,C_szEnvironmentTypeName,eEnvironment);
}
//ANNECY CB
BOOL fn_bIsAEnvironment(char *csString,stReturn *pstReturn)
{
	CSTRING_EQ(gcsGlob, csString);
	return fn_bIsAEnvironment(gcsGlob,pstReturn);
}
//END

//LipSynchro
/****************************************************************************/
//ANNECY CB
BOOL fn_bIsALipSynchro(CString &csString,stReturn *pstReturn)
//BOOL fn_bIsALipSynchro(CString csString,stReturn *pstReturn)
//END
{
	CPA_DLLBase *pclTLSDLL=(CPA_DLLBase*)(g_pclAIInterface->GetMainWorld()->GetToolDLLWithName(C_szLipSyncDLLName));

	if(pclTLSDLL!=NULL)
	{
		csString+=".SYN";

		tdstLipSyn_Info	stLipSyn_Info;
		stLipSyn_Info.pFamily=g_pclCurrentModel->m_pub_fn_pclGetFamily();
		stLipSyn_Info.csName=csString;

		CPA_SaveObject	*pclLipSynchro;
		pclLipSynchro=(CPA_SaveObject *)pclTLSDLL->OnQueryAction(g_pclAIInterface,C_uiLoadLipSynchro,(LPARAM)&stLipSyn_Info);

		if(pclLipSynchro!=NULL)
		{
			long	lIndex=long(pclLipSynchro->GetData());

			fn_vInitNode(pstReturn,g_clLex.m_lIndex,eLipSynchro,lIndex);
		}

		return (pclLipSynchro!=NULL);
	}
	else
		return FALSE;
}
//ANNECY CB
BOOL fn_bIsALipSynchro(char *csString,stReturn *pstReturn)
{
	CSTRING_EQ(gcsGlob, csString);
	return fn_bIsALipSynchro(gcsGlob,pstReturn);
}
//END

//Sector
/****************************************************************************/
//ANNECY CB
BOOL fn_bIsASector(CString &csString,stReturn *pstReturn)
//BOOL fn_bIsASector(CString csString,stReturn *pstReturn)
//END
{
	CPA_List<CPA_SuperObject>	*pclList;
	pclList=g_pclAIInterface->GetMainWorld()->GetInterface()->GetObjectListByType(C_szSectorTypeName);

	CPA_SuperObject	*pclSector=NULL;
	BOOL						bFound=FALSE;
	if(pclList!=NULL)
	{
		POSITION	pos=pclList->GetHeadPosition();
		while(pos!=NULL && !bFound)
		{
			pclSector=pclList->GetNext(pos);

			bFound=(pclSector->GetObject()->GetName().CompareNoCase(csString)==0);
		}

		if(bFound)
		{
			long	lIndex=long(pclSector->GetData());

			fn_vInitNode(pstReturn,g_clLex.m_lIndex,eSector,lIndex);
		}
	}

	return (bFound);
}
//ANNECY CB
BOOL fn_bIsASector(char *csString,stReturn *pstReturn)
{
	CSTRING_EQ(gcsGlob, csString);
	return fn_bIsASector(gcsGlob,pstReturn);
}
//END

//SuperObject
/****************************************************************************/
//ANNECY CB
BOOL fn_bIsASuperObject(CString &csString,stReturn *pstReturn)
//BOOL fn_bIsASuperObject(CString csString,stReturn *pstReturn)
//END
{
	//ANNECY VL 26/03/98{
	//CPA_SuperObject	*pclSuperObject=g_pclAIInterface->GetMainWorld()->GetInterface()->GetSuperObject("All Types",csString);
	CPA_SuperObject	*pclSuperObject = (CPA_SuperObject *)  g_pclAIInterface->GetMainWorld()->fn_p_oFindObject( csString, "SuperObject" );
	//ENDANNECY VL}
	if(pclSuperObject!=NULL)
	{
		long	lIndex=long(pclSuperObject->GetData());

		fn_vInitNode(pstReturn,g_clLex.m_lIndex,eSuperObject,lIndex);
	}

	return (pclSuperObject!=NULL);
}
//ANNECY CB
BOOL fn_bIsASuperObject(char *csString,stReturn *pstReturn)
{
	CSTRING_EQ(gcsGlob, csString);
	return fn_bIsASuperObject(gcsGlob,pstReturn);
}
//END

//ObjectTable
/****************************************************************************/
//ANNECY CB
BOOL fn_bIsAObjectTable(CString &csString,stReturn *pstReturn)
//BOOL fn_bIsAObjectTable(CString csString,stReturn *pstReturn)
//END
{
	return fn_bIsAKnownEditorObject(csString,pstReturn,C_szObjectTableTypeName,eObjectTable);
}
//ANNECY CB
BOOL fn_bIsAObjectTable(char *csString,stReturn *pstReturn)
{
	CSTRING_EQ(gcsGlob, csString);
	return fn_bIsAObjectTable(gcsGlob,pstReturn);
}
//END

//Family
/****************************************************************************/
//ANNECY CB
BOOL fn_bIsAFamily(CString &csString,stReturn *pstReturn)
//BOOL fn_bIsAFamily(CString csString,stReturn *pstReturn)
//END
{
	return fn_bIsAKnownEditorObject(csString,pstReturn,C_szFamilyTypeName,eFamily);
}
//ANNECY CB
BOOL fn_bIsAFamily(char *csString,stReturn *pstReturn)
{
	CSTRING_EQ(gcsGlob, csString);
	return fn_bIsAFamily(gcsGlob,pstReturn);
}
//END

//Model
/****************************************************************************/
//ANNECY CB
BOOL fn_bIsAModel(CString &csString,stReturn *pstReturn)
//BOOL fn_bIsAModel(CString csString,stReturn *pstReturn)
//END
{
	CPA_BaseObject	*pclBaseObject;
	pclBaseObject=g_pclAIInterface->GetMainWorld()->fn_p_oFindObject(M_MAKECHAR(csString),C_szActorModelTypeName);

	if(pclBaseObject!=NULL)
	{
		if(pclBaseObject->fn_bIsAvailable()==FALSE)
			pclBaseObject->GetEditor()->fn_bLoadBaseObject(pclBaseObject);

		//Keeps the editor pointer
		//Converts it to a engine pointer before engine start
		fn_vInitNode(pstReturn,g_clLex.m_lIndex,eModel,(long)pclBaseObject);
	}

	return (pclBaseObject!=NULL);
}
//ANNECY CB
BOOL fn_bIsAModel(char *csString,stReturn *pstReturn)
{
	CSTRING_EQ(gcsGlob, csString);
	return fn_bIsAModel(gcsGlob,pstReturn);
}
//END

//SoundEvent
/****************************************************************************/
//ANNECY CB
BOOL fn_bIsASoundEvent(CString &csString,stReturn *pstReturn)
//BOOL fn_bIsASoundEvent(CString csString,stReturn *pstReturn)
//END
{
	return fn_bIsAKnownEditorObject(csString,pstReturn,C_szSoundEventTypeName,eSoundEvent);
}
//ANNECY CB
BOOL fn_bIsASoundEvent(char *csString,stReturn *pstReturn)
{
	CSTRING_EQ(gcsGlob, csString);
	return fn_bIsASoundEvent(gcsGlob,pstReturn);
}
//END

//GameMaterial
/****************************************************************************/
//ANNECY CB
BOOL fn_bIsAGameMaterial(CString &csString,stReturn *pstReturn)
//BOOL fn_bIsAGameMaterial(CString csString,stReturn *pstReturn)
//END
{
	return fn_bIsAKnownEditorObject(csString,pstReturn,C_szGameMaterialTypeName,eGameMaterial);
}
//ANNECY CB
BOOL fn_bIsAGameMaterial(char *csString,stReturn *pstReturn)
{
	CSTRING_EQ(gcsGlob, csString);
	return fn_bIsAGameMaterial(gcsGlob,pstReturn);
}
//END

//Light
/****************************************************************************/
//ANNECY CB
BOOL fn_bIsALight(CString &csString,stReturn *pstReturn)
//BOOL fn_bIsALight(CString csString,stReturn *pstReturn)
//END
{
	return fn_bIsAKnownEditorObject(csString,pstReturn,C_szLightTypeName,eLight);
}
//ANNECY CB
BOOL fn_bIsALight(char *csString,stReturn *pstReturn)
{
	CSTRING_EQ(gcsGlob, csString);
	return fn_bIsALight(gcsGlob,pstReturn);
}
//END

/****************************************************************************/
//ANNECY CB
BOOL fn_bIsACaps(CString &csString, stReturn *pstReturn)
//BOOL fn_bIsACaps(CString csString, stReturn *pstReturn)
//END
{
	long lStringLength = csString.GetLength();
	if (lStringLength > 32)
	    return FALSE;
  
  for (int i = 0 ; i < lStringLength ; i ++)
  {
	char cCharAt = csString.GetAt(i);
    if ( (cCharAt != '0') && (cCharAt != '1') )
      return FALSE;
  }
  
  char* dummy;
  unsigned long ulData = strtoul(csString, &dummy, 2);
  fn_vInitNode(pstReturn, g_clLex.m_lIndex, eCaps, (long)ulData);

  return TRUE;
}
//ANNECY CB
BOOL fn_bIsACaps(char *csString,stReturn *pstReturn)
{
	CSTRING_EQ(gcsGlob, csString);
	return fn_bIsACaps(gcsGlob,pstReturn);
}
//END

/****************************************************************************/
//ANNECY CB
BOOL fn_bIsAGraph(CString &csString, stReturn *pstReturn)
//BOOL fn_bIsAGraph(CString csString, stReturn *pstReturn)
//END
{
  WP_tdHandleOfGraph hGraph = WPG_fn_hGetGraph(csString.GetBuffer(255));
  if (hGraph != NULL)
  {
    fn_vInitNode(pstReturn, g_clLex.m_lIndex, eGraph, (long)hGraph);
  }

  return (hGraph != NULL);
}
//ANNECY CB
BOOL fn_bIsAGraph(char *csString,stReturn *pstReturn)
{
	CSTRING_EQ(gcsGlob, csString);
	return fn_bIsAGraph(gcsGlob,pstReturn);
}
//END


//
/****************************************************************************/
//ANNECY CB
BOOL fn_bIsThisBehaviourIsUnique(CString &csString,CString &csBehaviourName,CPA_BaseObject **ppclModel)
//BOOL fn_bIsThisBehaviourIsUnique(CString csString,CString &csBehaviourName,CPA_BaseObject **ppclModel)
//END
{
	//Checks for multiple name
	CString	csModelName;
	fn_vSplitName(csString,csModelName,csBehaviourName);

	*ppclModel=NO_CRITERIA;
	if(!csModelName.IsEmpty())
	{
		*ppclModel=g_pclAIInterface->GetMainWorld()->fn_p_oFindObject(M_MAKECHAR(csModelName),C_szActorModelTypeName);

		if(*ppclModel==NULL)
			return FALSE;
	}

	CPA_List<CPA_BaseObject>	clBehavioursList;
	long											lNumberOfBehaviours;
	lNumberOfBehaviours=g_pclAIInterface->GetMainWorld()->fn_lFindObjects(&clBehavioursList,csBehaviourName,C_szIABehaviourTypeName,*ppclModel);

	if(lNumberOfBehaviours==0)
		return FALSE;

	if(lNumberOfBehaviours>1)
	{
		if(csModelName.IsEmpty())
			AfxMessageBox("Conflict with "+csString+"\nTry to use ModelName@BehaviourName");

		return FALSE;
	}

	if(*ppclModel==NO_CRITERIA)
		*ppclModel=NULL;

	return TRUE;
}

//Reflex Behaviour
/****************************************************************************/
//ANNECY CB
BOOL fn_bIsAReflexBehaviour(CString &csString,stReturn *pstReturn)
//BOOL fn_bIsAReflexBehaviour(CString csString,stReturn *pstReturn)
//END
{
	CPA_BaseObject *pclModel;

	//Checks for multiple name
	CString csBehaviourName;
	if(fn_bIsThisBehaviourIsUnique(csString,csBehaviourName,&pclModel))
	{
		//Checks if it is a reflex behaviour
		if(pclModel!=NULL)
		{
			//The model is known
			CPA_Actor										*pclActorModel=(CPA_Actor *)pclModel;
			CPA_EdIR_Brain							*pclBrain=((EdActors_EditorActorModel *)pclActorModel->m_fn_pclGetEditorActor())->m_pclBrain;
			CPA_EdIR_MainBehaviourList	*pclReflexList=&(pclBrain->m_clListOfReflexBehaviours);

			if(pclReflexList->m_fn_bIsInList(csBehaviourName))
			{
				CPA_EdIR_MainBehaviour	*pclMainBehaviour=pclReflexList->m_fn_pclGetMainBehaviour(csBehaviourName);

				//Keeps the editor pointer
				//Converts it to a engine pointer before engine start
				long	lIndex=(long)pclMainBehaviour;
				fn_vInitNode(pstReturn,g_clLex.m_lIndex,eRfxBehaviour,lIndex);

				return TRUE;
			}
			else
				return FALSE;
		}
		else
		{
			//Gets all models
			CPA_List<CPA_BaseObject> clModelsList;
			g_pclAIInterface->GetMainWorld()->fn_lFindObjects(&clModelsList,"",C_szActorModelTypeName,NO_CRITERIA);

			POSITION	pos=clModelsList.GetHeadPosition();
			long	lIndex=-1;
			while(pos!=NULL && lIndex==-1)
			{
				CPA_Actor										*pclModel=(CPA_Actor *)(clModelsList.GetNext(pos));
				CPA_EdIR_Brain							*pclBrain=((EdActors_EditorActorModel *)pclModel->m_fn_pclGetEditorActor())->m_pclBrain;
				CPA_EdIR_MainBehaviourList	*pclReflexList=&(pclBrain->m_clListOfReflexBehaviours);

				if(pclReflexList->m_fn_bIsInList(csBehaviourName))
				{
					CPA_EdIR_MainBehaviour	*pclMainBehaviour=pclReflexList->m_fn_pclGetMainBehaviour(csBehaviourName);

					//Keeps the editor pointer
					//Converts it to a engine pointer before engine start
					lIndex=(long)pclMainBehaviour;
					fn_vInitNode(pstReturn,g_clLex.m_lIndex,eRfxBehaviour,lIndex);
				}
			}

			return (lIndex!=-1);
		}
	}
	else
		return FALSE;
}
//ANNECY CB
BOOL fn_bIsAReflexBehaviour(char *csString,stReturn *pstReturn)
{
	CSTRING_EQ(gcsGlob, csString);
	return fn_bIsAReflexBehaviour(gcsGlob,pstReturn);
}
//END

//Intelligence Behaviour
/****************************************************************************/
//ANNECY CB
BOOL fn_bIsAIntelligenceBehaviour(CString &csString,stReturn *pstReturn)
//BOOL fn_bIsAIntelligenceBehaviour(CString csString,stReturn *pstReturn)
//END
{
	CPA_BaseObject *pclModel;

	//Checks for multiple name
	CString csBehaviourName;
	if(fn_bIsThisBehaviourIsUnique(csString,csBehaviourName,&pclModel))
	{
		//Checks if it is a reflex behaviour
		if(pclModel!=NULL)
		{
			//The model is known
			CPA_Actor										*pclActorModel=(CPA_Actor *)pclModel;
			CPA_EdIR_Brain							*pclBrain=((EdActors_EditorActorModel *)pclActorModel->m_fn_pclGetEditorActor())->m_pclBrain;
			CPA_EdIR_MainBehaviourList	*pclIntelligenceList=&(pclBrain->m_clListOfIntelligenceBehaviours);

			if(pclIntelligenceList->m_fn_bIsInList(csBehaviourName))
			{
				CPA_EdIR_MainBehaviour	*pclMainBehaviour=pclIntelligenceList->m_fn_pclGetMainBehaviour(csBehaviourName);

				//Keeps the editor pointer
				//Converts it to a engine pointer before engine start
				long	lIndex=(long)pclMainBehaviour;
				fn_vInitNode(pstReturn,g_clLex.m_lIndex,eIABehaviour,lIndex);

				return TRUE;
			}
			else
				return FALSE;
		}
		else
		{
			//Gets all models
			CPA_List<CPA_BaseObject> clModelsList;
			g_pclAIInterface->GetMainWorld()->fn_lFindObjects(&clModelsList,"",C_szActorModelTypeName,NO_CRITERIA);

			POSITION	pos=clModelsList.GetHeadPosition();
			long	lIndex=-1;
			while(pos!=NULL && lIndex==-1)
			{
				CPA_Actor										*pclModel=(CPA_Actor *)(clModelsList.GetNext(pos));
				CPA_EdIR_Brain							*pclBrain=((EdActors_EditorActorModel *)pclModel->m_fn_pclGetEditorActor())->m_pclBrain;
				CPA_EdIR_MainBehaviourList	*pclIntelligenceList=&(pclBrain->m_clListOfIntelligenceBehaviours);

				if(pclIntelligenceList->m_fn_bIsInList(csBehaviourName))
				{
					CPA_EdIR_MainBehaviour	*pclMainBehaviour=pclIntelligenceList->m_fn_pclGetMainBehaviour(csBehaviourName);

					//Keeps the editor pointer
					//Converts it to a engine pointer before engine start
					lIndex=(long)pclMainBehaviour;
					fn_vInitNode(pstReturn,g_clLex.m_lIndex,eIABehaviour,lIndex);
				}
			}

			return (lIndex!=-1);
		}
	}
	else
		return FALSE;
}
//ANNECY CB
BOOL fn_bIsAIntelligenceBehaviour(char *csString,stReturn *pstReturn)
{
	CSTRING_EQ(gcsGlob, csString);
	return fn_bIsAIntelligenceBehaviour(gcsGlob,pstReturn);
}
//END

//Reflex Behaviour (for me)
/****************************************************************************/
//ANNECY CB
BOOL fn_bIsMyReflexBehaviour(CString &csString,stReturn *pstReturn)
//BOOL fn_bIsMyReflexBehaviour(CString csString,stReturn *pstReturn)
//END
{
	CPA_BaseObject *pclModel;

	//Checks for multiple name
	CString csBehaviourName;
	if(fn_bIsThisBehaviourIsUnique(csString,csBehaviourName,&pclModel))
	{
		CPA_Actor										*pclModel=g_pclCurrentModel;
		CPA_EdIR_Brain							*pclBrain=((EdActors_EditorActorModel *)pclModel->m_fn_pclGetEditorActor())->m_pclBrain;
		CPA_EdIR_MainBehaviourList	*pclReflexList=&(pclBrain->m_clListOfReflexBehaviours);

		if(pclReflexList->m_fn_bIsInList(csBehaviourName))
		{
			CPA_EdIR_MainBehaviour	*pclMainBehaviour=pclReflexList->m_fn_pclGetMainBehaviour(csBehaviourName);

			//Keeps the editor pointer
			//Converts it to a engine pointer before engine start
			long	lIndex=(long)pclMainBehaviour;
			fn_vInitNode(pstReturn,g_clLex.m_lIndex,eRfxBehaviour,lIndex);

			return TRUE;
		}
		else
			return FALSE;
	}
	else
		return FALSE;
}
//ANNECY CB
BOOL fn_bIsMyReflexBehaviour(char *csString,stReturn *pstReturn)
{
	CSTRING_EQ(gcsGlob, csString);
	return fn_bIsMyReflexBehaviour(gcsGlob,pstReturn);
}
//END

//Intelligence Behaviour (for me)
/****************************************************************************/
//ANNECY CB
BOOL fn_bIsMyIntelligenceBehaviour(CString &csString,stReturn *pstReturn)
//BOOL fn_bIsMyIntelligenceBehaviour(CString csString,stReturn *pstReturn)
//END
{
	CPA_BaseObject *pclModel;

	//Checks for multiple name
	CString csBehaviourName;
	if(fn_bIsThisBehaviourIsUnique(csString,csBehaviourName,&pclModel))
	{
		CPA_Actor										*pclModel=g_pclCurrentModel;
		CPA_EdIR_Brain							*pclBrain=((EdActors_EditorActorModel *)pclModel->m_fn_pclGetEditorActor())->m_pclBrain;
		CPA_EdIR_MainBehaviourList	*pclIntelligenceList=&(pclBrain->m_clListOfIntelligenceBehaviours);

		if(pclIntelligenceList->m_fn_bIsInList(csBehaviourName))
		{
			CPA_EdIR_MainBehaviour	*pclMainBehaviour=pclIntelligenceList->m_fn_pclGetMainBehaviour(csBehaviourName);

			//Keeps the editor pointer
			//Converts it to a engine pointer before engine start
			long	lIndex=(long)pclMainBehaviour;
			fn_vInitNode(pstReturn,g_clLex.m_lIndex,eIABehaviour,lIndex);

			return TRUE;
		}
		else
			return FALSE;
	}
	else
		return FALSE;
}
//ANNECY CB
BOOL fn_bIsMyIntelligenceBehaviour(char *csString,stReturn *pstReturn)
{
	CSTRING_EQ(gcsGlob, csString);
	return fn_bIsMyIntelligenceBehaviour(gcsGlob,pstReturn);
}
//END

//KeyButton
/****************************************************************************/
//ANNECY CB
BOOL fn_bIsAKeyButton(CString &csString,stReturn *pstReturn)
//BOOL fn_bIsAKeyButton(CString csString,stReturn *pstReturn)
//END
{
	long	lIndex=(long)IPT_fn_hGetEntryActionHandle(M_MAKECHAR(csString));

	if(IPT_fn_bIsAValidEntryActionHandle((IPT_tdxHandleToEntryElement)lIndex))
	{
		fn_vInitNode(pstReturn,g_clLex.m_lIndex,eKeyButton,lIndex);

		return TRUE;
	}
	else
		return FALSE;
}
//ANNECY CB
BOOL fn_bIsAKeyButton(char *csString,stReturn *pstReturn)
{
	CSTRING_EQ(gcsGlob, csString);
	return fn_bIsAKeyButton(gcsGlob,pstReturn);
}
//END

//Mask Type
/****************************************************************************/
//ANNECY CB
BOOL fn_bIsAMaskType(CString &csString,stReturn *pstReturn)
//BOOL fn_bIsAMaskType(CString csString,stReturn *pstReturn)
//END
{
	CPA_BaseObject	*pclMaskType;
	pclMaskType=g_pclAIInterface->GetMainWorld()->fn_p_oFindObject(M_MAKECHAR(csString),C_szMaterialColName);

	if(pclMaskType!=NULL)
	{
		if(pclMaskType->fn_bIsAvailable()==FALSE)
			pclMaskType->GetEditor()->fn_bLoadBaseObject(pclMaskType);

		long	lIndex=(long)(*(unsigned char *)(pclMaskType->GetData()));

		fn_vInitNode(pstReturn,g_clLex.m_lIndex,eMaskType,lIndex);
	}

	return (pclMaskType!=NULL);
}
//ANNECY CB
BOOL fn_bIsAMaskType(char *csString,stReturn *pstReturn)
{
	CSTRING_EQ(gcsGlob, csString);
	return fn_bIsAMaskType(gcsGlob,pstReturn);
}
//END

#if 0
//Power
/****************************************************************************/
//ANNECY CB
BOOL fn_bIsAPower(CString &csString,stReturn *pstReturn)
//BOOL fn_bIsAPower(CString csString,stReturn *pstReturn)
//END
{
	long	lIndex=fn_uwGetPowerValueFromString(M_MAKECHAR(csString));

	if(lIndex!=INV_C_uwNotValid)
	{
		fn_vInitNode(pstReturn,g_clLex.m_lIndex,ePower,lIndex);

		return TRUE;
	}
	else
		return FALSE;
}
//ANNECY CB
BOOL fn_bIsAPower(char *csString,stReturn *pstReturn)
{
	CSTRING_EQ(gcsGlob, csString);
	return fn_bIsAPower(gcsGlob,pstReturn);
}
//END
#endif //0 car inutilise dans RM2

//Text
/****************************************************************************/
//ANNECY CB
BOOL fn_bIsAText(CString &csString,stReturn *pstReturn)
//BOOL fn_bIsAText(CString csString,stReturn *pstReturn)
//END
{
  FON_tdxHandleOfText hText = FON_fn_hGetTextHandleWithoutWarning(M_MAKECHAR(csString));

  if ( hText != FON_C_xInvalidTextHandle )
  {
    fn_vInitNode(pstReturn,g_clLex.m_lIndex,eText,hText);

    return TRUE;
  }
  else
    return FALSE;
}
//ANNECY CB
BOOL fn_bIsAText(char *csString,stReturn *pstReturn)
{
  CSTRING_EQ(gcsGlob, csString);
  return fn_bIsAText(gcsGlob,pstReturn);
}
//END

//ParticleGenerator
/****************************************************************************/
//ANNECY CB
BOOL fn_bIsAParticleGenerator(CString &csString,stReturn *pstReturn)
//BOOL fn_bIsAParticleGenerator(CString csString,stReturn *pstReturn)
//END
{
	return fn_bIsAKnownEditorObject(csString,pstReturn,C_szPartGenGeneratorName,eParticleGenerator);
}
//ANNECY CB
BOOL fn_bIsAParticleGenerator(char *csString,stReturn *pstReturn)
{
	CSTRING_EQ(gcsGlob, csString);
	return fn_bIsAParticleGenerator(gcsGlob,pstReturn);
}
//END

//State
/****************************************************************************/
//ANNECY CB
BOOL fn_bIsAState(CString &csString,stReturn *pstReturn)
//BOOL fn_bIsAState(CString csString,stReturn *pstReturn)
//END
{
	return fn_bIsAKnownEditorObject(csString,pstReturn,C_szStateTypeName,eState);
}
//ANNECY CB
BOOL fn_bIsAState(char *csString,stReturn *pstReturn)
{
	CSTRING_EQ(gcsGlob, csString);
	return fn_bIsAState(gcsGlob,pstReturn);
}
//END

/****************************************************************************/
void fn_vInitNode(stReturn *pstReturn,long lOffset,tdeNodeType eNodeType,long lIndex,CPA_Actor *pclModel)
{
	pstReturn->clIntermediateCodeList=new CPA_EdIR_IntermediateCode(lOffset,eNodeType,lIndex,pclModel);
}

/****************************************************************************/
void fn_vInitNode(stReturn *pstReturn,long lOffset,tdeNodeType eNodeType,double dfValue)
{
	pstReturn->clIntermediateCodeList=new CPA_EdIR_IntermediateCode(lOffset,eNodeType,dfValue);
}

/****************************************************************************/
void fn_vInitNode(stReturn *pstReturn,long lOffset,tdeNodeType eNodeType,CString csString)
{
	pstReturn->clIntermediateCodeList=new CPA_EdIR_IntermediateCode(lOffset,eNodeType,csString);
}

/****************************************************************************/
CLex::~CLex()
{
	if(yy_current_buffer)
		yy_delete_buffer(yy_current_buffer);
}

/****************************************************************************/
void CLex::yyinit(char *szStringToParse,tdeTypeText eTypeText)
{
	m_lIndex=0;
	m_lOldIndex=0;
	m_lIndexWithoutSpaceAndTab=0;
	m_lOldMacroIndex=0;
	m_bIsInMacro=FALSE;
	//BEGIN ROMTEAM Cristi Petrescu 98-04-
	m_bIsInDefine = FALSE;
	m_clDefineList . RemoveAll ();
	m_clDefineContextStack . m_fn_vDestroyAndRemoveAllEntries ();
	//END ROMTEAM Cristi Petrescu 98-04-

	m_eTypeText=eTypeText;

	if(yy_current_buffer)
		yyrestart(NULL);
	m_pcIndex=szStringToParse;

	if(m_eTypeText==DsgVarText)
		BEGIN(DECL_DSG_VAR);
	else
	if(g_pclAIInterface->M_GetMainWorld()->GetInterface()->fn_csGetCurrentLanguage()=="French")
		BEGIN(FRENCH);
	else
		BEGIN(ENGLISH);
}

//BEGIN ROMTEAM Cristi Petrescu 98-04-
void CPA_EdIR_DefineContextStack :: m_fn_vDestroyAndRemoveAllEntries (void)
{
	POSITION	pos=GetHeadPosition();
	while(pos!=NULL)
		delete GetNext(pos);

	RemoveAll();
}

void CLex :: m_fn_vEnterContext (char *szStringToParse)
{
	// get the current context
	CPA_EdIR_DefineContext *pCurrentDefineContext = new CPA_EdIR_DefineContext ();
	pCurrentDefineContext -> m_pcIndex = m_pcIndex;
	pCurrentDefineContext -> m_bufLexContext = yy_current_buffer;

	// push the current context
	m_clDefineContextStack . AddTail (pCurrentDefineContext);

	// build the new state
	YY_BUFFER_STATE bufNewContext = yy_create_buffer (NULL, YY_BUF_SIZE);

	// and activate it
	m_pcIndex = szStringToParse;
	yy_switch_to_buffer (bufNewContext);
}

void CLex :: m_fn_vExitContext (void)
{
	// cleanup the current state
	yy_delete_buffer (yy_current_buffer);

	// pop the old context
	CPA_EdIR_DefineContext *pOldDefineContext = m_clDefineContextStack . RemoveTail ();

	// activate it
	m_pcIndex = pOldDefineContext -> m_pcIndex;
	yy_switch_to_buffer (pOldDefineContext -> m_bufLexContext);

	// and clean
	delete pOldDefineContext;
}
//END ROMTEAM Cristi Petrescu 98-04-

#endif //D_ED_IR_ACTIVE
