Make CharClasses and FullCodeCharKind public

This commit is contained in:
Seiichi Uchida 2017-12-09 20:23:48 +09:00
parent 6d78bd5fdc
commit d1e5d7866b

View File

@ -581,7 +581,7 @@ pub fn remove_trailing_white_spaces(text: &str) -> String {
buffer
}
struct CharClasses<T>
pub struct CharClasses<T>
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<T> {
pub fn new(base: T) -> CharClasses<T> {
CharClasses {
base: base.peekable(),
status: CharClassesStatus::Normal,