Skip to content

Commit

Permalink
Fix map! argument handling
Browse files Browse the repository at this point in the history
Fix #58
  • Loading branch information
Geal committed Jul 3, 2015
1 parent 700c942 commit 240f3b2
Showing 1 changed file with 16 additions and 9 deletions.
25 changes: 16 additions & 9 deletions src/macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,22 @@ macro_rules! flat_map(
/// maps a function on the result of a parser
#[macro_export]
macro_rules! map(
($i:expr, $submac:ident!( $($args:tt)* ), $g:expr) => (
map_impl!($i, $submac!($($args)*), call!($g));
);
($i:expr, $submac:ident!( $($args:tt)* ), $submac2:ident!( $($args2:tt)* )) => (
map_impl!($i, $submac!($($args)*), $submac2!($($args2)*),);
);
($i:expr, $f:expr, $g:expr) => (
map_impl!($i, call!($f), call!($g));
);
($i:expr, $f:expr, $submac:ident!( $($args:tt)* )) => (
map_impl!($i, call!($f), $submac!($($args)*));
);
);

#[macro_export]
macro_rules! map_impl(
($i:expr, $submac:ident!( $($args:tt)* ), $submac2:ident!( $($args2:tt)* )) => (
{
match $submac!($i, $($args)*) {
Expand All @@ -305,15 +321,6 @@ macro_rules! map(
}
}
);
($i:expr, $submac:ident!( $($args:tt)* ), $g:expr) => (
map!($i, $submac!($($args)*), call!($g));
);
($i:expr, $f:expr, $g:expr) => (
map!($i, call!($f), call!($g));
);
($i:expr, $f:expr, $submac:ident!( $($args:tt)* )) => (
map!($i, call!($f), $submac!($($args)*));
);
);

/// maps a function returning a Result on the output of a parser
Expand Down

0 comments on commit 240f3b2

Please sign in to comment.