diff --git a/modcc/lexer.hpp b/modcc/lexer.hpp index a998287fabcf2edddc7c96b43675a1509ff41dbb..52917e94477a09173d7e580ea067f9e7b691f2ed 100644 --- a/modcc/lexer.hpp +++ b/modcc/lexer.hpp @@ -31,7 +31,7 @@ bool is_keyword(Token const& t); // takes a range of characters as input parameters class Lexer { public: - Lexer(const char * begin, const char* end) + Lexer(const char* begin, const char* end) : begin_(begin), end_(end), current_(begin), @@ -114,4 +114,3 @@ protected: Token token_; }; - diff --git a/tests/modcc/test_lexer.cpp b/tests/modcc/test_lexer.cpp index dacfe8c6e910f6beea2d44e0eb715a4c6fb1b672..091a752b4ee0f25ea929bed86129ba7efc41e573 100644 --- a/tests/modcc/test_lexer.cpp +++ b/tests/modcc/test_lexer.cpp @@ -205,7 +205,9 @@ TEST(Lexer, braces) { // test comments TEST(Lexer, comments) { - char string[] = "foo:this is one line\nbar : another comment\n"; + char string[] = "foo:this is one line\n" + "bar : another comment\n" + "foobar ? another comment\n"; PRINT_LEX_STRING Lexer lexer(string, string+sizeof(string)); @@ -218,7 +220,12 @@ TEST(Lexer, comments) { EXPECT_EQ(t2.location.line, 2); auto t3 = lexer.parse(); - EXPECT_EQ(t3.type, tok::eof); + EXPECT_EQ(t3.type, tok::identifier); + EXPECT_EQ(t3.spelling, "foobar"); + EXPECT_EQ(t3.location.line, 3); + + auto t4 = lexer.parse(); + EXPECT_EQ(t4.type, tok::eof); } // test numbers