Skip to content

Commit 509bc6c

Browse files
committed
use lexy argv_input
1 parent 4008b3c commit 509bc6c

File tree

1 file changed

+3
-10
lines changed

1 file changed

+3
-10
lines changed

args.h

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,11 @@
33
#include "lexy/action/parse.hpp"
44
#include "lexy/callback.hpp"
55
#include "lexy/dsl.hpp"
6-
#include "lexy/input/string_input.hpp"
6+
#include "lexy/input/argv_input.hpp"
77
#include "lexy_ext/report_error.hpp"
88

9-
#include <numeric>
109
#include <optional>
1110
#include <iostream>
12-
#include <string>
1311

1412
struct Args
1513
{
@@ -52,7 +50,7 @@ namespace dsl = lexy::dsl;
5250

5351
struct production
5452
{
55-
static constexpr auto sep = dsl::newline;
53+
static constexpr auto sep = dsl::argv_separator;
5654

5755
struct help
5856
{
@@ -105,12 +103,7 @@ Args ParseArgs(int argc, char** argv)
105103
{
106104
using namespace arg_parse_detail;
107105

108-
auto concat = [](std::string str, const char* arg) -> std::string {
109-
return (std::move(str) + arg) + '\n';
110-
};
111-
auto str = std::accumulate(argv + 1, argv + argc, std::string(), concat);
112-
113-
auto input = lexy::string_input(str);
106+
auto input = lexy::argv_input(argc, argv);
114107
if(auto parsed = lexy::parse<production>(input, lexy_ext::report_error); parsed.has_value()) {
115108
return parsed.value();
116109
}

0 commit comments

Comments
 (0)