Skip to content
This repository was archived by the owner on Oct 24, 2025. It is now read-only.

Commit 2dbc45a

Browse files
author
Aaron Leung
committed
More fixes for evaluation edge-cases.
1 parent f25d02b commit 2dbc45a

File tree

2 files changed

+222
-142
lines changed

2 files changed

+222
-142
lines changed

document_parser.cpp

Lines changed: 59 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -215,12 +215,10 @@ namespace Sass {
215215
if (lex< exactly<'('> >()) {
216216
if (!peek< exactly<')'> >(position)) {
217217
Node arg(parse_argument(Node::none));
218-
arg.should_eval() = true;
219218
args << arg;
220219
if (arg.type() == Node::assignment) arg_type = Node::assignment;
221220
while (lex< exactly<','> >()) {
222221
Node arg(parse_argument(arg_type));
223-
arg.should_eval() = true;
224222
args << arg;
225223
if (arg.type() == Node::assignment) arg_type = Node::assignment;
226224
}
@@ -239,6 +237,7 @@ namespace Sass {
239237
Node var(context.new_Node(Node::variable, path, line, lexed));
240238
lex< exactly<':'> >();
241239
Node val(parse_space_list());
240+
// val.should_eval() = true;
242241
Node assn(context.new_Node(Node::assignment, path, line, 2));
243242
assn << var << val;
244243
return assn;
@@ -254,23 +253,14 @@ namespace Sass {
254253
Node var(context.new_Node(Node::variable, path, line, lexed));
255254
lex< exactly<':'> >();
256255
Node val(parse_space_list());
256+
// val.should_eval() = true;
257257
Node assn(context.new_Node(Node::assignment, path, line, 2));
258258
assn << var << val;
259259
return assn;
260260
}
261-
return parse_space_list();
262-
// if (peek< sequence < variable, spaces_and_comments, exactly<':'> > >()) {
263-
// lex< variable >();
264-
// Node var(context.new_Node(Node::variable, path, line, lexed));
265-
// lex< exactly<':'> >();
266-
// Node val(parse_space_list());
267-
// Node assn(context.new_Node(Node::assignment, path, line, 2));
268-
// assn << var << val;
269-
// return assn;
270-
// }
271-
// else {
272-
// return parse_space_list();
273-
// }
261+
Node val(parse_space_list());
262+
val.should_eval() = true;
263+
return val;
274264
}
275265

276266
Node Document::parse_assignment()
@@ -909,45 +899,45 @@ namespace Sass {
909899
if (lex< identifier >())
910900
{ return context.new_Node(Node::identifier, path, line, lexed); }
911901

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

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

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

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

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

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

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

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-
}
925+
// if (lex< hex >()) {
926+
// Node triple(context.new_Node(Node::numeric_color, path, line, 4));
927+
// Token hext(Token::make(lexed.begin+1, lexed.end));
928+
// if (hext.length() == 6) {
929+
// for (int i = 0; i < 6; i += 2) {
930+
// triple << context.new_Node(path, line, static_cast<double>(strtol(string(hext.begin+i, 2).c_str(), NULL, 16)));
931+
// }
932+
// }
933+
// else {
934+
// for (int i = 0; i < 3; ++i) {
935+
// triple << context.new_Node(path, line, static_cast<double>(strtol(string(2, hext.begin[i]).c_str(), NULL, 16)));
936+
// }
937+
// }
938+
// triple << context.new_Node(path, line, 1.0);
939+
// return triple;
940+
// }
951941

952942
if (peek< string_constant >())
953943
{ return parse_string(); }
@@ -1023,30 +1013,34 @@ namespace Sass {
10231013
schema << context.new_Node(Node::identifier, path, line, lexed);
10241014
}
10251015
else if (lex< percentage >()) {
1026-
schema << context.new_Node(path, line, atof(lexed.begin), Node::numeric_percentage);
1016+
schema << context.new_Node(Node::textual_percentage, path, line, lexed);
1017+
// schema << context.new_Node(path, line, atof(lexed.begin), Node::numeric_percentage);
10271018
}
10281019
else if (lex< dimension >()) {
1029-
schema << context.new_Node(path, line, atof(lexed.begin),
1030-
Token::make(Prelexer::number(lexed.begin), lexed.end));
1020+
schema << context.new_Node(Node::textual_dimension, path, line, lexed);
1021+
// schema << context.new_Node(path, line, atof(lexed.begin),
1022+
// Token::make(Prelexer::number(lexed.begin), lexed.end));
10311023
}
10321024
else if (lex< number >()) {
1033-
schema << context.new_Node(path, line, atof(lexed.begin));
1025+
schema << context.new_Node(Node::textual_number, path, line, lexed);
1026+
// schema << context.new_Node(path, line, atof(lexed.begin));
10341027
}
10351028
else if (lex< hex >()) {
1036-
Node triple(context.new_Node(Node::numeric_color, path, line, 4));
1037-
Token hext(Token::make(lexed.begin+1, lexed.end));
1038-
if (hext.length() == 6) {
1039-
for (int i = 0; i < 6; i += 2) {
1040-
triple << context.new_Node(path, line, static_cast<double>(strtol(string(hext.begin+i, 2).c_str(), NULL, 16)));
1041-
}
1042-
}
1043-
else {
1044-
for (int i = 0; i < 3; ++i) {
1045-
triple << context.new_Node(path, line, static_cast<double>(strtol(string(2, hext.begin[i]).c_str(), NULL, 16)));
1046-
}
1047-
}
1048-
triple << context.new_Node(path, line, 1.0);
1049-
schema << triple;
1029+
schema << context.new_Node(Node::textual_hex, path, line, lexed);
1030+
// Node triple(context.new_Node(Node::numeric_color, path, line, 4));
1031+
// Token hext(Token::make(lexed.begin+1, lexed.end));
1032+
// if (hext.length() == 6) {
1033+
// for (int i = 0; i < 6; i += 2) {
1034+
// triple << context.new_Node(path, line, static_cast<double>(strtol(string(hext.begin+i, 2).c_str(), NULL, 16)));
1035+
// }
1036+
// }
1037+
// else {
1038+
// for (int i = 0; i < 3; ++i) {
1039+
// triple << context.new_Node(path, line, static_cast<double>(strtol(string(2, hext.begin[i]).c_str(), NULL, 16)));
1040+
// }
1041+
// }
1042+
// triple << context.new_Node(path, line, 1.0);
1043+
// schema << triple;
10501044
}
10511045
else if (lex< string_constant >()) {
10521046
Node str(context.new_Node(Node::string_constant, path, line, lexed));

0 commit comments

Comments
 (0)