diff options
author | Max Wipfli <mail@maxwipfli.ch> | 2021-06-04 21:00:17 +0200 |
---|---|---|
committer | Ali Mohammad Pur <Ali.mpfard@gmail.com> | 2021-06-05 00:32:28 +0430 |
commit | 617c54a00b59f1153e1c32745af51a8af6aad4c0 (patch) | |
tree | 8ca351a7b8ffcf428f1c0a66fb8a9950884aa3d1 /Userland/Libraries/LibCpp/Lexer.cpp | |
parent | 2aa0cbaf22365273defc3c1f4fd9bdc14c38f219 (diff) | |
download | serenity-617c54a00b59f1153e1c32745af51a8af6aad4c0.zip |
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.
Diffstat (limited to 'Userland/Libraries/LibCpp/Lexer.cpp')
-rw-r--r-- | Userland/Libraries/LibCpp/Lexer.cpp | 11 |
1 files 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<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() == '"') { |