From e07ceda8c7f6b547aa6ff009d6d78a33e0dd012f Mon Sep 17 00:00:00 2001 From: ConnorSkees <39542938+ConnorSkees@users.noreply.github.com> Date: Mon, 20 Apr 2020 03:20:08 -0400 Subject: [PATCH] add unit field to ident eating --- src/lib.rs | 2 +- src/selector/mod.rs | 10 +++++----- src/utils.rs | 5 +++-- src/value/parse.rs | 4 ++-- 4 files changed, 11 insertions(+), 10 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index 34ce876..8093905 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -616,7 +616,7 @@ pub(crate) fn eat_expr>( values.push(toks.next().unwrap()); continue; } - let name = eat_ident_no_interpolation(toks)?; + let name = eat_ident_no_interpolation(toks, false)?; devour_whitespace(toks); if toks.peek().unwrap().kind == ':' { toks.next(); diff --git a/src/selector/mod.rs b/src/selector/mod.rs index 299152b..52015df 100644 --- a/src/selector/mod.rs +++ b/src/selector/mod.rs @@ -258,7 +258,7 @@ impl Selector { inner.push(match tok.kind { _ if is_selector_name_char(tok.kind) => { inner.push(SelectorKind::Element( - eat_ident_no_interpolation(&mut iter)?.node, + eat_ident_no_interpolation(&mut iter, false)?.node, )); continue; } @@ -269,14 +269,14 @@ impl Selector { '.' => { iter.next(); inner.push(SelectorKind::Class( - eat_ident_no_interpolation(&mut iter)?.node, + eat_ident_no_interpolation(&mut iter, false)?.node, )); continue; } '#' => { iter.next(); inner.push(SelectorKind::Id( - eat_ident_no_interpolation(&mut iter)?.node, + eat_ident_no_interpolation(&mut iter, false)?.node, )); continue; } @@ -284,7 +284,7 @@ impl Selector { iter.next(); is_invisible = true; inner.push(SelectorKind::Placeholder( - eat_ident_no_interpolation(&mut iter)?.node, + eat_ident_no_interpolation(&mut iter, false)?.node, )); continue; } @@ -371,7 +371,7 @@ impl Selector { false }; 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( if toks.peek().is_some() && toks.peek().unwrap().kind == '(' { toks.next(); diff --git a/src/utils.rs b/src/utils.rs index e40bb96..e8ff368 100644 --- a/src/utils.rs +++ b/src/utils.rs @@ -533,6 +533,7 @@ pub(crate) fn eat_ident>( pub(crate) fn eat_ident_no_interpolation>( toks: &mut Peekable, + unit: bool, ) -> SassResult> { let mut span = toks.peek().unwrap().pos(); let mut text = String::new(); @@ -542,7 +543,7 @@ pub(crate) fn eat_ident_no_interpolation>( if toks.peek().unwrap().kind == '-' { toks.next(); 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 }); } } @@ -561,7 +562,7 @@ pub(crate) fn eat_ident_no_interpolation>( 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); text.push_str(&body.node); Ok(Spanned { node: text, span }) diff --git a/src/value/parse.rs b/src/value/parse.rs index 0fcb68a..8fd8710 100644 --- a/src/value/parse.rs +++ b/src/value/parse.rs @@ -607,7 +607,7 @@ impl Value { let unit = if let Some(tok) = toks.peek() { match tok.kind { '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); Unit::from(&u.node) } @@ -708,7 +708,7 @@ impl Value { } '$' => { toks.next(); - let val = eat_ident_no_interpolation(toks)?; + let val = eat_ident_no_interpolation(toks, false)?; Ok(IntermediateValue::Value(Spanned { node: scope.get_var(val.clone())?.node, span: val.span,