Skip to content

Commit 3c257cc

Browse files
authored
Update mathparser.cpp
1 parent e69d232 commit 3c257cc

1 file changed

Lines changed: 15 additions & 16 deletions

File tree

src/mathparser.cpp

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -16,22 +16,21 @@ void MathParser::registerConstant(const std::string& symbol, double value) {
1616
}
1717

1818
void MathParser::init() {
19-
// Добавить в init():
20-
registerOperator("=", {
21-
Operator::Type::BINARY,
22-
0, false, false, 2,
23-
[this](auto args) {
24-
if (args[0].type != Token::Type::VARIABLE)
25-
throw std::runtime_error("Left operand must be a variable");
26-
27-
std::string varName = std::get<std::string>(args[0].value);
28-
29-
double value = tokenToDouble(args[1]);
30-
31-
variables[varName] = value;
32-
return Token{Token::Type::NUMBER, value};
33-
},
34-
"="
19+
registerOperator("=", {
20+
Operator::Type::BINARY,
21+
0, false, false, 2,
22+
[this](auto args) {
23+
if (args[0].type != Token::Type::VARIABLE)
24+
throw std::runtime_error("Left operand must be a variable");
25+
26+
std::string varName = std::get<std::string>(args[0].value);
27+
28+
double value = tokenToDouble(args[1]);
29+
30+
variables[varName] = value;
31+
return Token{Token::Type::NUMBER, value};
32+
},
33+
"="
3534
});
3635
registerOperator("(", {
3736
Operator::Type::BRACKET,

0 commit comments

Comments
 (0)