diff options
-rw-r--r-- | paludis/elike_dep_parser-fwd.hh | 1 | ||||
-rw-r--r-- | paludis/elike_dep_parser.cc | 14 | ||||
-rw-r--r-- | paludis/elike_dep_parser.hh | 2 | ||||
-rw-r--r-- | paludis/elike_dep_parser_TEST.cc | 4 | ||||
-rw-r--r-- | paludis/repositories/e/dep_parser.cc | 14 | ||||
-rw-r--r-- | paludis/repositories/fake/dep_parser.cc | 11 |
6 files changed, 46 insertions, 0 deletions
diff --git a/paludis/elike_dep_parser-fwd.hh b/paludis/elike_dep_parser-fwd.hh index 63ceeaa5c..c61c44cee 100644 --- a/paludis/elike_dep_parser-fwd.hh +++ b/paludis/elike_dep_parser-fwd.hh @@ -40,6 +40,7 @@ namespace paludis typedef std::function<void (const std::string &, const std::string &)> ELikeDepParserArrowFunction; typedef std::function<void ()> ELikeDepParserAnyFunction; typedef std::function<void ()> ELikeDepParserAllFunction; + typedef std::function<void ()> ELikeDepParserAtMostOneFunction; typedef std::function<void ()> ELikeDepParserExactlyOneFunction; typedef std::function<void (const std::string &)> ELikeDepParserUseFunction; typedef std::function<void (const std::string &)> ELikeDepParserLabelFunction; diff --git a/paludis/elike_dep_parser.cc b/paludis/elike_dep_parser.cc index 7418ce642..07e233ca5 100644 --- a/paludis/elike_dep_parser.cc +++ b/paludis/elike_dep_parser.cc @@ -213,6 +213,20 @@ namespace callbacks.on_exactly_one()(); parse(parser, callbacks, options, true, true); } + else if (parser.consume(simple_parser::exact("??"))) + { + if (! parser.consume(+simple_parser::any_of(" \t\r\n"))) + error(parser, callbacks, "Expected space after '?""?'"); + + if (! parser.consume(simple_parser::exact("("))) + error(parser, callbacks, "Expected '(' after '?""?' then space"); + + if (! parser.consume(+simple_parser::any_of(" \t\r\n"))) + error(parser, callbacks, "Expected space after '?? ('"); + + callbacks.on_at_most_one()(); + parse(parser, callbacks, options, true, true); + } else if (parser.consume(+simple_parser::any_except(" \t\r\n") >> word)) { if ('?' == word.at(word.length() - 1)) diff --git a/paludis/elike_dep_parser.hh b/paludis/elike_dep_parser.hh index 0e5223efa..89107c5ea 100644 --- a/paludis/elike_dep_parser.hh +++ b/paludis/elike_dep_parser.hh @@ -31,6 +31,7 @@ namespace paludis typedef Name<struct name_on_annotations> on_annotations; typedef Name<struct name_on_any> on_any; typedef Name<struct name_on_arrow> on_arrow; + typedef Name<struct name_on_at_most_one> on_at_most_one; typedef Name<struct name_on_error> on_error; typedef Name<struct name_on_exactly_one> on_exactly_one; typedef Name<struct name_on_label> on_label; @@ -48,6 +49,7 @@ namespace paludis NamedValue<n::on_annotations, ELikeDepParserAnnotationsFunction> on_annotations; NamedValue<n::on_any, ELikeDepParserAnyFunction> on_any; NamedValue<n::on_arrow, ELikeDepParserArrowFunction> on_arrow; + NamedValue<n::on_at_most_one, ELikeDepParserAtMostOneFunction> on_at_most_one; NamedValue<n::on_error, ELikeDepParserErrorFunction> on_error; NamedValue<n::on_exactly_one, ELikeDepParserExactlyOneFunction> on_exactly_one; NamedValue<n::on_label, ELikeDepParserLabelFunction> on_label; diff --git a/paludis/elike_dep_parser_TEST.cc b/paludis/elike_dep_parser_TEST.cc index 299377ca4..7d14e2554 100644 --- a/paludis/elike_dep_parser_TEST.cc +++ b/paludis/elike_dep_parser_TEST.cc @@ -64,6 +64,7 @@ TEST(ELikeDepParser, Basic) n::on_annotations() = std::bind(&handle_annotations, std::ref(out), _1), n::on_any() = std::bind(&handler, std::ref(out), "any<", "", "", "", ""), n::on_arrow() = std::bind(&handler, std::ref(out), "a<", _1, ", ", _2, ">"), + n::on_at_most_one() = std::bind(&handler, std::ref(out), "m<", "", "", "", ""), n::on_error() = std::bind(&handler, std::ref(out), "error<", _1, ">", "", ""), n::on_exactly_one() = std::bind(&handler, std::ref(out), "x<", "", "", "", ""), n::on_label() = std::bind(&handler, std::ref(out), "label<", _1, "", "", ""), @@ -88,6 +89,7 @@ TEST(ELikeDepParser, Empty) n::on_annotations() = std::bind(&handle_annotations, std::ref(out), _1), n::on_any() = std::bind(&handler, std::ref(out), "any<", "", "", "", ""), n::on_arrow() = std::bind(&handler, std::ref(out), "a<", _1, ", ", _2, ">"), + n::on_at_most_one() = std::bind(&handler, std::ref(out), "m<", "", "", "", ""), n::on_error() = std::bind(&handler, std::ref(out), "error<", _1, ">", "", ""), n::on_exactly_one() = std::bind(&handler, std::ref(out), "x<", "", "", "", ""), n::on_label() = std::bind(&handler, std::ref(out), "label<", _1, "", "", ""), @@ -112,6 +114,7 @@ TEST(ELikeDepParser, Annotations) n::on_annotations() = std::bind(&handle_annotations, std::ref(out), _1), n::on_any() = std::bind(&handler, std::ref(out), "any<", "", "", "", ""), n::on_arrow() = std::bind(&handler, std::ref(out), "a<", _1, ", ", _2, ">"), + n::on_at_most_one() = std::bind(&handler, std::ref(out), "m<", "", "", "", ""), n::on_error() = std::bind(&handler, std::ref(out), "error<", _1, ">", "", ""), n::on_exactly_one() = std::bind(&handler, std::ref(out), "x<", "", "", "", ""), n::on_label() = std::bind(&handler, std::ref(out), "label<", _1, "", "", ""), @@ -136,6 +139,7 @@ TEST(ELikeDepParser, Comments) n::on_annotations() = std::bind(&handle_annotations, std::ref(out), _1), n::on_any() = std::bind(&handler, std::ref(out), "any<", "", "", "", ""), n::on_arrow() = std::bind(&handler, std::ref(out), "a<", _1, ", ", _2, ">"), + n::on_at_most_one() = std::bind(&handler, std::ref(out), "m<", "", "", "", ""), n::on_error() = std::bind(&handler, std::ref(out), "error<", _1, ">", "", ""), n::on_exactly_one() = std::bind(&handler, std::ref(out), "x<", "", "", "", ""), n::on_label() = std::bind(&handler, std::ref(out), "label<", _1, "", "", ""), diff --git a/paludis/repositories/e/dep_parser.cc b/paludis/repositories/e/dep_parser.cc index f0bde4399..0cd6c8570 100644 --- a/paludis/repositories/e/dep_parser.cc +++ b/paludis/repositories/e/dep_parser.cc @@ -238,6 +238,12 @@ namespace { throw EDepParseError(s, "Exactly one dep specs not allowed here"); } + void at_most_one_not_allowed_handler(const std::string & s) PALUDIS_ATTRIBUTE((noreturn)); + + void at_most_one_not_allowed_handler(const std::string & s) + { + throw EDepParseError(s, "At most one dep specs not allowed here"); + } void arrows_not_allowed_handler(const std::string & s, const std::string & f, const std::string & t) PALUDIS_ATTRIBUTE((noreturn)); @@ -518,6 +524,7 @@ paludis::erepository::parse_depend(const std::string & s, const Environment * co n::on_annotations() = std::bind(&apply_annotations, std::cref(eapi), std::ref(thing_to_annotate), std::cref(thing_to_star_annotate), _1), n::on_any() = std::bind(&any_all_handler<DependencySpecTree, AnyDepSpec>, std::ref(stack)), n::on_arrow() = std::bind(&arrows_not_allowed_handler, s, _1, _2), + n::on_at_most_one() = std::bind(&at_most_one_not_allowed_handler, s), n::on_error() = std::bind(&error_handler, s, _1), n::on_exactly_one() = std::bind(&exactly_one_not_allowed_handler, s), n::on_label() = std::bind(&dependency_label_handler<DependencySpecTree>, env, @@ -572,6 +579,7 @@ paludis::erepository::parse_commented_set(const std::string & s, const Environme n::on_annotations() = std::bind(&apply_annotations, std::cref(eapi), std::ref(thing_to_annotate), std::cref(thing_to_star_annotate), _1), n::on_any() = std::bind(&any_not_allowed_handler, s), n::on_arrow() = std::bind(&arrows_not_allowed_handler, s, _1, _2), + n::on_at_most_one() = std::bind(&at_most_one_not_allowed_handler, s), n::on_error() = std::bind(&error_handler, s, _1), n::on_exactly_one() = std::bind(&exactly_one_not_allowed_handler, s), n::on_label() = std::bind(&labels_not_allowed_handler, s, _1), @@ -624,6 +632,7 @@ paludis::erepository::parse_fetchable_uri(const std::string & s, const Environme n::on_arrow() = std::bind(&arrow_handler<FetchableURISpecTree>, std::ref(stack), ParseStackTypes<FetchableURISpecTree>::AnnotationsGoHere(std::bind( &set_thing_to_annotate, std::ref(thing_to_annotate), _1)), s, _1, _2, std::cref(eapi)), + n::on_at_most_one() = std::bind(&at_most_one_not_allowed_handler, s), n::on_error() = std::bind(&error_handler, s, _1), n::on_exactly_one() = std::bind(&exactly_one_not_allowed_handler, s), n::on_label() = std::bind(&fetchable_label_handler<FetchableURISpecTree>, std::ref(stack), @@ -672,6 +681,7 @@ paludis::erepository::parse_simple_uri(const std::string & s, const Environment n::on_annotations() = std::bind(&apply_annotations, std::cref(eapi), std::ref(thing_to_annotate), std::cref(thing_to_star_annotate), _1), n::on_any() = std::bind(&any_not_allowed_handler, s), n::on_arrow() = std::bind(&arrows_not_allowed_handler, s, _1, _2), + n::on_at_most_one() = std::bind(&at_most_one_not_allowed_handler, s), n::on_error() = std::bind(&error_handler, s, _1), n::on_exactly_one() = std::bind(&exactly_one_not_allowed_handler, s), n::on_label() = std::bind(&labels_not_allowed_handler, s, _1), @@ -718,6 +728,7 @@ paludis::erepository::parse_license(const std::string & s, const Environment * c n::on_annotations() = std::bind(&apply_annotations, std::cref(eapi), std::ref(thing_to_annotate), std::cref(thing_to_star_annotate), _1), n::on_any() = std::bind(&any_all_handler<LicenseSpecTree, AnyDepSpec>, std::ref(stack)), n::on_arrow() = std::bind(&arrows_not_allowed_handler, s, _1, _2), + n::on_at_most_one() = std::bind(&at_most_one_not_allowed_handler, s), n::on_error() = std::bind(&error_handler, s, _1), n::on_exactly_one() = std::bind(&exactly_one_not_allowed_handler, s), n::on_label() = std::bind(&labels_not_allowed_handler, s, _1), @@ -764,6 +775,7 @@ paludis::erepository::parse_plain_text(const std::string & s, const Environment n::on_annotations() = std::bind(&apply_annotations, std::cref(eapi), std::ref(thing_to_annotate), std::cref(thing_to_star_annotate), _1), n::on_any() = std::bind(&any_not_allowed_handler, s), n::on_arrow() = std::bind(&arrows_not_allowed_handler, s, _1, _2), + n::on_at_most_one() = std::bind(&at_most_one_not_allowed_handler, s), n::on_error() = std::bind(&error_handler, s, _1), n::on_exactly_one() = std::bind(&exactly_one_not_allowed_handler, s), n::on_label() = std::bind(&labels_not_allowed_handler, s, _1), @@ -810,6 +822,7 @@ paludis::erepository::parse_myoptions(const std::string & s, const Environment * n::on_annotations() = std::bind(&apply_annotations, std::cref(eapi), std::ref(thing_to_annotate), std::cref(thing_to_star_annotate), _1), n::on_any() = std::bind(&any_not_allowed_handler, s), n::on_arrow() = std::bind(&arrows_not_allowed_handler, s, _1, _2), + n::on_at_most_one() = std::bind(&at_most_one_not_allowed_handler, s), n::on_error() = std::bind(&error_handler, s, _1), n::on_exactly_one() = std::bind(&exactly_one_not_allowed_handler, s), n::on_label() = std::bind(&plain_text_label_handler<PlainTextSpecTree>, std::ref(stack), @@ -858,6 +871,7 @@ paludis::erepository::parse_required_use(const std::string & s, const Environmen n::on_annotations() = std::bind(&apply_annotations, std::cref(eapi), std::ref(thing_to_annotate), std::cref(thing_to_star_annotate), _1), n::on_any() = std::bind(&any_all_handler<RequiredUseSpecTree, AnyDepSpec>, std::ref(stack)), n::on_arrow() = std::bind(&arrows_not_allowed_handler, s, _1, _2), + n::on_at_most_one() = std::bind(&at_most_one_not_allowed_handler, s), n::on_error() = std::bind(&error_handler, s, _1), n::on_exactly_one() = std::bind(&any_all_handler<RequiredUseSpecTree, ExactlyOneDepSpec>, std::ref(stack)), n::on_label() = std::bind(&labels_not_allowed_handler, s, _1), diff --git a/paludis/repositories/fake/dep_parser.cc b/paludis/repositories/fake/dep_parser.cc index 02de94d0d..ec6366ab0 100644 --- a/paludis/repositories/fake/dep_parser.cc +++ b/paludis/repositories/fake/dep_parser.cc @@ -107,6 +107,13 @@ namespace throw FakeDepParseError(s, "Exactly one dep specs not allowed here"); } + void at_most_one_not_allowed_handler(const std::string & s) PALUDIS_ATTRIBUTE((noreturn)); + + void at_most_one_not_allowed_handler(const std::string & s) + { + throw FakeDepParseError(s, "At most one dep specs not allowed here"); + } + void arrows_not_allowed_handler(const std::string & s, const std::string & f, const std::string & t) PALUDIS_ATTRIBUTE((noreturn)); void arrows_not_allowed_handler(const std::string & s, const std::string & f, const std::string & t) @@ -180,6 +187,7 @@ paludis::fakerepository::parse_depend(const std::string & s, const Environment * n::on_annotations() = &discard_annotations, n::on_any() = std::bind(&any_all_handler<DependencySpecTree, AnyDepSpec>, std::ref(stack)), n::on_arrow() = std::bind(&arrows_not_allowed_handler, s, _1, _2), + n::on_at_most_one() = std::bind(&at_most_one_not_allowed_handler, s), n::on_error() = std::bind(&error_handler, s, _1), n::on_exactly_one() = std::bind(&exactly_one_not_allowed_handler, s), n::on_label() = std::bind(&labels_not_allowed_handler, s, _1), @@ -211,6 +219,7 @@ paludis::fakerepository::parse_fetchable_uri(const std::string & s, const Enviro n::on_annotations() = &discard_annotations, n::on_any() = std::bind(&any_not_allowed_handler, s), n::on_arrow() = std::bind(&arrow_handler<FetchableURISpecTree>, std::ref(stack), _1, _2), + n::on_at_most_one() = std::bind(&at_most_one_not_allowed_handler, s), n::on_error() = std::bind(&error_handler, s, _1), n::on_exactly_one() = std::bind(&exactly_one_not_allowed_handler, s), n::on_label() = std::bind(&labels_not_allowed_handler, s, _1), @@ -242,6 +251,7 @@ paludis::fakerepository::parse_simple_uri(const std::string & s, const Environme n::on_annotations() = &discard_annotations, n::on_any() = std::bind(&any_not_allowed_handler, s), n::on_arrow() = std::bind(&arrows_not_allowed_handler, s, _1, _2), + n::on_at_most_one() = std::bind(&at_most_one_not_allowed_handler, s), n::on_error() = std::bind(&error_handler, s, _1), n::on_exactly_one() = std::bind(&exactly_one_not_allowed_handler, s), n::on_label() = std::bind(&labels_not_allowed_handler, s, _1), @@ -273,6 +283,7 @@ paludis::fakerepository::parse_license(const std::string & s, const Environment n::on_annotations() = &discard_annotations, n::on_any() = std::bind(&any_all_handler<LicenseSpecTree, AnyDepSpec>, std::ref(stack)), n::on_arrow() = std::bind(&arrows_not_allowed_handler, s, _1, _2), + n::on_at_most_one() = std::bind(&at_most_one_not_allowed_handler, s), n::on_error() = std::bind(&error_handler, s, _1), n::on_exactly_one() = std::bind(&exactly_one_not_allowed_handler, s), n::on_label() = std::bind(&labels_not_allowed_handler, s, _1), |