mirror of
https://github.com/RGBCube/serenity
synced 2025-05-14 07:34:57 +00:00
LibCpp: Understand preprocessor macro definition and invocation
The preprocessor now understands when a function-like macro is defined, and can also parse calls to such macros. The actual evaluation of function-like macros will be done in a separate commit.
This commit is contained in:
parent
c7d3a7789c
commit
8505fcb8ae
4 changed files with 155 additions and 31 deletions
|
@ -17,6 +17,17 @@ int main(int, char**)
|
|||
auto content = file->read_all();
|
||||
Cpp::Preprocessor cpp("other.h", StringView { content });
|
||||
auto tokens = cpp.process_and_lex();
|
||||
|
||||
outln("Definitions:");
|
||||
for (auto& definition : cpp.definitions()) {
|
||||
if (definition.value.parameters.is_empty())
|
||||
outln("{}: {}", definition.key, definition.value.value);
|
||||
else
|
||||
outln("{}({}): {}", definition.key, String::join(",", definition.value.parameters), definition.value.value);
|
||||
}
|
||||
|
||||
outln("");
|
||||
|
||||
for (auto& token : tokens) {
|
||||
dbgln("{}", token.to_string());
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue