use pups_core::{Input, Mode, ParseResult, Parser};
use unicode_ident::{
is_xid_continue,
is_xid_start
};
pub trait Character where
Self: Sized
{
fn next_in(string: &str) -> Option<Self>;
fn is_ascii_decimal(&self) -> bool;
fn is_newline(&self) -> bool;
fn is_whitespace(&self) -> bool;
fn length(&self) -> usize;
fn is_unicode_identifier_start(&self) -> bool;
fn is_unicode_identifier_continuation(&self) -> bool;
fn write(&self, buffer: &mut String);
}
impl Character for char {
fn next_in(string: &str) -> Option<Self> { string.chars().next() }
fn is_ascii_decimal(&self) -> bool { self.is_ascii_digit() }
fn is_newline(&self) -> bool {
matches!(self,
'\u{000A}' | '\u{000B}' | '\u{000C}' | '\u{000D}' | '\u{0085}' | '\u{2028}' | '\u{2029}' )
}
fn is_whitespace(&self) -> bool { char::is_whitespace(*self) }
fn length(&self) -> usize { self.len_utf8() }
fn is_unicode_identifier_start(&self) -> bool { is_xid_start(*self) }
fn is_unicode_identifier_continuation(&self) -> bool { is_xid_continue(*self) }
fn write(&self, buffer: &mut String) { buffer.push(*self) }
}