nom::named! [] [src]

macro_rules! named (
    ($name:ident( $i:ty ) -> $o:ty, $submac:ident!( $($args:tt)* )) => (
        fn $name<'a>( i: $i ) -> $crate::IResult<'a,$i,$o> {
            $submac!(i, $($args)*)
        }
    );
    ($name:ident<$i:ty,$o:ty>, $submac:ident!( $($args:tt)* )) => (
        fn $name( i: $i ) -> $crate::IResult<$i, $o> {
            $submac!(i, $($args)*)
        }
    );
    ($name:ident<$o:ty>, $submac:ident!( $($args:tt)* )) => (
        fn $name<'a>( i: &'a[u8] ) -> $crate::IResult<'a, &'a [u8], $o> {
            $submac!(i, $($args)*)
        }
    );
    ($name:ident<$life:item,$i:ty,$o:ty>, $submac:ident!( $($args:tt)* )) => (
        fn $name<$life>( i: $i ) -> $crate::IResult<$life,$i, $o> {
            $submac!(i, $($args)*)
        }
    );
    ($name:ident, $submac:ident!( $($args:tt)* )) => (
        fn $name<'a>( i: &'a [u8] ) -> $crate::IResult<'a,&[u8], &[u8]> {
            $submac!(i, $($args)*)
        }
    );
    (pub $name:ident( $i:ty ) -> $o:ty, $submac:ident!( $($args:tt)* )) => (
        pub fn $name<'a>( i: $i ) -> $crate::IResult<'a,$i,$o> {
            $submac!(i, $($args)*)
        }
    );
    (pub $name:ident<$i:ty,$o:ty>, $submac:ident!( $($args:tt)* )) => (
        pub fn $name( i: $i ) -> $crate::IResult<$i, $o> {
            $submac!(i, $($args)*)
        }
    );
    (pub $name:ident<$o:ty>, $submac:ident!( $($args:tt)* )) => (
        pub fn $name<'a>( i: &'a[u8] ) -> $crate::IResult<'a, &'a [u8], $o> {
            $submac!(i, $($args)*)
        }
    );
    (pub $name:ident, $submac:ident!( $($args:tt)* )) => (
        pub fn $name<'a>( i: &'a [u8] ) -> $crate::IResult<'a,&[u8], &[u8]> {
            $submac!(i, $($args)*)
        }
    );
);

Makes a function from a parser combination

The type can be set up if the compiler needs more information

named!(my_function( &[u8] ) -> &[u8], tag!("abcd"));
// first type parameter is input, second is output
named!(my_function<&[u8], &[u8]>,     tag!("abcd"));
// will have &[u8] as input type, &[u8] as output type
named!(my_function,                   tag!("abcd"));
// will use &[u8] as input type (use this if the compiler
// complains about lifetime issues
named!(my_function<&[u8]>,            tag!("abcd"));
//prefix them with 'pub' to make the functions public
named!(pub my_function,               tag!("abcd"));