Skip to content

Commit 604c1da

Browse files
committed
Remove Textual intermediate AST node
We can directly parse them into Value Nodes!
1 parent 4c4af04 commit 604c1da

File tree

1 file changed

+11
-13
lines changed

1 file changed

+11
-13
lines changed

src/parser.cpp

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1442,19 +1442,22 @@ namespace Sass {
14421442
}
14431443
}
14441444

1445-
Number_Ptr Parser::lexed_number(const ParserState& pstate, const std::string& parsed)
1445+
bool number_has_zero(const std::string& parsed)
14461446
{
14471447
size_t L = parsed.length();
1448-
bool zero = !( (L > 0 && parsed.substr(0, 1) == ".") ||
1449-
(L > 1 && parsed.substr(0, 2) == "0.") ||
1450-
(L > 1 && parsed.substr(0, 2) == "-.") ||
1451-
(L > 2 && parsed.substr(0, 3) == "-0.")
1452-
);
1448+
return !( (L > 0 && parsed.substr(0, 1) == ".") ||
1449+
(L > 1 && parsed.substr(0, 2) == "0.") ||
1450+
(L > 1 && parsed.substr(0, 2) == "-.") ||
1451+
(L > 2 && parsed.substr(0, 3) == "-0.") );
1452+
}
1453+
1454+
Number_Ptr Parser::lexed_number(const ParserState& pstate, const std::string& parsed)
1455+
{
14531456
Number_Ptr nr = SASS_MEMORY_NEW(Number,
14541457
pstate,
14551458
sass_atof(parsed.c_str()),
14561459
"",
1457-
zero);
1460+
number_has_zero(parsed));
14581461
nr->is_interpolant(false);
14591462
nr->is_delayed(true);
14601463
return nr;
@@ -1475,11 +1478,6 @@ namespace Sass {
14751478
Number_Ptr Parser::lexed_dimension(const ParserState& pstate, const std::string& parsed)
14761479
{
14771480
size_t L = parsed.length();
1478-
bool zero = !( (L > 0 && parsed.substr(0, 1) == ".") ||
1479-
(L > 1 && parsed.substr(0, 2) == "0.") ||
1480-
(L > 1 && parsed.substr(0, 2) == "-.") ||
1481-
(L > 2 && parsed.substr(0, 3) == "-0.")
1482-
);
14831481
size_t num_pos = parsed.find_first_not_of(" \n\r\t");
14841482
if (num_pos == std::string::npos) num_pos = L;
14851483
size_t unit_pos = parsed.find_first_not_of("-+0123456789.", num_pos);
@@ -1489,7 +1487,7 @@ namespace Sass {
14891487
pstate,
14901488
sass_atof(num.c_str()),
14911489
Token(number(parsed.c_str())),
1492-
zero);
1490+
number_has_zero(parsed));
14931491
nr->is_interpolant(false);
14941492
nr->is_delayed(true);
14951493
return nr;

0 commit comments

Comments
 (0)