From d1e5d7866b3dc39481ba5e83287ba5078963137e Mon Sep 17 00:00:00 2001 From: Seiichi Uchida Date: Sat, 9 Dec 2017 20:23:48 +0900 Subject: [PATCH] Make CharClasses and FullCodeCharKind public --- src/comment.rs | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/src/comment.rs b/src/comment.rs index 8cd491b6ee3..bf462e38b7a 100644 --- a/src/comment.rs +++ b/src/comment.rs @@ -581,7 +581,7 @@ pub fn remove_trailing_white_spaces(text: &str) -> String { buffer } -struct CharClasses +pub struct CharClasses where T: Iterator, T::Item: RichChar, @@ -606,6 +606,12 @@ impl RichChar for (usize, char) { } } +impl RichChar for (char, usize) { + fn get_char(&self) -> char { + self.0 + } +} + #[derive(PartialEq, Eq, Debug, Clone, Copy)] enum CharClassesStatus { Normal, @@ -635,7 +641,7 @@ pub enum CodeCharKind { /// describing opening and closing of comments for ease when chunking /// code from tagged characters #[derive(PartialEq, Eq, Debug, Clone, Copy)] -enum FullCodeCharKind { +pub enum FullCodeCharKind { Normal, /// The first character of a comment, there is only one for a comment (always '/') StartComment, @@ -649,7 +655,7 @@ enum FullCodeCharKind { } impl FullCodeCharKind { - fn is_comment(&self) -> bool { + pub fn is_comment(&self) -> bool { match *self { FullCodeCharKind::StartComment | FullCodeCharKind::InComment @@ -658,6 +664,10 @@ impl FullCodeCharKind { } } + pub fn is_string(&self) -> bool { + *self == FullCodeCharKind::InString + } + fn to_codecharkind(&self) -> CodeCharKind { if self.is_comment() { CodeCharKind::Comment @@ -672,7 +682,7 @@ where T: Iterator, T::Item: RichChar, { - fn new(base: T) -> CharClasses { + pub fn new(base: T) -> CharClasses { CharClasses { base: base.peekable(), status: CharClassesStatus::Normal,