Rename eat_interpolation()
to parse_interpolation()
This commit is contained in:
parent
06be720f49
commit
3f929066c4
@ -1,6 +1,6 @@
|
|||||||
use crate::common::{Scope, Symbol};
|
use crate::common::{Scope, Symbol};
|
||||||
use crate::utils::{
|
use crate::utils::{
|
||||||
devour_whitespace, devour_whitespace_or_comment, eat_interpolation, IsWhitespace,
|
devour_whitespace, devour_whitespace_or_comment, parse_interpolation, IsWhitespace,
|
||||||
};
|
};
|
||||||
use crate::{Token, TokenKind};
|
use crate::{Token, TokenKind};
|
||||||
use std::fmt::{self, Display};
|
use std::fmt::{self, Display};
|
||||||
@ -283,7 +283,9 @@ impl<'a> SelectorParser<'a> {
|
|||||||
TokenKind::Interpolation => {
|
TokenKind::Interpolation => {
|
||||||
self.is_interpolated = true;
|
self.is_interpolated = true;
|
||||||
let v = self.tokens_to_selectors(
|
let v = self.tokens_to_selectors(
|
||||||
&mut eat_interpolation(tokens, self.scope).into_iter().peekable(),
|
&mut parse_interpolation(tokens, self.scope)
|
||||||
|
.into_iter()
|
||||||
|
.peekable(),
|
||||||
);
|
);
|
||||||
self.is_interpolated = false;
|
self.is_interpolated = false;
|
||||||
v
|
v
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
use crate::common::{Scope, Symbol};
|
use crate::common::{Scope, Symbol};
|
||||||
use crate::utils::{devour_whitespace_or_comment, eat_interpolation};
|
use crate::utils::{devour_whitespace_or_comment, parse_interpolation};
|
||||||
use crate::value::Value;
|
use crate::value::Value;
|
||||||
use crate::{Token, TokenKind};
|
use crate::{Token, TokenKind};
|
||||||
use std::fmt::{self, Display};
|
use std::fmt::{self, Display};
|
||||||
@ -47,7 +47,7 @@ impl<'a> StyleParser<'a> {
|
|||||||
TokenKind::Whitespace(_) | TokenKind::MultilineComment(_) => continue,
|
TokenKind::Whitespace(_) | TokenKind::MultilineComment(_) => continue,
|
||||||
TokenKind::Ident(ref s) => property.push_str(s),
|
TokenKind::Ident(ref s) => property.push_str(s),
|
||||||
TokenKind::Interpolation => property.push_str(
|
TokenKind::Interpolation => property.push_str(
|
||||||
&eat_interpolation(&mut self.tokens, self.scope)
|
&parse_interpolation(&mut self.tokens, self.scope)
|
||||||
.iter()
|
.iter()
|
||||||
.map(|x| x.kind.to_string())
|
.map(|x| x.kind.to_string())
|
||||||
.collect::<String>(),
|
.collect::<String>(),
|
||||||
|
@ -40,7 +40,7 @@ pub(crate) fn devour_whitespace_or_comment<I: Iterator<Item = W>, W: IsWhitespac
|
|||||||
found_whitespace
|
found_whitespace
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn eat_interpolation<I: Iterator<Item = Token>>(
|
pub(crate) fn parse_interpolation<I: Iterator<Item = Token>>(
|
||||||
tokens: &mut I,
|
tokens: &mut I,
|
||||||
scope: &Scope,
|
scope: &Scope,
|
||||||
) -> Vec<Token> {
|
) -> Vec<Token> {
|
||||||
@ -57,7 +57,7 @@ pub(crate) fn eat_interpolation<I: Iterator<Item = Token>>(
|
|||||||
TokenKind::Variable(ref v) => val.extend(
|
TokenKind::Variable(ref v) => val.extend(
|
||||||
Lexer::new(&scope.vars.get(v).unwrap().to_string()).collect::<Vec<Token>>(),
|
Lexer::new(&scope.vars.get(v).unwrap().to_string()).collect::<Vec<Token>>(),
|
||||||
),
|
),
|
||||||
TokenKind::Interpolation => val.extend(eat_interpolation(tokens, scope)),
|
TokenKind::Interpolation => val.extend(parse_interpolation(tokens, scope)),
|
||||||
_ => val.push(tok),
|
_ => val.push(tok),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -8,7 +8,7 @@ use crate::builtin::GLOBAL_FUNCTIONS;
|
|||||||
use crate::color::Color;
|
use crate::color::Color;
|
||||||
use crate::common::{Keyword, Op, QuoteKind, Scope, Symbol};
|
use crate::common::{Keyword, Op, QuoteKind, Scope, Symbol};
|
||||||
use crate::units::Unit;
|
use crate::units::Unit;
|
||||||
use crate::utils::{devour_whitespace_or_comment, eat_interpolation};
|
use crate::utils::{devour_whitespace_or_comment, parse_interpolation};
|
||||||
use crate::{Token, TokenKind};
|
use crate::{Token, TokenKind};
|
||||||
|
|
||||||
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
||||||
@ -245,7 +245,7 @@ impl Value {
|
|||||||
TokenKind::Interpolation => {
|
TokenKind::Interpolation => {
|
||||||
toks.next();
|
toks.next();
|
||||||
s.push_str(
|
s.push_str(
|
||||||
&eat_interpolation(toks, scope)
|
&parse_interpolation(toks, scope)
|
||||||
.iter()
|
.iter()
|
||||||
.map(|x| x.kind.to_string())
|
.map(|x| x.kind.to_string())
|
||||||
.collect::<String>(),
|
.collect::<String>(),
|
||||||
@ -308,7 +308,7 @@ impl Value {
|
|||||||
Some(scope.vars.get(v).expect("expected variable").clone())
|
Some(scope.vars.get(v).expect("expected variable").clone())
|
||||||
}
|
}
|
||||||
TokenKind::Interpolation => {
|
TokenKind::Interpolation => {
|
||||||
let mut s = eat_interpolation(toks, scope)
|
let mut s = parse_interpolation(toks, scope)
|
||||||
.iter()
|
.iter()
|
||||||
.map(|x| x.kind.to_string())
|
.map(|x| x.kind.to_string())
|
||||||
.collect::<String>();
|
.collect::<String>();
|
||||||
@ -317,7 +317,7 @@ impl Value {
|
|||||||
TokenKind::Interpolation => {
|
TokenKind::Interpolation => {
|
||||||
toks.next();
|
toks.next();
|
||||||
s.push_str(
|
s.push_str(
|
||||||
&eat_interpolation(toks, scope)
|
&parse_interpolation(toks, scope)
|
||||||
.iter()
|
.iter()
|
||||||
.map(|x| x.kind.to_string())
|
.map(|x| x.kind.to_string())
|
||||||
.collect::<String>(),
|
.collect::<String>(),
|
||||||
|
Loading…
x
Reference in New Issue
Block a user