Skip to content

Commit

Permalink
Add VERBATIM markers. (#1374)
Browse files Browse the repository at this point in the history
  • Loading branch information
1uc authored Jul 30, 2024
1 parent 0947aa4 commit 3e9e024
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
2 changes: 2 additions & 0 deletions src/codegen/codegen_cpp_visitor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -974,6 +974,7 @@ void CodegenCppVisitor::visit_function_call(const FunctionCall& node) {

void CodegenCppVisitor::visit_verbatim(const Verbatim& node) {
const auto& text = node.get_statement()->eval();
printer->add_line("// VERBATIM");
const auto& result = process_verbatim_text(text);

const auto& statements = stringutils::split_string(result, '\n');
Expand All @@ -983,6 +984,7 @@ void CodegenCppVisitor::visit_verbatim(const Verbatim& node) {
printer->add_line(trimed_stmt);
}
}
printer->add_line("// ENDVERBATIM");
}


Expand Down
11 changes: 7 additions & 4 deletions test/unit/codegen/codegen_coreneuron_cpp_visitor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -775,11 +775,14 @@ SCENARIO("Check that top verbatim blocks are well generated", "[codegen][top ver
ENDVERBATIM
)";

THEN("Correct code is generated") {
THEN("A using namespace is generated") {
auto const generated = get_coreneuron_cpp_code(nmodl_text);
std::string expected_code = R"(using namespace coreneuron;
std::string expected_code = "using namespace coreneuron;";
REQUIRE_THAT(generated, ContainsSubstring(expected_code));
}
THEN("Selected identifiers are expanded") {
auto const generated = get_coreneuron_cpp_code(nmodl_text);
std::string expected_code = R"(
double a = 2.;
foo_temp(nt);
&tqitem;
Expand Down

0 comments on commit 3e9e024

Please sign in to comment.