Minimal Imperative Parsing Library | https://docs.rs/mipl
at main 36 lines 822 B view raw
1use super::*; 2 3impl PeekerItem for TabToken { 4 fn from_tok(token: Token) -> Option<Self> { 5 if let Token::Tab(TabToken) = token { 6 Some(TabToken) 7 } else { 8 None 9 } 10 } 11} 12 13/// Match a tab. Works only if the tokenizer 14/// consider the tab character `\t` among the [KeepDelimiters]. 15pub struct IsTab; 16impl Peeker for IsTab { 17 type Item = TabToken; 18 19 fn peek_for_token(&self, parser: &mut Parser) -> Option<Token> { 20 match parser.peek()? { 21 Token::Tab(_) => Some(Token::Tab(TabToken)), 22 _ => None 23 } 24 } 25} 26impl ContainerCp for IsTab { 27 type ContainedType = (); 28 type Input = (); 29 30 fn new_contained(_value: Self::Input) -> Self::ContainedType { 31 () 32 } 33 fn new(_value: Self::Input) -> Self { 34 IsTab 35 } 36}