2020-03-29 13:28:17 -04:00
|
|
|
use crate::utils::IsWhitespace;
|
2020-03-19 19:32:11 -04:00
|
|
|
|
2020-04-12 19:37:12 -04:00
|
|
|
use codemap::Span;
|
|
|
|
|
2020-03-29 13:28:17 -04:00
|
|
|
#[derive(Copy, Clone, Debug, Eq, PartialEq)]
|
2020-03-19 19:32:11 -04:00
|
|
|
pub(crate) struct Token {
|
2020-04-12 19:37:12 -04:00
|
|
|
pub pos: Span,
|
2020-03-29 13:28:17 -04:00
|
|
|
pub kind: char,
|
2020-03-19 19:32:11 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
impl Token {
|
2020-04-12 19:37:12 -04:00
|
|
|
pub const fn new(pos: Span, kind: char) -> Self {
|
2020-03-29 13:28:17 -04:00
|
|
|
Self { pos, kind }
|
2020-03-19 19:32:11 -04:00
|
|
|
}
|
|
|
|
|
2020-04-12 19:37:12 -04:00
|
|
|
pub const fn pos(&self) -> Span {
|
2020-03-19 19:32:11 -04:00
|
|
|
self.pos
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
impl IsWhitespace for Token {
|
|
|
|
fn is_whitespace(&self) -> bool {
|
2020-03-29 13:28:17 -04:00
|
|
|
if self.kind.is_whitespace() {
|
2020-03-19 19:32:11 -04:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
false
|
|
|
|
}
|
|
|
|
}
|