@@ -1222,6 +1222,8 @@ parser::parser(std::shared_ptr<parser_base> parser) : ptr_(std::move(parser)) {}
12221222
12231223parser::parser (const std::string & literal) : ptr_(std::make_shared<literal_parser>(literal, -1 )) {}
12241224
1225+ parser::parser (const char * literal) : ptr_(std::make_shared<literal_parser>(literal, -1 )) {}
1226+
12251227parser parser::operator ~() const {
12261228 return parser (std::make_shared<not_parser>(*this , -1 ));
12271229}
@@ -1230,30 +1232,18 @@ parser parser::operator+(const parser & other) const {
12301232 return parser (std::make_shared<sequence_parser>(std::initializer_list<parser>{*this , other}, -1 ));
12311233}
12321234
1233- parser parser::operator +(const std::string & literal) const {
1234- auto lit = parser (std::make_shared<literal_parser>(literal, -1 ));
1235- return parser (std::make_shared<sequence_parser>(std::initializer_list<parser>{*this , lit}, -1 ));
1236- }
1237-
12381235parser parser::operator |(const parser & other) const {
12391236 return parser (std::make_shared<choice_parser>(std::initializer_list<parser>{*this , other}, -1 ));
12401237}
12411238
1242- parser parser::operator |(const std::string & literal) const {
1243- auto lit = parser (std::make_shared<literal_parser>(literal, -1 ));
1244- return parser (std::make_shared<choice_parser>(std::initializer_list<parser>{*this , lit}, -1 ));
1245- }
1246-
12471239parser parser::operator <<(const parser & other) const {
12481240 auto ws = parser (std::make_shared<space_parser>(-1 ));
12491241 return parser (std::make_shared<sequence_parser>(std::initializer_list<parser>{*this , ws, other}, -1 ));
12501242}
12511243
1252- parser parser::operator <<(const std::string & literal) const {
1253- auto ws = parser (std::make_shared<space_parser>(-1 ));
1254- auto lit = parser (std::make_shared<literal_parser>(literal, -1 ));
1255- return parser (std::make_shared<sequence_parser>(std::initializer_list<parser>{*this , ws, lit}, -1 ));
1256- }
1244+ parser operator +(const char * lhs, const parser & rhs) { return parser (lhs) + rhs; }
1245+ parser operator |(const char * lhs, const parser & rhs) { return parser (lhs) | rhs; }
1246+ parser operator <<(const char * lhs, const parser & rhs) { return parser (lhs) << rhs; }
12571247
12581248parser_base & parser::operator *() const {
12591249 return *ptr_;
@@ -1373,13 +1363,6 @@ parser parser_builder::json_string(const parser & p) {
13731363 return quote + p + quote;
13741364}
13751365
1376- parser parser_builder::between (const std::string & left, const parser & p, const std::string & right, bool allow_spaces) {
1377- if (allow_spaces) {
1378- return literal (left) << p << literal (right);
1379- }
1380- return literal (left) + p + literal (right);
1381- }
1382-
13831366parser parser_builder::add_rule (const std::string & name, const parser & p) {
13841367 (*rules_)[name] = p;
13851368 return rule (name);
0 commit comments