add operator conversion for efficient parallelizing

This commit is contained in:
2026-10-05 20:24:09 +03:00
parent 5fdcef4dd7
commit 6d1dfdac58
6 changed files with 277 additions and 5 deletions
+41
View File
@@ -110,6 +110,12 @@ public:
case OPERATOR:
v.o = other.v.o;
break;
case CV:
v.cv.w = other.v.cv.w;
v.cv.i = other.v.cv.i;
break;
case NAT:
break;
default:
std::cout << "Warning: token type is invalid\n";
break;
@@ -131,12 +137,47 @@ public:
case OPERATOR:
v.o = other.v.o;
break;
case CV:
v.cv.w = other.v.cv.w;
v.cv.i = other.v.cv.i;
break;
case NAT:
break;
default:
std::cout << "Warning: token type is invalid\n";
break;
}
}
Expression::Token& operator=(const Expression::Token& other)
{
t = other.t;
switch (t)
{
case VAR:
v.s = other.v.s;
break;
case CONST:
v.d = other.v.d;
break;
case OPERATOR:
v.o = other.v.o;
break;
case CV:
v.cv.w = other.v.cv.w;
v.cv.i = other.v.cv.i;
break;
case NAT:
break;
default:
std::cout << "Warning: token type is invalid\n";
break;
}
return const_cast<Expression::Token&>(other);
}
std::shared_ptr<std::string> to_str(void) const
{
switch (t)
+1
View File
@@ -8,5 +8,6 @@ namespace Parser {
std::vector<Expression::Token> tokenize_input(const char * const input_string);
int assert_same(const std::vector<Expression::Token>& a, const std::vector<Expression::Token>& b);
void print_token_vector(const std::vector<Expression::Token>& tv);
void print_math_vector(const std::vector<Expression::Token>& tv);
}
+1
View File
@@ -12,6 +12,7 @@ struct SyntaxIssue
};
std::vector<SyntaxIssue> check_syntax(std::vector<Expression::Token>& tv);
void apply_corrections(std::vector<Expression::Token>& tv);
std::vector<Expression::Operation> build_op_vector(const std::vector<Expression::Token>& tv);
}