aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2010-12-05 12:18:20 +0000
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2010-12-05 12:18:20 +0000
commit3db9761d1b7e8743d48aa079a97a57864a3efecf (patch)
tree7fb246dc51405ff0e3adfc15608475f5ea3a5a0b
parent8a2209af5322271d8741d8add2f9f965b30a6455 (diff)
downloadpaludis-3db9761d1b7e8743d48aa079a97a57864a3efecf.tar.gz
paludis-3db9761d1b7e8743d48aa079a97a57864a3efecf.tar.xz
Support parsing ^^ ( ) specs
-rw-r--r--paludis/elike_dep_parser-fwd.hh1
-rw-r--r--paludis/elike_dep_parser.cc14
-rw-r--r--paludis/elike_dep_parser.hh2
-rw-r--r--paludis/elike_dep_parser_TEST.cc3
-rw-r--r--paludis/repositories/e/dep_parser.cc14
-rw-r--r--paludis/repositories/fake/dep_parser.cc36
6 files changed, 58 insertions, 12 deletions
diff --git a/paludis/elike_dep_parser-fwd.hh b/paludis/elike_dep_parser-fwd.hh
index 09366f4..45c9336 100644
--- a/paludis/elike_dep_parser-fwd.hh
+++ b/paludis/elike_dep_parser-fwd.hh
@@ -35,6 +35,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 ()> ELikeDepParserExactlyOneFunction;
typedef std::function<void (const std::string &)> ELikeDepParserUseFunction;
typedef std::function<void (const std::string &)> ELikeDepParserLabelFunction;
typedef std::function<void ()> ELikeDepParserPushFunction;
diff --git a/paludis/elike_dep_parser.cc b/paludis/elike_dep_parser.cc
index 682a67e..54c0ba2 100644
--- a/paludis/elike_dep_parser.cc
+++ b/paludis/elike_dep_parser.cc
@@ -188,6 +188,20 @@ namespace
callbacks.on_any()();
parse(parser, callbacks, 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_exactly_one()();
+ parse(parser, callbacks, 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 1890951..69aa48c 100644
--- a/paludis/elike_dep_parser.hh
+++ b/paludis/elike_dep_parser.hh
@@ -32,6 +32,7 @@ namespace paludis
typedef Name<struct on_any_name> on_any;
typedef Name<struct on_arrow_name> on_arrow;
typedef Name<struct on_error_name> on_error;
+ typedef Name<struct on_exactly_one_name> on_exactly_one;
typedef Name<struct on_label_name> on_label;
typedef Name<struct on_pop_name> on_pop;
typedef Name<struct on_should_be_empty_name> on_should_be_empty;
@@ -47,6 +48,7 @@ namespace paludis
NamedValue<n::on_any, ELikeDepParserAnyFunction> on_any;
NamedValue<n::on_arrow, ELikeDepParserArrowFunction> on_arrow;
NamedValue<n::on_error, ELikeDepParserErrorFunction> on_error;
+ NamedValue<n::on_exactly_one, ELikeDepParserExactlyOneFunction> on_exactly_one;
NamedValue<n::on_label, ELikeDepParserLabelFunction> on_label;
NamedValue<n::on_pop, ELikeDepParserPopFunction> on_pop;
NamedValue<n::on_should_be_empty, ELikeDepParserShouldBeEmptyFunction> on_should_be_empty;
diff --git a/paludis/elike_dep_parser_TEST.cc b/paludis/elike_dep_parser_TEST.cc
index 2bb20be..ddc9c56 100644
--- a/paludis/elike_dep_parser_TEST.cc
+++ b/paludis/elike_dep_parser_TEST.cc
@@ -70,6 +70,7 @@ namespace test_cases
n::on_any() = std::bind(&handler, std::ref(out), "any<", "", "", "", ""),
n::on_arrow() = std::bind(&handler, std::ref(out), "a<", _1, ", ", _2, ">"),
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, "", "", ""),
n::on_pop() = std::bind(&handler, std::ref(out), ">", "", "", "", ""),
n::on_should_be_empty() = std::bind(&handler, std::ref(out), "EMPTY", "", "", "", ""),
@@ -97,6 +98,7 @@ namespace test_cases
n::on_any() = std::bind(&handler, std::ref(out), "any<", "", "", "", ""),
n::on_arrow() = std::bind(&handler, std::ref(out), "a<", _1, ", ", _2, ">"),
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, "", "", ""),
n::on_pop() = std::bind(&handler, std::ref(out), ">", "", "", "", ""),
n::on_should_be_empty() = std::bind(&handler, std::ref(out), "EMPTY", "", "", "", ""),
@@ -124,6 +126,7 @@ namespace test_cases
n::on_any() = std::bind(&handler, std::ref(out), "any<", "", "", "", ""),
n::on_arrow() = std::bind(&handler, std::ref(out), "a<", _1, ", ", _2, ">"),
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, "", "", ""),
n::on_pop() = std::bind(&handler, std::ref(out), ">", "", "", "", ""),
n::on_should_be_empty() = std::bind(&handler, std::ref(out), "EMPTY", "", "", "", ""),
diff --git a/paludis/repositories/e/dep_parser.cc b/paludis/repositories/e/dep_parser.cc
index 147974f..afe6c63 100644
--- a/paludis/repositories/e/dep_parser.cc
+++ b/paludis/repositories/e/dep_parser.cc
@@ -219,6 +219,13 @@ namespace
throw EDepParseError(s, "Any dep specs not allowed here");
}
+ void exactly_one_not_allowed_handler(const std::string & s) PALUDIS_ATTRIBUTE((noreturn));
+
+ void exactly_one_not_allowed_handler(const std::string & s)
+ {
+ throw EDepParseError(s, "Exactly 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)
@@ -414,6 +421,7 @@ paludis::erepository::parse_depend(const std::string & s,
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_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>,
std::ref(stack),
ParseStackTypes<DependencySpecTree>::AnnotationsGoHere(std::bind(
@@ -457,6 +465,7 @@ paludis::erepository::parse_provide(const std::string & s,
n::on_any() = std::bind(&any_not_allowed_handler, s),
n::on_arrow() = std::bind(&arrows_not_allowed_handler, s, _1, _2),
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),
n::on_pop() = std::bind(&pop_handler<ProvideSpecTree>, std::ref(stack),
ParseStackTypes<ProvideSpecTree>::AnnotationsGoHere(std::bind(
@@ -498,6 +507,7 @@ paludis::erepository::parse_fetchable_uri(const std::string & s,
ParseStackTypes<FetchableURISpecTree>::AnnotationsGoHere(std::bind(
&set_thing_to_annotate, std::ref(thing_to_annotate), _1)), s, _1, _2, std::cref(eapi)),
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),
ParseStackTypes<FetchableURISpecTree>::AnnotationsGoHere(std::bind(
&set_thing_to_annotate, std::ref(thing_to_annotate), _1)), _1, std::cref(eapi)),
@@ -539,6 +549,7 @@ paludis::erepository::parse_simple_uri(const std::string & s,
n::on_any() = std::bind(&any_not_allowed_handler, s),
n::on_arrow() = std::bind(&arrows_not_allowed_handler, s, _1, _2),
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),
n::on_pop() = std::bind(&pop_handler<SimpleURISpecTree>, std::ref(stack),
ParseStackTypes<SimpleURISpecTree>::AnnotationsGoHere(std::bind(
@@ -578,6 +589,7 @@ paludis::erepository::parse_license(const std::string & s,
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_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),
n::on_pop() = std::bind(&pop_handler<LicenseSpecTree>, std::ref(stack),
ParseStackTypes<LicenseSpecTree>::AnnotationsGoHere(std::bind(
@@ -617,6 +629,7 @@ paludis::erepository::parse_plain_text(const std::string & s,
n::on_any() = std::bind(&any_not_allowed_handler, s),
n::on_arrow() = std::bind(&arrows_not_allowed_handler, s, _1, _2),
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),
n::on_pop() = std::bind(&pop_handler<PlainTextSpecTree>, std::ref(stack),
ParseStackTypes<PlainTextSpecTree>::AnnotationsGoHere(std::bind(
@@ -656,6 +669,7 @@ paludis::erepository::parse_myoptions(const std::string & s,
n::on_any() = std::bind(&any_not_allowed_handler, s),
n::on_arrow() = std::bind(&arrows_not_allowed_handler, s, _1, _2),
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),
ParseStackTypes<PlainTextSpecTree>::AnnotationsGoHere(std::bind(
&set_thing_to_annotate, std::ref(thing_to_annotate), _1)), _1),
diff --git a/paludis/repositories/fake/dep_parser.cc b/paludis/repositories/fake/dep_parser.cc
index b627b1c..806115e 100644
--- a/paludis/repositories/fake/dep_parser.cc
+++ b/paludis/repositories/fake/dep_parser.cc
@@ -104,6 +104,13 @@ namespace
throw FakeDepParseError(s, "Any dep specs not allowed here");
}
+ void exactly_one_not_allowed_handler(const std::string & s) PALUDIS_ATTRIBUTE((noreturn));
+
+ void exactly_one_not_allowed_handler(const std::string & s)
+ {
+ throw FakeDepParseError(s, "Exactly 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,
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_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),
n::on_pop() = std::bind(&pop_handler<DependencySpecTree>, std::ref(stack), s),
n::on_should_be_empty() = std::bind(&should_be_empty_handler<DependencySpecTree>, std::ref(stack), s),
@@ -210,6 +218,7 @@ paludis::fakerepository::parse_provide(const std::string & s,
n::on_any() = std::bind(&any_not_allowed_handler, s),
n::on_arrow() = std::bind(&arrows_not_allowed_handler, s, _1, _2),
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),
n::on_pop() = std::bind(&pop_handler<ProvideSpecTree>, std::ref(stack), s),
n::on_should_be_empty() = std::bind(&should_be_empty_handler<ProvideSpecTree>, std::ref(stack), s),
@@ -240,6 +249,7 @@ paludis::fakerepository::parse_fetchable_uri(const std::string & s,
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_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),
n::on_pop() = std::bind(&pop_handler<FetchableURISpecTree>, std::ref(stack), s),
n::on_should_be_empty() = std::bind(&should_be_empty_handler<FetchableURISpecTree>, std::ref(stack), s),
@@ -270,6 +280,7 @@ paludis::fakerepository::parse_simple_uri(const std::string & s,
n::on_any() = std::bind(&any_not_allowed_handler, s),
n::on_arrow() = std::bind(&arrows_not_allowed_handler, s, _1, _2),
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),
n::on_pop() = std::bind(&pop_handler<SimpleURISpecTree>, std::ref(stack), s),
n::on_should_be_empty() = std::bind(&should_be_empty_handler<SimpleURISpecTree>, std::ref(stack), s),
@@ -295,18 +306,19 @@ paludis::fakerepository::parse_license(const std::string & s,
ELikeDepParserCallbacks callbacks(
make_named_values<ELikeDepParserCallbacks>(
- n::on_all() = std::bind(&any_all_handler<LicenseSpecTree, AllDepSpec>, std::ref(stack)),
- 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_error() = std::bind(&error_handler, s, _1),
- n::on_label() = std::bind(&labels_not_allowed_handler, s, _1),
- n::on_pop() = std::bind(&pop_handler<LicenseSpecTree>, std::ref(stack), s),
- n::on_should_be_empty() = std::bind(&should_be_empty_handler<LicenseSpecTree>, std::ref(stack), s),
- n::on_string() = std::bind(&license_handler<LicenseSpecTree>, std::ref(stack), _1),
- n::on_use() = std::bind(&use_handler<LicenseSpecTree>, std::ref(stack), _1, env, id),
- n::on_use_under_any() = &do_nothing
- ));
+ n::on_all() = std::bind(&any_all_handler<LicenseSpecTree, AllDepSpec>, std::ref(stack)),
+ 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_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),
+ n::on_pop() = std::bind(&pop_handler<LicenseSpecTree>, std::ref(stack), s),
+ n::on_should_be_empty() = std::bind(&should_be_empty_handler<LicenseSpecTree>, std::ref(stack), s),
+ n::on_string() = std::bind(&license_handler<LicenseSpecTree>, std::ref(stack), _1),
+ n::on_use() = std::bind(&use_handler<LicenseSpecTree>, std::ref(stack), _1, env, id),
+ n::on_use_under_any() = &do_nothing
+ ));
parse_elike_dependencies(s, callbacks);