Rename eat_interpolation() to parse_interpolation()

This commit is contained in:
ConnorSkees 2020-02-01 19:24:37 -05:00
parent 06be720f49
commit 3f929066c4
4 changed files with 12 additions and 10 deletions

View File

@ -1,6 +1,6 @@
use crate::common::{Scope, Symbol};
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 std::fmt::{self, Display};
@ -283,7 +283,9 @@ impl<'a> SelectorParser<'a> {
TokenKind::Interpolation => {
self.is_interpolated = true;
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;
v

View File

@ -1,5 +1,5 @@
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::{Token, TokenKind};
use std::fmt::{self, Display};
@ -47,7 +47,7 @@ impl<'a> StyleParser<'a> {
TokenKind::Whitespace(_) | TokenKind::MultilineComment(_) => continue,
TokenKind::Ident(ref s) => property.push_str(s),
TokenKind::Interpolation => property.push_str(
&eat_interpolation(&mut self.tokens, self.scope)
&parse_interpolation(&mut self.tokens, self.scope)
.iter()
.map(|x| x.kind.to_string())
.collect::<String>(),

View File

@ -40,7 +40,7 @@ pub(crate) fn devour_whitespace_or_comment<I: Iterator<Item = W>, W: IsWhitespac
found_whitespace
}
pub(crate) fn eat_interpolation<I: Iterator<Item = Token>>(
pub(crate) fn parse_interpolation<I: Iterator<Item = Token>>(
tokens: &mut I,
scope: &Scope,
) -> Vec<Token> {
@ -57,7 +57,7 @@ pub(crate) fn eat_interpolation<I: Iterator<Item = Token>>(
TokenKind::Variable(ref v) => val.extend(
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),
}
}

View File

@ -8,7 +8,7 @@ use crate::builtin::GLOBAL_FUNCTIONS;
use crate::color::Color;
use crate::common::{Keyword, Op, QuoteKind, Scope, Symbol};
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};
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
@ -245,7 +245,7 @@ impl Value {
TokenKind::Interpolation => {
toks.next();
s.push_str(
&eat_interpolation(toks, scope)
&parse_interpolation(toks, scope)
.iter()
.map(|x| x.kind.to_string())
.collect::<String>(),
@ -308,7 +308,7 @@ impl Value {
Some(scope.vars.get(v).expect("expected variable").clone())
}
TokenKind::Interpolation => {
let mut s = eat_interpolation(toks, scope)
let mut s = parse_interpolation(toks, scope)
.iter()
.map(|x| x.kind.to_string())
.collect::<String>();
@ -317,7 +317,7 @@ impl Value {
TokenKind::Interpolation => {
toks.next();
s.push_str(
&eat_interpolation(toks, scope)
&parse_interpolation(toks, scope)
.iter()
.map(|x| x.kind.to_string())
.collect::<String>(),