span_before in quoted string

This commit is contained in:
ConnorSkees 2020-05-24 16:27:07 -04:00
parent 8d4b4bedbe
commit 3c129780d0
5 changed files with 12 additions and 9 deletions

View File

@ -123,7 +123,7 @@ impl Attribute {
let value = match peek.kind { let value = match peek.kind {
q @ '\'' | q @ '"' => { q @ '\'' | q @ '"' => {
toks.next(); toks.next();
match parse_quoted_string(toks, scope, q, super_selector)?.node { match parse_quoted_string(toks, scope, q, super_selector, span_before)?.node {
Value::String(s, ..) => s, Value::String(s, ..) => s,
_ => unreachable!(), _ => unreachable!(),
} }

View File

@ -256,6 +256,7 @@ impl<'a> StyleSheetParser<'a> {
&Scope::new(), &Scope::new(),
q, q,
&Selector::new(), &Selector::new(),
next.pos,
)? )?
.node .node
.unquote() .unquote()

View File

@ -281,13 +281,13 @@ pub(crate) fn parse_quoted_string<I: Iterator<Item = Token>>(
scope: &Scope, scope: &Scope,
q: char, q: char,
super_selector: &Selector, super_selector: &Selector,
span_before: Span,
) -> SassResult<Spanned<Value>> { ) -> SassResult<Spanned<Value>> {
let mut s = String::new(); let mut s = String::new();
let mut span = if let Some(tok) = toks.peek() { let mut span = toks
tok.pos() .peek()
} else { .ok_or((format!("Expected {}.", q), span_before))?
todo!() .pos();
};
while let Some(tok) = toks.next() { while let Some(tok) = toks.next() {
span = span.merge(tok.pos()); span = span.merge(tok.pos());
match tok.kind { match tok.kind {

View File

@ -823,7 +823,7 @@ impl Value {
q @ '"' | q @ '\'' => { q @ '"' | q @ '\'' => {
let span_start = toks.next().unwrap().pos(); let span_start = toks.next().unwrap().pos();
let Spanned { node, span } = let Spanned { node, span } =
match parse_quoted_string(toks, scope, q, super_selector) { match parse_quoted_string(toks, scope, q, super_selector, span_start) {
Ok(v) => v, Ok(v) => v,
Err(e) => return Some(Err(e)), Err(e) => return Some(Err(e)),
}; };

View File

@ -224,7 +224,9 @@ error!(
ident_colon_closing_brace, ident_colon_closing_brace,
"r:}", "Error: Expected expression." "r:}", "Error: Expected expression."
); );
error!(dollar_sign_alone, "$", "Error: Expected identifier.");
error!( error!(
dollar_sign_alone, nothing_after_dbl_quote,
"$", "Error: Expected identifier." "a {color: \"", "Error: Expected \"."
); );
error!(nothing_after_sgl_quote, "a {color: '", "Error: Expected '.");