%{
#include "stdafx.h"

#include <malloc.h>
#include <afxwin.h> //for AfxMessageBox

//A SUPPRIMER (pour toupper)
#include <stdlib.h>

#include "EdIRStrg.hpp"

#include "EdIRflx.hpp"

#include "EdIRDVLs.hpp"
#include "EdIRMacL.hpp"
#include "EdIRIRD.hpp"
#include "EdIRBeEn.hpp"
#include "EdIRBeha.hpp"
#include "EdIR2Eng.hpp"
#include "EdIRGlob.hpp"
#include "EdIRIAGl.hpp"

#include "EdIRIAWd.hpp"

#include "acp_base.h"

#include "ITF.h"
#include "IncMEC.h"
#include "incAI.h"

#include "GMT.h"

#include "x:\cpa\main\inc\_EditID.h"
#include "_Ainterf.hpp"	//for g_pclInterface
#include "EDACModl.hpp"

#include "_Actors.hpp"

#undef extern

long gl_MacroAddress;
// SHAITAN => CORRECTION SUBR
//ACP_tdxBool g_bPrevStatementWasAMacroRef = FALSE ;
// SHAITAN => END CORRECTION SUBR

#define YY_USE_CLASS

/*************/
/* Constants */
/*************/

#define C_OPEN_DEPTH	'{'
#define C_CLOSE_DEPTH	'}'

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

#define M_PASS_IN_1PARM(a,b)					(a).csInitial=(b).csInitial

#define M_PASS_IN_2PARMS(a,b,c)				M_PASS_IN_1PARM(a,b);																								\
																			(a).csInitial+=" "+(c).csInitial

#define M_PASS_IN_3PARMS(a,b,c,d)			M_PASS_IN_2PARMS(a,b,c);																						\
																			(a).csInitial+=" "+(d).csInitial

#define M_PASS_IN_4PARMS(a,b,c,d,e)		M_PASS_IN_3PARMS(a,b,c,d);																					\
																			(a).csInitial+=" "+(e).csInitial

#define M_PASS_IN_5PARMS(a,b,c,d,e,f)	M_PASS_IN_4PARMS(a,b,c,d,e);																				\
																			(a).csInitial+=" "+(f).csInitial

#define M_PASS_IN_6PARMS(a,b,c,d,e,\
												 f,g)					M_PASS_IN_5PARMS(a,b,c,d,e,f);																			\
																			(a).csInitial+=" "+(g).csInitial

#define M_PASS_IN_7PARMS(a,b,c,d,e,\
												 f,g,h)				M_PASS_IN_6PARMS(a,b,c,d,e,f,g);																		\
																			(a).csInitial+=" "+(h).csInitial

#define M_PASS_IN_8PARMS(a,b,c,d,e,\
												 f,g,h,i)			M_PASS_IN_7PARMS(a,b,c,d,e,f,g,h);																	\
																			(a).csInitial+=" "+(i).csInitial

#define M_PASS_ALL(a,b)								(a)=(b)

#define M_CONCAT2PARMS(a,b,c)					M_PASS_IN_2PARMS(a,b,c);																						\
																			(a).clIntermediateCodeList=(b).clIntermediateCodeList;							\
																			(a).clIntermediateCodeList.m_fn_vConcat((c).clIntermediateCodeList)

#define M_CREATENODE(a,b,c)						(a).clIntermediateCodeList=																					\
																					new CPA_EdIR_IntermediateCode(g_clLex.m_lIndex,(b),(c))

#define M_CREATEVECTORNODE(a,b,c,d,e)	(a).clIntermediateCodeList=																					\
																					new CPA_EdIR_IntermediateCode(g_clLex.m_lIndex,(b),(c),(d),(e))

#define C_INC_DEPTH										0,eIncDepth,0L
#define C_DEC_DEPTH										0,eDecDepth,0L
#define C_INC_DEPTH_NODE							new CPA_EdIR_IntermediateCode(C_INC_DEPTH)
#define C_DEC_DEPTH_NODE							new CPA_EdIR_IntermediateCode(C_DEC_DEPTH)

#define M_ADD1PARM(a,b)								(a).clIntermediateCodeList.m_fn_vAdd(C_INC_DEPTH_NODE);							\
																			(a).clIntermediateCodeList.m_fn_vConcat((b).clIntermediateCodeList);\
																			(a).clIntermediateCodeList.m_fn_vAdd(C_DEC_DEPTH_NODE)

#define M_PASS1PARM(a,b,c)						(a).clIntermediateCodeList=(b).clIntermediateCodeList;							\
																			M_ADD1PARM(a,c)
																																										
#define M_PASS2PARMS(a,b,c,d)					M_PASS1PARM(a,b,c);																									\
																			M_ADD1PARM(a,d)

#define M_PASS3PARMS(a,b,c,d,e)				M_PASS2PARMS(a,b,c,d);																							\
																			M_ADD1PARM(a,e)

#define M_PASS1PARM4OP(a,b,c,d)				(a).clIntermediateCodeList=																					\
																					new CPA_EdIR_IntermediateCode(g_clLex.m_lIndex,(b),(c));				\
																			M_ADD1PARM(a,d)
																			
#define M_PASS2PARMS4OP(a,b,c,d,e)		(a).clIntermediateCodeList=																					\
																					new CPA_EdIR_IntermediateCode(g_clLex.m_lIndex,(b),(c));				\
																			M_ADD1PARM(a,d);																										\
																			M_ADD1PARM(a,e)

#define M_IFTHEN(a,b,c,d,e,f)					(a).clIntermediateCodeList=(b).clIntermediateCodeList;							\
																			M_ADD1PARM(a,c);																										\
																			(a).clIntermediateCodeList.m_fn_vConcat((d).clIntermediateCodeList);\
																			M_ADD1PARM(a,e);																										\
																			(a).clIntermediateCodeList.m_fn_vConcat((f).clIntermediateCodeList);\
																																										
#define M_IFTHENELSE(a,b,c,d,e,f,g,h)	(a).clIntermediateCodeList=(b).clIntermediateCodeList;							\
																			M_ADD1PARM(a,c);																										\
																			(a).clIntermediateCodeList.m_fn_vConcat((d).clIntermediateCodeList);\
																			M_ADD1PARM(a,e);																										\
																			(a).clIntermediateCodeList.m_fn_vConcat((f).clIntermediateCodeList);\
																			M_ADD1PARM(a,g);																										\
																			(a).clIntermediateCodeList.m_fn_vConcat((h).clIntermediateCodeList);\

#define M_CREATEULTRANODE(a,b,c,d)		stReturn	stOperatorUltra;																					\
																			M_CREATENODE(stOperatorUltra,eOperator,long(eOperator_Ultra));			\
																																																					\
																			stReturn	stUltraNode;																							\
																			M_PASS1PARM(stUltraNode,c,d);																				\
																																																					\
																			M_PASS2PARMS(a,stOperatorUltra,b,stUltraNode)

//Stefan Dumitrean 21-05-98
/*
#define	M_CHECKPARMS(a,b)							CString	csMsgError;																									\
																			if((a).GetLength()<((b).csType).GetLength())												\
																			{																																		\
																				yyerror("There are too many params");															\
																				YYERROR;																													\
																			}																																		\
																			else																																\
																			if((a).GetLength()>((b).csType).GetLength())												\
																			{																																		\
																				yyerror("There are not enough params");														\
																				YYERROR;																													\
																			}																																		\
																			else																																\
																			if(!fn_bIsParmsCompatible((a),&(b),csMsgError))											\
																			{																																		\
																				yyerror(M_MAKECHAR(csMsgError));																	\
																				YYERROR;																													\
																			}																																		\
																			else
*/
#define	M_CHECKPARMS(a,b,c)							CString	csMsgError;																                   \
																			if((a).GetLength()<((b).csType).GetLength())							   \
																			{																		   \
																				csMsgError.Format("There are too many parameters for the %s", c );	   \
																				yyerror(M_MAKECHAR(csMsgError));									   \
																				YYERROR;															   \
																			}																		   \
																			else																	   \
																			if((a).GetLength()>((b).csType).GetLength())							   \
																			{																		   \
																				csMsgError.Format("There are not enough parameters for the %s", c );   \
																				yyerror(M_MAKECHAR(csMsgError));									   \
																				YYERROR;															   \
																			}																		   \
																			else																	   \
																			if(!fn_bIsParmsCompatible((a),&(b),c,csMsgError))						   \
																			{																		   \
																				yyerror(M_MAKECHAR(csMsgError));									   \
																				YYERROR;															   \
																			}																		   \
																			else
//End Stefan Dumitrean 21-05-98

#define M_GETINDEX(a)									(a).clIntermediateCodeList.m_fn_lGetIndex(0)
#define M_SETINDEX(a,b)								(a).clIntermediateCodeList.m_fn_vSetIndex(0,(b))

//In order to put the good model because Flex don't check for dot operation
//Example : if there are two dsgvar "x" in two models M1 and M2
//In M1, we write "Actor2".x (Actor2's model is M2)
//Flex puts M1 model for "x" and this is not good (it is M2 model for "x")
#define M_SETMODEL(a,b)								(a).clIntermediateCodeList.m_fn_vSetModel(0,(b))
#define M_SETMODELFROMPERSO(a,b)																																									\
	{																																																								\
		CPA_Actor	*pclActorInstance=(CPA_Actor *)fn_pclGetReachableObject(lHandleToPerso,C_szActorInstanceTypeName);	\
		CPA_Actor	*pclActorModel=pclActorInstance->m_fn_pclGetModel();																								\
																																																									\
		M_SETMODEL(a,pclActorModel);																																									\
	}

%}

%name CParse

%header{

#include "stdafx.h"

#include "EdIRICLs.hpp"

struct stReturn
{
	CString												csInitial;
	CString												csType;
	CString												csSubType;	//for array
	CPA_EdIR_IntermediateCodeList	clIntermediateCodeList;
};

/*********/
/* Enums */
/*********/

typedef enum tdeTypeText_
{
	IntelligenceText,
	ReflexText,
	DsgVarText,
	MacroText,
	// BEGIN ROMTEAM CPA2 Cristi Petrescu 98-04-
	// this is used for the new style of defining macros...
	Macro_2_Text,
	SubrText,
	// END ROMTEAM CPA2 Cristi Petrescu 98-04-
	CRRGeneration,
} tdeTypeText;

/*************/
/* Variables */
/*************/

class CParse;
class CLex;
class CPA_EdIR_DesignerVariableList;
class CPA_EdIR_MacroList;
// BEGIN CPA2 Cristi Petrescu 98-03-
class CPA_EdIR_MainBehaviourList;
// END CPA2 Cristi Petrescu 98-03-
class CPA_Actor;

extern CParse													g_clParse;
extern CLex														g_clLex;
extern CPA_EdIR_DesignerVariableList	g_clDsgVarList;
extern CPA_EdIR_MacroList							g_clMacroList;
// BEGIN CPA2 Cristi Petrescu 98-03-
extern CPA_EdIR_MainBehaviourList		*g_pclListOfSubrs;
// END CPA2 Cristi Petrescu 98-03-
extern CPA_Actor											*g_pclCurrentModel;
extern char gcGenerateOneRule ;
/*************/
/* Functions */
/*************/

//exports fn_bAnalysesText()
//BEGIN ROMTEAM Cristi Petrescu 98-05-
BOOL fn_bAnalysesText(CString,tdeTypeText,long &,CPA_EdIR_IntermediateCodeList *, CString csBehaviourName);
//END ROMTEAM Cristi Petrescu 98-05-

//KeyWord
CString	fn_csGetKeyWordParams(long);
CString	fn_csGetKeyWordType(long);

//MetaAction
CString	fn_csGetMetaActionParams(long);

//Condition
CString	fn_csGetConditionParams(long);
BOOL		fn_bIsConditionUsableWithUltraOperator(long);

//Designer Variable
#define	C_NOT_A_DSG_VAR	-1
void		fn_vGetDesignerVariableType(stReturn *,long);
void		fn_vGetDesignerVariableTypeFromEngineType(stReturn *,long);
void		fn_vGetDesignerVariableTypeForThisModel(stReturn *,CPA_Actor *,long);
long		fn_lIsADsgVarForThisModel(CPA_Actor *,CString);
void		fn_vGetDesignerVariableTypeForThisPerso(stReturn *,long,long);
long		fn_lIsADsgVarForThisPerso(long,CString);

//Field
CString	fn_csGetFieldType(long);

//Type
BOOL		fn_bIsTypeCompatible(CString,stReturn *,long,BOOL bIsOperator=FALSE);
#define C_NOT_COMPATIBLE -1
long		fn_lIsTypeCompatibleForArithmOp(long lIndex,stReturn *st1,stReturn *st2=NULL);
BOOL		fn_bIsTypeCompatibleForBinaryOp(long lIndex,stReturn *st1,stReturn *st2);
BOOL		fn_bIsTypeCompatibleForInitialization(CString,stReturn *);
//Stefan Dumitrean 21-05-98
BOOL		fn_bIsParmsCompatible(CString,stReturn *,CString,CString &);
//End Stefan Dumitrean 21-05-98
BOOL		fn_bIsStringCompatible(CString,CString);
BOOL		fn_bIsStringCompatibleForAffect(CString,CString);

//Function
CString	fn_csGetFunctionParams(long);
CString	fn_csGetFunctionType(long);
BOOL		fn_bIsFunctionUsableWithUltraOperator(long);

//Procedure
CString	fn_csGetProcedureParams(long);
BOOL		fn_bIsProcedureUsableWithUltraOperator(long);

//Operator
CString	fn_csGetOperatorParams(long);
CString fn_csGetOperatorType(long,CString csParm1="",CString csParm2="");

//Perso
long		fn_lGetHandleOfPerso(stReturn *);

//BEGIN ROMTEAM Cristi Petrescu 98-06-
BOOL fn_bIsDsgVarQualifier(CString csQualifier);
//END ROMTEAM Cristi Petrescu 98-06-
%}

%define STYPE stReturn

%define MEMBERS	CString												m_csMsgError;								\
								BOOL													m_bNoError;									\
								long													m_lIndexError;							\
								BOOL													m_bIsInITRules;							\
								stReturn							* m_pstMyStack;							\
								CPA_EdIR_IntermediateCodeList	m_clIntermediateCodeList;

//BEGIN ROMTEAM Cristi Petrescu 98-04-
// hide the #define from the parser. so use lex at full capacity
// %token DEFINITION
//END ROMTEAM Cristi Petrescu 98-04-
%token STRING	TEXT /*FONT*/ BOOLEAN INT REAL PERSO ZDD ZDE ZDM ZDR
%token ACTION WAYPOINT CHANNEL SURFACE ENVIRONMENT SECTOR SUPEROBJECT
%token LIPSYNCHRO OBJECTTABLE FAMILY MODEL SOUNDEVENT GAMEMATERIAL LIGHT
%token CAPS GRAPH
%token MYREFLEX MYBEHAV REFLEX BEHAV KEYBUTTON PARTGEN STATE

%token METAACTION CONDITION DESVAR CONSTANTINT CONSTANTREAL DVTYPE FUNCTION PROCEDURE FIELD 
//BEGIN ROMTEAM Cristi Petrescu 98-06-
%token DVQUALIFIER
//END ROMTEAM Cristi Petrescu 98-06-
//BEGIN ROMTEAM Cristi Petrescu 98-04-
%token SUBRREF
//END ROMTEAM Cristi Petrescu 98-04-
%token OPWITH1PARM OPWITH2PARMS OPCOND OPGETCOMPO
%token VECTOR MASKTYPE CONSTVECTOR POWER

%token MACRO BEGINMACRO ENDMACRO
%token SCHEDULE
%token ITRULES
//BEGIN ROMTEAM Cristi Petrescu 98-04-
%token SUBROUTINE
//END ROMTEAM Cristi Petrescu 98-04-
%token IF IF2 IF4 IF8 IF16 IFDEBUG IFNOTU64 IFNOT THEN ELSE ENDIF
%token ME MAINACTOR NOBODY NOWHERE NOCOMPORT NOACTION /*WORLD*/ EMPTYTEXT NOSUPEROBJECT
%token CAPSNULL NOGRAPH
%token STOPENGINE STOPRULE NONSTOP

%token NOT AND OR XOR

%token SYNTAXERROR

%left '+' '-'
%left	'*' '/'
%left NEG

%%

text:						behaviour			{
																M_PASS_ALL($$,$1);
																m_clIntermediateCodeList=$$.clIntermediateCodeList
															}
							|	declarations	{
																M_PASS_ALL($$,$1);
																m_clIntermediateCodeList=$$.clIntermediateCodeList
															}
							//BEGIN ROMTEAM Cristi Petrescu 98-04-
							|	subroutine		{
																M_PASS_ALL($$,$1);
																m_clIntermediateCodeList=$$.clIntermediateCodeList
															}
							//|	define			{
							//						// just recognize it, do nothing
							//						;
							//					}
							//END ROMTEAM Cristi Petrescu 98-04-
;

//BEGIN ROMTEAM Cristi Petrescu 98-04-
subroutine:					SUBROUTINE 
							':' 
							statements			{
													$$.clIntermediateCodeList=new CPA_EdIR_IntermediateCode(g_clLex.m_lIndex,eCreateSubr,0L);
													$$.clIntermediateCodeList.m_fn_vConcat($3.clIntermediateCodeList);
													//$$.clIntermediateCodeList = $3.clIntermediateCodeList;
													M_PASS_IN_3PARMS($$,$1,$2,$3)
												}
;

//define:						DEFINITION
//												{
//													// add the definition in the definition table
//													;
//												}
//;
//END ROMTEAM Cristi Petrescu 98-04-

declarations:	
							|	macrodecls		{
																// BEGIN ROMTEAM Cristi Petrescu 98-09-
																$$.csInitial=$$.csType="";
																$$.clIntermediateCodeList.m_fn_vMakeEmpty();
																//M_PASS_ALL($$,$1)
																$1.clIntermediateCodeList.m_fn_vDestroyAndRemoveAllEntries ();
																// END ROMTEAM Cristi Petrescu 98-09-
															}
							|	dvdecls				{
																M_PASS_ALL($$,$1)
													}
;

macrodecls:			macrodecl	{
									// BEGIN ROMTEAM Cristi Petrescu 98-09-
									M_PASS_ALL($$,$1)
									// END ROMTEAM Cristi Petrescu 98-09-
								}
							|	macrodecls
								macrodecl
								{
									// BEGIN ROMTEAM Cristi Petrescu 98-09-
									M_CONCAT2PARMS($$,$1,$2)
									// END ROMTEAM Cristi Petrescu 98-09-
								}
;

macrodecl:			MACRO
								macroname
								':'
								macrodef			{
																CPA_EdIR_Macro	*pclMacro;

																pclMacro=new CPA_EdIR_Macro($2.csInitial,
																														$4.csInitial);

																g_clMacroList.AddTail(pclMacro);
																
																// to pass the tree up, otherwise this is unused...
																// if you don't do this, the result of parsing is lost... -> memory leaks
																M_CONCAT2PARMS ($$, $2, $4);
													}
;	

macroname:			STRING	{M_PASS_ALL($$,$1)}
;

macrodef:				/*actions				{M_PASS_ALL($$,$1)}*/
								statements			{M_PASS_ALL($$,$1)}
;

dvdecls:				dvdecl				{M_PASS_ALL($$,$1)}
							|	dvdecls
								dvdecl				{M_CONCAT2PARMS($$,$1,$2)}
;

dvdecl:					dvqual
							dvtype
								dvname
								':'
								dvvalue				{
																//BEGIN ROMTEAM Cristi Petrescu 98-06-
																if(!g_clDsgVarList.m_fn_bIsADesignerVariable($3.csInitial))
																{
																	if(fn_bIsTypeCompatibleForInitialization($2.csType,&($5)))
																	{
																		CString		csInitial;
																		POSITION	pos;
																		if(!$5.clIntermediateCodeList.IsEmpty())
																		{
																			if($2.csType==C_ADDR_LIST_PARAM)
																			{
																				long	lInitValue=atoi($5.csInitial);
																				if(lInitValue<1 || lInitValue>30)
																				{
																					yyerror("You must specify a number between 1 and 30 for a list");
																					YYERROR;
																				}
																			}
																			if($2.csType==C_ADDR_ARRAY_PARAM)
																			{
																				long	lInitValue=atoi($5.csInitial);
																				if(lInitValue<C_ucSizeOfMinimalArray || lInitValue>C_ucSizeOfMaximalArray)
																				{
																					yyerror("You must specify a number between 2 and 255 for an array");
																					YYERROR;
																				}
																			}

																			if($5.csType!=C_VECTOR_PARAM)
																			{
																				//First node is the initial value
																				pos=$5.clIntermediateCodeList.FindIndex(0);
																			}
																			else
																			{
																				//First node is the vector node
																				//Second node is the inc depth node
																				//Third node is the initial value
																				pos=$5.clIntermediateCodeList.FindIndex(2);
																			}

																			if(pos!=NULL)
																			{
																				csInitial=$5.clIntermediateCodeList.GetAt(pos)->m_fn_csGetValue();

																				CPA_EdIR_DesignerVariable	*pclDsgVar;
																				CStringList								cslValues;
																				cslValues.AddTail(csInitial);
																				pclDsgVar=new CPA_EdIR_DesignerVariable($3.csInitial,
																																								$2.csInitial,
																																								&cslValues,
																																								$1.csInitial.CompareNoCase("private") == 0);

																				g_clDsgVarList.AddTail(pclDsgVar);

																				//Gets initial value from $4 node
																				stReturn									stInitialValue;
																				CPA_EdIR_IntermediateCode	*pclInitialValue;

																				pclInitialValue=new CPA_EdIR_IntermediateCode($5.clIntermediateCodeList.GetAt(pos));

																				stInitialValue.clIntermediateCodeList.AddTail(pclInitialValue);

																				M_PASS2PARMS($$,$2,$3,stInitialValue);

																				// BEGIN ROMTEAM Cristi Petrescu 98-09-
																				$5.clIntermediateCodeList . m_fn_vDestroyAndRemoveAllEntries ();
																				// END ROMTEAM Cristi Petrescu 98-09-
																			}
																			else
																			{
																				yyerror("[DEV] Try to get initial value for a dsg var (parse) but pos is NULL");
																				yyerror("[DEV] Please contact Xavier Billault (53-74)");
																				YYERROR;
																			}
																		}
																		else
																		{
																			yyerror("[DEV] Try to get initial value for a dsg var (parse) but the IC list is empty");
																			yyerror("[DEV] Please contact Xavier Billault (53-74)");
																			YYERROR;
																		}
																	}
																	else
																	{
																		yyerror("Init value and dsg var have not the same type");
																		YYERROR;
																	}
																}
																else
																{
																	yyerror(M_MAKECHAR("The dsgvar "+$3.csInitial+" already exists !!"));
																	YYERROR;
																}
																//END ROMTEAM Cristi Petrescu 98-06-
															}
;

dvtype:					DVTYPE				{
																long	lIndex=M_GETINDEX($1);
																fn_vGetDesignerVariableTypeFromEngineType(&$$,lIndex);
																M_PASS_IN_1PARM($$,$1)
															}
;

dvname:					STRING				{M_PASS_ALL($$,$1)}
;

dvvalue:				constant			{M_PASS_ALL($$,$1)}
							|	null					{M_PASS_ALL($$,$1)}
;

dvqual:											{
													//BEGIN ROMTEAM Cristi Petrescu 98-06-
													$$.csInitial = "public";
													$$.csType="";
													$$.clIntermediateCodeList.m_fn_vMakeEmpty();
													//END ROMTEAM Cristi Petrescu 98-06-
												}
							|	DVQUALIFIER		
												{
													//BEGIN ROMTEAM Cristi Petrescu 98-06-
													M_PASS_ALL($$,$1);
													if (! fn_bIsDsgVarQualifier ($$.csInitial))
													{
														yyerror (M_MAKECHAR("The dsgvar qualifier "+$$.csInitial+" in invalid"));
														YYERROR;
													}
													//END ROMTEAM Cristi Petrescu 98-06-
												}
;

behaviour:			schedule			{M_PASS_ALL($$,$1)}
							|	itrules				{M_PASS_ALL($$,$1)}
							|	schedule
								itrules				{M_CONCAT2PARMS($$,$1,$2)}
;

schedule:				SCHEDULE
/*								actions				{
																$$.csPrefixed=g_c_csCreateSchedule+'\n'+$2.csPrefixed;
																M_PASS_IN_2PARMS($$,$1,$2)
															}*/
								statements		{
																$$.clIntermediateCodeList=new CPA_EdIR_IntermediateCode(g_clLex.m_lIndex,eCreateSchedule,0L);
																$$.clIntermediateCodeList.m_fn_vConcat($2.clIntermediateCodeList);
																M_PASS_IN_2PARMS($$,$1,$2) ;
																// BEGIN ROMTEAM Cristi Petrescu 98-09-
																$1 . clIntermediateCodeList . m_fn_vDestroyAndRemoveAllEntries ();
																// END ROMTEAM Cristi Petrescu 98-09-
															}
;

/*actions:				action				{M_PASS_ALL($$,$1)}
							|	actions
								action				{M_CONCAT2PARMS($$,$1,$2)}
;*/

action:					metaflag
								metaaction
								'('
								parms
								')'						{
																CString	csType;
																long	lIndex=M_GETINDEX($2);
																csType=fn_csGetMetaActionParams(lIndex);
//Stefan Dumitrean 21-05-98
																CString csMetaName = "metaaction "+$2.csInitial;
																M_CHECKPARMS(csType,$4,csMetaName)
//End Stefan Dumitrean 21-05-98
																{
																	$$.csType="";
																}
																M_PASS1PARM($$,$2,$4);
																CPA_EdIR_IntermediateCodeList	clIntermediateCodeList=$1.clIntermediateCodeList;
																clIntermediateCodeList.m_fn_vConcat($$.clIntermediateCodeList);
																$$.clIntermediateCodeList=clIntermediateCodeList;
																M_PASS_IN_5PARMS($$,$1,$2,$3,$4,$5)
															}
							|	affectation		{M_PASS_ALL($$,$1)}
							| beginmacro
								//actions
								statements
								endmacro			{
//																$$.clIntermediateCodeList = $2.clIntermediateCodeList;
																$$.clIntermediateCodeList = $1.clIntermediateCodeList;
                                /* jawaka : need for CFast, DON'T COMMENT IT AGAIN !! */
																M_SETINDEX($$, gl_MacroAddress);
                                /* end jawaka */
																$$.clIntermediateCodeList.m_fn_vConcat($2.clIntermediateCodeList);
																$$.clIntermediateCodeList.m_fn_vConcat($3.clIntermediateCodeList);
																M_PASS_IN_3PARMS($$,$1,$2,$3)
															}
							|	metaflag
								procedure
								'('
								parms
								')'						{
																CString	csType;
																long	lIndex=M_GETINDEX($2);
																csType=fn_csGetProcedureParams(lIndex);
//Stefan Dumitrean 21-05-98
																CString csProcName = "procedure "+$2.csInitial;
																M_CHECKPARMS(csType,$4,csProcName)
//End Stefan Dumitrean 21-05-98
																{
																	$$.csType="";
																}
																M_PASS1PARM($$,$2,$4);
																CPA_EdIR_IntermediateCodeList	clIntermediateCodeList=$1.clIntermediateCodeList;
																clIntermediateCodeList.m_fn_vConcat($$.clIntermediateCodeList);
																$$.clIntermediateCodeList=clIntermediateCodeList;
																M_PASS_IN_5PARMS($$,$1,$2,$3,$4,$5)
															}
							|	perso
								'.'
								procedure
								'('
								parms
								')'						{
																long	lIndex=M_GETINDEX($3);
																if(fn_bIsProcedureUsableWithUltraOperator(lIndex))
																{
																	CString	csType;
																	csType=fn_csGetProcedureParams(lIndex);
//Stefan Dumitrean 21-05-98
																	CString csProcName = "procedure "+$3.csInitial;
																	M_CHECKPARMS(csType,$5,csProcName)
//End Stefan Dumitrean 21-05-98
																	{
																		$$.csType="";
																	}

																	if(fn_lGetKeyWordIdFromEditorName($1.csInitial)==eKeyWord_Me)
																	{
																		M_PASS1PARM($$,$3,$5);
																		// BEGIN ROMTEAM Cristi Petrescu 98-09-
																		$1 . clIntermediateCodeList . m_fn_vDestroyAndRemoveAllEntries ();
																		// END ROMTEAM Cristi Petrescu 98-09-													
																	}
																	else
																	{
																		M_CREATEULTRANODE($$,$1,$3,$5);
																	}

																	M_PASS_IN_6PARMS($$,$1,$2,$3,$4,$5,$6);
																}
																else
																{
																	yyerror(M_MAKECHAR("Can't use <character>.<procedure> for the procedure "+$3.csInitial));
																	YYERROR;
																}
															}
							|	variable
								'.'
								procedure
								'('
								parms
								')'						{
																long	lRes=fn_lIsADsgVarForThisModel(g_pclCurrentModel,$1.csInitial);
																if(lRes!=C_NOT_A_DSG_VAR)
																{
																	M_SETINDEX($1,lRes);
																	M_SETMODEL($1,g_pclCurrentModel);

																	fn_vGetDesignerVariableTypeForThisModel(&$1,g_pclCurrentModel,lRes);
																}
																else
																{
																	yyerror(M_MAKECHAR($1.csInitial+" is not a valid variable for this model"));
																	YYERROR;
																}

																if($1.csType==C_ADDR_PERSO_PARAM)
																{
																	long	lIndex=M_GETINDEX($3);
																	if(fn_bIsProcedureUsableWithUltraOperator(lIndex))
																	{
																		CString	csType;
																		csType=fn_csGetProcedureParams(lIndex);
//Stefan Dumitrean 21-05-98
																		CString csProcName = "procedure "+$3.csInitial;
																		M_CHECKPARMS(csType,$5,csProcName)
//End Stefan Dumitrean 21-05-98
																		{
																			$$.csType="";
																		}

																		M_CREATEULTRANODE($$,$1,$3,$5);
																		M_PASS_IN_6PARMS($$,$1,$2,$3,$4,$5,$6);
																	}
																	else
																	{
																		yyerror(M_MAKECHAR("Can't use <character>.<procedure> for the procedure "+$3.csInitial));
																		YYERROR;
																	}
																}
																else
																{
																	yyerror(M_MAKECHAR($1.csInitial+" is not a character"));
																	YYERROR;
																}
															}
// SHAITAN => CORRECTION SUBR
							//BEGIN ROMTEAM Cristi Petrescu 98-04-
							|
								subrref		
															{
																//$$.clIntermediateCodeList = new CPA_EdIR_IntermediateCode(g_clLex.m_lIndex,eSubrRef,$1.csInitial);
																M_PASS_ALL($$,$1);
															}
							//END ROMTEAM Cristi Petrescu 98-04-

/*
		//BEGIN ROMTEAM Cristi Petrescu 98-04-
		|
			subrref		{
							
							//$$.clIntermediateCodeList = new CPA_EdIR_IntermediateCode(g_clLex.m_lIndex,eSubrRef,$1.csInitial);
							if ( m_bIsInITRules && ! gcGenerateOneRule && ! g_bPrevStatementWasAMacroRef )
							{
								//ici on ajoute la création d'un noeud CreateRule
								//il sera créée dans EdIR2Eng seulement si la profondeur de la subref est 1
								stReturn	stCreateRule;
								M_CREATENODE(stCreateRule,eCreateRule,0L);

								M_CONCAT2PARMS($$,stCreateRule,$1);

								M_PASS_IN_1PARM($$,$1);
							}
							else
							{
								M_PASS_ALL($$,$1);
							}
							g_bPrevStatementWasAMacroRef = TRUE ;
						}
		//END ROMTEAM Cristi Petrescu 98-04-
*/
// SHAITAN => END CORRECTION SUBR
;

metaflag:											{
																$$.csInitial=$$.csType="";
																$$.clIntermediateCodeList.m_fn_vMakeEmpty();
															}
							| stopflag			{
																stReturn	stProcedure;
																M_CREATENODE(stProcedure,eProcedure,(long)(eProc_SetActionReturn));

																stReturn	stConstant;
																long	lIndex=M_GETINDEX($1);
																M_CREATENODE(stConstant,eConstant,lIndex);
																
																M_PASS1PARM($$,stProcedure,stConstant);
																M_PASS_IN_1PARM($$,$1);

																// BEGIN ROMTEAM Cristi Petrescu 98-09-
																$1 . clIntermediateCodeList . m_fn_vDestroyAndRemoveAllEntries ();
																// END ROMTEAM Cristi Petrescu 98-09-
															}
;

stopflag:				STOPENGINE		{M_PASS_ALL($$,$1)}
							|	STOPRULE			{M_PASS_ALL($$,$1)}
							|	NONSTOP				{M_PASS_ALL($$,$1)}
;

beginmacro:			BEGINMACRO	
								'('
								INT
								','
								INT
								')'						{
// BEGIN ROMTEAM Cristi Petrescu 98-08-
// this is anyway shitty, because does not keep good record of code.
// see new fn_vPostProcessIA for better treatment
																//long	lLen;

																//Begin macro	name length
																//lLen=$1.csInitial.GetLength();
//Stefan Dumitrean 14-05-98  these must not be added because m_bIsInMacro becomes TRUE
//immediately after BEGINMACRO and g_clLex.m_lIndex is not incremented until ENDMACRO
//is ecountered
																//'(' length
																//lLen+=1;
																//INT length
																//lLen+=$3.csInitial.GetLength();
																//')' length
																//lLen+=1;
//End Stefan Dumitrean
																//Macro name length
																//lLen-=M_GETINDEX($3);

																//g_clLex.m_lOldMacroIndex=g_clLex.m_lIndex-lLen;
																//M_SETINDEX($1, M_GETINDEX($5));
																$$.clIntermediateCodeList = $1.clIntermediateCodeList;

                                /* jawaka : need for CFast, DON'T COMMENT IT AGAIN !! */
                                gl_MacroAddress = M_GETINDEX($5);
                                /* end jawaka */

																// BEGIN ROMTEAM Cristi Petrescu 98-09-
																$3 . clIntermediateCodeList . m_fn_vDestroyAndRemoveAllEntries ();
																$5 . clIntermediateCodeList . m_fn_vDestroyAndRemoveAllEntries ();
																// END ROMTEAM Cristi Petrescu 98-09-
// END ROMTEAM Cristi Petrescu 98-08-

															}
;

endmacro:				ENDMACRO							{
																M_PASS_ALL($$,$1)
															}
;

metaaction:			METAACTION		{M_PASS_ALL($$,$1)}
;

procedure:			PROCEDURE			{M_PASS_ALL($$,$1)}
;

//BEGIN ROMTEAM Cristi Petrescu 98-04-
subrref:					SUBRREF		{ M_PASS_ALL($$,$1) };
//END ROMTEAM Cristi Petrescu 98-04-

affectation:		lvariable
								opaffect
								exp						{
																long	lRes=fn_lIsTypeCompatibleForArithmOp(M_GETINDEX($2),&($1),&($3));
																if(lRes==C_NOT_COMPATIBLE)
																{
																	yyerror("Can't assign two expressions with different types");
																	YYERROR;
																}
																M_SETINDEX($2,lRes);
																M_PASS2PARMS($$,$2,$1,$3);
																M_PASS_IN_3PARMS($$,$1,$2,$3)
															}
							| lvariable
								opaffect
								null					{
																long	lRes=fn_lIsTypeCompatibleForArithmOp(M_GETINDEX($2),&($1),&($3));
																if(lRes==C_NOT_COMPATIBLE)
																{
																	yyerror("Can't assign two expressions with different types");
																	YYERROR;
																}
																M_SETINDEX($2,lRes);
																M_PASS2PARMS($$,$2,$1,$3);
																M_PASS_IN_3PARMS($$,$1,$2,$3)
															}
							|	lvariable
								opaffect1			{
																long	lRes=fn_lIsTypeCompatibleForArithmOp(M_GETINDEX($2),&($1));
																if(lRes==C_NOT_COMPATIBLE)
																{
																	yyerror(M_MAKECHAR("Can't use "+$2.csInitial+" with "+$1.csInitial));
																	YYERROR;
																}
																M_SETINDEX($2,lRes);
																M_PASS1PARM($$,$2,$1);
																M_PASS_IN_2PARMS($$,$1,$2)
															}
;

null:						NOBODY				{
																$1.csType=C_PERSO_PARAM;
																M_PASS_ALL($$,$1)
															}
							|   NOSUPEROBJECT		{
																$1.csType=C_SUPEROBJECT_PARAM;
																M_PASS_ALL($$,$1)
															}
							|	NOWHERE				{
																$1.csType=C_WAYPOINT_PARAM;
																M_PASS_ALL($$,$1)
															}
							|	NOCOMPORT			{
																$1.csType=C_COMPORT_PARAM;
																M_PASS_ALL($$,$1)
															}
							|	NOACTION			{
																$1.csType=C_ACTION_PARAM;
																M_PASS_ALL($$,$1)
															}
							|	CAPSNULL			{
																$1.csType=C_CAPS_PARAM;
																M_PASS_ALL($$,$1)
															}
              | NOGRAPH       {
																$1.csType=C_GRAPH_PARAM;
																M_PASS_ALL($$,$1)
							}
              | EMPTYTEXT     {
																$1.csType=C_TEXT_PARAM;
																M_PASS_ALL($$,$1)
							}
;

lvariable:			extfield			{M_PASS_ALL($$,$1)}
							|	extfield
								opgetcompo		{
																if($1.csType==C_ADDR_VECTOR_PARAM)
																{
																	M_PASS1PARM($$,$2,$1);
																	$$.csType=fn_csGetOperatorType(M_GETINDEX($2));

																	M_PASS_IN_2PARMS($$,$1,$2);
																}
																else
																{
																	yyerror(M_MAKECHAR("Can't use "+$2.csInitial+" because the field "+$1.csInitial+" is not a vector"));
																	YYERROR;
																}
															}
							|	ext2var				{M_PASS_ALL($$,$1)}
							|	ext2var
								opgetcompo		{
																if($1.csType==C_ADDR_VECTOR_PARAM)
																{
																	M_PASS1PARM($$,$2,$1);
																	$$.csType=fn_csGetOperatorType(M_GETINDEX($2));

																	M_PASS_IN_2PARMS($$,$1,$2);
																}
																else
																{
																	yyerror(M_MAKECHAR("Can't use "+$2.csInitial+" because the dsgvar "+$1.csInitial+" is not a vector"));
																	YYERROR;
																}
															}
;

ext2var:				extvar				{M_PASS_ALL($$,$1)}
							|	extvar
								'['
								exp
								']'						{
																//Checks $1 dsg var
																if($1.csType!=C_ADDR_ARRAY_PARAM)
																{
																	yyerror(M_MAKECHAR("The dsgvar "+$1.csInitial+" is not an array"));
																	YYERROR;
																}

																//Checks $3 expression
																long	lIndex=fn_lGetOperatorIdFromEditorName("[");
																long	lRes=fn_lIsTypeCompatibleForArithmOp(lIndex,&$1,&$3);
																if(lRes==C_NOT_COMPATIBLE)
																{
																	yyerror(M_MAKECHAR($3.csInitial+" has not the good type !!"));
																	YYERROR;
																}
																else
																{
																	M_PASS2PARMS4OP($$,eOperator,long(eOperator_Array),$1,$3);
																	$$.csType=$1.csSubType;

																	M_PASS_IN_4PARMS($$,$1,$2,$3,$4);
																}
															}
;

extvar:					variable			{
																long	lRes=fn_lIsADsgVarForThisModel(g_pclCurrentModel,$1.csInitial);
																if(lRes!=C_NOT_A_DSG_VAR)
																{
																	M_SETINDEX($1,lRes);
																	M_SETMODEL($1,g_pclCurrentModel);

																	M_PASS_ALL($$,$1);
																	fn_vGetDesignerVariableTypeForThisModel(&$$,g_pclCurrentModel,lRes);
																}
																else
																{
																	yyerror(M_MAKECHAR($1.csInitial+" is not a valid variable for this model"));
																	YYERROR;
																}
															}
							|	perso
								'.'
								variable			{
																if(fn_lGetKeyWordIdFromEditorName($1.csInitial)==eKeyWord_Me)
																{
																	long	lRes=fn_lIsADsgVarForThisModel(g_pclCurrentModel,$3.csInitial);
																	if(lRes!=C_NOT_A_DSG_VAR)
																	{
																		M_SETINDEX($3,lRes);
																		M_SETMODEL($3,g_pclCurrentModel);

																		M_PASS_ALL($$,$3);
																		fn_vGetDesignerVariableTypeForThisModel(&$$,g_pclCurrentModel,lRes);

																		// BEGIN ROMTEAM Cristi Petrescu 98-09-
																		$1 . clIntermediateCodeList . m_fn_vDestroyAndRemoveAllEntries ();
																		// END ROMTEAM Cristi Petrescu 98-09-
																	}
																	else
																	{
																		yyerror(M_MAKECHAR($1.csInitial+" is not a valid variable for this model"));
																		YYERROR;
																	}
																}
																else
																{
																	long lIndex;
																	lIndex=fn_lGetOperatorIdFromEditorName(".");

																	long	lHandleToPerso=fn_lGetHandleOfPerso(&$1);

																	long	lRes=fn_lIsADsgVarForThisPerso(lHandleToPerso,$3.csInitial);
																	if(lRes!=C_NOT_A_DSG_VAR)
																	{
																		M_SETINDEX($3,lRes);
																		M_SETMODELFROMPERSO($3,lHandleToPerso);

																		M_PASS2PARMS4OP($$,eOperator,lIndex,$1,$3);
																		fn_vGetDesignerVariableTypeForThisPerso(&$$,lHandleToPerso,lRes);
																	}
																	else
																	{
																		yyerror(M_MAKECHAR($3.csInitial+" is not a valid variable for the character "+$1.csInitial));
																		YYERROR;
																	}
																}

																M_PASS_IN_3PARMS($$,$1,$2,$3);
															}
							|	variable
								'.'
								MODEL
								'@'
								variable			{
																//Checks $1 dsg var
																long	lRes=fn_lIsADsgVarForThisModel(g_pclCurrentModel,$1.csInitial);
																if(lRes!=C_NOT_A_DSG_VAR)
																{
																	M_SETINDEX($1,lRes);
																	M_SETMODEL($1,g_pclCurrentModel);

																	fn_vGetDesignerVariableTypeForThisModel(&$1,g_pclCurrentModel,lRes);
																}
																else
																{
																	yyerror(M_MAKECHAR($1.csInitial+" is not a valid variable for this model"));
																	YYERROR;
																}

																if($1.csType!=C_ADDR_PERSO_PARAM)
																{
																	yyerror(M_MAKECHAR("Can't use \'.\' because the dsgvar "+$1.csInitial+" is not a character"));
																	YYERROR;
																}

																//Checks $5 dsg var
																CPA_Actor	*pclModel=(CPA_Actor *)M_GETINDEX($3);
																lRes=fn_lIsADsgVarForThisModel(pclModel,$5.csInitial);
																if(lRes!=C_NOT_A_DSG_VAR)
																{
																	M_SETINDEX($5,lRes);
																	M_SETMODEL($5,pclModel);

																	fn_vGetDesignerVariableTypeForThisModel(&$5,pclModel,lRes);
																}
																else
																{
																	yyerror(M_MAKECHAR($5.csInitial+" is not a valid variable for the model "+$3.csInitial));
																	YYERROR;
																}

																//Builds intermediate code list
																stReturn	stCastNode;
																M_PASS2PARMS4OP(stCastNode,eOperator,long(eOperator_ModelCast),$3,$1);

																M_PASS2PARMS4OP($$,eOperator,long(eOperator_Dot),stCastNode,$5);
																$$.csType=$5.csType;

																M_PASS_IN_5PARMS($$,$1,$2,$3,$4,$5)
															}
							|	perso
								'.'
								variable
								'.'
								MODEL
								'@'
								variable			{
																if(fn_lGetKeyWordIdFromEditorName($1.csInitial)==eKeyWord_Me)
																{
																	//Checks $3 dsg var
																	long	lRes=fn_lIsADsgVarForThisModel(g_pclCurrentModel,$3.csInitial);
																	if(lRes!=C_NOT_A_DSG_VAR)
																	{
																		M_SETINDEX($3,lRes);
																		M_SETMODEL($3,g_pclCurrentModel);

																		fn_vGetDesignerVariableTypeForThisModel(&$3,g_pclCurrentModel,lRes);
																	}
																	else
																	{
																		yyerror(M_MAKECHAR($3.csInitial+" is not a valid variable for this model"));
																		YYERROR;
																	}

																	if($3.csType!=C_ADDR_PERSO_PARAM)
																	{
																		yyerror(M_MAKECHAR("Can't use \'.\' because the dsgvar "+$3.csInitial+" is not a character"));
																		YYERROR;
																	}

																	//Checks $7 dsg var
																	CPA_Actor	*pclModel=(CPA_Actor *)M_GETINDEX($5);
																	lRes=fn_lIsADsgVarForThisModel(pclModel,$7.csInitial);
																	if(lRes!=C_NOT_A_DSG_VAR)
																	{
																		M_SETINDEX($7,lRes);
																		M_SETMODEL($7,pclModel);

																		fn_vGetDesignerVariableTypeForThisModel(&$7,pclModel,lRes);
																	}
																	else
																	{
																		yyerror(M_MAKECHAR($7.csInitial+" is not a valid variable for the model "+$5.csInitial));
																		YYERROR;
																	}

																	//Builds intermediate code list
																	stReturn	stCastNode;
																	M_PASS2PARMS4OP(stCastNode,eOperator,long(eOperator_ModelCast),$5,$3);

																	M_PASS2PARMS4OP($$,eOperator,long(eOperator_Dot),stCastNode,$7);
																	$$.csType=$7.csType;

																	// BEGIN ROMTEAM Cristi Petrescu 98-09-
																	$1 . clIntermediateCodeList . m_fn_vDestroyAndRemoveAllEntries ();
																	// END ROMTEAM Cristi Petrescu 98-09-
																}
																else
																{
																	//Checks $3 dsg var
																	long	lHandleToPerso=fn_lGetHandleOfPerso(&$1);

																	long	lRes=fn_lIsADsgVarForThisPerso(lHandleToPerso,$3.csInitial);
																	if(lRes!=C_NOT_A_DSG_VAR)
																	{
																		M_SETINDEX($3,lRes);
																		M_SETMODELFROMPERSO($3,lHandleToPerso);

																		fn_vGetDesignerVariableTypeForThisPerso(&$3,lHandleToPerso,lRes);
																	}
																	else
																	{
																		yyerror(M_MAKECHAR($3.csInitial+" is not a valid variable for the character "+$1.csInitial));
																		YYERROR;
																	}

																	if($3.csType!=C_ADDR_PERSO_PARAM)
																	{
																		yyerror(M_MAKECHAR("Can't use \'.\' because the dsgvar "+$3.csInitial+" is not a character"));
																		YYERROR;
																	}

																	//Checks $7 dsg var
																	CPA_Actor	*pclModel=(CPA_Actor *)M_GETINDEX($5);
																	lRes=fn_lIsADsgVarForThisModel(pclModel,$7.csInitial);
																	if(lRes!=C_NOT_A_DSG_VAR)
																	{
																		M_SETINDEX($7,lRes);
																		M_SETMODEL($7,pclModel);

																		fn_vGetDesignerVariableTypeForThisModel(&$7,pclModel,lRes);
																	}
																	else
																	{
																		yyerror(M_MAKECHAR($7.csInitial+" is not a valid variable for the model "+$5.csInitial));
																		YYERROR;
																	}

																	//Builds intermediate code list
																	stReturn	stCastNode;
																	M_PASS2PARMS4OP(stCastNode,eOperator,long(eOperator_ModelCast),$5,$3);

																	stReturn	stDotNode;
																	M_PASS2PARMS4OP(stDotNode,eOperator,long(eOperator_Dot),$1,stCastNode);

																	M_PASS2PARMS4OP($$,eOperator,long(eOperator_Dot),stDotNode,$7);
																	$$.csType=$7.csType;
																}

																M_PASS_IN_7PARMS($$,$1,$2,$3,$4,$5,$6,$7);
															}
;

variable:				DESVAR				{
																fn_vGetDesignerVariableType(&$1,M_GETINDEX($1));
																M_PASS_ALL($$,$1)
															}
;

extfield:				field					{M_PASS_ALL($$,$1)}
							|	perso
								'.'
								field
															{
																if(fn_lGetKeyWordIdFromEditorName($1.csInitial)==eKeyWord_Me)
																{
																	M_PASS_ALL($$,$3);
																	// BEGIN ROMTEAM Cristi Petrescu 98-09-
																	$1 . clIntermediateCodeList . m_fn_vDestroyAndRemoveAllEntries ();
																	// END ROMTEAM Cristi Petrescu 98-09-
																}
																else
																{
																	long lIndex;
																	lIndex=fn_lGetOperatorIdFromEditorName(".");

																	M_PASS2PARMS4OP($$,eOperator,lIndex,$1,$3);
																	$$.csType=$3.csType;
																}

																M_PASS_IN_3PARMS($$,$1,$2,$3)
															}
							|	variable
								'.'
								field					{
																long	lRes=fn_lIsADsgVarForThisModel(g_pclCurrentModel,$1.csInitial);
																if(lRes!=C_NOT_A_DSG_VAR)
																{
																	M_SETINDEX($1,lRes);
																	M_SETMODEL($1,g_pclCurrentModel);

																	fn_vGetDesignerVariableTypeForThisModel(&$1,g_pclCurrentModel,lRes);
																}
																else
																{
																	yyerror(M_MAKECHAR($1.csInitial+" is not a valid variable for this model"));
																	YYERROR;
																}

																if($1.csType==C_ADDR_PERSO_PARAM)
																{
																	long lIndex;
																	lIndex=fn_lGetOperatorIdFromEditorName(".");

																	M_PASS2PARMS4OP($$,eOperator,lIndex,$1,$3);
																	$$.csType=$3.csType;

																	M_PASS_IN_3PARMS($$,$1,$2,$3);
																}
																else
																{
																	yyerror(M_MAKECHAR("Can't use \'.\' because the dsgvar "+$1.csInitial+" is not a character"));
																	YYERROR;
																}
															}
;

field:					FIELD					{
																$1.csType=fn_csGetFieldType(M_GETINDEX($1));
																M_PASS_ALL($$,$1)
															}
;

opaffect:				OPWITH2PARMS	{
																$1.csType=fn_csGetOperatorParams(M_GETINDEX($1));
																M_PASS_ALL($$,$1)
															}
;

opaffect1:			OPWITH1PARM		{
																$1.csType=fn_csGetOperatorParams(M_GETINDEX($1));
																M_PASS_ALL($$,$1)
															}
;

opgetcompo:			OPGETCOMPO		{
																$1.csType=fn_csGetOperatorParams(M_GETINDEX($1));
																M_PASS_ALL($$,$1)
															}
;

exp:						lvariable			{M_PASS_ALL($$,$1)}
							|	constant			{M_PASS_ALL($$,$1)}
              | '{' conditions '}' {
                                $$.csType = $2.csType;
                                M_PASS_ALL($$,$2);                
																M_PASS_IN_3PARMS($$,$1,$2,$3);
                                }
							| vector
								'('
								parms
								')'						{
																long	lIndex=M_GETINDEX($1);
//Stefan Dumitrean 21-05-98
																CString csVectName = "vector "+$1.csInitial;
																M_CHECKPARMS($1.csType,$3,csVectName)
//End Stefan Dumitrean 21-05-98
																{
																	$$.csType=fn_csGetKeyWordType(lIndex);
																}
																M_PASS1PARM($$,$1,$3);
																M_PASS_IN_4PARMS($$,$1,$2,$3,$4)
															}
							|	function
								'('
								parms
								')'						{
																CString	csType;
																long		lIndex=M_GETINDEX($1);
																csType=fn_csGetFunctionParams(lIndex);
//Stefan Dumitrean 21-05-98
																CString csFuncName = "function "+$1.csInitial;
																M_CHECKPARMS(csType,$3,csFuncName)
//End Stefan Dumitrean 21-05-98
																{
																	$$.csType=fn_csGetFunctionType(lIndex);
																}
																M_PASS1PARM($$,$1,$3);
																M_PASS_IN_4PARMS($$,$1,$2,$3,$4)
															}
							|	perso
								'.'
								function
								'('
								parms
								')'						{
																long	lIndex=M_GETINDEX($3);
																if(fn_bIsFunctionUsableWithUltraOperator(lIndex))
																{
																	CString	csType;
																	csType=fn_csGetFunctionParams(lIndex);
//Stefan Dumitrean 21-05-98
																	CString csFuncName = "function "+$3.csInitial;
																	M_CHECKPARMS(csType,$5,csFuncName)
//End Stefan Dumitrean 21-05-98
																	{
																		$$.csType=fn_csGetFunctionType(lIndex);
																	}

																	if(fn_lGetKeyWordIdFromEditorName($1.csInitial)==eKeyWord_Me)
																	{
																		M_PASS1PARM($$,$3,$5);
																		// BEGIN ROMTEAM Cristi Petrescu 98-09-
																		$1 . clIntermediateCodeList . m_fn_vDestroyAndRemoveAllEntries ();
																		// END ROMTEAM Cristi Petrescu 98-09-
																	}
																	else
																	{
																		M_CREATEULTRANODE($$,$1,$3,$5);
																	}

																	M_PASS_IN_6PARMS($$,$1,$2,$3,$4,$5,$6);
																}
																else
																{
																	yyerror(M_MAKECHAR("Can't use <character>.<function> for the function "+$3.csInitial));
																	YYERROR;
																}
															}
							|	variable
								'.'
								function
								'('
								parms
								')'						{
																long	lRes=fn_lIsADsgVarForThisModel(g_pclCurrentModel,$1.csInitial);
																if(lRes!=C_NOT_A_DSG_VAR)
																{
																	M_SETINDEX($1,lRes);
																	M_SETMODEL($1,g_pclCurrentModel);

																	fn_vGetDesignerVariableTypeForThisModel(&$1,g_pclCurrentModel,lRes);
																}
																else
																{
																	yyerror(M_MAKECHAR($1.csInitial+" is not a valid variable for this model"));
																	YYERROR;
																}

																if($1.csType==C_ADDR_PERSO_PARAM)
																{
																	long	lIndex=M_GETINDEX($3);
																	if(fn_bIsFunctionUsableWithUltraOperator(lIndex))
																	{
																		CString	csType;
																		csType=fn_csGetFunctionParams(lIndex);
//Stefan Dumitrean 21-05-98
																		CString csFuncName = "function "+ $3.csInitial;
																		M_CHECKPARMS(csType,$5,csFuncName)
//End Stefan Dumitrean 21-05-98
																		{
																			$$.csType=fn_csGetFunctionType(lIndex);
																		}

																		M_CREATEULTRANODE($$,$1,$3,$5);
																		M_PASS_IN_6PARMS($$,$1,$2,$3,$4,$5,$6);
																	}
																	else
																	{
																		yyerror(M_MAKECHAR("Can't use <character>.<function> for the function "+$3.csInitial));
																		YYERROR;
																	}
																}
																else
																{
																	yyerror(M_MAKECHAR($1.csInitial+" is not a character"));
																	YYERROR;
																}
															}
							|	exp
								'+'
								exp						{
																long	lIndex=fn_lGetOperatorIdFromEditorName("+");
																long	lRes=fn_lIsTypeCompatibleForArithmOp(lIndex,&($1),&($3));
																if(lRes==C_NOT_COMPATIBLE)
																{
																	yyerror("Can't add two expressions with different types");
																	YYERROR;
																}
																else
																{
																	$$.csType=fn_csGetOperatorType(lRes,$1.csType,$3.csType);
																}
																M_PASS2PARMS4OP($$,eOperator,lRes,$1,$3);
																M_PASS_IN_3PARMS($$,$1,$2,$3)
															}
							|	exp
								'-'
								exp						{
																long	lIndex=fn_lGetOperatorIdFromEditorName("-");
																long	lRes=fn_lIsTypeCompatibleForArithmOp(lIndex,&($1),&($3));
																if(lRes==C_NOT_COMPATIBLE)
																{
																	yyerror("Can't substract two expressions with different types");
																	YYERROR;
																}
																else
																{
																	$$.csType=fn_csGetOperatorType(lRes,$1.csType,$3.csType);
																}
																M_PASS2PARMS4OP($$,eOperator,lRes,$1,$3);
																M_PASS_IN_3PARMS($$,$1,$2,$3)
															}
							|	exp
								'*'
								exp						{
																long	lIndex=fn_lGetOperatorIdFromEditorName("*");
																long	lRes=fn_lIsTypeCompatibleForArithmOp(lIndex,&($1),&($3));
																// BEGIN ROMTEAM Cristi Petrescu 99-1 debug
																if(lRes==C_NOT_COMPATIBLE)
																{
																	// try reverse
																	lRes = fn_lIsTypeCompatibleForArithmOp(lIndex,&($3),&($1));

																	if (lRes == C_NOT_COMPATIBLE)
																	{
																		yyerror("Can't multiply two expressions with different types");
																		YYERROR;
																	}
																	else
																	{	
																		if ($3.csType == C_ADDR_VECTOR_PARAM)
																		{
																			$$.csType=fn_csGetOperatorType(lRes,$3.csType,$1.csType);

																			M_PASS2PARMS4OP($$,eOperator,lRes,$3,$1);
																			M_PASS_IN_3PARMS($$,$3,$2,$1);
																		}
																		else
																		{
																			$$.csType=fn_csGetOperatorType(lRes,$1.csType,$3.csType);
																		
																			M_PASS2PARMS4OP($$,eOperator,lRes,$1,$3);
																			M_PASS_IN_3PARMS($$,$1,$2,$3);
																		}
																	}
																}
																else
																{
																	$$.csType=fn_csGetOperatorType(lRes,$1.csType,$3.csType);
																
																	M_PASS2PARMS4OP($$,eOperator,lRes,$1,$3);
																	M_PASS_IN_3PARMS($$,$1,$2,$3);
																}
																// END ROMTEAM Cristi Petrescu 99-1 debug
															}
							|	exp
								'/'
								exp						{
																long	lIndex=fn_lGetOperatorIdFromEditorName("/");
																long	lRes=fn_lIsTypeCompatibleForArithmOp(lIndex,&($1),&($3));
																if(lRes==C_NOT_COMPATIBLE)
																{
																	yyerror("Can't divide two expressions with different types");
																	YYERROR;
																}
																else
																{
																	$$.csType=fn_csGetOperatorType(lRes,$1.csType,$3.csType);
																}
																M_PASS2PARMS4OP($$,eOperator,lRes,$1,$3);
																M_PASS_IN_3PARMS($$,$1,$2,$3)
															}
							|	'-'
								exp
								%prec NEG			{
																long	lIndex=fn_lGetOperatorIdFromEditorName("_");
																long	lRes=fn_lIsTypeCompatibleForArithmOp(lIndex,&($2));
																if(lRes==C_NOT_COMPATIBLE)
																{
																	yyerror("Can't use unary minus operator with this type");
																	YYERROR;
																}
																else
																{
																	$$.csType=$2.csType;
																}
																M_PASS1PARM4OP($$,eOperator,lRes,$2);
																M_PASS_IN_2PARMS($$,$1,$2)
															}
							|	'('
								exp
								')'						{
																M_PASS_ALL($$,$2);
																M_PASS_IN_3PARMS($$,$1,$2,$3)
															}
;

vector:					VECTOR				{
																$$.csType=fn_csGetKeyWordParams(M_GETINDEX($1));
																M_CREATENODE($$,eVector,M_GETINDEX($1));
																M_PASS_IN_1PARM($$,$1);
																// BEGIN ROMTEAM Cristi Petrescu 98-09-
																$1 . clIntermediateCodeList . m_fn_vDestroyAndRemoveAllEntries ();
																// END ROMTEAM Cristi Petrescu 98-09-
															}
;

perso:					PERSO					{
																if(fn_ucIsAnAlwaysModel((tdstEngineObject *)(M_GETINDEX($1))))
																	$1.csType=C_ALWAYS_PARAM;
																else
																	$1.csType=C_PERSO_PARAM;
																M_PASS_ALL($$,$1)
															}
							|	ME						{
																$1.csType=C_PERSO_PARAM;
																M_PASS_ALL($$,$1)
															}
							|	MAINACTOR			{
																$1.csType=C_PERSO_PARAM;
																M_PASS_ALL($$,$1)
															}
							/*|	WORLD					{
																$1.csType=C_PERSO_PARAM;
																M_PASS_ALL($$,$1)
															}*/
;

constant:				INT						{
																$1.csType=C_LONG_PARAM;
																M_PASS_ALL($$,$1)
															}
							|	REAL					{
																$1.csType=C_REAL_PARAM;
																M_PASS_ALL($$,$1)
															}
							|	CONSTANTINT		{
																$1.csType=C_LONG_PARAM;
																M_PASS_ALL($$,$1)
															}
							|	CONSTANTREAL	{
																$1.csType=C_REAL_PARAM;
																M_PASS_ALL($$,$1)
															}
							| perso					{M_PASS_ALL($$,$1)}						
							| ZDD						{
																$1.csType=C_ZDD_PERSO_PARAM;
																M_PASS_ALL($$,$1)
															}
							| ZDE						{
																$1.csType=C_ZDE_PERSO_PARAM;
																M_PASS_ALL($$,$1)
															}
							| ZDM						{
																$1.csType=C_ZDM_PERSO_PARAM;
																M_PASS_ALL($$,$1)
															}
							| ZDR						{
																$1.csType=C_ZDR_PERSO_PARAM;
																M_PASS_ALL($$,$1)
															}
							| ACTION				{
																$1.csType=C_ACTION_PARAM;
																M_PASS_ALL($$,$1)
															}
							| WAYPOINT			{
																$1.csType=C_WAYPOINT_PARAM;
																M_PASS_ALL($$,$1)
															}
							| CHANNEL				{
																$1.csType=C_CHANNEL_PARAM;
																M_PASS_ALL($$,$1)
															}
							| SURFACE				{
																$1.csType=C_SURFACE_PARAM;
																M_PASS_ALL($$,$1)
															}
							| ENVIRONMENT		{
																$1.csType=C_ENV_PARAM;
																M_PASS_ALL($$,$1)
															}
							| SECTOR				{
																$1.csType=C_SECTOR_PARAM;
																M_PASS_ALL($$,$1)
															}
							| SUPEROBJECT		{
																$1.csType=C_SUPEROBJECT_PARAM;
																M_PASS_ALL($$,$1)
															}
							| LIPSYNCHRO		{
																$1.csType=C_LIPSYNCHRO_PARAM;
																M_PASS_ALL($$,$1)
															}
							| OBJECTTABLE		{
																$1.csType=C_OBJECTTABLE_PARAM;
																M_PASS_ALL($$,$1)
															}
							| FAMILY				{
																$1.csType=C_FAMILY_PARAM;
																M_PASS_ALL($$,$1)
															}
							| SOUNDEVENT		{
																$1.csType=C_SOUNDEVENT_PARAM;
																M_PASS_ALL($$,$1)
															}
							| GAMEMATERIAL	{
																$1.csType=C_GMT_PARAM;
																M_PASS_ALL($$,$1)
															}
							| LIGHT					{
																$1.csType=C_LIGHT_PARAM;
																M_PASS_ALL($$,$1)
															}
							| CAPS					{
																$1.csType=C_CAPS_PARAM;
																M_PASS_ALL($$,$1)
															}
							| GRAPH					{
																$1.csType=C_GRAPH_PARAM;
																M_PASS_ALL($$,$1)
															}
							|	BOOLEAN				{
																$1.csType=C_BOOLEAN_PARAM;
																M_PASS_ALL($$,$1)
															}
							|	MYREFLEX			{
																$1.csType=C_MY_REFLEX_COMPORT_PARAM;
																M_PASS_ALL($$,$1)
															}
							|	MYBEHAV				{
																$1.csType=C_MY_INTELL_COMPORT_PARAM;
																M_PASS_ALL($$,$1)
															}
							|	REFLEX				{
																$1.csType=C_REFLEX_COMPORT_PARAM;
																M_PASS_ALL($$,$1)
															}
							|	BEHAV					{
																$1.csType=C_INTELL_COMPORT_PARAM;
																M_PASS_ALL($$,$1)
															}
							|	KEYBUTTON			{
																$1.csType=C_BUTTON_PARAM;
																M_PASS_ALL($$,$1)
															}
							|	masktypes			{
																$1.csType=C_MASK_PARAM;
																M_PASS_ALL($$,$1)
															}
							|	POWER					{
																$1.csType=C_POWER_PARAM;
																M_PASS_ALL($$,$1)
															}
							|	STRING				{
																$1.csType=C_STRING_PARAM;
																M_PASS_ALL($$,$1)
															}
							|	TEXT					{
																$1.csType=C_TEXT_PARAM;
																M_PASS_ALL($$,$1)
															}
							/*|	FONT					{
																$1.csType=C_FONT_PARAM;
																M_PASS_ALL($$,$1)
															}*/
							|	PARTGEN				{
																$1.csType=C_PARTICLEGENERATOR_PARAM;
																M_PASS_ALL($$,$1)
															}
							|	MODEL							{	
																$1.csType=C_MODEL_PARAM;
																M_PASS_ALL($$,$1)
																}	
							|	STATE					{
																//$1.csType=C_STATE_PARAM;
																M_PASS_ALL($$,$1);
																yyerror("State are not known by the AI Engine !!");
																YYERROR;
															}
							| constvector
								'('
								constparms
								')'						{
																long	lIndex=M_GETINDEX($1);
//Stefan Dumitrean 21-05-98
																CString csVectName = "vector "+$1.csInitial;
																M_CHECKPARMS($1.csType,$3,csVectName)
//End Stefan Dumitrean 21-05-98
																{
																	$$.csType=fn_csGetKeyWordType(lIndex);
																}

																stReturn	stVector;
																double		dfX=$3.clIntermediateCodeList.m_fn_dfGetValue(0);
																double		dfY=$3.clIntermediateCodeList.m_fn_dfGetValue(1);
																double		dfZ=$3.clIntermediateCodeList.m_fn_dfGetValue(2);
																M_CREATEVECTORNODE(stVector,eVectorConstant,dfX,dfY,dfZ);

																M_PASS1PARM($$,$1,stVector);
																M_PASS_IN_4PARMS($$,$1,$2,$3,$4);

																// BEGIN ROMTEAM Cristi Petrescu 98-09-
																$3 . clIntermediateCodeList . m_fn_vDestroyAndRemoveAllEntries ();
																// END ROMTEAM Cristi Petrescu 98-09-
															}
;

constvector:		CONSTVECTOR		{
																$1.csType=fn_csGetKeyWordParams(M_GETINDEX($1));
																M_PASS_ALL($$,$1)
															}
;

constparms:										{
																$$.csInitial=$$.csType="";
																$$.clIntermediateCodeList.m_fn_vMakeEmpty();
															}
							|	constparm			{M_PASS_ALL($$,$1)}
							|	constparms
								','
								constparm			{
																$$.clIntermediateCodeList=$1.clIntermediateCodeList;
																$$.clIntermediateCodeList.m_fn_vConcat($3.clIntermediateCodeList);
																$$.csType=$1.csType+$3.csType;
																M_PASS_IN_3PARMS($$,$1,$2,$3)
															}
;

constparm:			constant			{M_PASS_ALL($$,$1)}
;

masktypes:			masktype			{M_PASS_ALL($$,$1)}
							|	masktypes
								'&'
								masktype			{
																long	lIndex=GMT_fn_xCombineMask((GMT_tdxMask)(M_GETINDEX($1)),
																																(GMT_tdxMask)(M_GETINDEX($3)));

																M_CREATENODE($$,eMaskType,lIndex);
																M_PASS_IN_3PARMS($$,$1,$2,$3);
																// BEGIN ROMTEAM Cristi Petrescu 98-09-
																$1 . clIntermediateCodeList . m_fn_vDestroyAndRemoveAllEntries ();
																$3 . clIntermediateCodeList . m_fn_vDestroyAndRemoveAllEntries ();
																// END ROMTEAM Cristi Petrescu 98-09-
															}
;

masktype:				MASKTYPE			{
																long	lIndex=(1<<(M_GETINDEX($1)));

																M_CREATENODE($$,eMaskType,lIndex);
																M_PASS_IN_1PARM($$,$1);
																// BEGIN ROMTEAM Cristi Petrescu 98-09-
																$1 . clIntermediateCodeList . m_fn_vDestroyAndRemoveAllEntries ();
																// END ROMTEAM Cristi Petrescu 98-09-
															}
;

function:				FUNCTION			{M_PASS_ALL($$,$1)}
;

parms:												{
																$$.csInitial=$$.csType="";
																$$.clIntermediateCodeList.m_fn_vMakeEmpty();
															}
							|	parm					{M_PASS_ALL($$,$1)}
							|	parms
								','
								parm					{
																$$.clIntermediateCodeList=$1.clIntermediateCodeList;
																$$.clIntermediateCodeList.m_fn_vConcat($3.clIntermediateCodeList);
																$$.csType=$1.csType+$3.csType;
																M_PASS_IN_3PARMS($$,$1,$2,$3)
															}
;

parm:						exp						{M_PASS_ALL($$,$1)}
							| null					{M_PASS_ALL($$,$1)}
;

itrules:				itrstart
								statements		{M_CONCAT2PARMS($$,$1,$2)}
;

itrstart:				ITRULES				{
																M_CREATENODE($$,eCreateRule,0L);
																m_bIsInITRules=TRUE;
// SHAITAN => CORRECTION SUBR
//																g_bPrevStatementWasAMacroRef = FALSE ;
// SHAITAN => END CORRECTION SUBR
																// BEGIN ROMTEAM Cristi Petrescu 98-09-
																$1 . clIntermediateCodeList . m_fn_vDestroyAndRemoveAllEntries ();
																// END ROMTEAM Cristi Petrescu 98-09-
															}
;

statements:			statement			{M_PASS_ALL($$,$1)}
							|	statements
								statement			{M_CONCAT2PARMS($$,$1,$2)}
;

// SHAITAN => CORRECTION SUBR
statement:			action				{M_PASS_ALL($$,$1)}
/*
statement:			action				{
											if ( g_bPrevStatementWasAMacroRef )
											{
												//$$.clIntermediateCodeList = new CPA_EdIR_IntermediateCode(g_clLex.m_lIndex,eSubrRef,$1.csInitial);
												if ( m_bIsInITRules && ! gcGenerateOneRule )
												{
													//ici on ajoute la création d'un noeud CreateRule
													//il sera créée dans EdIR2Eng seulement si la profondeur de la subref est 1
													stReturn	stCreateRule;
													M_CREATENODE(stCreateRule,eCreateRule,(long)0);//en fait on s'en fout

													M_CONCAT2PARMS($$,$1,stCreateRule);

													M_PASS_IN_1PARM($$,$1);
												}
												else
												{
													M_PASS_ALL($$,$1);
												}
												g_bPrevStatementWasAMacroRef = FALSE ;
											}
											else
												M_PASS_ALL($$,$1)
										}
*/
// SHAITAN => END CORRECTION SUBR
							|	condaction		{M_PASS_ALL($$,$1)}
;

condaction:			if
								conditions
								then
								statements
								endif					{
																M_IFTHEN($$,$1,$2,$3,$4,$5);
																M_PASS_IN_5PARMS($$,$1,$2,$3,$4,$5)
															}
							|	if
								conditions
								then
								statements
								else
								statements
								endif					{
																M_IFTHENELSE($$,$1,$2,$3,$4,$5,$6,$7);
																M_PASS_IN_7PARMS($$,$1,$2,$3,$4,$5,$6,$7)
															}
							|	ifdebug
								statements
								endif					{
																			$$.clIntermediateCodeList=$1.clIntermediateCodeList;\
																			M_ADD1PARM($$,$2);\
																			$$.clIntermediateCodeList.m_fn_vConcat($3.clIntermediateCodeList);\
																			M_PASS_IN_3PARMS($$,$1,$2,$3)

															}
							|	ifnotu64
								statements
								endif					{
																			$$.clIntermediateCodeList=$1.clIntermediateCodeList;\
																			M_ADD1PARM($$,$2);\
																			$$.clIntermediateCodeList.m_fn_vConcat($3.clIntermediateCodeList);\
																			M_PASS_IN_3PARMS($$,$1,$2,$3)

															}
;

ifdebug:					IFDEBUG									{M_PASS_ALL($$,$1)}
ifnotu64:					IFNOTU64								{M_PASS_ALL($$,$1)}
if:							IF|IF2|IF4|IF8|IF16|IFNOT				{M_PASS_ALL($$,$1)}
;

then:						THEN					{M_PASS_ALL($$,$1)}
;

else:						ELSE					{M_PASS_ALL($$,$1)}
;

endif:					ENDIF					{
																if ( gcGenerateOneRule )
																{
																	$$.clIntermediateCodeList.m_fn_vMakeEmpty();
																}
																else
																{
																	if(m_bIsInITRules)
																	{
																		M_CREATENODE($$,eCreateRule,M_GETINDEX($1));
																	}
																	else
																	{
																		$$.clIntermediateCodeList.m_fn_vMakeEmpty();
																	}
																	M_PASS_IN_1PARM($$,$1);
																	// BEGIN ROMTEAM Cristi Petrescu 98-09-
																	$1 . clIntermediateCodeList . m_fn_vDestroyAndRemoveAllEntries ();
																	// END ROMTEAM Cristi Petrescu 98-09-
																}
															}
;

conditions:			condition
								'('
								parms
								')'						{
																CString	csType;
																long	lIndex=M_GETINDEX($1);
																csType=fn_csGetConditionParams(lIndex);
//Stefan Dumitrean 21-05-98
																CString csCondName = "condition "+$1.csInitial;
																M_CHECKPARMS(csType,$3,csCondName)
//End Stefan Dumitrean 21-05-98
																{
																	$$.csType=C_BOOLEAN_PARAM;
																}
																M_PASS1PARM($$,$1,$3);
																M_PASS_IN_4PARMS($$,$1,$2,$3,$4)
															}
							|	perso
								'.'
								condition
								'('
								parms
								')'						{
																long	lIndex=M_GETINDEX($3);
																if(fn_bIsConditionUsableWithUltraOperator(lIndex))
																{
																	CString	csType;
																	csType=fn_csGetConditionParams(lIndex);
//Stefan Dumitrean 21-05-98								
																	CString csCondName = "condition "+$3.csInitial;
																	M_CHECKPARMS(csType,$5,csCondName)
//End Stefan Dumitrean 21-05-98
																	{
																		$$.csType=C_BOOLEAN_PARAM;
																	}

																	if(fn_lGetKeyWordIdFromEditorName($1.csInitial)==eKeyWord_Me)
																	{
																		M_PASS1PARM($$,$3,$5);
																		// BEGIN ROMTEAM Cristi Petrescu 98-09-
																		$1 . clIntermediateCodeList . m_fn_vDestroyAndRemoveAllEntries ();
																		// END ROMTEAM Cristi Petrescu 98-09-
																	}
																	else
																	{
																		M_CREATEULTRANODE($$,$1,$3,$5);
																	}

																	M_PASS_IN_6PARMS($$,$1,$2,$3,$4,$5,$6);
																}
																else
																{
																	yyerror(M_MAKECHAR("Can't use <character>.<condition> for the condition "+$3.csInitial));
																	YYERROR;
																}
															}
							|	variable
								'.'
								condition
								'('
								parms
								')'						{
																long	lRes=fn_lIsADsgVarForThisModel(g_pclCurrentModel,$1.csInitial);
																if(lRes!=C_NOT_A_DSG_VAR)
																{
																	M_SETINDEX($1,lRes);
																	M_SETMODEL($1,g_pclCurrentModel);

																	fn_vGetDesignerVariableTypeForThisModel(&$1,g_pclCurrentModel,lRes);
																}
																else
																{
																	yyerror(M_MAKECHAR($1.csInitial+" is not a valid variable for this model"));
																	YYERROR;
																}

																if($1.csType==C_ADDR_PERSO_PARAM)
																{
																	long	lIndex=M_GETINDEX($3);
																	if(fn_bIsConditionUsableWithUltraOperator(lIndex))
																	{
																		CString	csType;
																		csType=fn_csGetConditionParams(lIndex);
//Stefan Dumitrean 21-05-98
																		CString csCondName = "condition "+$3.csInitial;
																		M_CHECKPARMS(csType,$5,csCondName)
//End Stefan Dumitrean 21-05-98
																		{
																			$$.csType=C_BOOLEAN_PARAM;
																		}

																		M_CREATEULTRANODE($$,$1,$3,$5);
																		M_PASS_IN_6PARMS($$,$1,$2,$3,$4,$5,$6);
																	}
																	else
																	{
																		yyerror(M_MAKECHAR("Can't use <character>.<condition> for the condition "+$3.csInitial));
																		YYERROR;
																	}
																}
																else
																{
																	yyerror(M_MAKECHAR($1.csInitial+" is not a character"));
																	YYERROR;
																}
															}
							|	not
								conditions
														{
                                //the type of the expression is the type of the operator
																$$.csType=$1.csType;
																M_PASS1PARM($$,$1,$2);
																M_PASS_IN_2PARMS($$,$1,$2)
															}
							|	not
								'('
								conditions
								')'						{
                                //the type of the expression is the type of the operator
																$$.csType=$1.csType;
																M_PASS1PARM($$,$1,$3);
																M_PASS_IN_4PARMS($$,$1,$2,$3,$4)
															}
							|	'('
								conditions
								opcond
								conditions
								')'						{
                                //the type of the expression is the type of the operator
																$$.csType=$3.csType;
																M_PASS2PARMS($$,$3,$2,$4);
																M_PASS_IN_5PARMS($$,$1,$2,$3,$4,$5)
															}
							|	'('
								exp
								opbin
								exp
								')'						{
																if(!fn_bIsTypeCompatibleForBinaryOp(M_GETINDEX($3),&($2),&($4)))
																{
																	yyerror("Can't make a test between two expressions with different types");
																	YYERROR;
																}
                                //the type of the expression is the type of the operator
																$$.csType=$3.csType;
																M_PASS2PARMS($$,$3,$2,$4);
																M_PASS_IN_5PARMS($$,$1,$2,$3,$4,$5)
															}
              | '?' parm      {
																if
																( // accept only integer, real, boolean or mask values!!!
																	   ($2.csType == C_BOOLEAN_PARAM)
																	|| ($2.csType == C_ADDR_BOOLEAN_PARAM)
																	|| ($2.csType == C_MASK_PARAM)
																	|| ($2.csType == C_LONG_PARAM)
																	|| ($2.csType == C_ADDR_LONG_PARAM)
																	|| ($2.csType == C_REAL_PARAM)
																	|| ($2.csType == C_ADDR_REAL_PARAM)
																)
																{
                                  //if we are here, everything is fine...
   																$$.csType=C_BOOLEAN_PARAM; //fake a boolean value
                                  M_PASS_ALL($$,$2);
  																M_PASS_IN_2PARMS($$,$1,$2);
                                }
                                else
                                {
																	yyerror(M_MAKECHAR("the '?' operator cannot be used on " + $2.csInitial + " because it is not numeric"));
																	YYERROR;
																}
                              }
;

condition:			CONDITION			{
                                M_PASS_ALL($$,$1);
 																$$.csType=C_BOOLEAN_PARAM;
                              }
;

not:						NOT						{
                                M_PASS_ALL($$,$1);
 																$$.csType=C_BOOLEAN_PARAM;
                              }
;

opcond:					AND         {
                                M_PASS_ALL($$,$1);
  															$$.csType=C_BOOLEAN_PARAM;
                              }
                | OR         {
                                M_PASS_ALL($$,$1);
  															$$.csType=C_BOOLEAN_PARAM;
                              }
                | XOR         {
                                M_PASS_ALL($$,$1);
  															$$.csType=C_BOOLEAN_PARAM;
                              }
;

opbin:					OPCOND				{
																M_CREATENODE($$,eCondition,M_GETINDEX($1));
																M_PASS_IN_1PARM($$,$1);
																$$.csType=C_BOOLEAN_PARAM;
																// BEGIN ROMTEAM Cristi Petrescu 98-09-
																$1 . clIntermediateCodeList . m_fn_vDestroyAndRemoveAllEntries ();
																// END ROMTEAM Cristi Petrescu 98-09-
															}
;								

%%

/*************/
/* Variables */
/*************/

CParse												g_clParse;
CLex													g_clLex;
CPA_EdIR_DesignerVariableList	g_clDsgVarList;
CPA_EdIR_MacroList						g_clMacroList;
// BEGIN CPA2 Cristi Petrescu 98-03-
// this is pointer to the m_clistOfMacros of the current Brain
CPA_EdIR_MainBehaviourList		*g_pclListOfSubrs;
//CPA_EdIR_MacroList						g_clTempMacroList;
// END CPA2 Cristi Petrescu 98-03-
CPA_Actor											*g_pclCurrentModel=NULL;

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

#define M_KEYWORDID(a)			((tdeKeyWordId)(a))
#define M_METAACTID(a)			((tdeMetaActionId)(a))
#define M_CONDITIONID(a)		((tdeCondId)(a))
#define M_FUNCTIONID(a)			((tdeFuncId)(a))
#define M_PROCEDUREID(a)		((tdeProcedureId)(a))
#define M_OPERATORID(a)			((tdeOperatorId)(a))
#define M_FIELDID(a)				((tdeFieldId)(a))
#define M_DSGVARID(a)				((tdeDsgVarTypeId)(a))

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

//KeyWord (for Vector)
/****************************************************************************/
CString fn_csGetKeyWordParams(long lIndex)
{
	return szGetKeyWordTypeInParamFromId(M_KEYWORDID(lIndex));
}

/****************************************************************************/
CString fn_csGetKeyWordType(long lIndex)
{
	return szGetKeyWordTypeOutParamFromId(M_KEYWORDID(lIndex));
}

//MetaAction
/****************************************************************************/
CString fn_csGetMetaActionParams(long lIndex)
{
	return szGetMetaActionTypeInParamFromId(M_METAACTID(lIndex));
}

//Condition
/****************************************************************************/
CString fn_csGetConditionParams(long lIndex)
{
	return szGetConditionTypeInParamFromId(M_CONDITIONID(lIndex));
}

/****************************************************************************/
BOOL fn_bIsConditionUsableWithUltraOperator(long lIndex)
{
	return fn_ucGetConditionUltraOperator(M_CONDITIONID(lIndex))==1;
}

//Designer Variable
/****************************************************************************/
void fn_vGetDesignerVariableType(stReturn *pstReturn,long lIndex)
{
	CString csType=g_clDsgVarList.m_fn_csGetTypeOfADesignerVariable(lIndex);
	long lDsgVarIndex=fn_lGetDsgVarTypeIdFromEditorName(csType);

	fn_vGetDesignerVariableTypeFromEngineType(pstReturn,M_DSGVARID(lDsgVarIndex));
}

/****************************************************************************/
void fn_vGetDesignerVariableTypeFromEngineType(stReturn *pstReturn,long lIndex)
{
	pstReturn->csType=fn_szFindStringTypeFromDsgVarType(M_DSGVARID(lIndex));
	if(pstReturn->csType==C_ADDR_ARRAY_PARAM)
	{
		pstReturn->csSubType=fn_szFindStringSubTypeFromDsgVarType(M_DSGVARID(lIndex));
	}
}

/****************************************************************************/
void fn_vGetDesignerVariableTypeForThisModel(stReturn *pstReturn,CPA_Actor *pclActorModel,long lIndex)
{
	if(pclActorModel==g_pclCurrentModel)
	{
		//Looks in current dsg var list
		CString	csType=g_clDsgVarList.m_fn_csGetTypeOfADesignerVariable(lIndex);

		long lDsgVarTypeIndex=fn_lGetDsgVarTypeIdFromEditorName(csType);

		fn_vGetDesignerVariableTypeFromEngineType(pstReturn,M_DSGVARID(lDsgVarTypeIndex));
	}
	else
	{
		CPA_EdIR_Brain	*pclBrain=((EdActors_EditorActorModel *)pclActorModel->m_fn_pclGetEditorActor())->m_pclBrain;

		CString	csType;
		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
			CString	csIn;
			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;
			long		lNoDsgVar=0;
			CString	csWord=fn_csGetNextWord(csIn,lCurrentIndex);
			csType=csWord;
			while(!csWord.IsEmpty() && lNoDsgVar<lIndex)
			{
				// skip private & public
				if (fn_bIsDsgVarQualifier(csWord))
					csWord=fn_csGetNextWord(csIn,lCurrentIndex);

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

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

				//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);
				csType=csWord;

				lNoDsgVar++;
			}
		}

		long lDsgVarTypeIndex=fn_lGetDsgVarTypeIdFromEditorName(csType);

		fn_vGetDesignerVariableTypeFromEngineType(pstReturn,M_DSGVARID(lDsgVarTypeIndex));
	}
}

/****************************************************************************/
long fn_lIsADsgVarForThisModel(CPA_Actor *pclActorModel,CString csDsgVarName)
{
	long	lRes=0;

	if(pclActorModel==g_pclCurrentModel)
	{
		//Looks in current dsg var list
//ANNECY CB
		lRes = g_clDsgVarList.m_fn_bIsADesignerVariable(csDsgVarName) - 1;
//		if(g_clDsgVarList.m_fn_bIsADesignerVariable(csDsgVarName))
		if(lRes >= 0)
			return lRes;
/*		{
			lRes=g_clDsgVarList.m_fn_lGetIndexOfADesignerVariable(csDsgVarName);

			return lRes;
		}*/
//END
		else
			return C_NOT_A_DSG_VAR;
	}
	else
	{
		CPA_EdIR_Brain	*pclBrain=((EdActors_EditorActorModel *)pclActorModel->m_fn_pclGetEditorActor())->m_pclBrain;

		long		lNoDsgVar=0;
		BOOL		bFound=FALSE;
		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
			CString	csIn;
			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);
			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(csDsgVarName)==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++;
				}
			}
		}

		lRes=lNoDsgVar;

		if(bFound)
		{
			return lRes;
		}
		else
			return C_NOT_A_DSG_VAR;
	}
}

/****************************************************************************/
void fn_vGetDesignerVariableTypeForThisPerso(stReturn *pstReturn,long lHandleToPerso,long lIndex)
{
	CPA_Actor	*pclActorInstance=(CPA_Actor *)fn_pclGetReachableObject(lHandleToPerso,C_szActorInstanceTypeName);
	CPA_Actor	*pclActorModel=pclActorInstance->m_fn_pclGetModel();

	fn_vGetDesignerVariableTypeForThisModel(pstReturn,pclActorModel,lIndex);
}

/****************************************************************************/
long fn_lIsADsgVarForThisPerso(long lHandleToPerso,CString csDsgVarName)
{
	CPA_Actor	*pclActorInstance=(CPA_Actor *)fn_pclGetReachableObject(lHandleToPerso,C_szActorInstanceTypeName);
	CPA_Actor	*pclActorModel=pclActorInstance->m_fn_pclGetModel();

	return fn_lIsADsgVarForThisModel(pclActorModel,csDsgVarName);
}

//Field
/****************************************************************************/
CString	fn_csGetFieldType(long lIndex)
{
	return fn_szFindStringTypeFromVariableType(fn_eGetFieldType(M_FIELDID(lIndex)));
}

//Type
/****************************************************************************/
BOOL fn_bIsTypeCompatible(CString csType1,stReturn *pclParms2,long lIndex,BOOL bIsOperator)
{
	BOOL	bRes=fn_bIsCompatibleType(csType1[0],pclParms2->csType[(int)lIndex]);

	if(bRes)
	{
		//Changes constant node to float node if needed
		if((csType1[0]==C_REAL_PARAM[0]) &&
			 (pclParms2->csType[(int)lIndex]==C_LONG_PARAM[0]) &&
			 !bIsOperator)
		{
			POSITION	pos=pclParms2->clIntermediateCodeList.FindIndex(lIndex);
			if(pos!=NULL)
			{
				//Checks if node is a constant node or a dsgvar node
				if(pclParms2->clIntermediateCodeList.GetAt(pos)->m_fn_tdeGetNodeType()==eConstant)
				{
					//Converts lIndex th node to a float node
					long	lValue=pclParms2->clIntermediateCodeList.GetAt(pos)->m_fn_lGetIndex();

					pclParms2->clIntermediateCodeList.GetAt(pos)->m_fn_vSetNodeType(eReal);
					pclParms2->clIntermediateCodeList.GetAt(pos)->m_fn_vSetValue(double(lValue));
				}
			}
		}
	}

	return bRes;
}

/****************************************************************************/
BOOL fn_bIsStringCompatible(CString csType1,CString csType2)
{
	return fn_bIsCompatibleStringType(M_MAKECHAR(csType1),M_MAKECHAR(csType2));
}

/****************************************************************************/
BOOL fn_bIsStringCompatibleForAffect(CString csType1,CString csType2)
{
	return fn_bIsCompatibleStringTypeForAffect(M_MAKECHAR(csType1),M_MAKECHAR(csType2));
}

/****************************************************************************/
long fn_lIsTypeCompatibleForArithmOp(long lIndex,
																		 stReturn *pclParms1,
																		 stReturn *pclParms2)
{
	long	lRes=lIndex;

	//for vector operations
	CString	csType;
	switch(lRes)
	{
		case eOperator_ScalarPlusScalar:
			{
				csType=pclParms1->csType+pclParms2->csType;
				if(fn_bIsStringCompatible(fn_csGetOperatorParams(eOperator_VectorPlusVector),csType))
					lRes=eOperator_VectorPlusVector;
			}
			break;

		case eOperator_ScalarMinusScalar:
			{
				csType=pclParms1->csType+pclParms2->csType;
				if(fn_bIsStringCompatible(fn_csGetOperatorParams(eOperator_VectorMinusVector),csType))
					lRes=eOperator_VectorMinusVector;
			}
			break;

		case eOperator_ScalarMulScalar:
			{
				csType=pclParms1->csType+pclParms2->csType;
				if(fn_bIsStringCompatible(fn_csGetOperatorParams(eOperator_VectorMulScalar),csType))
					lRes=eOperator_VectorMulScalar;
			}
			break;

		case eOperator_ScalarDivScalar:
			{
				csType=pclParms1->csType+pclParms2->csType;
				if(fn_bIsStringCompatible(fn_csGetOperatorParams(eOperator_VectorDivScalar),csType))
					lRes=eOperator_VectorDivScalar;
			}
			break;

		case eOperator_ScalarUnaryMinus:
			{
				csType=pclParms1->csType;
				if(fn_bIsStringCompatible(fn_csGetOperatorParams(eOperator_VectorUnaryMinus),csType))
					lRes=eOperator_VectorUnaryMinus;
			}
			break;
	}

	if(lRes==eOperator_Affect)
	{
		if(fn_bIsCompatibleTypeForAffect(pclParms1->csType[0],pclParms2->csType[0]))
			return lRes;
		else
			return C_NOT_COMPATIBLE;
	}
	else
	if(lRes==eOperator_PlusPlusAffect		||
		 lRes==eOperator_MinusMinusAffect ||
		 lRes==eOperator_ScalarUnaryMinus ||
		 lRes==eOperator_VectorUnaryMinus)
	{
		CString	csType=fn_csGetOperatorParams(lRes);

		if(fn_bIsTypeCompatible(csType[0],pclParms1,0,TRUE))
			return lRes;
		else
			return C_NOT_COMPATIBLE;
	}
	else
	if(lRes==eOperator_PlusAffect	||
		 lRes==eOperator_MinusAffect)
	{
		//For vector
		if(
				(pclParms1->csType==C_ADDR_VECTOR_PARAM)
				&&
				(fn_cConvertFromADDRType(pclParms2->csType[0])==C_VECTOR_PARAM[0])
			)
		{
			return lRes;
		}
		else
		//For scalar
		{
			CString	csType=fn_csGetOperatorParams(lRes);

			if(fn_bIsTypeCompatible(csType[0],pclParms1,0,TRUE) &&
				 fn_bIsTypeCompatible(csType[1],pclParms2,0,TRUE))
				return lRes;
			else
				return C_NOT_COMPATIBLE;
		}
	}
	else
	if(lRes==eOperator_MulAffect	||
		 lRes==eOperator_DivAffect)
	{
		char	cType=fn_cConvertFromADDRType(pclParms2->csType[0]);

		//For vector
		if(
				(pclParms1->csType==C_ADDR_VECTOR_PARAM)
				&&
				(
					(cType==C_LONG_PARAM[0])
					||
					(cType==C_REAL_PARAM[0])
				)
			)
		{
			return lRes;
		}
		else
		//For scalar
		{
			CString	csType=fn_csGetOperatorParams(lRes);

			if(fn_bIsTypeCompatible(csType[0],pclParms1,0,TRUE) &&
				 fn_bIsTypeCompatible(csType[1],pclParms2,0,TRUE))
				return lRes;
			else
				return C_NOT_COMPATIBLE;
		}
	}
	else
	{
		CString	csType=fn_csGetOperatorParams(lRes);

		if(fn_bIsTypeCompatible(csType[0],pclParms1,0,TRUE) &&
			 fn_bIsTypeCompatible(csType[1],pclParms2,0,TRUE))
			return lRes;
		else
			return C_NOT_COMPATIBLE;
	}
}

/****************************************************************************/
BOOL fn_bIsTypeCompatibleForBinaryOp(long lIndex,
																		 stReturn *pclParms1,
																		 stReturn *pclParms2)
{
	if((lIndex==eCond_Equal) || (lIndex==eCond_Different))
	{
		if(IsADDRType(pclParms1->csType[0]))
		{
			//Changes node type
			pclParms1->csType.SetAt(0,toupper(pclParms1->csType[0]));
		}

		if(IsADDRType(pclParms2->csType[0]))
		{
			//Changes node type
			pclParms2->csType.SetAt(0,toupper(pclParms2->csType[0]));
		}

		return fn_bIsTypeCompatible(pclParms1->csType,pclParms2,0);
	}
	else
	{
		CString	csType=fn_csGetConditionParams(lIndex);

		if(!(IsADDRType(csType[0])) && IsADDRType(pclParms1->csType[0]))
		{
			//Changes node type
			pclParms1->csType.SetAt(0,toupper(pclParms1->csType[0]));
		}

		if(!(IsADDRType(csType[1])) && IsADDRType(pclParms2->csType[0]))
		{
			//Changes node type
			pclParms2->csType.SetAt(0,toupper(pclParms2->csType[0]));
		}
				
		return (fn_bIsTypeCompatible(csType[0],pclParms1,0) &&
						fn_bIsTypeCompatible(csType[1],pclParms2,0));
	}
}

/****************************************************************************/
BOOL fn_bIsTypeCompatibleForInitialization(CString csType1,stReturn *pclParms2)
{
	//Special treatment for list
	if(csType1==C_ADDR_LIST_PARAM[0] && pclParms2->csType==C_LONG_PARAM[0])
		return TRUE;
	else
	if(csType1==C_ADDR_ARRAY_PARAM[0] && pclParms2->csType==C_LONG_PARAM[0])
		return TRUE;
	else
	{
		//Changes constant node to float node if needed
		if(csType1==C_ADDR_REAL_PARAM[0] && pclParms2->csType==C_LONG_PARAM[0])
		{
			ASSERT(pclParms2->clIntermediateCodeList.GetCount()==1);

			//Checks if node is a constant node or a dsgvar node
			if(pclParms2->clIntermediateCodeList.GetHead()->m_fn_tdeGetNodeType()==eConstant)
			{
				//Converts lIndex th node to a float node
				long	lValue=pclParms2->clIntermediateCodeList.GetHead()->m_fn_lGetIndex();

				pclParms2->clIntermediateCodeList.GetHead()->m_fn_vSetNodeType(eReal);
				pclParms2->clIntermediateCodeList.GetHead()->m_fn_vSetValue(double(lValue));
			}
		}
		
		return fn_bIsCompatibleTypeForAffect(csType1[0],pclParms2->csType[0]);
	}
}

/****************************************************************************/
//Stefan Dumitrean 21-05-98
void fn_vDeleteSpacesFrom(CString &csString)
{
	CString csRet = "";
	for( int i = 0; i < csString.GetLength(); i++ )
		if( csString[i] != ' ' )
			csRet = csRet + csString[i];
	csString = csRet;
}

BOOL fn_bIsParmsCompatible(CString csParms1,stReturn *pclParms2,CString csFunctionName,
													 CString &csMsgError)
{
	CString csStrParam = pclParms2->csInitial + ',', csCurrentParam;
	int iPos;
//End Stefan Dumitrean 21-05-98
	BOOL	bRes=TRUE;
	for(int i=0;bRes && i<csParms1.GetLength();i++)
	{
		bRes=fn_bIsTypeCompatible(csParms1[i],pclParms2,i);
//Stefan Dumitrean 21-05-98
		csStrParam.TrimLeft();
		iPos = csStrParam.Find( ',' );
		if( iPos > 0 )
		{	
			csCurrentParam = csStrParam.Left( iPos );
			fn_vDeleteSpacesFrom( csCurrentParam );
			csStrParam = csStrParam.Right( csStrParam.GetLength() - iPos - 1);
		}
		else csCurrentParam = "";
//End Stefan Dumitrean 21-05-98
	}

	if(!bRes)
	{
//Stefan Dumitrean 21-05-98
		csMsgError.Format("parameter %s must be of type ",csCurrentParam );
		csMsgError+=fn_csGetParamTypeInEnglish(csParms1[i-1])+" not "+
					fn_csGetParamTypeInEnglish(pclParms2->csType[i-1]) +
					" in " + csFunctionName;
//End Stefan Dumitrean 21-05-98
	}

	return bRes;
}


//Function
/****************************************************************************/
CString fn_csGetFunctionParams(long lIndex)
{
	return szGetFunctionTypeInParamFromId(M_FUNCTIONID(lIndex));
}

/****************************************************************************/
CString fn_csGetFunctionType(long lIndex)
{
	return szGetFunctionTypeOutParamFromId(M_FUNCTIONID(lIndex));
}

/****************************************************************************/
BOOL fn_bIsFunctionUsableWithUltraOperator(long lIndex)
{
	return fn_ucGetFunctionUltraOperator(M_FUNCTIONID(lIndex))==1;
}

//Procedure
/****************************************************************************/
CString fn_csGetProcedureParams(long lIndex)
{
	return szGetProcedureTypeInParamFromId(M_PROCEDUREID(lIndex));
}

/****************************************************************************/
BOOL fn_bIsProcedureUsableWithUltraOperator(long lIndex)
{
	return fn_ucGetProcedureUltraOperator(M_PROCEDUREID(lIndex))==1;
}

//Operator
/****************************************************************************/
CString fn_csGetOperatorParams(long lIndex)
{
	return szGetOperatorTypeInParamFromId(M_OPERATORID(lIndex));
}

/****************************************************************************/
CString fn_csGetOperatorType(long lIndex,CString csParm1,CString csParm2)
{
	//A CHANGER !!!
	if((csParm1==C_LONG_PARAM || csParm1==C_ADDR_LONG_PARAM) && 
		 (csParm2==C_LONG_PARAM || csParm2==C_ADDR_LONG_PARAM))
		return C_LONG_PARAM;
	else
		return szGetOperatorTypeOutParamFromId(M_OPERATORID(lIndex));
}

//Perso
/****************************************************************************/
long fn_lGetHandleOfPerso(stReturn *pstPerso)
{
	if(M_GETINDEX(*pstPerso)==eKeyWord_MainActor)
		return (long)fn_pstGetMainActor();
	else
	/*if(M_GETINDEX(*pstPerso)==eKeyWord_World)
		return (long)fn_pstGetWorld();
	else*/
		return M_GETINDEX(*pstPerso);
}

//qualifier
//****************************************************************************
BOOL fn_bIsDsgVarQualifier(CString csQualifier)
{
	return ( !csQualifier.CompareNoCase("public") || !csQualifier.CompareNoCase("private") );
}

/****************************************************************************/
void CParse::yyerror(char *msg)
{
#if 0
	CString	csMsg;
//	sprintf(sz,"error %s (i=%ld)= %s\n",
	csMsg.Format("error %s (%s): %s",
								(char *)LPCTSTR(m_csMsgError),
								g_clLex.yytext,
//							g_clLex.m_lOldIndex,
								msg);

	AfxMessageBox(csMsg);
#endif
	m_csMsgError = msg;
	m_bNoError=FALSE;
	m_lIndexError=g_clLex.m_lOldIndex;
}

/****************************************************************************/
int	CParse::yylex()
{
	return g_clLex.yylex();
}

/****************************************************************************/
//BEGIN ROMTEAM Cristi Petrescu 98-05-
BOOL fn_bAnalysesText(CString csStringToParse,tdeTypeText eTypeText,
											long &lIndexError,CPA_EdIR_IntermediateCodeList *pclIntermediateCodeList, CString csBehaviourName)
//END ROMTEAM Cristi Petrescu 98-05-
{
	g_clParse.m_bNoError=TRUE;
	g_clParse.m_bIsInITRules=FALSE;
	g_clParse.m_clIntermediateCodeList.m_fn_vDestroyAndRemoveAllEntries();
	g_clParse.yydebug=0;

	// BEGIN ROMTEAM Cristi Petrescu 98-09-
	g_clParse . m_pstMyStack = NULL;
	// END ROMTEAM Cristi Petrescu 98-09-

	char	*szStringToParse=new char[csStringToParse.GetLength()+1];
	strcpy(szStringToParse,(char *)LPCTSTR(csStringToParse));
	g_clLex.yyinit(szStringToParse,eTypeText);

	g_clParse.yyparse();

	delete[] szStringToParse;

	// BEGIN ROMTEAM Cristi Petrescu 98-09-
	if (g_clParse . m_pstMyStack)
		delete[] g_clParse . m_pstMyStack;
	// END ROMTEAM Cristi Petrescu 98-09-

	//Computes depth
	POSITION			pos=g_clParse.m_clIntermediateCodeList.GetHeadPosition();
	unsigned char	ucDepth=1;
	while(pos!=NULL)
	{
		CPA_EdIR_IntermediateCode	*pclIntermediateCode=g_clParse.m_clIntermediateCodeList.GetNext(pos);

		if(pclIntermediateCode->m_fn_tdeGetNodeType()==eIncDepth)
		{
			ucDepth++;
		}
		else
		if(pclIntermediateCode->m_fn_tdeGetNodeType()==eDecDepth)
		{
			ucDepth--;
		}
		else
		{
			pclIntermediateCode->m_fn_vSetDepth(ucDepth);
			pclIntermediateCodeList->AddTail(new CPA_EdIR_IntermediateCode(pclIntermediateCode));
		}
	}

	g_clParse.m_clIntermediateCodeList.m_fn_vDestroyAndRemoveAllEntries();

	lIndexError=g_clParse.m_lIndexError;

	return g_clParse.m_bNoError;
}

#endif //D_ED_IR_ACTIVE
