35 #define CBOTVERSION 104
72 CBotTypArrayPointer = 10,
73 CBotTypArrayBody = 11,
76 CBotTypNullPointer = 13,
84 #define OBJECTDELETED (reinterpret_cast<void*>(-1))
86 #define OBJECTCREATED (reinterpret_cast<void*>(-2))
118 int GetType(
int mode = 0)
const;
127 int GetLimite()
const;
130 void SetLimite(
int n);
133 void SetArray(
int* max );
142 bool Eq(
int type)
const;
181 #define CBotErrOpenPar 5000 // missing the opening parenthesis
182 #define CBotErrClosePar 5001 // missing the closing parenthesis
183 #define CBotErrNotBoolean 5002 // expression must be a boolean
184 #define CBotErrUndefVar 5003 // undeclared variable
185 #define CBotErrBadLeft 5004 // assignment impossible ( 5 = ... )
186 #define CBotErrNoTerminator 5005 // semicolon expected
187 #define CBotErrCaseOut 5006 // case outside a switch
189 #define CBotErrCloseBlock 5008 // missing " } "
190 #define CBotErrElseWhitoutIf 5009 // else without matching if
191 #define CBotErrOpenBlock 5010 // missing " { "
192 #define CBotErrBadType1 5011 // wrong type for the assignment
193 #define CBotErrRedefVar 5012 // redefinition of the variable
194 #define CBotErrBadType2 5013 // Two operands are incompatible
195 #define CBotErrUndefCall 5014 // routine undefined
196 #define CBotErrNoDoubleDots 5015 // " : " expected
198 #define CBotErrBreakOutside 5017 // break outside of a loop
199 #define CBotErrUndefLabel 5019 // label udnefined
200 #define CBotErrLabel 5018 // label ne peut se mettre ici (label can not get here)
201 #define CBotErrNoCase 5020 // missing " case "
202 #define CBotErrBadNum 5021 // expected number
203 #define CBotErrVoid 5022 // " void " not possible here
204 #define CBotErrNoType 5023 // type declaration expected
205 #define CBotErrNoVar 5024 // variable name expected
206 #define CBotErrNoFunc 5025 // expected function name
207 #define CBotErrOverParam 5026 // too many parameters
208 #define CBotErrRedefFunc 5027 // this function already exists
209 #define CBotErrLowParam 5028 // not enough parameters
210 #define CBotErrBadParam 5029 // wrong types of parameters
211 #define CBotErrNbParam 5030 // wrong number of parameters
212 #define CBotErrUndefItem 5031 // element does not exist in the class
213 #define CBotErrUndefClass 5032 // variable is not a class
214 #define CBotErrNoConstruct 5033 // no appropriate constructor
215 #define CBotErrRedefClass 5034 // class already exists
216 #define CBotErrCloseIndex 5035 // " ] " expected
217 #define CBotErrReserved 5036 // reserved word (for a DefineNum)
218 #define CBotErrBadNew 5037 // wrong setting for new
219 #define CBotErrOpenIndex 5038 // " [ " expected
220 #define CBotErrBadString 5039 // expected string
221 #define CBotErrBadIndex 5040 // wrong index type "[ false ]"
222 #define CBotErrPrivate 5041 // protected item
223 #define CBotErrNoPublic 5042 // missing word "public"
228 #define CBotErrZeroDiv 6000 // division by zero
229 #define CBotErrNotInit 6001 // uninitialized variable
230 #define CBotErrBadThrow 6002 // throw a negative value
231 #define CBotErrNoRetVal 6003 // function did not return results
232 #define CBotErrNoRun 6004 // Run() without active function
233 #define CBotErrUndefFunc 6005 // calling a function that no longer exists
234 #define CBotErrNotClass 6006 // this class does not exist
235 #define CBotErrNull 6007 // null pointer
236 #define CBotErrNan 6008 // calculation with a NAN
237 #define CBotErrOutArray 6009 // index out of array
238 #define CBotErrStackOver 6010 // stack overflow
239 #define CBotErrDeletedPtr 6011 // pointer to an object destroyed
241 #define CBotErrFileOpen 6012 // cannot open the file
242 #define CBotErrNotOpen 6013 // channel not open
243 #define CBotErrRead 6014 // error while reading
244 #define CBotErrWrite 6015 // writing error
268 bool IsEmpty()
const;
270 int Find(
const char c);
271 int Find(
const char* lpsz);
272 int ReverseFind(
const char c);
273 int ReverseFind(
const char* lpsz);
274 bool LoadString(
unsigned int id);
280 int Compare(
const char* lpsz)
const;
297 bool operator==(
const char* p);
299 bool operator!=(
const char* p);
301 bool operator>(
const char* p);
303 bool operator>=(
const char* p);
305 bool operator<(
const char* p);
307 bool operator<=(
const char* p);
309 operator const char*()
const;
321 static const std::map<EID,const char *> s_keywordString;
328 static const char * MapIdToString(EID
id);
344 void SetSize(
int nb);
384 bool m_bCompileClass;
403 bool Compile(
const char* program,
CBotStringArray& ListFonctions,
void* pUser =
nullptr);
410 void SetIdent(
long n);
417 bool GetError(
int& code,
int& start,
int& end);
418 bool GetError(
int& code,
int& start,
int& end,
CBotProgram* &pProg);
427 bool Start(
const char* name);
432 bool Run(
void* pUser =
nullptr,
int timer = -1);
438 bool GetRunPos(
const char* &FunctionName,
int &start,
int &end);
444 CBotVar* GetStackVars(
const char* &FunctionName,
int level);
457 void SetTimer(
int n);
462 bool AddFunction(
const char* name,
463 bool rExec (
CBotVar* pVar,
CBotVar* pResult,
int& Exception,
void* pUser),
469 bool DefineNum(
const char* name,
long val);
471 bool SaveState(FILE* pf);
475 bool RestoreState(FILE* pf);
479 bool GetPosition(
const char* name,
int& start,
int& stop,
480 CBotGet modestart = GetPosExtern,
481 CBotGet modestop = GetPosBloc);
493 FILE* fOpen(
const char* name,
const char* mode);
494 int fClose(FILE* filehandle);
495 size_t fWrite(
const void *buffer,
size_t elemsize,
size_t length, FILE* filehandle);
496 size_t fRead(
void *buffer,
size_t elemsize,
size_t length, FILE* filehandle);
516 if ( pVar ==
nullptr )
return 6001;
518 while ( pVar !=
nullptr )
520 if ( pVar->GetType() > CBotTypDouble )
return 6002;
521 pVar = pVar -> GetNext();
532 while (pVar !=
nullptr)
534 total += pVar->GetValFloat();
535 pVar = pVar->GetNext();
538 pResult->SetValFloat(total/nb);
552 #define PR_PUBLIC 0 // public variable
553 #define PR_READ 1 // read only
554 #define PR_PROTECT 2 // protected (inheritance)
555 #define PR_PRIVATE 3 // strictly private
561 enum class InitType : int { UNDEF = 0, DEF = 1, IS_POINTER = 2, IS_NAN = 999 };
588 static long m_identcpt;
614 void SetUserPtr(
void* pUser);
617 virtual void SetIdent(
long UniqId);
626 void SetName(
const char* name);
628 int GetType(
int mode = 0);
638 void SetInit(InitType initType);
639 InitType GetInit()
const;
640 bool IsUndefined()
const {
return GetInit() == InitType::UNDEF; }
641 bool IsDefined()
const {
return GetInit() == InitType::DEF; }
642 bool IsNAN()
const {
return GetInit() == InitType::IS_NAN; }
644 void SetStatic(
bool bStatic);
647 void SetPrivate(
int mPrivate);
648 bool IsPrivate(
int mode = PR_PROTECT);
652 void ConstructorSet();
657 CBotVar* GetItem(
const char* name);
659 CBotVar* GetItemRef(
int nIdent);
662 CBotVar* GetItem(
int row,
bool bGrow =
false);
669 bool IsElemOfClass(
const char* name);
679 void Copy(
CBotVar* pSrc,
bool bName =
true);
681 virtual void SetValInt(
int val,
const char* name =
nullptr);
685 virtual void SetValFloat(
float val);
688 virtual void SetValString(
const char* p);
691 virtual int GetValInt();
694 virtual float GetValFloat();
701 virtual void SetClass(
CBotClass* pClass);
705 virtual void SetPointer(
CBotVar* p);
737 virtual bool Save0State(FILE* pf);
738 virtual bool Save1State(FILE* pf);
739 static bool RestoreState(FILE* pf,
CBotVar* &pVar);
747 void Maj(
void* pUser =
nullptr,
bool bContinue =
true);
749 void SetUniqNum(
long n);
751 static long NextUniqNum();
793 void (*m_rMaj) (
CBotVar* pThis,
void* pUser );
803 CBotClass* pParent,
bool bIntrinsic =
false );
810 bool AddFunction(
const char* name,
816 bool AddUpdateFunc(
void rMaj (
CBotVar* pThis,
void* pUser ) );
846 CBotVar* GetItem(
const char* name);
847 CBotVar* GetItemRef(
int nIdent);
869 bool SaveStaticState(FILE* pf);
872 bool RestoreStaticState(FILE* pf);
883 #define MAXDEFNUM 1000 // limited number of DefineNum
888 #define TokenTypKeyWord 1 // a keyword of the language (see TokenKeyWord)
889 #define TokenTypNum 2 // number
890 #define TokenTypString 3 // string
891 #define TokenTypVar 4 // a variable name
892 #define TokenTypDef 5 // value according DefineNum
894 #define TokenKeyWord 2000 // keywords of the language
895 #define TokenKeyDeclare 2100 // keywords of declarations (int, float,..)
896 #define TokenKeyVal 2200 // keywords representing the value (true, false, null, nan)
897 #define TokenKeyOp 2300 // operators
909 int m_ListIdKeyWords[200];
914 long m_ListKeyNums[MAXDEFNUM];
933 int GetKeyWords(
const char* w);
935 bool GetKeyDefNum(
const char* w,
CBotToken* &token);
950 CBotToken(
const char* mot,
const char* sep =
nullptr);
1004 bool DefineNum(
const char* name,
long val);
1005 void SetString(
const char* name);
1007 void SetPos(
int start,
int end);
static void Delete(CBotToken *pToken)
releases the list
Definition: CBotToken.cpp:434
Definition: CBotDll.h:903
~CBotToken()
Destructor.
Definition: CBotToken.cpp:98
int GetType()
Returns the type of token.
Definition: CBotToken.cpp:127
bool AddItem(CBotString name, CBotTypResult type, int mPrivate=PR_PUBLIC)
Definition: CBotClass.cpp:178
CBotString & GetString()
makes the string corresponding to this token
Definition: CBotToken.cpp:163
const CBotString & operator=(const CBotString &stringSrc)
Overloaded oprators to work on CBotString classes.
Definition: CBotString.cpp:366
Definition: CBotDll.h:365
CBotToken()
Constructors.
Definition: CBotToken.cpp:38
static CBotToken * NextToken(char *&program, int &error, bool first=false)
Definition: CBotToken.cpp:233
CBotType
CBotType Defines known types. This types are modeled on Java types. Do not change the order of elemen...
Definition: CBotDll.h:59
CBotString Class used to work on strings.
Definition: CBotDll.h:259
Management of the execution stack.
Definition: CBot.h:73
CBotTypResult class to define the complete type of a result.
Definition: CBotDll.h:90
int GetEnd()
end position in the text
Definition: CBotToken.cpp:185
Definition: CBotDll.h:334
CBotString & GetSep()
makes the following separator token
Definition: CBotToken.cpp:168
Definition: CBotDll.h:557
Definition: CBotDll.h:776
CBotToken * GetNext()
gives the next token in the list
Definition: CBotToken.cpp:139
int GetStart()
position of the beginning in the text
Definition: CBotToken.cpp:179
void AddNext(CBotToken *p)
adds a token (a copy)
Definition: CBotToken.cpp:151
static CBotToken * CompileTokens(const char *p, int &error)
transforms the entire program
Definition: CBotToken.cpp:392
CBotToken * GetPrev()
gives the previous token in a list
Definition: CBotToken.cpp:145