1313
1414/* *
1515 * @file
16- * @brief This file implements an expressopn evaluator
16+ * @brief This file implements an expression evaluator
1717 *
1818 * The expression evaluator is capable of performing many operations on given variables,
1919 * after parsing the expression. The parser goes character by character and identifies
2020 * the type of char or chars. (e.g bracket, comma, number, operator, variable).
2121 * The supported operations include addition, subtraction, multiplication, division,
2222 * 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.
2424 * (e.g given 3-2*4, the result will be -5). This class is also used to parse expressions
2525 * indicating breakpoints. The breakpoint expressions consist of variable names such as
2626 * move_num, temp_num, from_block etc, and boolean operators (e.g move_num == 3).
@@ -46,12 +46,11 @@ class t_formula_data {
4646 // /@brief set the value of a specific part of the formula
4747 void set_var_value (std::string_view var, int value) { vars_[var] = value; }
4848
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.
5050 int get_var_value (std::string_view var) const {
5151 auto iter = vars_.find (var);
5252 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__);
5554 }
5655
5756 return iter->second ;
0 commit comments