diff --git a/src/regexp/token.rs b/src/regexp/token.rs --- a/src/regexp/token.rs +++ b/src/regexp/token.rs @@ -52,6 +52,7 @@ pub struct Chain { } pub enum Token { + Lambda, Symbol(Symbol), Asterisk(Asterisk), Plus(Plus), @@ -225,6 +226,7 @@ impl Chain { impl Token { pub fn is_skippable(&self) -> bool { match self { + Token::Lambda => true, Token::Symbol(_) => false, Token::Asterisk(_) => true, Token::Plus(_) => false, @@ -236,6 +238,7 @@ impl Token { pub fn list_first(&self) -> Vec { match self { + Token::Lambda => vec![], Token::Symbol(t) => t.list_first(), Token::Asterisk(t) => t.list_first(), Token::Plus(t) => t.list_first(), @@ -247,6 +250,7 @@ impl Token { pub fn list_last(&self) -> Vec { match self { + Token::Lambda => vec![], Token::Symbol(t) => t.list_last(), Token::Asterisk(t) => t.list_last(), Token::Plus(t) => t.list_last(), @@ -258,6 +262,7 @@ impl Token { pub fn list_neighbours(&self) -> Vec<(usize, usize)> { match self { + Token::Lambda => vec![], Token::Symbol(t) => t.list_neighbours(), Token::Asterisk(t) => t.list_neighbours(), Token::Plus(t) => t.list_neighbours(), @@ -313,6 +318,10 @@ pub fn parse(pattern: &String, offset: u res.push(Box::new(Token::AlternativeSeparator)); i += 1; } + '_' => { + res.push(Box::new(Token::Lambda)); + i += 1; + } _c => { res.push(Box::new(Token::Symbol(Symbol{position: i+offset}))); i += 1;