瀏覽代碼

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.
Max Wipfli 4 年之前
父節點
當前提交
617c54a00b
共有 1 個文件被更改,包括 7 次插入4 次删除
  1. 7 4
      Userland/Libraries/LibCpp/Lexer.cpp

+ 7 - 4
Userland/Libraries/LibCpp/Lexer.cpp

@@ -534,10 +534,13 @@ Vector<Token> 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() == '"') {