1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 06:07:34 +00:00

LibCpp: Correctly parse lines that end in '\'

Such lines should be considered to be joined into the next line.
This makes multiline preprocessor stuff "work".
This commit is contained in:
Ali Mohammad Pur 2021-07-28 05:04:39 +04:30 committed by Andreas Kling
parent 8fefbfd5ac
commit dc68c765b7
3 changed files with 62 additions and 7 deletions

View file

@ -556,8 +556,16 @@ Vector<Token> Lexer::lex()
begin_token();
}
} else {
while (peek() && peek() != '\n')
consume();
while (peek()) {
if (peek() == '\\' && peek(1) == '\n') {
consume();
consume();
} else if (peek() == '\n') {
break;
} else {
consume();
}
}
commit_token(Token::Type::PreprocessorStatement);
}