10 #include <catch2/catch_test_macros.hpp>
16 using namespace nmodl;
20 using parser::NmodlParser;
21 using Token = NmodlParser::token;
28 std::istringstream ss(name);
29 std::istream& in = ss;
37 auto get_token_type = [](
TokenType token) {
38 return parser::NmodlParser::by_type(token).type_get();
47 if (
token_type == get_token_type(Token::NAME) ||
50 token_type == get_token_type(Token::VALENCE) ||
54 REQUIRE(!value.get_node_name().empty());
58 else if (
token_type == get_token_type(Token::PRIME)) {
60 REQUIRE(!value.get_node_name().empty());
63 else if (
token_type == get_token_type(Token::INTEGER)) {
65 REQUIRE(value.get_value() != 0);
68 else if (
token_type == get_token_type(Token::REAL)) {
70 REQUIRE(value.to_double() != 0);
73 else if (
token_type == get_token_type(Token::STRING)) {
75 REQUIRE(!value.get_value().empty());
78 else if (
token_type == get_token_type(Token::VERBATIM) ||
79 token_type == get_token_type(Token::BLOCK_COMMENT) ||
80 token_type == get_token_type(Token::LINE_PART)) {
81 auto value = sym.value.as<std::string>();
82 REQUIRE(!value.empty());
86 auto value = sym.value.as<
ModToken>();
87 REQUIRE(!value.text().empty());
90 return sym.type_get() == get_token_type(type);
93 TEST_CASE(
"NMODL Lexer returning valid token types",
"[Lexer]") {
94 SECTION(
"Some keywords") {
100 SECTION(
"NMODL language keywords and constructs") {
111 SECTION(
"Different number types") {
122 SECTION(
"Name/Strings types") {
127 SECTION(
"Logical operator types") {
137 SECTION(
"Brace types") {