summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibCpp/Lexer.cpp
diff options
context:
space:
mode:
authorItamar <itamar8910@gmail.com>2021-08-13 12:11:26 +0300
committerAndreas Kling <kling@serenityos.org>2021-08-14 12:40:55 +0200
commitc7d3a7789c6a14100ff0b4c8eaf2b0d7d111347c (patch)
treede3ddc915d94d7ebf9a775faa890f3694cd7b3fa /Userland/Libraries/LibCpp/Lexer.cpp
parent06e47ce7aa365dec0a6cc82cdb3560cbd5527fad (diff)
downloadserenity-c7d3a7789c6a14100ff0b4c8eaf2b0d7d111347c.zip
LibCpp: Add lexer option to ignore whitespace tokens
Diffstat (limited to 'Userland/Libraries/LibCpp/Lexer.cpp')
-rw-r--r--Userland/Libraries/LibCpp/Lexer.cpp2
1 files changed, 2 insertions, 0 deletions
diff --git a/Userland/Libraries/LibCpp/Lexer.cpp b/Userland/Libraries/LibCpp/Lexer.cpp
index 56ab1afd6c..2edb5b4863 100644
--- a/Userland/Libraries/LibCpp/Lexer.cpp
+++ b/Userland/Libraries/LibCpp/Lexer.cpp
@@ -222,6 +222,8 @@ Vector<Token> Lexer::lex()
token_start_position = m_position;
};
auto commit_token = [&](auto type) {
+ if (m_options.ignore_whitespace && type == Token::Type::Whitespace)
+ return;
tokens.empend(type, token_start_position, m_previous_position, m_input.substring_view(token_start_index, m_index - token_start_index));
};