make read_until_newline parser method public

This commit is contained in:
Connor Skees 2020-07-10 21:48:19 -04:00
parent 5902ebd642
commit 005f0e52e8
2 changed files with 9 additions and 6 deletions

View File

@ -459,7 +459,13 @@ impl<'a> Parser<'a> {
found_whitespace
}
fn read_until_newline(&mut self) {
/// Eat tokens until a newline
///
/// This exists largely to eat silent comments, "//"
/// We only have to check for \n as the lexing step normalizes all newline characters
///
/// The newline is consumed
pub fn read_until_newline(&mut self) {
while let Some(tok) = self.toks.next() {
if tok.kind == '\n' {
break;

View File

@ -3,10 +3,7 @@ use codemap::Spanned;
use crate::{
common::Identifier,
error::SassResult,
utils::{
peek_ident_no_interpolation, read_until_closing_paren, read_until_closing_quote,
read_until_newline,
},
utils::{peek_ident_no_interpolation, read_until_closing_paren, read_until_closing_quote},
value::Value,
Token,
};
@ -124,7 +121,7 @@ impl<'a> Parser<'a> {
'/' => {
let next = self.toks.next().unwrap();
match self.toks.peek() {
Some(Token { kind: '/', .. }) => read_until_newline(self.toks),
Some(Token { kind: '/', .. }) => self.read_until_newline(),
Some(..) | None => val_toks.push(next),
};
continue;