MCPcopy Create free account
hub / github.com/AMReX-Codes/amrex / pp_make_parser

Function pp_make_parser

Src/Base/AMReX_ParmParse.cpp:1514–1575  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1512 && !std::is_same_v<bool,T>,
1513 IParser, Parser>>
1514PARSER_t
1515pp_make_parser (std::string const& func, Vector<std::string> const& vars,
1516 ParmParse::Table const& table, std::string const& parser_prefix,
1517 bool use_querywithparser)
1518{
1519 using value_t = std::conditional_t<std::is_integral_v<T> && !std::is_same_v<bool,T>,
1520 long long, double>;
1521
1522 std::vector<std::string> prefixes;
1523 prefixes.reserve(3);
1524 prefixes.emplace_back();
1525 if (! parser_prefix.empty()) {
1526 prefixes.emplace_back(parser_prefix+".");
1527 }
1528 if (! ParmParse::ParserPrefix.empty()) {
1529 prefixes.emplace_back(ParmParse::ParserPrefix+".");
1530 }
1531
1532 PARSER_t parser(func);
1533
1534 auto symbols = parser.symbols();
1535 for (auto const& var : vars) {
1536 symbols.erase(var);
1537 }
1538
1539 bool recursive = false;
1540 auto& recursive_symbols = g_parser_recursive_symbols[OpenMP::get_thread_num()];
1541
1542 for (auto const& s : symbols) {
1543 value_t v = 0;
1544 bool r = false;
1545 for (auto const& pf : prefixes) {
1546 std::string pfs = pf + s;
1547 if (auto found = recursive_symbols.find(pfs); found != recursive_symbols.end()) {
1548 recursive = true;
1549 continue;
1550 }
1551 if (use_querywithparser) {
1552 r = squeryWithParser(table, parser_prefix, pfs, v);
1553 } else {
1554 r = squeryval(table, parser_prefix, pfs, v,
1555 ParmParse::FIRST, ParmParse::LAST);
1556 }
1557 if (r) { break; }
1558 }
1559 if (r == false) {
1560 std::string msg("ParmParse: failed to parse "+func);
1561 if (recursive) {
1562 msg.append(" due to recursive symbol ").append(s);
1563 } else {
1564 msg.append(" due to unknown symbol ").append(s);
1565 }
1566 amrex::Error(msg);
1567 }
1568 parser.setConstant(s, v);
1569 }
1570 if (!vars.empty()) {
1571 parser.registerVariables(vars);

Callers

nothing calls this directly

Calls 11

get_thread_numFunction · 0.85
squeryWithParserFunction · 0.85
squeryvalFunction · 0.85
reserveMethod · 0.45
emptyMethod · 0.45
symbolsMethod · 0.45
eraseMethod · 0.45
endMethod · 0.45
appendMethod · 0.45
setConstantMethod · 0.45
registerVariablesMethod · 0.45

Tested by

no test coverage detected