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

Method define

Src/Base/Parser/AMReX_Parser.cpp:23–47  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

21}
22
23void
24Parser::define (std::string const& func_body)
25{
26 m_data = std::make_shared<Data>();
27
28 if (!func_body.empty()) {
29 m_data->m_expression = func_body;
30 std::erase_if(m_data->m_expression, [](char c) { return c == '\n' || c == '\r'; });
31 std::string f = m_data->m_expression + "\n";
32
33 std::scoped_lock parser_lock(parser_mutex);
34 YY_BUFFER_STATE buffer = amrex_parser_scan_string(f.c_str());
35 try {
36 amrex_parserparse();
37 } catch (const std::runtime_error& e) {
38 amrex_parser_delete_buffer(buffer); // delete buffer allocated by bison
39 amrex_parser_delete_ptrs(); // delete ptrs allocated by amrex
40 throw std::runtime_error(std::string(e.what()) + " in Parser expression \""
41 + m_data->m_expression + "\"");
42 }
43 m_data->m_parser = amrex_parser_new();
44 amrex_parser_delete_buffer(buffer);
45 m_ufs = parser_get_user_functions(m_data->m_parser);
46 }
47}
48
49/// \cond DOXYGEN_IGNORE
50Parser::Data::~Data ()

Callers

nothing calls this directly

Calls 4

amrex_parser_delete_ptrsFunction · 0.85
amrex_parser_newFunction · 0.85
emptyMethod · 0.45

Tested by

no test coverage detected