Remove nesting check in ruleset parsing
This commit is contained in:
parent
5b631fb588
commit
d4f50c8acc
22
src/mixin.rs
22
src/mixin.rs
@ -1,25 +1,17 @@
|
|||||||
use crate::common::{Pos, Scope, Symbol};
|
use crate::common::Scope;
|
||||||
use crate::selector::Selector;
|
use crate::selector::Selector;
|
||||||
use crate::style::Style;
|
use crate::{eat_expr, Expr, RuleSet, Stmt, Token};
|
||||||
use crate::utils::{devour_whitespace, eat_variable_value_ref};
|
|
||||||
use crate::{eat_expr, Expr, RuleSet, Stmt, Token, TokenKind};
|
|
||||||
use std::vec::IntoIter;
|
|
||||||
use std::iter::Peekable;
|
use std::iter::Peekable;
|
||||||
|
use std::vec::IntoIter;
|
||||||
|
|
||||||
#[derive(Debug, Clone)]
|
#[derive(Debug, Clone)]
|
||||||
pub struct Mixin {
|
pub struct Mixin {
|
||||||
scope: Scope,
|
scope: Scope,
|
||||||
args: FuncArgs,
|
args: FuncArgs,
|
||||||
// body: Vec<Token>,
|
|
||||||
body: Peekable<IntoIter<Token>>,
|
body: Peekable<IntoIter<Token>>,
|
||||||
nesting: u32,
|
nesting: u32,
|
||||||
}
|
}
|
||||||
|
|
||||||
// struct MixinEvaluator<'a> {
|
|
||||||
// body: Vec<Token>,
|
|
||||||
// nesting: u32,
|
|
||||||
// }
|
|
||||||
|
|
||||||
impl Mixin {
|
impl Mixin {
|
||||||
pub fn new(scope: Scope, args: FuncArgs, body: Vec<Token>) -> Self {
|
pub fn new(scope: Scope, args: FuncArgs, body: Vec<Token>) -> Self {
|
||||||
let body = body.clone().into_iter().peekable();
|
let body = body.clone().into_iter().peekable();
|
||||||
@ -36,11 +28,10 @@ impl Mixin {
|
|||||||
while let Ok(expr) = eat_expr(&mut self.body, scope, super_selector) {
|
while let Ok(expr) = eat_expr(&mut self.body, scope, super_selector) {
|
||||||
match expr {
|
match expr {
|
||||||
Expr::Style(s) => stmts.push(Stmt::Style(s)),
|
Expr::Style(s) => stmts.push(Stmt::Style(s)),
|
||||||
Expr::Include(_) => todo!(),
|
Expr::Include(_) => todo!(),
|
||||||
Expr::MixinDecl(_, _) => todo!(),
|
Expr::MixinDecl(_, _) => todo!(),
|
||||||
Expr::Selector(s) => {
|
Expr::Selector(s) => {
|
||||||
self.nesting += 1;
|
self.nesting += 1;
|
||||||
dbg!(&self.nesting);
|
|
||||||
let rules = self.eval(&super_selector.clone().zip(s.clone()), scope);
|
let rules = self.eval(&super_selector.clone().zip(s.clone()), scope);
|
||||||
stmts.push(Stmt::RuleSet(RuleSet {
|
stmts.push(Stmt::RuleSet(RuleSet {
|
||||||
super_selector: super_selector.clone(),
|
super_selector: super_selector.clone(),
|
||||||
@ -48,9 +39,6 @@ impl Mixin {
|
|||||||
rules,
|
rules,
|
||||||
}));
|
}));
|
||||||
self.nesting -= 1;
|
self.nesting -= 1;
|
||||||
if self.nesting == 0 {
|
|
||||||
return stmts;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
Expr::VariableDecl(name, val) => {
|
Expr::VariableDecl(name, val) => {
|
||||||
if self.nesting == 0 {
|
if self.nesting == 0 {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user