2026-05-11 10:55:50 -05:00
|
|
|
//+------------------------------------------------------------------+
|
2026-05-10 22:20:05 -05:00
|
|
|
//| Def.mqh |
|
|
|
|
|
//| Copyright 2026, Niquel Mendoza. |
|
|
|
|
|
//| https://www.mql5.com/es/users/nique_372 |
|
|
|
|
|
//+------------------------------------------------------------------+
|
|
|
|
|
#property copyright "Copyright 2026, Niquel Mendoza."
|
|
|
|
|
#property link "https://www.mql5.com/es/users/nique_372"
|
|
|
|
|
#property strict
|
|
|
|
|
|
2026-05-11 10:55:50 -05:00
|
|
|
#ifndef EXPRESSEVALBYLEO_SRC_COMMON_DEF_MQH
|
|
|
|
|
#define EXPRESSEVALBYLEO_SRC_COMMON_DEF_MQH
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//--- Necesitamos activar la tabla de hex asi que definimos esto..
|
|
|
|
|
#ifndef MQLARTICLES_ACTIVE_VALID_VALUES_HEX_ARRAY
|
|
|
|
|
#define MQLARTICLES_ACTIVE_VALID_VALUES_HEX_ARRAY
|
|
|
|
|
#endif // MQLARTICLES_ACTIVE_VALID_VALUES_HEX_ARRAY
|
|
|
|
|
|
|
|
|
|
|
2026-05-14 14:13:20 -05:00
|
|
|
//--- Neceistamos los tipos custom double\int etc
|
|
|
|
|
#ifndef MQLARTICLES_ENUMREG_ENUM_DATATYPE_CUSTOM
|
|
|
|
|
#define MQLARTICLES_ENUMREG_ENUM_DATATYPE_CUSTOM
|
|
|
|
|
#endif // MQLARTICLES_ENUMREG_ENUM_DATATYPE_CUSTOM
|
|
|
|
|
|
2026-05-10 22:20:05 -05:00
|
|
|
//+------------------------------------------------------------------+
|
2026-05-11 10:55:50 -05:00
|
|
|
//| Include |
|
2026-05-10 22:20:05 -05:00
|
|
|
//+------------------------------------------------------------------+
|
|
|
|
|
#include <TSN\\MQLArticles\\Utils\\Basic.mqh>
|
|
|
|
|
|
2026-05-14 14:13:20 -05:00
|
|
|
|
|
|
|
|
|
|
|
|
|
#include <TSN\\MQLArticles\\Utils\\EnumReg.mqh>
|
|
|
|
|
|
2026-05-11 10:55:50 -05:00
|
|
|
//+------------------------------------------------------------------+
|
|
|
|
|
//| Defines \ Enums |
|
|
|
|
|
//+------------------------------------------------------------------+
|
|
|
|
|
//--- Start bit para extra type para type
|
|
|
|
|
#define AST_LOGIC_EXTRA_TYPE_START_BIT (16)
|
|
|
|
|
|
|
|
|
|
//--- Start bit para tipo de error
|
|
|
|
|
#define AST_LOGIC_ERR_TYPE_START_BIT (24)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//---
|
|
|
|
|
#define AST_LOGIC_ERR_TYPE_EXTERNAL (1)
|
|
|
|
|
|
|
|
|
|
//--- Tipos
|
|
|
|
|
#define AST_LOGIC_NUMBER_DOUBLE (0)
|
|
|
|
|
#define AST_LOGIC_NUMBER_INTEGER (1)
|
|
|
|
|
|
|
|
|
|
//--- Tipos de errores genericos
|
|
|
|
|
enum ENUM_GENERIC_ERR_PARSE
|
|
|
|
|
{
|
2026-05-11 12:24:14 -05:00
|
|
|
GENERIC_ERR_PARSE_STRING_RAW_INICIO_NO_FOUND_EN_CUSTOM = 0,
|
2026-05-11 10:55:50 -05:00
|
|
|
GENERIC_ERR_PARSE_STRING_RAW_SUPERO_EL_LEN,
|
|
|
|
|
GENERIC_ERR_PARSE_STRING_RAW_NO_CERRADO,
|
|
|
|
|
GENERIC_ERR_PARSE_DBL_TIENE_MAS_DE_DOS_PUNTOS,
|
|
|
|
|
GENERIC_ERR_PARSE_DBL_TIENE_MAS_DE_DOS_MENOS,
|
|
|
|
|
GENERIC_ERR_PARSE_NUMERO_INVALIDO,
|
|
|
|
|
GENERIC_ERR_PARSE_NUMERO_MAL_FORMADO,
|
|
|
|
|
GENERIC_ERR_PARSE_NUMERO_HEX_INVALIDO,
|
|
|
|
|
GENERIC_ERR_PARSE_STRING_NO_CERRADO,
|
|
|
|
|
GENERIC_ERR_PARSE_STRING_MALFORMADO_ACABA_CON_SLASH,
|
|
|
|
|
GENERIC_ERR_PARSE_SE_ESPERABA_UN_FIN_DE_FUNCION,
|
|
|
|
|
GENERIC_ERR_PARSE_SE_ESPERABA_UN_INICIO_DE_FUNCION
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
//--- Separador general para el parser
|
|
|
|
|
#define OPS_TOKENIZER_CHAR_SEP ("│")
|
|
|
|
|
|
2026-05-11 12:24:14 -05:00
|
|
|
//---
|
|
|
|
|
#define AST_OPS_CHECK_RESIZE \
|
|
|
|
|
current_size++; \
|
|
|
|
|
if(current_size >= reserve_size) \
|
|
|
|
|
{ \
|
|
|
|
|
reserve_size <<= 1; \
|
2026-05-13 16:27:54 -05:00
|
|
|
ArrayResize(tokns, reserve_size, reserve_size); \
|
2026-05-11 12:24:14 -05:00
|
|
|
}
|
|
|
|
|
|
2026-05-14 14:13:20 -05:00
|
|
|
//---
|
|
|
|
|
//--- Tipo de nodo valor
|
|
|
|
|
enum ENUM_AST_NODE_TYPE
|
|
|
|
|
{
|
|
|
|
|
AST_EXPVAL_NODE_TYPE_VARIABLE = 0,
|
|
|
|
|
AST_EXPVAL_NODE_TYPE_FUNCTION,
|
|
|
|
|
AST_EXPVAL_NODE_TYPE_CAST_PRODUCT,
|
|
|
|
|
AST_EXPVAL_NODE_TYPE_BINRAY_NODE
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
2026-05-11 12:24:14 -05:00
|
|
|
//+------------------------------------------------------------------+
|
|
|
|
|
//| |
|
|
|
|
|
//+------------------------------------------------------------------+
|
2026-05-13 16:27:54 -05:00
|
|
|
struct CTokenizerBase
|
2026-05-11 12:24:14 -05:00
|
|
|
{
|
|
|
|
|
protected:
|
|
|
|
|
int m_len;
|
|
|
|
|
int m_pos;
|
|
|
|
|
int m_err_pos;
|
2026-05-14 14:13:20 -05:00
|
|
|
|
2026-05-11 12:24:14 -05:00
|
|
|
public:
|
|
|
|
|
CTokenizerBase(void) : m_len(0), m_pos(0), m_err_pos(0) {}
|
2026-05-14 14:13:20 -05:00
|
|
|
// ~CTokenizerBase(void) {}
|
2026-05-11 12:24:14 -05:00
|
|
|
|
|
|
|
|
//---
|
|
|
|
|
int LastErrorPos() const { return m_err_pos; }
|
|
|
|
|
void GetCharPosLocation(const int char_pos, const string& text, int& col, int& line) const;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
//+------------------------------------------------------------------+
|
|
|
|
|
void CTokenizerBase::GetCharPosLocation(const int char_pos, const string& text, int &col, int &line) const
|
|
|
|
|
{
|
|
|
|
|
col = 1;
|
|
|
|
|
line = 1;
|
|
|
|
|
|
|
|
|
|
for(int i = 0; i <= char_pos && i < m_len; i++)
|
|
|
|
|
{
|
|
|
|
|
if(text[i] == '\n')
|
|
|
|
|
{
|
|
|
|
|
line++;
|
|
|
|
|
col = 1;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
col++;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2026-05-11 10:55:50 -05:00
|
|
|
//+------------------------------------------------------------------+
|
2026-05-11 12:24:14 -05:00
|
|
|
#endif // EXPRESSEVALBYLEO_SRC_COMMON_DEF_MQH
|