aboutsummaryrefslogtreecommitdiffstats
path: root/src/parse/mod.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/parse/mod.rs')
-rw-r--r--src/parse/mod.rs20
1 files changed, 19 insertions, 1 deletions
diff --git a/src/parse/mod.rs b/src/parse/mod.rs
index 5815730..b475943 100644
--- a/src/parse/mod.rs
+++ b/src/parse/mod.rs
@@ -1537,8 +1537,26 @@ impl<'a> Cursor<'a> {
matches!(self.buf[0], b' ' | b'\t' | b'\n' | b'\r')
}
+ fn peek_comment(&self) -> bool {
+ self.has() && self.peek() == b'#'
+ }
+
+ fn consume_comment(&mut self) {
+ assert_eq!(self.adv(), b'#');
+ while self.has() && self.peek() != b'\n' {
+ self.adv();
+ }
+ }
+
fn spaces(&mut self) {
- while self.peek_space() {
+ while {
+ if self.peek_comment() {
+ self.consume_comment();
+ true
+ } else {
+ self.peek_space()
+ }
+ } {
self.adv();
self.spaced = true;
}