summaryrefslogtreecommitdiffstats
path: root/src/path
diff options
context:
space:
mode:
authorRyan Leckey <leckey.ryan@gmail.com>2018-07-02 15:24:10 -0700
committerRyan Leckey <leckey.ryan@gmail.com>2018-07-02 15:24:10 -0700
commit5e5f1a7f000dc227070ccb4bd8e0e3c1c4948282 (patch)
treee0f3a5ee3b40da91dd50699ea5bb338f8fdf2816 /src/path
parentfc1a965519dbb687c28a3cdf903f43b4e1e1d213 (diff)
Fix test failures from upgrade to nom 4
Diffstat (limited to 'src/path')
-rw-r--r--src/path/parser.rs45
1 files changed, 21 insertions, 24 deletions
diff --git a/src/path/parser.rs b/src/path/parser.rs
index b998ee1..1ecd6e7 100644
--- a/src/path/parser.rs
+++ b/src/path/parser.rs
@@ -1,40 +1,37 @@
-use nom::*;
+use nom::{ErrorKind, digit, IResult};
+use nom::types::CompleteStr;
use std::str::{FromStr, from_utf8};
use super::Expression;
-named!(ident_<String>,
- map!(
- map_res!(is_a!(
- "abcdefghijklmnopqrstuvwxyz \
- ABCDEFGHIJKLMNOPQRSTUVWXYZ \
- 0123456789 \
- _-"
- ), from_utf8),
- |s: &str| {
- s.to_string()
- }
- )
+named!(raw_ident<CompleteStr, String>,
+ map!(is_a!(
+ "abcdefghijklmnopqrstuvwxyz \
+ ABCDEFGHIJKLMNOPQRSTUVWXYZ \
+ 0123456789 \
+ _-"
+ ), |s: CompleteStr| {
+ s.to_string()
+ })
);
-named!(integer <isize>,
+named!(integer<CompleteStr, isize>,
map_res!(
- map_res!(
- ws!(digit),
- from_utf8
- ),
- FromStr::from_str
+ ws!(digit),
+ |s: CompleteStr| {
+ s.parse()
+ }
)
);
-named!(ident<Expression>, map!(ident_, Expression::Identifier));
+named!(ident<CompleteStr, Expression>, map!(raw_ident, Expression::Identifier));
#[allow(cyclomatic_complexity)]
-fn postfix(expr: Expression) -> Box<Fn(&[u8]) -> IResult<&[u8], Expression>> {
- Box::new(move |i: &[u8]| {
+fn postfix(expr: Expression) -> Box<Fn(CompleteStr) -> IResult<CompleteStr, Expression>> {
+ Box::new(move |i: CompleteStr| {
alt!(i,
do_parse!(
tag!(".") >>
- id: ident_ >>
+ id: raw_ident >>
(Expression::Child(Box::new(expr.clone()), id))
) |
delimited!(
@@ -54,7 +51,7 @@ fn postfix(expr: Expression) -> Box<Fn(&[u8]) -> IResult<&[u8], Expression>> {
}
pub fn from_str(input: &str) -> Result<Expression, ErrorKind> {
- match ident(input.as_bytes()) {
+ match ident(CompleteStr(input)) {
Ok((mut rem, mut expr)) => {
while !rem.is_empty() {
match postfix(expr)(rem) {