Skip to content

Commit

Permalink
Merge pull request #2271 from xzyfer/remove/parser-ast-validation
Browse files Browse the repository at this point in the history
Remove left over AST validation from the parser
  • Loading branch information
xzyfer committed Dec 29, 2016
2 parents 5ec71fd + 558dd71 commit 20b0f9a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 13 deletions.
12 changes: 8 additions & 4 deletions src/check_nesting.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,10 @@ namespace Sass {
Statement_Ptr CheckNesting::operator()(Definition_Ptr n)
{
if (!this->should_visit(n)) return NULL;
if (!is_mixin(n)) return n;
if (!is_mixin(n)) {
visit_children(n);
return n;
}

Definition_Ptr old_mixin_definition = this->current_mixin_definition;
this->current_mixin_definition = n;
Expand Down Expand Up @@ -129,9 +132,8 @@ namespace Sass {
if (SASS_MEMORY_CAST_PTR(Declaration, node))
{ this->invalid_prop_parent(this->parent); }

if (
SASS_MEMORY_CAST_PTR(Declaration, this->parent)
) { this->invalid_prop_child(node); }
if (SASS_MEMORY_CAST_PTR(Declaration, this->parent))
{ this->invalid_prop_child(node); }

if (SASS_MEMORY_CAST_PTR(Return, node))
{ this->invalid_return_parent(this->parent); }
Expand Down Expand Up @@ -258,6 +260,8 @@ namespace Sass {
SASS_MEMORY_CAST_PTR(Debug, child) ||
SASS_MEMORY_CAST_PTR(Return, child) ||
SASS_MEMORY_CAST_PTR(Variable, child) ||
// Ruby Sass doesn't distinguish variables and assignments
SASS_MEMORY_CAST_PTR(Assignment, child) ||
SASS_MEMORY_CAST_PTR(Warning, child) ||
SASS_MEMORY_CAST_PTR(Error, child)
)) {
Expand Down
9 changes: 0 additions & 9 deletions src/parser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -222,11 +222,6 @@ namespace Sass {
else if (lex < kwd_while_directive >(true)) { block->append(&parse_while_directive()); }
else if (lex < kwd_return_directive >(true)) { block->append(&parse_return_directive()); }

// abort if we are in function context and have nothing parsed yet
else if (stack.back() == Scope::Function) {
error("Functions can only contain variable declarations and control directives.", pstate);
}

// parse imports to process later
else if (lex < kwd_import >(true)) {
Scope parent = stack.empty() ? Scope::Rules : stack.back();
Expand All @@ -245,10 +240,6 @@ namespace Sass {
}

else if (lex < kwd_extend >(true)) {
if (block->is_root()) {
error("Extend directives may only be used within rules.", pstate);
}

Lookahead lookahead = lookahead_for_include(position);
if (!lookahead.found) css_error("Invalid CSS", " after ", ": expected selector, was ");
Selector_Obj target;
Expand Down

0 comments on commit 20b0f9a

Please sign in to comment.