Skip to content
Permalink
Browse files

Merge pull request #13330 from joshuahansel/pi_and_e_in_parser

Added pi and e to ${fparse ..} in input file parser
  • Loading branch information...
rwcarlsen committed May 1, 2019
2 parents dad4461 + d98ab22 commit 13401298425ea8735521791322b39d3e27231dca
Showing with 4 additions and 1 deletion.
  1. +2 −1 framework/include/parser/Parser.h
  2. +2 −0 unit/src/HitTests.C
@@ -42,6 +42,8 @@ class FuncParseEvaler : public hit::Evaler
auto n_errs = exp.errors.size();

FunctionParser fp;
fp.AddConstant("pi", libMesh::pi);
fp.AddConstant("e", std::exp(Real(1)));
std::vector<std::string> var_names;
auto ret = fp.ParseAndDeduceVariables(func_text, var_names);
if (ret != -1)
@@ -267,4 +269,3 @@ class Parser : public ConsoleStreamInterface, public hit::Walker
std::string hitCLIFilter(std::string appname, const std::vector<std::string> & argv);
void walkRaw(std::string fullpath, std::string nodepath, hit::Node * n);
};

@@ -331,6 +331,8 @@ TEST(HitTests, BraceExpressions)
"42",
hit::Field::Kind::String},
{"fparse", "foo=${fparse 40 + 2}\n", "foo", "42", hit::Field::Kind::Float},
{"fparse-with-pi", "foo=${fparse cos(pi)}\n", "foo", "-1", hit::Field::Kind::Float},
{"fparse-with-e", "foo=${fparse log(e)}\n", "foo", "1", hit::Field::Kind::Float},
{"fparse-with-var", "var=39 foo=${fparse var + 3}", "foo", "42", hit::Field::Kind::Float},
{"brace-expression-ends-before-newline",
"foo=${raw 42} bar=23",

0 comments on commit 1340129

Please sign in to comment.
You can’t perform that action at this time.