Skip to content

Commit b6bb421

Browse files
committed
[WIP] [DNM] Backport dart sass parser 12
1 parent 667786b commit b6bb421

File tree

9 files changed

+27
-145
lines changed

9 files changed

+27
-145
lines changed

src/ast.cpp

Lines changed: 0 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -742,30 +742,6 @@ namespace Sass {
742742
operand_(ptr->operand_),
743743
hash_(ptr->hash_)
744744
{ }
745-
const std::string Unary_Expression::type_name() {
746-
switch (optype_) {
747-
case PLUS: return "plus";
748-
case MINUS: return "minus";
749-
case SLASH: return "slash";
750-
case NOT: return "not";
751-
default: return "invalid";
752-
}
753-
}
754-
bool Unary_Expression::operator==(const Expression& rhs) const
755-
{
756-
try
757-
{
758-
const Unary_Expression* m = Cast<Unary_Expression>(&rhs);
759-
if (m == 0) return false;
760-
return type() == m->type() &&
761-
*operand() == *m->operand();
762-
}
763-
catch (std::bad_cast&)
764-
{
765-
return false;
766-
}
767-
catch (...) { throw; }
768-
}
769745
size_t Unary_Expression::hash() const
770746
{
771747
if (hash_ == 0) {
@@ -798,21 +774,6 @@ namespace Sass {
798774
is_delayed(delayed);
799775
}
800776

801-
bool Argument::operator==(const Expression& rhs) const
802-
{
803-
try
804-
{
805-
const Argument* m = Cast<Argument>(&rhs);
806-
if (!(m && name() == m->name())) return false;
807-
return *value() == *m->value();
808-
}
809-
catch (std::bad_cast&)
810-
{
811-
return false;
812-
}
813-
catch (...) { throw; }
814-
}
815-
816777
size_t Argument::hash() const
817778
{
818779
if (hash_ == 0) {

src/ast.hpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -912,8 +912,6 @@ namespace Sass {
912912
mutable size_t hash_;
913913
public:
914914
Unary_Expression(ParserState pstate, Type t, Expression_Obj o);
915-
const std::string type_name();
916-
virtual bool operator==(const Expression& rhs) const override;
917915
size_t hash() const override;
918916
ATTACH_COPY_OPERATIONS(Unary_Expression)
919917
ATTACH_CRTP_PERFORM_METHODS()
@@ -999,7 +997,6 @@ namespace Sass {
999997
public:
1000998
Argument(ParserState pstate, Expression_Obj val, std::string n = "", bool rest = false, bool keyword = false);
1001999
void set_delayed(bool delayed) override;
1002-
bool operator==(const Expression& rhs) const override;
10031000
size_t hash() const override;
10041001
ATTACH_COPY_OPERATIONS(Argument)
10051002
ATTACH_CRTP_PERFORM_METHODS()

src/ast_values.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -375,7 +375,6 @@ namespace Sass {
375375
: Value(ptr),
376376
Units(ptr),
377377
value_(ptr->value_),
378-
zero_(ptr->zero_),
379378
lhsAsSlash_(ptr->lhsAsSlash_),
380379
rhsAsSlash_(ptr->rhsAsSlash_),
381380
hash_(ptr->hash_)

src/eval.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1256,7 +1256,6 @@ namespace Sass {
12561256
if (rv.found) value = static_cast<Expression*>(rv.it->second.ptr());
12571257
else error("Undefined variable: \"" + v->name() + "\".", v->pstate(), traces);
12581258
if (Argument* arg = Cast<Argument>(value)) value = arg->value();
1259-
if (Number* nr = Cast<Number>(value)) nr->zero(true); // force flag
12601259
value->is_interpolant(v->is_interpolant());
12611260
if (force) value->is_expanded(false);
12621261
value->set_delayed(false); // verified

src/inspect.cpp

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -210,20 +210,10 @@ namespace Sass {
210210
append_mandatory_space();
211211
import->urls().front()->perform(this);
212212
if (import->urls().size() == 1) {
213-
if (import->import_queries()) {
214-
append_mandatory_space();
215-
import->import_queries()->perform(this);
216-
}
217213
for (auto query : import->queries()) {
218214
append_mandatory_space();
219215
query->perform(this);
220216
}
221-
/*
222-
if (import->queries()) {
223-
append_mandatory_space();
224-
import->import_queries()->perform(this);
225-
}
226-
*/
227217
}
228218
append_delimiter();
229219
for (size_t i = 1, S = import->urls().size(); i < S; ++i) {
@@ -233,10 +223,6 @@ namespace Sass {
233223

234224
import->urls()[i]->perform(this);
235225
if (import->urls().size() - 1 == i) {
236-
if (import->import_queries()) {
237-
append_mandatory_space();
238-
import->import_queries()->perform(this);
239-
}
240226
for (auto query : import->queries()) {
241227
append_mandatory_space();
242228
query->perform(this);
@@ -668,15 +654,6 @@ namespace Sass {
668654
else if (res == "") res = "0";
669655
else if (res == "-0") res = "0";
670656
else if (res == "-0.0") res = "0";
671-
else if (opt.output_style == COMPRESSED)
672-
{
673-
if (n->zero()) {
674-
// check if handling negative nr
675-
size_t off = res[0] == '-' ? 1 : 0;
676-
// remove leading zero from floating point in compressed mode
677-
if (res[off] == '0' && res[off+1] == '.') res.erase(off, 1);
678-
}
679-
}
680657

681658
// add unit now
682659
res += n->unit();

src/parser.cpp

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -56,12 +56,12 @@ namespace Sass {
5656
}
5757

5858
// Like [whitespace], but returns whether any was consumed.
59-
bool Parser::scanWhitespace()
60-
{
61-
auto start = scanner.position;
62-
whitespace(); // consume spaces
63-
return scanner.position != start;
64-
}
59+
// bool Parser::scanWhitespace()
60+
// {
61+
// auto start = scanner.position;
62+
// whitespace(); // consume spaces
63+
// return scanner.position != start;
64+
// }
6565

6666
// Consumes whitespace, but not comments.
6767
void Parser::whitespaceWithoutComments()
@@ -651,25 +651,25 @@ namespace Sass {
651651
// last separating newline. Otherwise returns [position]. This helps avoid
652652
// missing token errors pointing at the next closing bracket rather than
653653
// the line where the problem actually occurred.
654-
const char* Parser::_firstNewlineBefore(const char* position)
655-
{
656-
const char* lastNewline = 0;
657-
const char* index = position - 1;
658-
while (index >= scanner.startpos) {
659-
if (!isWhitespace(*index)) {
660-
return lastNewline == 0 ?
661-
position : lastNewline;
662-
}
663-
if (isNewline(*index)) {
664-
lastNewline = index;
665-
}
666-
index -= 1;
667-
}
668-
669-
// If the document *only* contains whitespace
670-
// before [position], always return [position].
671-
return position;
672-
}
654+
// const char* Parser::_firstNewlineBefore(const char* position)
655+
// {
656+
// const char* lastNewline = 0;
657+
// const char* index = position - 1;
658+
// while (index >= scanner.startpos) {
659+
// if (!isWhitespace(*index)) {
660+
// return lastNewline == 0 ?
661+
// position : lastNewline;
662+
// }
663+
// if (isNewline(*index)) {
664+
// lastNewline = index;
665+
// }
666+
// index -= 1;
667+
// }
668+
//
669+
// // If the document *only* contains whitespace
670+
// // before [position], always return [position].
671+
// return position;
672+
// }
673673
// EO _firstNewlineBefore
674674

675675
}

src/parser.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ namespace Sass {
6161
virtual void whitespace();
6262

6363
// Like [whitespace], but returns whether any was consumed.
64-
bool scanWhitespace();
64+
// bool scanWhitespace();
6565

6666
// Consumes whitespace, but not comments.
6767
void whitespaceWithoutComments();
@@ -207,7 +207,7 @@ namespace Sass {
207207
// last separating newline. Otherwise returns [position]. This helps avoid
208208
// missing token errors pointing at the next closing bracket rather than
209209
// the line where the problem actually occurred.
210-
const char* _firstNewlineBefore(const char* position);
210+
// const char* _firstNewlineBefore(const char* position);
211211

212212
};
213213

src/unicode.cpp

Lines changed: 0 additions & 5 deletions
This file was deleted.

src/unicode.hpp

Lines changed: 0 additions & 46 deletions
This file was deleted.

0 commit comments

Comments
 (0)