mirror of
https://github.com/fergalmoran/ladybird.git
synced 2025-12-28 12:18:25 +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:
@@ -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());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user