summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/atom/parsers.rs17
1 files changed, 14 insertions, 3 deletions
diff --git a/src/atom/parsers.rs b/src/atom/parsers.rs
index 59bd23f..109e3bc 100644
--- a/src/atom/parsers.rs
+++ b/src/atom/parsers.rs
@@ -1,6 +1,6 @@
use core::option::Option::None;
-use mon::{Parser, ParserIter, alphanumeric, r#if, numeric1, one_of, tag};
+use mon::{Parser, ParserIter, alphanumeric, eof, r#if, input::InputIter, numeric1, one_of, tag};
use crate::{
Parseable,
@@ -126,7 +126,7 @@ impl<'a> Parseable<'a, &'a str> for Name {
type Parser = impl Parser<&'a str, Output = Self>;
fn parser() -> Self::Parser {
- let start = alphanumeric().or(one_of("_".chars()));
+ let start = || alphanumeric().or(one_of("_".chars()));
let rest = alphanumeric()
.or(one_of("_+".chars()))
@@ -138,9 +138,19 @@ impl<'a> Parseable<'a, &'a str> for Name {
.repeated()
.many();
- start
+ let verify = alphanumeric()
+ .or(one_of("_+".chars()))
+ .or(one_of("-".chars())
+ .and_not(Version::parser().preceded_by(tag("-")).followed_by(eof())))
+ .repeated()
+ .many();
+
+ start()
.and(rest)
.recognize()
+ .verify_output(move |output: &&str| {
+ verify.check_finished(InputIter::new(*output)).is_ok()
+ })
.map(|output: &str| Name(output.to_string()))
}
}
@@ -541,6 +551,7 @@ mod test {
"media-libs/libsdl2[haptitick(+),sound(+)vd,eio(+)]",
"=kde-frameworks/kcodecs-6.19*86",
"=dev-ml/stdio-0.17*t:=[ocamlopt?]",
+ ">=dev-libs/libgee-0-8.5:0..8=",
];
for atom in atoms {