From 617c54a00b59f1153e1c32745af51a8af6aad4c0 Mon Sep 17 00:00:00 2001 From: Max Wipfli Date: Fri, 4 Jun 2021 21:00:17 +0200 Subject: [PATCH] LibCpp: Do not emit empty whitespace token after include statement If an include statement didn't contain whitespace between the word "include" and the '<' or '"', the lexer would previous emit an empty whitespace token. This has been changed now. --- Userland/Libraries/LibCpp/Lexer.cpp | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/Userland/Libraries/LibCpp/Lexer.cpp b/Userland/Libraries/LibCpp/Lexer.cpp index 6b02479a16..e4bc45fcf3 100644 --- a/Userland/Libraries/LibCpp/Lexer.cpp +++ b/Userland/Libraries/LibCpp/Lexer.cpp @@ -534,10 +534,13 @@ Vector Lexer::lex() if (directive == "#include") { commit_token(Token::Type::IncludeStatement); - begin_token(); - while (is_ascii_space(peek())) - consume(); - commit_token(Token::Type::Whitespace); + if (is_ascii_space(peek())) { + begin_token(); + do { + consume(); + } while (is_ascii_space(peek())); + commit_token(Token::Type::Whitespace); + } begin_token(); if (peek() == '<' || peek() == '"') {