/// Proceeds with parsing.
///
/// Spits out a `Grammar` if string is valid wildcard representation,
/// or some `GrammarParseError` otherwise.
Proceeds with parsing.
Spits out a `Grammar` if string is valid wildcard representation,
or some `GrammarParseError` otherwise.
Proceeds with parsing . Spits out a ` Grammar ` if string is valid wildcard representation or some ` GrammarParseError ` otherwise .
fn run(&mut self) -> Result<Wildcard<'a>, WildcardParseError> {
        use Production::*;
        use Choice::*;
        use WildcardParseError::*;
        let mut token = Sequence(self.source);
        let mut iter = self.source.char_indices();
        let mut prev: (usize, char) = Default::default();
        while let Some((index, c)) = iter.next() {
            if self.start.is_none() {
                self.start = Some(index);
            }
            match c {
                '*' =>
                    if let Sequence(_) = &token {
                        self.flush(index);
                        self.reset_capture();
                        self.push(ManyOf(Vec::new()));
                    },
                '?' =>
                    if let Sequence(_) = &token {
                        self.flush(index);
                        self.reset_capture();
                        self.push(OneOf(Vec::new()));
                    },
                '[' =>
                    if let Sequence(_) = &token {
                        self.flush(index);
                        token = OneOf(Vec::new());
                        let (index, c) = iter.next().ok_or(Incomplete)?;
                        self.start_capture(index);
                        if '!' == c {
                            self.negate = true;
                            self.reset_capture();
                        }
                    },
                '-' => {
                    if let OneOf(choices) = &mut token {
                        if let Some(capture) = self.capture(prev.0) {
                            choices.push(AnyOf(capture));
                        }
                        let (_, c) = iter.next().ok_or(Incomplete)?;
                        if c < prev.1 {
                            return Err(InvalidCharRange(prev.1, c))
                        }
                        self.reset_capture();
                        choices.push(Range(prev.1, c));
                    }
                }
                ']' =>
                    if let OneOf(choices) = &mut token {
                        if let Some(capture) = self.capture(index) {
                            choices.push(AnyOf(capture));
                        }
                        let token = std::mem::replace(&mut token, Sequence(self.source));
                        self.reset_capture();
                        self.push(token);
                    }
                _ =>
                    ()
            }
            prev = (index, c);
        }
        if let Sequence(_) = &token {
            self.flush(self.source.len());
            let result = std::mem::replace(&mut self.result, Wildcard::new());
            Ok(result)
        }
        else {
            Err(WildcardParseError::Incomplete)
        }
    }
fn run ( & mut self ) -> Result < Wildcard < ' a > , WildcardParseError > { use Production :: * ; use Choice :: * ; use WildcardParseError :: * ; let mut token = Sequence ( self . source ) ; let mut iter = self . source . char_indices ( ) ; let mut prev : ( usize , char ) = Default :: default ( ) ; while let Some ( ( index , c ) ) = iter . next ( ) { if self . start . is_none ( ) { self . start = Some ( index ) ; } match c { '*' => if let Sequence ( _ ) = & token { self . flush ( index ) ; self . reset_capture ( ) ; self . push ( ManyOf ( Vec :: new ( ) ) ) ; } , '?' => if let Sequence ( _ ) = & token { self . flush ( index ) ; self . reset_capture ( ) ; self . push ( OneOf ( Vec :: new ( ) ) ) ; } , '[' => if let Sequence ( _ ) = & token { self . flush ( index ) ; token = OneOf ( Vec :: new ( ) ) ; let ( index , c ) = iter . next ( ) . ok_or ( Incomplete ) ? ; self . start_capture ( index ) ; if '!' == c { self . negate = true ; self . reset_capture ( ) ; } } , '-' => { if let OneOf ( choices ) = & mut token { if let Some ( capture ) = self . capture ( prev . 0 ) { choices . push ( AnyOf ( capture ) ) ; } let ( _ , c ) = iter . next ( ) . ok_or ( Incomplete ) ? ; if c < prev . 1 { return Err ( InvalidCharRange ( prev . 1 , c ) ) } self . reset_capture ( ) ; choices . push ( Range ( prev . 1 , c ) ) ; } } ']' => if let OneOf ( choices ) = & mut token { if let Some ( capture ) = self . capture ( index ) { choices . push ( AnyOf ( capture ) ) ; } let token = std :: mem :: replace ( & mut token , Sequence ( self . source ) ) ; self . reset_capture ( ) ; self . push ( token ) ; } _ => ( ) } prev = ( index , c ) ; } if let Sequence ( _ ) = & token { self . flush ( self . source . len ( ) ) ; let result = std :: mem :: replace ( & mut self . result , Wildcard :: new ( ) ) ; Ok ( result ) } else { Err ( WildcardParseError :: Incomplete ) } }
Proceeds with parsing.
Proceeds with parsing .
&mut self