Skip to content

Commit 580c318

Browse files
author
Aaron Leung
committed
Don't think we need to eagerly evaluate numeric values after all, now that we're fully evaluating function args.
1 parent 1839dc8 commit 580c318

File tree

1 file changed

+54
-50
lines changed

1 file changed

+54
-50
lines changed

document_parser.cpp

Lines changed: 54 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -909,45 +909,45 @@ namespace Sass {
909909
if (lex< identifier >())
910910
{ return context.new_Node(Node::identifier, path, line, lexed); }
911911

912-
// if (lex< percentage >())
913-
// { return context.new_Node(Node::textual_percentage, path, line, lexed); }
912+
if (lex< percentage >())
913+
{ return context.new_Node(Node::textual_percentage, path, line, lexed); }
914914

915-
// if (lex< dimension >())
916-
// { return context.new_Node(Node::textual_dimension, path, line, lexed); }
915+
if (lex< dimension >())
916+
{ return context.new_Node(Node::textual_dimension, path, line, lexed); }
917917

918-
// if (lex< number >())
919-
// { return context.new_Node(Node::textual_number, path, line, lexed); }
918+
if (lex< number >())
919+
{ return context.new_Node(Node::textual_number, path, line, lexed); }
920920

921-
// if (lex< hex >())
922-
// { return context.new_Node(Node::textual_hex, path, line, lexed); }
921+
if (lex< hex >())
922+
{ return context.new_Node(Node::textual_hex, path, line, lexed); }
923923

924-
if (lex< percentage >())
925-
{ return context.new_Node(path, line, atof(lexed.begin), Node::numeric_percentage); }
924+
// if (lex< percentage >())
925+
// { return context.new_Node(path, line, atof(lexed.begin), Node::numeric_percentage); }
926926

927-
if (lex< dimension >()) {
928-
return context.new_Node(path, line, atof(lexed.begin),
929-
Token::make(Prelexer::number(lexed.begin), lexed.end));
930-
}
927+
// if (lex< dimension >()) {
928+
// return context.new_Node(path, line, atof(lexed.begin),
929+
// Token::make(Prelexer::number(lexed.begin), lexed.end));
930+
// }
931931

932-
if (lex< number >())
933-
{ return context.new_Node(path, line, atof(lexed.begin)); }
932+
// if (lex< number >())
933+
// { return context.new_Node(path, line, atof(lexed.begin)); }
934934

935-
if (lex< hex >()) {
936-
Node triple(context.new_Node(Node::numeric_color, path, line, 4));
937-
Token hext(Token::make(lexed.begin+1, lexed.end));
938-
if (hext.length() == 6) {
939-
for (int i = 0; i < 6; i += 2) {
940-
triple << context.new_Node(path, line, static_cast<double>(strtol(string(hext.begin+i, 2).c_str(), NULL, 16)));
941-
}
942-
}
943-
else {
944-
for (int i = 0; i < 3; ++i) {
945-
triple << context.new_Node(path, line, static_cast<double>(strtol(string(2, hext.begin[i]).c_str(), NULL, 16)));
946-
}
947-
}
948-
triple << context.new_Node(path, line, 1.0);
949-
return triple;
950-
}
935+
// if (lex< hex >()) {
936+
// Node triple(context.new_Node(Node::numeric_color, path, line, 4));
937+
// Token hext(Token::make(lexed.begin+1, lexed.end));
938+
// if (hext.length() == 6) {
939+
// for (int i = 0; i < 6; i += 2) {
940+
// triple << context.new_Node(path, line, static_cast<double>(strtol(string(hext.begin+i, 2).c_str(), NULL, 16)));
941+
// }
942+
// }
943+
// else {
944+
// for (int i = 0; i < 3; ++i) {
945+
// triple << context.new_Node(path, line, static_cast<double>(strtol(string(2, hext.begin[i]).c_str(), NULL, 16)));
946+
// }
947+
// }
948+
// triple << context.new_Node(path, line, 1.0);
949+
// return triple;
950+
// }
951951

952952
if (peek< string_constant >())
953953
{ return parse_string(); }
@@ -1022,30 +1022,34 @@ namespace Sass {
10221022
schema << context.new_Node(Node::identifier, path, line, lexed);
10231023
}
10241024
else if (lex< percentage >()) {
1025-
schema << context.new_Node(path, line, atof(lexed.begin), Node::numeric_percentage);
1025+
schema << context.new_Node(Node::textual_percentage, path, line, lexed);
1026+
// schema << context.new_Node(path, line, atof(lexed.begin), Node::numeric_percentage);
10261027
}
10271028
else if (lex< dimension >()) {
1028-
schema << context.new_Node(path, line, atof(lexed.begin),
1029-
Token::make(Prelexer::number(lexed.begin), lexed.end));
1029+
schema << context.new_Node(Node::textual_dimension, path, line, lexed);
1030+
// schema << context.new_Node(path, line, atof(lexed.begin),
1031+
// Token::make(Prelexer::number(lexed.begin), lexed.end));
10301032
}
10311033
else if (lex< number >()) {
1032-
schema << context.new_Node(path, line, atof(lexed.begin));
1034+
schema << context.new_Node(Node::textual_number, path, line, lexed);
1035+
// schema << context.new_Node(path, line, atof(lexed.begin));
10331036
}
10341037
else if (lex< hex >()) {
1035-
Node triple(context.new_Node(Node::numeric_color, path, line, 4));
1036-
Token hext(Token::make(lexed.begin+1, lexed.end));
1037-
if (hext.length() == 6) {
1038-
for (int i = 0; i < 6; i += 2) {
1039-
triple << context.new_Node(path, line, static_cast<double>(strtol(string(hext.begin+i, 2).c_str(), NULL, 16)));
1040-
}
1041-
}
1042-
else {
1043-
for (int i = 0; i < 3; ++i) {
1044-
triple << context.new_Node(path, line, static_cast<double>(strtol(string(2, hext.begin[i]).c_str(), NULL, 16)));
1045-
}
1046-
}
1047-
triple << context.new_Node(path, line, 1.0);
1048-
schema << triple;
1038+
schema << context.new_Node(Node::textual_hex, path, line, lexed);
1039+
// Node triple(context.new_Node(Node::numeric_color, path, line, 4));
1040+
// Token hext(Token::make(lexed.begin+1, lexed.end));
1041+
// if (hext.length() == 6) {
1042+
// for (int i = 0; i < 6; i += 2) {
1043+
// triple << context.new_Node(path, line, static_cast<double>(strtol(string(hext.begin+i, 2).c_str(), NULL, 16)));
1044+
// }
1045+
// }
1046+
// else {
1047+
// for (int i = 0; i < 3; ++i) {
1048+
// triple << context.new_Node(path, line, static_cast<double>(strtol(string(2, hext.begin[i]).c_str(), NULL, 16)));
1049+
// }
1050+
// }
1051+
// triple << context.new_Node(path, line, 1.0);
1052+
// schema << triple;
10491053
}
10501054
else if (lex< string_constant >()) {
10511055
Node str(context.new_Node(Node::string_constant, path, line, lexed));

0 commit comments

Comments
 (0)