Changeset - 4eed8a486a3b
[Not reviewed]
default
0 1 0
Laman - 10 months ago 2024-06-19 23:41:57

removed Symbol.value
1 file changed with 2 insertions and 3 deletions:
0 comments (0 inline, 0 general)
src/regexp/token.rs
Show inline comments
 
@@ -26,26 +26,25 @@ impl fmt::Display for ParsingError {
 
		}
 
	}
 
}
 

	
 
pub trait Token {
 
	fn is_skippable(&self) -> bool {false}
 
	fn list_first(&self) -> Vec<usize>;
 
	fn list_last(&self) -> Vec<usize>;
 
	fn list_neighbours(&self) -> Vec<(usize, usize)>;
 
}
 

	
 
pub struct Symbol {
 
	position: usize,
 
	value: char
 
	position: usize
 
}
 

	
 
pub struct Asterisk {
 
	content: Box<dyn Token>
 
}
 

	
 
pub struct Plus {
 
	content: Box<dyn Token>
 
}
 

	
 
pub struct Chain {
 
	content: Vec<Box<dyn Token>>
 
@@ -191,25 +190,25 @@ pub fn parse(pattern: &String, offset: u
 
				res.push(Box::new(Asterisk{content: token}));
 
				i += 1;
 
			}
 
			'+' => {
 
				let token = res.pop().ok_or(ParsingError::Plus{s: pattern.clone(), pos: i})?;
 
				res.push(Box::new(Plus{content: token}));
 
				i += 1;
 
			}
 
			')' => {
 
				return Err(ParsingError::OpeningParenthesis {s: pattern.clone(), pos: i});
 
			}
 
			c => {
 
				res.push(Box::new(Symbol{position: i+offset, value: c}));
 
				res.push(Box::new(Symbol{position: i+offset}));
 
				i += 1;
 
			}
 
		}
 
	}
 

	
 
	return Ok(Chain{content: res});
 
}
 

	
 
mod test {
 
	use super::*;
 

	
 
	#[test]
0 comments (0 inline, 0 general)