Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Separate parsing and execution of blocks #178

Open
eevee opened this issue Aug 2, 2013 · 1 comment
Open

Separate parsing and execution of blocks #178

eevee opened this issue Aug 2, 2013 · 1 comment
Milestone

Comments

@eevee
Copy link
Collaborator

eevee commented Aug 2, 2013

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:

  • @imported files, mixins, % rules, and @for bodies can be parsed once and executed multiple times
  • Probably would make @while actually work (@while loop not implemented #121)
  • AST manipulation is cool
@eevee
Copy link
Collaborator Author

eevee commented Aug 30, 2014

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!)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant