From 2439579d2046e506bd376624273c9be9a8f3365c Mon Sep 17 00:00:00 2001 From: ConnorSkees <39542938+ConnorSkees@users.noreply.github.com> Date: Sun, 12 Jan 2020 19:56:58 -0500 Subject: [PATCH] Initial implementation of @include and mixin eval --- src/lexer.rs | 4 +- src/main.rs | 125 +++++++++++++++++++++++++++++------------------- src/selector.rs | 14 +++--- src/style.rs | 16 ++++--- 4 files changed, 94 insertions(+), 65 deletions(-) diff --git a/src/lexer.rs b/src/lexer.rs index 261aa9c..ab52375 100644 --- a/src/lexer.rs +++ b/src/lexer.rs @@ -58,9 +58,9 @@ impl<'a> Iterator for Lexer<'a> { TokenKind::Whitespace(Whitespace::CarriageReturn) } '#' => self.lex_hash(), - '{' => symbol!(self, OpenBrace), + '{' => symbol!(self, OpenCurlyBrace), '*' => symbol!(self, Mul), - '}' => symbol!(self, CloseBrace), + '}' => symbol!(self, CloseCurlyBrace), '&' => symbol!(self, BitAnd), '/' => self.lex_forward_slash(), '%' => { diff --git a/src/main.rs b/src/main.rs index aa16d86..b147491 100644 --- a/src/main.rs +++ b/src/main.rs @@ -26,14 +26,13 @@ clippy::module_name_repetitions )] // todo! handle erroring on styles at the toplevel -use std::collections::HashMap; use std::fmt::{self, Display}; use std::fs; use std::io; use std::iter::{Iterator, Peekable}; use std::path::Path; -use crate::common::{AtRule, Keyword, Op, Pos, Symbol, Whitespace}; +use crate::common::{AtRule, Keyword, Op, Pos, Scope, Symbol, Whitespace}; use crate::css::Css; use crate::error::SassError; use crate::format::PrettyPrinter; @@ -42,6 +41,7 @@ use crate::mixin::{CallArgs, FuncArgs, Mixin}; use crate::selector::{Attribute, Selector}; use crate::style::Style; use crate::units::Unit; +use crate::utils::{IsWhitespace, devour_whitespace}; mod color; mod common; @@ -54,6 +54,7 @@ mod mixin; mod selector; mod style; mod units; +mod utils; type SassResult = Result; @@ -139,6 +140,8 @@ pub struct RuleSet { enum Expr { /// A style: `color: red` Style(Style), + /// A collection of styles, from a mixin or function + Styles(Vec