Parse comments in whitespace
This commit is contained in:
parent
a559966c1d
commit
41723eb4ca
2 changed files with 41 additions and 8 deletions
|
|
@ -2,15 +2,25 @@ use std::fmt;
|
|||
|
||||
use crate::span::{HasSpan, Span};
|
||||
|
||||
#[derive(Clone)]
|
||||
pub enum Line {
|
||||
Empty,
|
||||
Comment(String),
|
||||
}
|
||||
|
||||
#[derive(Clone)]
|
||||
pub struct Space {
|
||||
pub comment: Vec<(String, Span)>,
|
||||
pub lines: Vec<Line>,
|
||||
pub span: Span,
|
||||
}
|
||||
|
||||
impl fmt::Debug for Space {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
f.debug_struct("Space").finish()
|
||||
if self.lines.iter().any(|l| matches!(l, Line::Comment(_))) {
|
||||
write!(f, "space with comments")
|
||||
} else {
|
||||
write!(f, "space")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue