mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-09-20 09:49:15 +03:00
LibCpp: Allow whitespace between # and preprocessor directive
For example, '# include <stdio.h>' is now supported by the Lexer.
This commit is contained in:
parent
feab5e8a3e
commit
165a0082c4
Notes:
sideshowbarker
2024-07-18 05:25:58 +09:00
Author: https://github.com/itamar8910 Commit: https://github.com/SerenityOS/serenity/commit/165a0082c44 Pull-request: https://github.com/SerenityOS/serenity/pull/9528 Reviewed-by: https://github.com/alimpfard
@ -528,13 +528,16 @@ Vector<Token> Lexer::lex()
|
||||
if (ch == '#') {
|
||||
begin_token();
|
||||
consume();
|
||||
while (AK::is_ascii_space(peek()))
|
||||
consume();
|
||||
|
||||
size_t directive_start = m_index;
|
||||
if (is_valid_first_character_of_identifier(peek()))
|
||||
while (peek() && is_valid_nonfirst_character_of_identifier(peek()))
|
||||
consume();
|
||||
|
||||
auto directive = StringView(m_input.characters_without_null_termination() + token_start_index, m_index - token_start_index);
|
||||
if (directive == "#include") {
|
||||
auto directive = StringView(m_input.characters_without_null_termination() + directive_start, m_index - directive_start);
|
||||
if (directive == "include"sv) {
|
||||
commit_token(Token::Type::IncludeStatement);
|
||||
|
||||
if (is_ascii_space(peek())) {
|
||||
|
Loading…
Reference in New Issue
Block a user