Kronuz / pyScss

pyScss, a Scss compiler for Python
MIT License
582 stars 141 forks source link

Separate parsing and execution of blocks #178

Open eevee opened 11 years ago

eevee commented 11 years ago

Much like the splitting of parsing vs. execution of expressions.

I think this is a necessary step for fixing several scoping problems; at the moment, an entire block is executed before any blocks nested within it, which is obviously wrong in cases like the following:

h1 {
    $color: green;
    h2 {
        color: $color;
    }
    $color: red;
}

Ruby correctly outputs green. pyScss outputs red, because all the outer statements execute before anything in h2.

It's possible to fix this by fixing the rule execution order, with some code juggling. But that requires either heavy recursion or delaying examining some blocks, which is effectively this ticket anyway.

Separate steps make life easier in a couple other ways:

eevee commented 10 years ago

I have a branch that takes a crack at this. Virtually everything is broken at the moment, but it's looking promising, and I'm hoping there'll be a decent speedup from not having to constantly reparse mixins and functions. (Watch mode would be able to skip reparsing entire files!)