Struct flood_tide::Lex[][src]

pub struct Lex<'a> { /* fields omitted */ }
Expand description

Lexical analyzer

this is analyzing command line arguments, returning tokens.

Examples

#[cfg(not(feature = "long_only"))]
#[cfg(feature = "option_argument")]
{
    use flood_tide::{Arg, Lex, Opt, OptNum};
     
    #[rustfmt::skip]
    let args = ["-ab", "--barn", "--eat", "jum"];
     
    #[rustfmt::skip]
    #[repr(u8)]
    #[derive(Debug, PartialEq)]
    enum CmdOP { A = 1, Barn, Eat, };
    impl CmdOP { pub const fn to(self) -> OptNum { self as OptNum } }
      
    #[rustfmt::skip]
    const OPT_ARY: [Opt;3] = [
        Opt { sho: b'a', lon: "",     has: Arg::No,  num: CmdOP::A.to(), },
        Opt { sho: b'b', lon: "barn", has: Arg::No,  num: CmdOP::Barn.to(), },
        Opt { sho: 0u8,  lon: "eat",  has: Arg::Yes, num: CmdOP::Eat.to(), },
    ];
    #[rustfmt::skip]
    const OPT_ARY_SHO_IDX: [(u8,usize);2] = [(b'a',0),(b'b',1)];
    
    let lex = Lex::create_with(&OPT_ARY, &OPT_ARY_SHO_IDX);
    let tokens = match lex.tokens_from(&args) {
        Ok(t) => t,
        Err(e) => unreachable!(),
    };
}

Implementations

create lexical analyzer

setup subcommand ary

analyze and return tokens

Trait Implementations

Formats the value using the given formatter. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.