diff options
| author | fusion32 <marcopuzziello@gmail.com> | 2025-05-22 01:02:13 -0300 |
|---|---|---|
| committer | fusion32 <marcopuzziello@gmail.com> | 2025-05-22 09:59:14 -0300 |
| commit | de848a4131beb288335b6aaa29c2a6a439c50e0e (patch) | |
| tree | 64aceaf19d47fc3ff3b26663cb36fd1de0fcdccf /src/script.hh | |
| parent | 91d7adad320c34ff0cb25aa21b16d59b67387c43 (diff) | |
| download | game-de848a4131beb288335b6aaa29c2a6a439c50e0e.tar.gz game-de848a4131beb288335b6aaa29c2a6a439c50e0e.zip | |
implement script lexer
Diffstat (limited to 'src/script.hh')
| -rw-r--r-- | src/script.hh | 94 |
1 files changed, 94 insertions, 0 deletions
diff --git a/src/script.hh b/src/script.hh new file mode 100644 index 0000000..2825d6d --- /dev/null +++ b/src/script.hh @@ -0,0 +1,94 @@ +#ifndef TIBIA_SCRIPT_HH_ +#define TIBIA_SCRIPT_HH_ 1 + +#include "main.hh" +#include "enums.hh" + +struct TReadScriptFile { + // REGULAR FUNCTIONS + // ========================================================================= + TReadScriptFile(void); + ~TReadScriptFile(void); + void open(const char *FileName); + void close(void); + void error(const char *Text); + void nextToken(void); + char *getIdentifier(void); + int getNumber(void); + char *getString(void); + uint8 *getBytesequence(void); + void getCoordinate(int *x, int *y, int *z); + char getSpecial(void); + + char *readIdentifier(void){ + this->nextToken(); + return this->getIdentifier(); + } + + int readNumber(void){ + this->nextToken(); + + int Sign = 1; + if(this->Token == SPECIAL && this->Special == '-'){ + Sign = -1; + this->nextToken(); + } + + return Sign * this->getNumber(); + } + + char *readString(void){ + this->nextToken(); + return this->getString(); + } + + uint8 *readBytesequence(void){ + this->nextToken(); + return this->getBytesequence(); + } + + void readCoordinate(int *x, int *y, int *z){ + this->nextToken(); + this->getCoordinate(x, y, z); + } + + char readSpecial(void){ + this->nextToken(); + return this->getSpecial(); + } + + void TReadScriptFile::readSymbol(char Symbol){ + if(this->readSpecial() != Symbol){ + this->error("symbol mismatch"); + } + } + + // DATA + // ========================================================================= + TOKEN Token; + FILE *File[3]; + char Filename[3][4096]; + int Line[3]; + char String[4000]; + int RecursionDepth; + uint8 *Bytes; + int Number; + int CoordX; + int CoordY; + int CoordZ; + char Special; +}; + +struct TWriteScriptFile { + // REGULAR FUNCTIONS + // ========================================================================= + //TWriteScriptFile(void); + + // DATA + // ========================================================================= + FILE *File; + char Filename[4096]; + int Line; +}; + +#endif //TIBIA_SCRIPT_HH_ |
