use crate::loc_ext::LocExt;
use crate::source::DecodedInput;
use crate::Loc;
#[repr(C)]
#[derive(Debug, Clone, PartialEq, Eq)]
pub enum CommentType {
Inline,
Document,
Unknown,
}
#[repr(C)]
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct Comment {
pub location: Loc,
pub kind: CommentType,
}
impl Comment {
pub fn new(location: Loc, input: &DecodedInput) -> Self {
let kind = match location.source(input) {
Some(source) => {
if source.starts_with('#') {
CommentType::Inline
} else if source.starts_with("=begin") {
CommentType::Document
} else {
CommentType::Unknown
}
}
None => CommentType::Unknown,
};
Self { location, kind }
}
}