diff --git a/src/parser/unit_driver.cpp b/src/parser/unit_driver.cpp index 768b104d40..23d6a15340 100644 --- a/src/parser/unit_driver.cpp +++ b/src/parser/unit_driver.cpp @@ -14,10 +14,6 @@ namespace nmodl { namespace parser { -UnitDriver::UnitDriver(bool strace, bool ptrace) - : trace_scanner(strace) - , trace_parser(ptrace) {} - /// parse Units file provided as istream bool UnitDriver::parse_stream(std::istream& in) { UnitLexer scanner(*this, &in); @@ -26,8 +22,6 @@ bool UnitDriver::parse_stream(std::istream& in) { this->lexer = &scanner; this->parser = &parser; - scanner.set_debug(trace_scanner); - parser.set_debug_level(trace_parser); return (parser.parse() == 0); } @@ -48,28 +42,5 @@ bool UnitDriver::parse_string(const std::string& input) { return parse_stream(iss); } -void UnitDriver::error(const std::string& m) { - std::cerr << m << std::endl; -} - -void UnitDriver::error(const std::string& m, const location& l) { - std::cerr << l << " : " << m << std::endl; -} - -void UnitDriver::scan_string(std::string& text) { - std::istringstream in(text); - UnitLexer scanner(*this, &in); - UnitParser parser(scanner, *this); - this->lexer = &scanner; - this->parser = &parser; - while (true) { - auto sym = lexer->next_token(); - auto token_type = sym.type_get(); - if (token_type == UnitParser::by_type(UnitParser::token::END).type_get()) { - break; - } - } -} - } // namespace parser } // namespace nmodl diff --git a/src/parser/unit_driver.hpp b/src/parser/unit_driver.hpp index feb3bba6ad..4e9c265993 100644 --- a/src/parser/unit_driver.hpp +++ b/src/parser/unit_driver.hpp @@ -38,12 +38,6 @@ class location; */ class UnitDriver { private: - /// enable debug output in the flex scanner - bool trace_scanner = false; - - /// enable debug output in the bison parser - bool trace_parser = false; - /// pointer to the lexer instance being used UnitLexer* lexer = nullptr; @@ -68,12 +62,9 @@ class UnitDriver { /// \} - static void error(const std::string& m); bool parse_stream(std::istream& in); bool parse_string(const std::string& input); bool parse_file(const std::string& filename); - void scan_string(std::string& text); - static void error(const std::string& m, const location& l); void set_verbose(bool b) { verbose = b; diff --git a/test/unit/visitor/inline.cpp b/test/unit/visitor/inline.cpp index 2eb82fd930..6905c3389c 100644 --- a/test/unit/visitor/inline.cpp +++ b/test/unit/visitor/inline.cpp @@ -21,6 +21,7 @@ using namespace visitor; using namespace test; using namespace test_utils; +using Catch::Matchers::Equals; using nmodl::parser::NmodlDriver; //============================================================================= @@ -55,7 +56,7 @@ SCENARIO("Inlining of external procedure calls", "[visitor][inline]") { } )"; - THEN("nothing gets inlinine") { + THEN("nothing gets inlined") { std::string input = reindent_text(nmodl_text); auto result = run_inline_visitor(input); REQUIRE(result == input); @@ -646,3 +647,60 @@ SCENARIO("Inlining pass handles local-global name conflict", "[visitor][inline]" } } } + +SCENARIO("Trying to inline a function with VERBATIM block") { + GIVEN("A VERBATIM block without a return inside") { + std::string input_nmodl = R"( + PROCEDURE verb_1() { + VERBATIM + pow(1,2); + ENDVERBATIM + } + + PROCEDURE verb_2() { + verb_1() + } + )"; + + std::string output_nmodl = R"( + PROCEDURE verb_1() { + VERBATIM + pow(1,2); + ENDVERBATIM + } + + PROCEDURE verb_2() { + { + VERBATIM + pow(1,2); + ENDVERBATIM + } + } + )"; + THEN("It gets inlined") { + std::string input = reindent_text(input_nmodl); + auto expected_result = reindent_text(output_nmodl); + auto result = run_inline_visitor(input); + REQUIRE(expected_result == result); + } + } + GIVEN("A VERBATIM block with a return value") { + std::string nmodl_text = R"( + PROCEDURE verb_1() { + VERBATIM + return pow(1,2); + ENDVERBATIM + } + + PROCEDURE verb_2() { + verb_1() + } + )"; + + THEN("It is not inlined") { + std::string input = reindent_text(nmodl_text); + auto result = run_inline_visitor(input); + REQUIRE(result == input); + } + } +}