span_before in quoted string
This commit is contained in:
parent
8d4b4bedbe
commit
3c129780d0
@ -123,7 +123,7 @@ impl Attribute {
|
||||
let value = match peek.kind {
|
||||
q @ '\'' | q @ '"' => {
|
||||
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,
|
||||
_ => unreachable!(),
|
||||
}
|
||||
|
@ -256,6 +256,7 @@ impl<'a> StyleSheetParser<'a> {
|
||||
&Scope::new(),
|
||||
q,
|
||||
&Selector::new(),
|
||||
next.pos,
|
||||
)?
|
||||
.node
|
||||
.unquote()
|
||||
|
@ -281,13 +281,13 @@ pub(crate) fn parse_quoted_string<I: Iterator<Item = Token>>(
|
||||
scope: &Scope,
|
||||
q: char,
|
||||
super_selector: &Selector,
|
||||
span_before: Span,
|
||||
) -> SassResult<Spanned<Value>> {
|
||||
let mut s = String::new();
|
||||
let mut span = if let Some(tok) = toks.peek() {
|
||||
tok.pos()
|
||||
} else {
|
||||
todo!()
|
||||
};
|
||||
let mut span = toks
|
||||
.peek()
|
||||
.ok_or((format!("Expected {}.", q), span_before))?
|
||||
.pos();
|
||||
while let Some(tok) = toks.next() {
|
||||
span = span.merge(tok.pos());
|
||||
match tok.kind {
|
||||
|
@ -823,7 +823,7 @@ impl Value {
|
||||
q @ '"' | q @ '\'' => {
|
||||
let span_start = toks.next().unwrap().pos();
|
||||
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,
|
||||
Err(e) => return Some(Err(e)),
|
||||
};
|
||||
|
@ -224,7 +224,9 @@ error!(
|
||||
ident_colon_closing_brace,
|
||||
"r:}", "Error: Expected expression."
|
||||
);
|
||||
error!(dollar_sign_alone, "$", "Error: Expected identifier.");
|
||||
error!(
|
||||
dollar_sign_alone,
|
||||
"$", "Error: Expected identifier."
|
||||
nothing_after_dbl_quote,
|
||||
"a {color: \"", "Error: Expected \"."
|
||||
);
|
||||
error!(nothing_after_sgl_quote, "a {color: '", "Error: Expected '.");
|
||||
|
Loading…
x
Reference in New Issue
Block a user