add unit field to ident eating
This commit is contained in:
parent
9790846c99
commit
e07ceda8c7
@ -616,7 +616,7 @@ pub(crate) fn eat_expr<I: Iterator<Item = Token>>(
|
|||||||
values.push(toks.next().unwrap());
|
values.push(toks.next().unwrap());
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
let name = eat_ident_no_interpolation(toks)?;
|
let name = eat_ident_no_interpolation(toks, false)?;
|
||||||
devour_whitespace(toks);
|
devour_whitespace(toks);
|
||||||
if toks.peek().unwrap().kind == ':' {
|
if toks.peek().unwrap().kind == ':' {
|
||||||
toks.next();
|
toks.next();
|
||||||
|
@ -258,7 +258,7 @@ impl Selector {
|
|||||||
inner.push(match tok.kind {
|
inner.push(match tok.kind {
|
||||||
_ if is_selector_name_char(tok.kind) => {
|
_ if is_selector_name_char(tok.kind) => {
|
||||||
inner.push(SelectorKind::Element(
|
inner.push(SelectorKind::Element(
|
||||||
eat_ident_no_interpolation(&mut iter)?.node,
|
eat_ident_no_interpolation(&mut iter, false)?.node,
|
||||||
));
|
));
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -269,14 +269,14 @@ impl Selector {
|
|||||||
'.' => {
|
'.' => {
|
||||||
iter.next();
|
iter.next();
|
||||||
inner.push(SelectorKind::Class(
|
inner.push(SelectorKind::Class(
|
||||||
eat_ident_no_interpolation(&mut iter)?.node,
|
eat_ident_no_interpolation(&mut iter, false)?.node,
|
||||||
));
|
));
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
'#' => {
|
'#' => {
|
||||||
iter.next();
|
iter.next();
|
||||||
inner.push(SelectorKind::Id(
|
inner.push(SelectorKind::Id(
|
||||||
eat_ident_no_interpolation(&mut iter)?.node,
|
eat_ident_no_interpolation(&mut iter, false)?.node,
|
||||||
));
|
));
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -284,7 +284,7 @@ impl Selector {
|
|||||||
iter.next();
|
iter.next();
|
||||||
is_invisible = true;
|
is_invisible = true;
|
||||||
inner.push(SelectorKind::Placeholder(
|
inner.push(SelectorKind::Placeholder(
|
||||||
eat_ident_no_interpolation(&mut iter)?.node,
|
eat_ident_no_interpolation(&mut iter, false)?.node,
|
||||||
));
|
));
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -371,7 +371,7 @@ impl Selector {
|
|||||||
false
|
false
|
||||||
};
|
};
|
||||||
if is_selector_name_char(toks.peek().unwrap().kind) {
|
if is_selector_name_char(toks.peek().unwrap().kind) {
|
||||||
let name = eat_ident_no_interpolation(toks)?.node;
|
let name = eat_ident_no_interpolation(toks, false)?.node;
|
||||||
Ok(
|
Ok(
|
||||||
if toks.peek().is_some() && toks.peek().unwrap().kind == '(' {
|
if toks.peek().is_some() && toks.peek().unwrap().kind == '(' {
|
||||||
toks.next();
|
toks.next();
|
||||||
|
@ -533,6 +533,7 @@ pub(crate) fn eat_ident<I: Iterator<Item = Token>>(
|
|||||||
|
|
||||||
pub(crate) fn eat_ident_no_interpolation<I: Iterator<Item = Token>>(
|
pub(crate) fn eat_ident_no_interpolation<I: Iterator<Item = Token>>(
|
||||||
toks: &mut Peekable<I>,
|
toks: &mut Peekable<I>,
|
||||||
|
unit: bool,
|
||||||
) -> SassResult<Spanned<String>> {
|
) -> SassResult<Spanned<String>> {
|
||||||
let mut span = toks.peek().unwrap().pos();
|
let mut span = toks.peek().unwrap().pos();
|
||||||
let mut text = String::new();
|
let mut text = String::new();
|
||||||
@ -542,7 +543,7 @@ pub(crate) fn eat_ident_no_interpolation<I: Iterator<Item = Token>>(
|
|||||||
if toks.peek().unwrap().kind == '-' {
|
if toks.peek().unwrap().kind == '-' {
|
||||||
toks.next();
|
toks.next();
|
||||||
text.push('-');
|
text.push('-');
|
||||||
text.push_str(&ident_body(toks, false, span)?.node);
|
text.push_str(&ident_body(toks, unit, span)?.node);
|
||||||
return Ok(Spanned { node: text, span });
|
return Ok(Spanned { node: text, span });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -561,7 +562,7 @@ pub(crate) fn eat_ident_no_interpolation<I: Iterator<Item = Token>>(
|
|||||||
return Err(("Expected identifier.", first.pos()).into());
|
return Err(("Expected identifier.", first.pos()).into());
|
||||||
}
|
}
|
||||||
|
|
||||||
let body = ident_body(toks, false, span)?;
|
let body = ident_body(toks, unit, span)?;
|
||||||
span = span.merge(body.span);
|
span = span.merge(body.span);
|
||||||
text.push_str(&body.node);
|
text.push_str(&body.node);
|
||||||
Ok(Spanned { node: text, span })
|
Ok(Spanned { node: text, span })
|
||||||
|
@ -607,7 +607,7 @@ impl Value {
|
|||||||
let unit = if let Some(tok) = toks.peek() {
|
let unit = if let Some(tok) = toks.peek() {
|
||||||
match tok.kind {
|
match tok.kind {
|
||||||
'a'..='z' | 'A'..='Z' | '_' => {
|
'a'..='z' | 'A'..='Z' | '_' => {
|
||||||
let u = eat_ident(toks, scope, super_selector)?;
|
let u = eat_ident_no_interpolation(toks, true)?;
|
||||||
span = span.merge(u.span);
|
span = span.merge(u.span);
|
||||||
Unit::from(&u.node)
|
Unit::from(&u.node)
|
||||||
}
|
}
|
||||||
@ -708,7 +708,7 @@ impl Value {
|
|||||||
}
|
}
|
||||||
'$' => {
|
'$' => {
|
||||||
toks.next();
|
toks.next();
|
||||||
let val = eat_ident_no_interpolation(toks)?;
|
let val = eat_ident_no_interpolation(toks, false)?;
|
||||||
Ok(IntermediateValue::Value(Spanned {
|
Ok(IntermediateValue::Value(Spanned {
|
||||||
node: scope.get_var(val.clone())?.node,
|
node: scope.get_var(val.clone())?.node,
|
||||||
span: val.span,
|
span: val.span,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user