mirror of
https://github.com/RGBCube/serenity
synced 2025-07-24 22:17:42 +00:00
StateMachineGenerator: Port to LibMain and Core::Stream
This commit is contained in:
parent
cb45fa79ee
commit
684c3efc04
2 changed files with 8 additions and 11 deletions
|
@ -2,4 +2,4 @@ set(SOURCES
|
||||||
main.cpp
|
main.cpp
|
||||||
)
|
)
|
||||||
|
|
||||||
lagom_tool(StateMachineGenerator)
|
lagom_tool(StateMachineGenerator LIBS LibMain)
|
||||||
|
|
|
@ -12,7 +12,8 @@
|
||||||
#include <AK/StringBuilder.h>
|
#include <AK/StringBuilder.h>
|
||||||
#include <AK/Types.h>
|
#include <AK/Types.h>
|
||||||
#include <LibCore/ArgsParser.h>
|
#include <LibCore/ArgsParser.h>
|
||||||
#include <LibCore/File.h>
|
#include <LibCore/Stream.h>
|
||||||
|
#include <LibMain/Main.h>
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
|
|
||||||
struct Range {
|
struct Range {
|
||||||
|
@ -213,19 +214,15 @@ parse_state_machine(StringView input)
|
||||||
|
|
||||||
void output_header(StateMachine const&, SourceGenerator&);
|
void output_header(StateMachine const&, SourceGenerator&);
|
||||||
|
|
||||||
int main(int argc, char** argv)
|
ErrorOr<int> serenity_main(Main::Arguments arguments)
|
||||||
{
|
{
|
||||||
Core::ArgsParser args_parser;
|
Core::ArgsParser args_parser;
|
||||||
char const* path = nullptr;
|
StringView path;
|
||||||
args_parser.add_positional_argument(path, "Path to parser description", "input", Core::ArgsParser::Required::Yes);
|
args_parser.add_positional_argument(path, "Path to parser description", "input", Core::ArgsParser::Required::Yes);
|
||||||
args_parser.parse(argc, argv);
|
args_parser.parse(arguments);
|
||||||
|
|
||||||
auto file_or_error = Core::File::open(path, Core::OpenMode::ReadOnly);
|
auto file = TRY(Core::Stream::File::open(path, Core::Stream::OpenMode::Read));
|
||||||
if (file_or_error.is_error()) {
|
auto content = TRY(file->read_all());
|
||||||
fprintf(stderr, "Cannot open %s\n", path);
|
|
||||||
}
|
|
||||||
|
|
||||||
auto content = file_or_error.value()->read_all();
|
|
||||||
auto state_machine = parse_state_machine(content);
|
auto state_machine = parse_state_machine(content);
|
||||||
|
|
||||||
StringBuilder builder;
|
StringBuilder builder;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue