2024-01-24 03:46:26 +01:00
|
|
|
#pragma once
|
2024-01-28 21:38:40 +01:00
|
|
|
#include <iostream>
|
|
|
|
#include <optional>
|
2024-01-24 03:46:26 +01:00
|
|
|
#include <string>
|
|
|
|
#include <vector>
|
|
|
|
|
2024-01-28 21:38:40 +01:00
|
|
|
#define PL(msg) std::cout << msg << '\n' // print line
|
|
|
|
|
|
|
|
enum Op
|
|
|
|
{ // https://en.cppreference.com/w/cpp/language/operator_precedence
|
|
|
|
BRL,
|
|
|
|
BRR,
|
|
|
|
LOR,
|
|
|
|
LAND,
|
|
|
|
BOR,
|
|
|
|
BXOR,
|
|
|
|
BAND,
|
|
|
|
EQ,
|
|
|
|
UEQ,
|
|
|
|
LT,
|
|
|
|
LTE,
|
|
|
|
BT,
|
|
|
|
BTE,
|
|
|
|
PLS,
|
|
|
|
MIN,
|
|
|
|
MUL,
|
|
|
|
DIV,
|
|
|
|
MOD,
|
2024-01-24 03:46:26 +01:00
|
|
|
};
|
|
|
|
|
2024-01-28 21:38:40 +01:00
|
|
|
__forceinline int op_prec(Op op)
|
|
|
|
{
|
|
|
|
switch (op)
|
|
|
|
{
|
|
|
|
case BRL:
|
|
|
|
return -9000;
|
|
|
|
case LOR:
|
|
|
|
return -15;
|
|
|
|
case LAND:
|
|
|
|
return -14;
|
|
|
|
case BOR:
|
|
|
|
return -13;
|
|
|
|
case BXOR:
|
|
|
|
return -12;
|
|
|
|
case BAND:
|
|
|
|
return -11;
|
|
|
|
case EQ:
|
|
|
|
case UEQ:
|
|
|
|
return -10;
|
|
|
|
case LT:
|
|
|
|
case LTE:
|
|
|
|
case BT:
|
|
|
|
case BTE:
|
|
|
|
return -9;
|
|
|
|
case PLS:
|
|
|
|
case MIN:
|
|
|
|
return -6;
|
|
|
|
case MUL:
|
|
|
|
case DIV:
|
|
|
|
case MOD:
|
|
|
|
return -5;
|
|
|
|
}
|
|
|
|
return -1; // unsupporeted op
|
|
|
|
}
|
|
|
|
|
|
|
|
std::optional<int> prsi(std::string str);
|
2024-01-24 03:46:26 +01:00
|
|
|
std::vector<char>* lf(std::string& path);
|
|
|
|
std::vector<char>* lf(const char* path);
|
2024-01-28 21:38:40 +01:00
|
|
|
bool lnew(std::string& ln, const char* ew);
|
2024-01-24 03:46:26 +01:00
|
|
|
bool lnsw(std::string& ln, int idx, const char* sw);
|
|
|
|
void ssie(std::string& str, std::string repl);
|