Fix incomplete errors
diff --git a/src/helper.rs b/src/helper.rs
index 6c9f6e2..eec26d6 100644
--- a/src/helper.rs
+++ b/src/helper.rs
@@ -4,16 +4,29 @@
macro_rules! punct {
($i:expr, $punct:expr) => {
- tuple!($i, opt!(call!(::nom::multispace)), tag_s!($punct))
+ complete!($i, preceded!(opt!(call!(::nom::multispace)), tag_s!($punct)))
};
}
+macro_rules! option (
+ ($i:expr, $submac:ident!( $($args:tt)* )) => ({
+ match $submac!($i, $($args)*) {
+ ::nom::IResult::Done(i, o) => ::nom::IResult::Done(i, Some(o)),
+ ::nom::IResult::Error(_) => ::nom::IResult::Done($i, None),
+ ::nom::IResult::Incomplete(_) => ::nom::IResult::Done($i, None),
+ }
+ });
+ ($i:expr, $f:expr) => (
+ option!($i, call!($f));
+ );
+);
+
macro_rules! opt_vec (
($i:expr, $submac:ident!( $($args:tt)* )) => ({
match $submac!($i, $($args)*) {
::nom::IResult::Done(i, o) => ::nom::IResult::Done(i, o),
::nom::IResult::Error(_) => ::nom::IResult::Done($i, Vec::new()),
- ::nom::IResult::Incomplete(i) => ::nom::IResult::Incomplete(i)
+ ::nom::IResult::Incomplete(_) => ::nom::IResult::Done($i, Vec::new()),
}
});
);