mirror of
https://github.com/RGBCube/serenity
synced 2025-07-10 09:07: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:
parent
bf7262681e
commit
4673a517f6
9 changed files with 42 additions and 39 deletions
|
@ -13,9 +13,7 @@ int main(int argc, char** argv)
|
|||
Core::ArgsParser args_parser;
|
||||
const char* path = nullptr;
|
||||
bool tokens_mode = false;
|
||||
bool preprocess_mode = false;
|
||||
args_parser.add_option(tokens_mode, "Print Tokens", "tokens", 'T');
|
||||
args_parser.add_option(preprocess_mode, "Print Preprocessed source", "preprocessed", 'P');
|
||||
args_parser.add_positional_argument(path, "Cpp File", "cpp-file", Core::ArgsParser::Required::No);
|
||||
args_parser.parse(argc, argv);
|
||||
|
||||
|
@ -30,13 +28,9 @@ int main(int argc, char** argv)
|
|||
StringView content_view(content);
|
||||
|
||||
::Cpp::Preprocessor processor(path, content_view);
|
||||
auto preprocessed_content = processor.process();
|
||||
if (preprocess_mode) {
|
||||
outln(preprocessed_content);
|
||||
return 0;
|
||||
}
|
||||
auto tokens = processor.process_and_lex();
|
||||
|
||||
::Cpp::Parser parser(preprocessed_content, path);
|
||||
::Cpp::Parser parser(tokens, path);
|
||||
if (tokens_mode) {
|
||||
parser.print_tokens();
|
||||
return 0;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue