Skip to content

Commit

Permalink
Improve ie property and expression parsing
Browse files Browse the repository at this point in the history
  • Loading branch information
mgreter committed May 10, 2015
1 parent fb82f0b commit 60f3439
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 6 deletions.
4 changes: 4 additions & 0 deletions debugger.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -450,6 +450,10 @@ inline void debug_ast(AST_Node* node, string ind = "", Env* env = 0)
cerr << ind << "Map " << expression;
cerr << " (" << pstate_source_position(node) << ")";
cerr << " [Hashed]" << endl;
// for (auto i : expression->elements()) {
// debug_ast(i.first, ind + " key: ");
// debug_ast(i.second, ind + " val: ");
// }
} else if (dynamic_cast<List*>(node)) {
List* expression = dynamic_cast<List*>(node);
cerr << ind << "List " << expression;
Expand Down
3 changes: 1 addition & 2 deletions eval.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1018,8 +1018,7 @@ namespace Sass {
is_rest_argument = false;
is_keyword_argument = true;
}
else
if(val->concrete_type() != Expression::LIST) {
else if(val->concrete_type() != Expression::LIST) {
List* wrapper = new (ctx.mem) List(val->pstate(),
0,
List::COMMA,
Expand Down
2 changes: 1 addition & 1 deletion prelexer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -606,7 +606,7 @@ namespace Sass {
>(src);
}
const char* ie_expression(const char* src) {
return sequence < word<expression_kwd>, delimited_by< '(', ')', true> >(src);
return sequence < word<expression_kwd>, exactly<'('>, skip_over_scopes< exactly<'('>, exactly<')'> > >(src);
}
const char* ie_property(const char* src) {
return alternatives < ie_expression, ie_progid >(src);
Expand Down
18 changes: 15 additions & 3 deletions prelexer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ namespace Sass {
// recursive skip stuff delimited by start/stop
// first start/opener must be consumed already!
template<prelexer start, prelexer stop>
const char* skip_over_scopes(const char* src, const char* end = 0) {
const char* skip_over_scopes(const char* src, const char* end) {

size_t level = 0;
bool in_squote = false;
Expand All @@ -85,8 +85,9 @@ namespace Sass {
}

// find another opener inside?
else if (start(src)) {
++ level; // increase counter
else if (const char* pos = start(src)) {
++ level; // increase stack counter
src = pos - 1; // advance position
}

// look for the closer (maybe final, maybe not)
Expand All @@ -96,6 +97,8 @@ namespace Sass {
// return position at end of stop
// delimiter may be multiple chars
else return final;
// advance position
src = final - 1;
}

// next
Expand All @@ -105,6 +108,15 @@ namespace Sass {
return 0;
}

// skip to delimiter (mx) inside given range
// this will savely skip over all quoted strings
// recursive skip stuff delimited by start/stop
// first start/opener must be consumed already!
template<prelexer start, prelexer stop>
const char* skip_over_scopes(const char* src) {
return skip_over_scopes<start, stop>(src, 0);
}

// Match a sequence of characters delimited by the supplied chars.
template <prelexer start, prelexer stop>
const char* recursive_scopes(const char* src) {
Expand Down

0 comments on commit 60f3439

Please sign in to comment.