13
13
14
14
/* *
15
15
* @file
16
- * @brief This file implements an expressopn evaluator
16
+ * @brief This file implements an expression evaluator
17
17
*
18
18
* The expression evaluator is capable of performing many operations on given variables,
19
19
* after parsing the expression. The parser goes character by character and identifies
20
20
* the type of char or chars. (e.g bracket, comma, number, operator, variable).
21
21
* The supported operations include addition, subtraction, multiplication, division,
22
22
* finding max, min, gcd, lcm, as well as boolean operators such as &&, ||, ==, >=, <= etc.
23
- * The result is returned as an int value and operation precedance is taken into account.
23
+ * The result is returned as an int value and operation precedence is taken into account.
24
24
* (e.g given 3-2*4, the result will be -5). This class is also used to parse expressions
25
25
* indicating breakpoints. The breakpoint expressions consist of variable names such as
26
26
* move_num, temp_num, from_block etc, and boolean operators (e.g move_num == 3).
@@ -46,12 +46,11 @@ class t_formula_data {
46
46
// /@brief set the value of a specific part of the formula
47
47
void set_var_value (std::string_view var, int value) { vars_[var] = value; }
48
48
49
- // /@brief get the value of a specific part of the formula (the var can be c-style string)
49
+ // /@brief get the value of a specific part of the formula.
50
50
int get_var_value (std::string_view var) const {
51
51
auto iter = vars_.find (var);
52
52
if (iter == vars_.end ()) {
53
- std::string copy (var.data (), var.size ());
54
- throw vtr::VtrError (vtr::string_fmt (" No value found for variable '%s' from expression\n " , copy.c_str ()), __FILE__, __LINE__);
53
+ throw vtr::VtrError (vtr::string_fmt (" No value found for variable '%s' from expression\n " , var.data ()), __FILE__, __LINE__);
55
54
}
56
55
57
56
return iter->second ;
0 commit comments