diff --git a/src/Lexer.cpp b/src/Lexer.cpp index 8cd6eb8..e3eb81c 100644 --- a/src/Lexer.cpp +++ b/src/Lexer.cpp @@ -27,6 +27,18 @@ namespace grino skip_spaces(); + while (has_more(m_cursor) + && at(m_cursor) == ';') + { + while (has_more(m_cursor) + && at(m_cursor) != '\n') + { + m_cursor++; + } + + skip_spaces(); + } + for (auto const& scanner: m_scanners) { auto my_info = scanner(); @@ -84,6 +96,7 @@ namespace grino char c = m_source[index]; if (std::isspace(c)) { return true; } + if (c == ';') { return true; } auto itr = std::find(std::begin(m_separators), std::end(m_separators), diff --git a/src/Node.hpp b/src/Node.hpp index 74a2b49..24a2f1a 100644 --- a/src/Node.hpp +++ b/src/Node.hpp @@ -6,7 +6,7 @@ #define NODE_TYPE(G) \ G(NODE_MODULE), \ - G(NODE_BOOL) + G(NODE_BOOL), namespace grino { diff --git a/tests/Lexer.cpp b/tests/Lexer.cpp index 4bdc426..b866e94 100644 --- a/tests/Lexer.cpp +++ b/tests/Lexer.cpp @@ -51,3 +51,14 @@ TEST_CASE_METHOD(LexerTest, "Lexer_booleans") test_end(lexer); } } + +TEST_CASE_METHOD(LexerTest, "Lexer_comments") +{ + grino::Lexer lexer {m_logger, "tests/lexer"}; + + lexer.scan(" true ; false \n\n true "); + test_next(lexer, "BOOL[true]"); + test_next(lexer, "BOOL[true]"); + test_end(lexer); + +}