1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 09:57:35 +00:00

LibCpp: Do lexing in the Preprocessor

We now call Preprocessor::process_and_lex() and pass the result to the
parser.

Doing the lexing in the preprocessor will allow us to maintain the
original position information of tokens after substituting definitions.
This commit is contained in:
Itamar 2021-08-06 10:29:57 +03:00 committed by Andreas Kling
parent bf7262681e
commit 4673a517f6
9 changed files with 42 additions and 39 deletions

View file

@ -18,7 +18,7 @@ class Parser final {
AK_MAKE_NONCOPYABLE(Parser);
public:
explicit Parser(const StringView& program, const String& filename, Preprocessor::Definitions&& = {});
explicit Parser(Vector<Token> const& tokens, const String& filename, Preprocessor::Definitions&& = {});
~Parser() = default;
NonnullRefPtr<TranslationUnit> parse();
@ -185,8 +185,8 @@ private:
void consume_attribute_specification();
void consume_access_specifier();
bool match_ellipsis();
void initialize_program_tokens(const StringView& program);
void add_tokens_for_preprocessor(Token& replaced_token, Preprocessor::DefinedValue&);
void initialize_program_tokens(Vector<Token> const& tokens);
void add_tokens_for_preprocessor(Token const& replaced_token, Preprocessor::DefinedValue&);
Vector<StringView> parse_type_qualifiers();
Vector<StringView> parse_function_qualifiers();