2021-08-20 15:05:11 +03:00
|
|
|
/*
|
2022-09-14 13:24:13 +03:00
|
|
|
* Copyright (c) 2021-2022, the SerenityOS developers.
|
2021-08-20 15:05:11 +03:00
|
|
|
*
|
|
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
|
|
*/
|
|
|
|
|
2022-09-14 13:24:13 +03:00
|
|
|
#include <AK/Try.h>
|
2021-08-20 15:05:11 +03:00
|
|
|
#include <LibCore/ArgsParser.h>
|
2023-02-09 05:02:46 +03:00
|
|
|
#include <LibCore/File.h>
|
2021-08-20 15:05:11 +03:00
|
|
|
#include <LibCpp/Lexer.h>
|
2021-11-27 23:11:59 +03:00
|
|
|
#include <LibMain/Main.h>
|
2021-08-20 15:05:11 +03:00
|
|
|
|
2021-11-27 23:11:59 +03:00
|
|
|
ErrorOr<int> serenity_main(Main::Arguments arguments)
|
2021-08-20 15:05:11 +03:00
|
|
|
{
|
|
|
|
Core::ArgsParser args_parser;
|
2022-09-14 13:24:13 +03:00
|
|
|
StringView path;
|
2021-08-20 15:05:11 +03:00
|
|
|
args_parser.add_positional_argument(path, "Cpp File", "cpp-file", Core::ArgsParser::Required::Yes);
|
2021-11-27 23:11:59 +03:00
|
|
|
args_parser.parse(arguments);
|
2021-08-20 15:05:11 +03:00
|
|
|
|
2023-02-09 05:02:46 +03:00
|
|
|
auto file = TRY(Core::File::open(path, Core::File::OpenMode::Read));
|
2022-12-11 19:49:00 +03:00
|
|
|
auto content = TRY(file->read_until_eof());
|
2021-08-20 15:05:11 +03:00
|
|
|
StringView content_view(content);
|
|
|
|
|
|
|
|
Cpp::Lexer lexer(content);
|
2021-08-21 16:48:21 +03:00
|
|
|
lexer.lex_iterable([](auto token) {
|
2022-12-06 04:12:49 +03:00
|
|
|
outln("{}", token.to_deprecated_string());
|
2021-08-21 16:48:21 +03:00
|
|
|
});
|
2021-11-27 23:11:59 +03:00
|
|
|
|
|
|
|
return 0;
|
2021-08-20 15:05:11 +03:00
|
|
|
}
|