nom::separated_nonempty_list!
[−]
[src]
macro_rules! separated_nonempty_list( ($i:expr, $sep:ident!( $($args:tt)* ), $submac:ident!( $($args2:tt)* )) => ( { let mut begin = 0; let mut remaining = $i.len(); let mut res = Vec::new(); // get the first element match $submac!($i, $($args2)*) { $crate::IResult::Error(a) => $crate::IResult::Error(a), $crate::IResult::Incomplete(i) => $crate::IResult::Incomplete(i), $crate::IResult::Done(i,o) => { if i.len() == $i.len() { $crate::IResult::Error($crate::Err::Position($crate::ErrorCode::SeparatedNonEmptyList as u32,$i)) } else { res.push(o); begin += remaining - i.len(); remaining = i.len(); loop { // get the separator first match $sep!(&$i[begin..], $($args)*) { $crate::IResult::Error(_) => break, $crate::IResult::Incomplete(_) => break, $crate::IResult::Done(i2,_) => { if i2.len() == (&$i[begin..]).len() { break; } begin += remaining - i2.len(); remaining = i2.len(); // get the element next match $submac!(&$i[begin..], $($args2)*) { $crate::IResult::Error(_) => break, $crate::IResult::Incomplete(_) => break, $crate::IResult::Done(i3,o3) => { if i3.len() == $i[begin..].len() { break; } res.push(o3); begin += remaining - i3.len(); remaining = i3.len(); }, } } } } $crate::IResult::Done(&$i[begin..], res) } }, } } ); ($i:expr, $submac:ident!( $($args:tt)* ), $g:expr) => ( separated_nonempty_list!($i, $submac!($($args)*), call!($g)); ); ($i:expr, $f:expr, $submac:ident!( $($args:tt)* )) => ( separated_nonempty_list!($i, call!($f), $submac!($($args)*)); ); ($i:expr, $f:expr, $g:expr) => ( separated_nonempty_list!($i, call!($f), call!($g)); ); );
separated_nonempty_list!(I -> IResult<I,T>, I -> IResult<I,O>) => I -> IResult<I, Vec<O>>
separated_nonempty_list(sep, X) returns Vec