Skip to content

Commit

Permalink
Merge pull request sass#1085 from mgreter/bugfix/issue_1082
Browse files Browse the repository at this point in the history
Improve block comment parsing for lists
  • Loading branch information
mgreter committed Apr 11, 2015
2 parents e60ad9a + 980e17d commit c4fb559
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 15 deletions.
2 changes: 2 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ matrix:
env: AUTOTOOLS=yes COVERAGE=yes BUILD=static
- os: osx
compiler: gcc
- os: osx
env: AUTOTOOLS=no COVERAGE=yes BUILD=static

script: ./script/ci-build-libsass
before_install: ./script/ci-install-deps
Expand Down
12 changes: 9 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,15 @@ RM ?= rm -f
CP ?= cp -a
MKDIR ?= mkdir
WINDRES ?= windres
CFLAGS ?= -Wall -O2
CXXFLAGS ?= -Wall -O2
LDFLAGS ?= -Wall -O2 -Wl,--no-undefined
CFLAGS ?= -Wall
CXXFLAGS ?= -Wall
LDFLAGS ?= -Wall
ifneq "$(COVERAGE)" "yes"
CFLAGS += -O2
CXXFLAGS += -O2
LDFLAGS += -O2
endif
LDFLAGS += -Wl,-undefined,error
CAT ?= $(if $(filter $(OS),Windows_NT),type,cat)

ifneq (,$(findstring /cygdrive/,$(PATH)))
Expand Down
9 changes: 9 additions & 0 deletions ast.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
namespace Sass {
using namespace std;

static Null sass_null(Sass::Null(ParserState("null")));

bool Compound_Selector::operator<(const Compound_Selector& rhs) const
{
To_String to_string;
Expand Down Expand Up @@ -587,5 +589,12 @@ namespace Sass {
return result;
}*/

Expression* Hashed::at(Expression* k) const
{
if (elements_.count(k))
{ return elements_.at(k); }
else { return &sass_null; }
}

}

3 changes: 2 additions & 1 deletion ast.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -210,9 +210,10 @@ namespace Sass {
size_t length() const { return list_.size(); }
bool empty() const { return list_.empty(); }
bool has(Expression* k) const { return elements_.count(k) == 1; }
Expression* at(Expression* k) const { return elements_.at(k); }
Expression* at(Expression* k) const;
bool has_duplicate_key() const { return duplicate_key_ != 0; }
Expression* get_duplicate_key() const { return duplicate_key_; }
const unordered_map<Expression*, Expression*> elements() { return elements_; }
Hashed& operator<<(pair<Expression*, Expression*> p)
{
reset_hash();
Expand Down
16 changes: 8 additions & 8 deletions parser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1051,7 +1051,7 @@ namespace Sass {

Expression* Parser::parse_comma_list()
{
if (peek< alternatives <
if (peek_css< alternatives <
// exactly<'!'>,
// exactly<':'>,
exactly<';'>,
Expand All @@ -1063,14 +1063,14 @@ namespace Sass {
{ return new (ctx.mem) List(pstate, 0); }
Expression* list1 = parse_space_list();
// if it's a singleton, return it directly; don't wrap it
if (!peek< exactly<','> >(position)) return list1;
if (!peek_css< exactly<','> >(position)) return list1;

List* comma_list = new (ctx.mem) List(pstate, 2, List::COMMA);
(*comma_list) << list1;

while (lex< exactly<','> >())
while (lex_css< exactly<','> >())
{
if (peek< alternatives <
if (peek_css< alternatives <
// exactly<'!'>,
exactly<';'>,
exactly<'}'>,
Expand All @@ -1091,7 +1091,7 @@ namespace Sass {
{
Expression* disj1 = parse_disjunction();
// if it's a singleton, return it directly; don't wrap it
if (peek< alternatives <
if (peek_css< alternatives <
// exactly<'!'>,
exactly<';'>,
exactly<'}'>,
Expand All @@ -1108,7 +1108,7 @@ namespace Sass {
List* space_list = new (ctx.mem) List(pstate, 2, List::SPACE);
(*space_list) << disj1;

while (!(peek< alternatives <
while (!(peek_css< alternatives <
// exactly<'!'>,
exactly<';'>,
exactly<'}'>,
Expand Down Expand Up @@ -1229,9 +1229,9 @@ namespace Sass {

Expression* Parser::parse_factor()
{
if (lex< exactly<'('> >()) {
if (lex_css< exactly<'('> >()) {
Expression* value = parse_map();
if (!lex< exactly<')'> >()) error("unclosed parenthesis", pstate);
if (!lex_css< exactly<')'> >()) error("unclosed parenthesis", pstate);
value->is_delayed(false);
// make sure wrapped lists and division expressions are non-delayed within parentheses
if (value->concrete_type() == Expression::LIST) {
Expand Down
6 changes: 3 additions & 3 deletions script/ci-build-libsass
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ if [ "x$SASS_SPEC_PATH" == "x" ]; then export SASS_SPEC_PATH=$(pwd)/sass-spec; f

if [ "x$COVERAGE" == "xyes" ]; then
COVERAGE_OPT="--enable-coverage"
export EXTRA_CFLAGS="-O0 --coverage"
export EXTRA_CXXFLAGS="-O0 --coverage"
export EXTRA_LDFLAGS="-O0 --coverage"
export EXTRA_CFLAGS="--coverage"
export EXTRA_CXXFLAGS="--coverage"
export EXTRA_LDFLAGS="--coverage"
else
COVERAGE_OPT="--disable-coverage"
fi
Expand Down

0 comments on commit c4fb559

Please # to comment.