Skip to content

Commit

Permalink
Add definition for missing parse overload
Browse files Browse the repository at this point in the history
  • Loading branch information
Krzmbrzl committed Jan 13, 2025
1 parent a5fba28 commit befd214
Showing 1 changed file with 16 additions and 11 deletions.
27 changes: 16 additions & 11 deletions SeQuant/core/parse/deparse.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -96,18 +96,23 @@ std::wstring deparse_scalar(const Constant::scalar_type& scalar) {
} // namespace details

std::wstring deparse(const ExprPtr& expr, bool annot_sym) {
using namespace details;
if (!expr) return {};
if (expr->is<Tensor>())
return deparse(expr->as<Tensor>(), annot_sym);
else if (expr->is<Sum>())
return deparse(expr->as<Sum>(), annot_sym);
else if (expr->is<Product>())
return deparse(expr->as<Product>(), annot_sym);
else if (expr->is<Constant>())
return deparse(expr->as<Constant>());
else if (expr->is<Variable>())
return deparse(expr->as<Variable>());

return deparse(*expr, annot_sym);
}

std::wstring deparse(const Expr& expr, bool annot_sym) {
using namespace details;
if (expr.is<Tensor>())
return deparse(expr.as<Tensor>(), annot_sym);
else if (expr.is<Sum>())
return deparse(expr.as<Sum>(), annot_sym);
else if (expr.is<Product>())
return deparse(expr.as<Product>(), annot_sym);
else if (expr.is<Constant>())
return deparse(expr.as<Constant>());
else if (expr.is<Variable>())
return deparse(expr.as<Variable>());
else
throw std::runtime_error("Unsupported expr type for deparse!");
}
Expand Down

0 comments on commit befd214

Please sign in to comment.