Skip to content

Commit 32e967a

Browse files
committed
Improve expression
1 parent de12491 commit 32e967a

File tree

2 files changed

+1301
-3
lines changed

2 files changed

+1301
-3
lines changed

modules/yup_core/maths/yup_Expression.cpp

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1094,9 +1094,14 @@ Expression::Expression (const String& stringToParse, String& parseError)
10941094
Expression Expression::parse (String::CharPointerType& stringToParse, String& parseError)
10951095
{
10961096
Helpers::Parser parser (stringToParse);
1097-
Expression e (parser.readUpToComma().get());
1097+
1098+
auto result = parser.readUpToComma();
10981099
parseError = parser.error;
1099-
return e;
1100+
1101+
if (result)
1102+
return Expression (result.get());
1103+
1104+
return {};
11001105
}
11011106

11021107
double Expression::evaluate() const
@@ -1114,7 +1119,9 @@ double Expression::evaluate (const Scope& scope, String& evaluationError) const
11141119
{
11151120
try
11161121
{
1117-
return term->resolve (scope, 0)->toDouble();
1122+
if (term != nullptr)
1123+
if (auto result = term->resolve (scope, 0))
1124+
return result->toDouble();
11181125
}
11191126
catch (Helpers::EvaluationError& e)
11201127
{

0 commit comments

Comments
 (0)