#pragma once
#include "OutputCode.h"

const static char* STR_FUNCTION = "function";
const static char* STR_ENDFUNCTION = "endfunction";
const static char* STR_GLOBALS = "globals";
const static char* STR_ENDGLOBALS = "endglobals";
const static char* STR_CONSTANT_FUNCTION = "constant function";
const static char* STR_NOTHING = "nothing";
const static char* STR_NULL = "null";
const static char* STR_SPACE = " ";
const static char* STR_COMMA = ",";
const static char* STR_BRACKET_1 = "(";
const static char* STR_BRACKET_2 = ")";
const static char* STR_SQUARE_BRACKET_1 = "[";
const static char* STR_SQUARE_BRACKET_2 = "]";
const static char* STR_EQUALLY = "=";
const static char* STR_PLUS = "+";
const static char* STR_MINUS = "-";
const static char* STR_MUL = "*";
const static char* STR_DIV = "/";
const static char* STR_DOUBLE_QUOTES = "\"";
const static char* STR_DOLLOR = "$";
const static char* STR_NOT_2 = "!";
const static char* STR_LESS = "<";
const static char* STR_MORE = ">";
const static char* STR_IF = "if";
const static char* STR_THEN = "then";
const static char* STR_ELSE = "else";
const static char* STR_ELSEIF = "elseif";
const static char* STR_ENDIF = "endif";
const static char* STR_LOOP = "loop";
const static char* STR_EXITWHEN = "exitwhen";
const static char* STR_ENDLOOP = "endloop";
const static char* STR_LOCAL = "local";
const static char* STR_SET = "set";
const static char* STR_CALL = "call";
const static char* STR_RETURN = "return";
const static char* STR_OR = "or";
const static char* STR_AND = "and";
const static char* STR_NOT = "not";
const static char* STR_CONSTANT = "constant";
const static char* STR_TAKES = "takes";
const static char* STR_RETURNS = "returns";
const static char* STR_ARRAY = "array";
const static char* STR_UNIT = "unit";
const static char* STR_PLAYER = "player";
const static char* STR_GROUP = "group";
const static char* STR_INTEGER = "integer";
const static char* STR_STRING = "string";
const static char* STR_REAL = "real";
const static char* STR_BOOLEAN = "boolean";
const static char* STR_CODE = "code";
const static char* STR_RECT = "rect";
const static char* STR_TIMER = "timer";
const static char* STR_HASHTABLE = "hashtable";
const static char* STR_DESTRUCTABLE = "destructable";
const static char* STR_SOUND = "sound";
const static char* STR_TRIGGER = "trigger";
const static char* STR_MULTIBOARD = "multiboard";
const static char* STR_MULTIBOARDITEM = "multiboarditem";
const static char* STR_LIGHTNING = "lightning";
const static char* STR_TIMERDIALOG = "timerdialog";
const static char* STR_REGION = "region";
const static char* STR_EFFECT = "effect";
const static char* STR_TEXTTAG = "texttag";
const static char* STR_UNITSTATE = "unitstate";
const static char* STR_EXECUTE_FUNC = "ExecuteFunc";
const static char* STR_WEATHEREFFECT = "weathereffect";
const static char* STR_PLAYEREVENT = "playerevent";
const static char* STR_PLAYERUNITEVENT = "playerunitevent";
const static char* STR_BOOLEXPR = "boolexpr";
const static char* STR_GAMETYPE = "gametype";
const static char* STR_FORCE = "force";
const static char* STR_QUEST = "quest";
const static char* STR_FOGMODIFIER = "fogmodifier";
const static char* STR_ITEM = "item";
const static char* STR_EVENT = "event";
const static int LEN_FUNCTION = strlen(STR_FUNCTION);
const static int LEN_CONSTANT_FUNCTION = strlen(STR_CONSTANT_FUNCTION);
const static int LEN_ENDFUNCTION = strlen(STR_ENDFUNCTION);
const static int LEN_GLOBALS = strlen(STR_GLOBALS);
const static int LEN_ENDGLOBALS = strlen(STR_ENDGLOBALS);
const static int LEN_NOTHING = strlen(STR_NOTHING);
const static int LEN_NULL = strlen(STR_NULL);
const static int LEN_SPACE = strlen(STR_SPACE);
const static int LEN_COMMA = strlen(STR_COMMA);
const static int LEN_BRACKET_1 = strlen(STR_BRACKET_1);
const static int LEN_BRACKET_2 = strlen(STR_BRACKET_2);
const static int LEN_SQUARE_BRACKET_1 = strlen(STR_SQUARE_BRACKET_1);
const static int LEN_SQUARE_BRACKET_2 = strlen(STR_SQUARE_BRACKET_2);
const static int LEN_EQUALLY = strlen(STR_EQUALLY);
const static int LEN_PLUS = strlen(STR_PLUS);
const static int LEN_MINUS = strlen(STR_MINUS);
const static int LEN_MUL = strlen(STR_MUL);
const static int LEN_DIV = strlen(STR_DIV);
const static int LEN_DOUBLE_QUOTES = strlen(STR_DOUBLE_QUOTES);
const static int LEN_DOLLOR = strlen(STR_DOLLOR);
const static int LEN_NOT_2 = strlen(STR_NOT_2);
const static int LEN_LESS = strlen(STR_LESS);
const static int LEN_MORE = strlen(STR_MORE);
const static int LEN_IF = strlen(STR_IF);
const static int LEN_THEN = strlen(STR_THEN);
const static int LEN_ELSE = strlen(STR_ELSE);
const static int LEN_ELSEIF = strlen(STR_ELSEIF);
const static int LEN_ENDIF = strlen(STR_ENDIF);
const static int LEN_LOOP = strlen(STR_LOOP);
const static int LEN_EXITWHEN = strlen(STR_EXITWHEN);
const static int LEN_ENDLOOP = strlen(STR_ENDLOOP);
const static int LEN_LOCAL = strlen(STR_LOCAL);
const static int LEN_SET = strlen(STR_SET);
const static int LEN_CALL = strlen(STR_CALL);
const static int LEN_RETURN = strlen(STR_RETURN);
const static int LEN_OR = strlen(STR_OR);
const static int LEN_AND = strlen(STR_AND);
const static int LEN_NOT = strlen(STR_NOT);
const static int LEN_CONSTANT = strlen(STR_CONSTANT);
const static int LEN_TAKES = strlen(STR_TAKES);
const static int LEN_RETURNS = strlen(STR_RETURNS);
const static int LEN_ARRAY = strlen(STR_ARRAY);
const static int LEN_UNIT = strlen(STR_UNIT);
const static int LEN_PLAYER = strlen(STR_PLAYER);
const static int LEN_GROUP = strlen(STR_GROUP);
const static int LEN_INTEGER = strlen(STR_INTEGER);
const static int LEN_STRING = strlen(STR_STRING);
const static int LEN_REAL = strlen(STR_REAL);
const static int LEN_BOOLEAN = strlen(STR_BOOLEAN);
const static int LEN_CODE = strlen(STR_CODE);
const static int LEN_RECT = strlen(STR_RECT);
const static int LEN_TIMER = strlen(STR_TIMER);
const static int LEN_HASHTABLE = strlen(STR_HASHTABLE);
const static int LEN_DESTRUCTABLE = strlen(STR_DESTRUCTABLE);
const static int LEN_SOUND = strlen(STR_SOUND);
const static int LEN_TRIGGER = strlen(STR_TRIGGER);
const static int LEN_MULTIBOARD = strlen(STR_MULTIBOARD);
const static int LEN_LIGHTNING = strlen(STR_LIGHTNING);
const static int LEN_TIMERDIALOG = strlen(STR_TIMERDIALOG);
const static int LEN_REGION = strlen(STR_REGION);
const static int LEN_EFFECT = strlen(STR_EFFECT);
const static int LEN_TEXTTAG = strlen(STR_TEXTTAG);
const static int LEN_UNITSTATE = strlen(STR_UNITSTATE);
const static int LEN_EXECUTE_FUNC = strlen(STR_EXECUTE_FUNC);
const static int LEN_WEATHEREFFECT = strlen(STR_WEATHEREFFECT);
const static int LEN_PLAYEREVENT = strlen(STR_PLAYEREVENT);
const static int LEN_PLAYERUNITEVENT = strlen(STR_PLAYERUNITEVENT);
const static int LEN_BOOLEXPR = strlen(STR_BOOLEXPR);
const static int LEN_GAMETYPE = strlen(STR_GAMETYPE);
const static int LEN_FORCE = strlen(STR_FORCE);
const static int LEN_QUEST = strlen(STR_QUEST);
const static int LEN_FOGMODIFIER = strlen(STR_FOGMODIFIER);
const static int LEN_ITEM = strlen(STR_ITEM);
const static int LEN_EVENT = strlen(STR_EVENT);
const static int LEN_MULTIBOARDITEM = strlen(STR_MULTIBOARDITEM);
const static int FLAG_FUNCTION = 0;
const static int FLAG_CONSTANT_FUNCTION = 1;
const static int FLAG_ENDFUNCTION = 2;
const static int FLAG_GLOBALS = 3;
const static int FLAG_ENDGLOBALS = 4;
const static int FLAG_IF = 5;
const static int FLAG_ENDIF = 6;
const static int FLAG_LOCAL = 7;
const static int FLAG_SET = 8;
const static int FLAG_CALL = 9;
const static int FLAG_RETURN = 10;
const static int FLAG_OR = 11;
const static int FLAG_AND = 12;
const static int FLAG_NOT = 13;
const static int FLAG_CONSTANT = 14;
const static int FLAG_TAKES = 15;
const static int FLAG_RETURNS = 16;
const static int FLAG_ARRAY = 17;
const static int FLAG_UNIT = 18;
const static int FLAG_PLAYER = 19;
const static int FLAG_GROUP = 20;
const static int FLAG_INTEGER = 21;
const static int FLAG_STRING = 22;
const static int FLAG_REAL = 23;
const static int FLAG_CODE = 24;
const static int FLAG_RECT = 25;
const static int FLAG_TIMER = 26;
const static int FLAG_HASHTABLE = 27;
const static int FLAG_DESTRUCTABLE = 28;
const static int FLAG_SOUND = 29;
const static int FLAG_TRIGGER = 30;
const static int FLAG_MULTIBOARD = 31;
const static int FLAG_LIGHTNING = 32;
const static int FLAG_TIMERDIALOG = 33;
const static int FLAG_REGION = 34;
const static int FLAG_EFFECT = 35;
const static int FLAG_TEXTTAG = 36;
const static int FLAG_UNITSTATE = 37;
const static int FLAG_THEN = 38;
const static int FLAG_LOOP = 39;
const static int FLAG_EXITWHEN = 40;
const static int FLAG_ENDLOOP = 41;
const static int FLAG_BRACKET_1 = 42;
const static int FLAG_BRACKET_2 = 43;
const static int FLAG_STR = 44;
const static int FLAG_ELSE = 45;
const static int FLAG_ELSEIF = 46;
const static int FLAG_NOTHING = 47;
const static int FLAG_NULL = 48;
const static int FLAG_SPACE = 49;
const static int FLAG_COMMA = 50;
const static int FLAG_EQUALLY = 51;
const static int FLAG_TEXT_EN = 52;
const static int FLAG_TEXT_RU = 53;
const static int FLAG_TEXT = 54;
const static int FLAG_PLUS = 55;
const static int FLAG_DOUBLE_QUOTES = 56;
const static int FLAG_DOLLOR = 57;
const static int FLAG_NUMBER = 58;
const static int FLAG_NOT_2 = 59;
const static int FLAG_BOOLEAN = 60;
const static int FLAG_MUL = 61;
const static int FLAG_LESS = 62;
const static int FLAG_MORE = 63;
const static int FLAG_SQUARE_BRACKET_1 = 64;
const static int FLAG_SQUARE_BRACKET_2 = 65;
const static int FLAG_ARG = 66;
const static int FLAG_IF_ARG = 67;
const static int FLAG_MINUS = 68;
const static int FLAG_DIV = 69;
const static int FLAG_HEX = 70;
const static int FLAG_COMMA_ARG = 71;
const static int FLAG_STR_ARG = 72;
const static int FLAG_FUNCTION_ARG = 73;
const static int FLAG_EXECUTE_FUNC = 74;
const static int FLAG_JASS_CODE = 75;
const static int FLAG_WEATHEREFFECT = 76;
const static int FLAG_END = 77;
const static int FLAG_PLAYEREVENT = 78;
const static int FLAG_PLAYERUNITEVENT = 79;
const static int FLAG_BOOLEXPR = 80;
const static int FLAG_GAMETYPE = 81;
const static int FLAG_DOUBLE_QUOTES_2 = 82;
const static int FLAG_BRACKET_1_2 = 83;
const static int FLAG_BRACKET_2_2 = 84;
const static int FLAG_IF_2 = 85;
const static int FLAG_LOOP_2 = 86;
const static int FLAG_ENDIF_2 = 87;
const static int FLAG_ENDLOOP_2 = 88;
const static int FLAG_ELSEIF_2 = 89;
const static int FLAG_FORCE = 90;
const static int FLAG_QUEST = 91;
const static int FLAG_FOGMODIFIER = 92;
const static int FLAG_ITEM = 93;
const static int FLAG_EVENT = 94;
const static int FLAG_MULTIBOARDITEM = 95;

bool fConverter(char *vBufferIn, int vSizeIn);
bool fGlobals(sCode *vCodeIn, sCode *vCodeOut);
bool fConstantFunction(sCode *vCodeIn, sCode *vCodeOut);
bool fFunction(sCode *vCodeIn, sCode *vCodeOut);
bool fIf(sCode *vCodeIn, sCode *vCodeOut);
bool fLoop(sCode *vCodeIn, sCode *vCodeOut);

bool fIndexs(char *szBuffer, int vvi, int vvj, int *vIndex1, int *vIndex2, int *vFlag1, int *vFlag2, int vFirst, ...);
bool fParserCode(sCode *vCodeIn, sCode *vCodeOut, int vFlag);
bool fNavigator(int vFlag2, sCode *szBuffer2, sCode *szBuffer3);
int fIndent(int vFlag);
char * fGetStr(int vFlag);

bool fStr(sCode *vCodeIn, sCode *vCodeOut);
bool fThen(sCode *vCodeIn, sCode *vCodeOut);
bool fTakes(sCode *vCodeIn, sCode *vCodeOut);
bool fReturns(sCode *vCodeIn, sCode *vCodeOut);
bool fNothing(sCode *vCodeIn, sCode *vCodeOut);
bool fNull(sCode *vCodeIn, sCode *vCodeOut);
bool fSpace(sCode *vCodeIn, sCode *vCodeOut);
bool fAnd(sCode *vCodeIn, sCode *vCodeOut);
bool fOr(sCode *vCodeIn, sCode *vCodeOut);
bool fNot(sCode *vCodeIn, sCode *vCodeOut);

int fIndexs2(char *szBuffer, int vvi, int vvj, int *vIndex1, int *vIndex2, int *vFlag1, int *vFlag2, int vFlag3);

bool fArray(sCode *vCodeIn, sCode *vCodeOut);
bool fRefreshVar();
bool fEqually(sCode *vCodeIn, sCode *vCodeOut);
bool fDoubleQuotes(sCode *vCodeIn, sCode *vCodeOut);
bool fDollor(sCode *vCodeIn, sCode *vCodeOut);
bool fNumber(sCode *vCodeIn, sCode *vCodeOut);
bool fNot_2(sCode *vCodeIn, sCode *vCodeOut);
bool fVar(sCode *vCodeIn, sCode *vCodeOut);
bool fComma(sCode *vCodeIn, sCode *vCodeOut);
bool fMul(sCode *vCodeIn, sCode *vCodeOut);
bool fLess(sCode *vCodeIn, sCode *vCodeOut);
bool fMore(sCode *vCodeIn, sCode *vCodeOut);
bool fElse(sCode *vCodeIn, sCode *vCodeOut);

bool fCheckChar(sCode *vCodeIn, char vChar, int vPos);

bool fPlus(sCode *vCodeIn, sCode *vCodeOut);
bool fMinus(sCode *vCodeIn, sCode *vCodeOut);
bool fElseIf(sCode *vCodeIn, sCode *vCodeOut);
bool fDiv(sCode *vCodeIn, sCode *vCodeOut);
bool fExitWhen(sCode *vCodeIn, sCode *vCodeOut);
bool fFunctionArg(sCode *vCodeIn, sCode *vCodeOut);

bool fAddStrToOutputCode(sOutputCode *vOutputCode, char *vStr);
bool fFileHeader();
bool fFileCpp();
void fMyFunc();
void fMyFunc2();

bool fString(sCode *vCodeIn, sCode *vCodeOut);