Compare commits

..

No commits in common. "master" and "v0.2.4" have entirely different histories.

3 changed files with 35 additions and 59 deletions

View File

@ -1,6 +1,6 @@
[package]
name = "abortable_parser"
version = "0.2.5"
version = "0.2.4"
authors = ["Jeremy Wall <jeremy@marzhillstudios.com>"]
description = "A parser combinator library with an emphasis on error handling"
repository = "https://github.com/zaphar/abortable_parser"

View File

@ -63,14 +63,12 @@ macro_rules! not {
}};
($i:expr, $f:ident( $( $args:tt )* ) ) => {
use $crate::run
$crate::not!($i, run!($f($($args)*)))
};
($i:expr, $f:ident) => {{
use $crate::run;
($i:expr, $f:ident) => {
$crate::not!($i, run!($f))
}};
};
}
/// Checks the given matcher without consuming the input.
@ -182,15 +180,13 @@ macro_rules! with_err {
}
}};
($i:expr, $f:ident( $( $args:tt )* ), $e:expr ) => {{
use $crate::run;
($i:expr, $f:ident( $( $args:tt )* ), $e:expr ) => {
$crate::with_err!($i, run!($f($($args)*)), $e:expr)
}};
};
($i:expr, $f:ident, $e:expr) => {{
use $crate::run;
($i:expr, $f:ident, $e:expr) => {
$crate::with_err!($i, run!($f), $e)
}};
};
}
/// Wraps any Error return from a subparser in another error. Stores the position at
@ -300,8 +296,7 @@ macro_rules! complete {
};
($i:expr, $efn:expr, $f:ident) => {
use $crate::run
$crate::complete!($i, $efn, run!($f))
$crate::complete!($i, $efn, $crate::run!($f))
};
}
@ -455,13 +450,13 @@ macro_rules! do_each {
macro_rules! either {
// Initialization case.
($i:expr, $f:ident!( $( $args:tt )* ), $( $rest:tt)* ) => { // 0
$crate::either!(__impl $i, $f!( $($args)* ), $($rest)*)
either!(__impl $i, $f!( $($args)* ), $($rest)*)
};
// Initialization case.
($i:expr, $f:ident, $($rest:tt)* ) => {{ // 1
use $crate::run;
$crate::either!(__impl $i, run!($f), $($rest)*)
either!(__impl $i, run!($f), $($rest)*)
}};
// Initialization failure case.
@ -472,24 +467,24 @@ macro_rules! either {
// Initialization failure case.
($i:expr, $f:ident) => {{ // 3
use $crate::run;
$crate::either!($i, run!($f))
either!($i, run!($f))
}};
// Termination clause
(__impl $i:expr, $f:ident) => {{ // 4
use $crate::run;
$crate::either!(__impl $i, run!($f))
either!(__impl $i, run!($f))
}};
// Termination clause
(__impl $i:expr, $f:ident,) => {{ // 5
use $crate::run;
$crate::either!(__impl $i, run!($f))
either!(__impl $i, run!($f))
}};
// Termination clause
(__impl $i:expr, $f:ident!( $( $args:tt )* ),) => { // 6
$crate::either!(__impl $i, $f!($($args)*) __end)
either!(__impl $i, $f!($($args)*) __end)
};
// Termination clause
@ -538,7 +533,7 @@ macro_rules! either {
// Internal Loop Implementation
(__impl $i:expr, $f:ident, $( $rest:tt )* ) => {{ // 9
use $crate::run;
$crate::either!(__impl $i, run!($f), $( $rest )* )
either!(__impl $i, run!($f), $( $rest )* )
}}
}
@ -587,11 +582,11 @@ where
macro_rules! optional {
($i:expr, $f:ident) => {{
use $crate::run;
$crate::optional!(__impl $i, run!($f))
optional!(__impl $i, run!($f))
}};
($i:expr, $f:ident!( $( $args:tt )* ) ) => {
$crate::optional!(__impl $i, $f!( $( $args )* ))
optional!(__impl $i, $f!( $( $args )* ))
};
(__impl $i:expr, $f:ident!( $( $args:tt )* )) => {{
@ -658,7 +653,7 @@ macro_rules! repeat {
($i:expr, $f:ident) => {{
use $crate::run;
$crate::repeat!($i, run!($f))
repeat!($i, run!($f))
}};
}
@ -714,20 +709,17 @@ macro_rules! separated {
}
}};
($i:expr, $sep_rule:ident, $item_rule:ident ) => {{
use $crate::run;
$crate::separated!($i, run!($sep_rule), run!($item_rule))
}};
($i:expr, $sep_rule:ident, $item_rule:ident ) => {
separated!($i, $crate::run!($sep_rule), $crate::run!($item_rule))
};
($i:expr, $sep_rule:ident!( $( $args:tt )* ), $item_rule:ident ) => {{
use $crate::run;
$crate::separated!($i, $sep_rule!($($args)*), run!($item_rule))
}};
($i:expr, $sep_rule:ident!( $( $args:tt )* ), $item_rule:ident ) => {
separated!($i, $sep_rule!($($args)*), $crate::run!($item_rule))
};
($i:expr, $sep_rule:ident, $item_rule:ident!( $( $args:tt )* ) ) => {{
use $crate::run;
$crate::separated!($i, run!($sep_rule), $item_rule!($($args)*))
}};
($i:expr, $sep_rule:ident, $item_rule:ident!( $( $args:tt )* ) ) => {
separated!($i, $crate::run!($sep_rule), $item_rule!($($args)*))
};
}
/// Convenience macro for looking for a specific text token in a byte input stream.
@ -819,10 +811,9 @@ macro_rules! until {
pfn()
}};
($i:expr, $rule:ident) => {{
use $crate::run;
$crate::until!($i, run!($rule))
}};
($i:expr, $rule:ident) => {
until!($i, $crate::run!($rule))
};
}
/// Discards the output of a combinator rule when it completes and just returns `()`.
@ -831,7 +822,7 @@ macro_rules! until {
macro_rules! discard {
($i:expr, $rule:ident) => {{
use $crate::run;
$crate::discard!($i, run!($rule))
discard!($i, run!($rule))
}};
($i:expr, $rule:ident!( $( $args:tt )* ) ) => {{
@ -913,13 +904,11 @@ macro_rules! make_fn {
};
($name:ident<$i:ty, $o:ty>, $rule:ident) => {
use $crate::run
$crate::make_fn!($name<$i, $o>, run!($rule));
make_fn!($name<$i, $o>, $crate::run!($rule));
};
(pub $name:ident<$i:ty, $o:ty>, $rule:ident) => {
use $crate::run
$crate::make_fn!(pub $name<$i, $o>, run!($rule));
make_fn!(pub $name<$i, $o>, $crate::run!($rule));
};
}
@ -930,7 +919,7 @@ macro_rules! make_fn {
#[macro_export]
macro_rules! input {
($i:expr) => {
$crate::input!($i,)
input!($i,)
};
($i:expr,) => {{
@ -987,7 +976,7 @@ macro_rules! consume_all {
($i:expr, $rule:ident) => {{
use $crate::run;
$crate::consume_all!($i, run!($rule))
consume_all!($i, run!($rule))
}}
}

View File

@ -402,19 +402,6 @@ fn test_until() {
}
}
#[test]
fn test_until_with_function_composition() {
let input_str = "foo ";
let iter = StrIter::new(input_str);
let result = until!(iter, ascii_ws);
assert!(result.is_complete());
if let Result::Complete(i, o) = result {
assert_eq!(i.get_offset(), 3);
assert_eq!(o.len(), 3);
assert_eq!(o, "foo");
}
}
#[test]
fn test_until_abort() {
let input_str = "foo ";