Skip to content

Commit

Permalink
Merge pull request #1069 from mgreter/feature/restore-token-on-fail
Browse files Browse the repository at this point in the history
Improve `lex_css` to restore old token on non-match
  • Loading branch information
mgreter committed Apr 11, 2015
2 parents 72bebed + 8330a1a commit 0dd6543
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions parser.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -165,11 +165,17 @@ namespace Sass {
template <prelexer mx>
const char* lex_css()
{
// copy old token
Token prev = lexed;
// throw away comments
// update srcmap position
lex < css_comments >();
// now lex a token
return lex< mx >();
// now lex a new token
const char* pos = lex< mx >();
// maybe restore prev token
if (pos == 0) lexed = prev;
// return match
return pos;
}

// all block comments will be skipped and thrown away
Expand Down

0 comments on commit 0dd6543

Please sign in to comment.