@@ -1000,13 +1000,8 @@ namespace Sass {
10001000 List_Obj map = SASS_MEMORY_NEW (List, pstate, 0 , SASS_HASH);
10011001
10021002 // it's not a map so return the lexed value as a list value
1003- if (!lex_css< exactly<' :' > >()) {
1004- List_Obj list = SASS_MEMORY_CAST (List, key);
1005- if (list && list->delimiter () == SASS_NO_DELIMITER) {
1006- list->delimiter (SASS_PARENTHESIS);
1007- }
1008- return key;
1009- }
1003+ if (!lex_css< exactly<' :' > >())
1004+ { return key; }
10101005
10111006 Expression_Obj value = parse_space_list ();
10121007
@@ -1037,6 +1032,49 @@ namespace Sass {
10371032 return ↦
10381033 }
10391034
1035+ Expression_Obj Parser::parse_bracket_list ()
1036+ {
1037+ // check if we have an empty list
1038+ // return the empty list as such
1039+ if (peek_css< list_terminator >(position))
1040+ {
1041+ // return an empty list (nothing to delay)
1042+ return SASS_MEMORY_NEW (List, pstate, 0 , SASS_SPACE, false , true );
1043+ }
1044+
1045+ bool has_paren = peek_css< exactly<' (' > >();
1046+
1047+ // now try to parse a space list
1048+ Expression_Obj list = parse_space_list ();
1049+ // if it's a singleton, return it (don't wrap it)
1050+ if (!peek_css< exactly<' ,' > >(position)) {
1051+ List_Obj l = SASS_MEMORY_CAST (List, list);
1052+ if (!l || l->is_bracketed () || has_paren) {
1053+ List_Obj bracketed_list = SASS_MEMORY_NEW (List, pstate, 1 , SASS_SPACE, false , true );
1054+ bracketed_list->append (&list);
1055+ return &bracketed_list;
1056+ }
1057+ l->is_bracketed (&list);
1058+ return &l;
1059+ }
1060+
1061+ // if we got so far, we actually do have a comma list
1062+ List_Obj bracketed_list = SASS_MEMORY_NEW (List, pstate, 2 , SASS_COMMA, false , true );
1063+ // wrap the first expression
1064+ bracketed_list->append (list);
1065+
1066+ while (lex_css< exactly<' ,' > >())
1067+ {
1068+ // check for abort condition
1069+ if (peek_css< list_terminator >(position)
1070+ ) { break ; }
1071+ // otherwise add another expression
1072+ bracketed_list->append (parse_space_list ());
1073+ }
1074+ // return the list
1075+ return &bracketed_list;
1076+ }
1077+
10401078 // parse list returns either a space separated list,
10411079 // a comma separated list or any bare expression found.
10421080 // so to speak: we unwrap items from lists if possible here!
@@ -1050,19 +1088,7 @@ namespace Sass {
10501088 {
10511089 // check if we have an empty list
10521090 // return the empty list as such
1053- if (peek_css< alternatives <
1054- // exactly<'!'>,
1055- exactly<' ;' >,
1056- exactly<' }' >,
1057- exactly<' {' >,
1058- exactly<' )' >,
1059- exactly<' ]' >,
1060- exactly<' :' >,
1061- end_of_file,
1062- exactly<ellipsis>,
1063- default_flag,
1064- global_flag
1065- > >(position))
1091+ if (peek_css< list_terminator >(position))
10661092 {
10671093 // return an empty list (nothing to delay)
10681094 return SASS_MEMORY_NEW (List, pstate, 0 );
@@ -1086,18 +1112,7 @@ namespace Sass {
10861112 while (lex_css< exactly<' ,' > >())
10871113 {
10881114 // check for abort condition
1089- if (peek_css< alternatives <
1090- exactly<' ;' >,
1091- exactly<' }' >,
1092- exactly<' {' >,
1093- exactly<' )' >,
1094- exactly<' ]' >,
1095- exactly<' :' >,
1096- end_of_file,
1097- exactly<ellipsis>,
1098- default_flag,
1099- global_flag
1100- > >(position)
1115+ if (peek_css< list_terminator >(position)
11011116 ) { break ; }
11021117 // otherwise add another expression
11031118 comma_list->append (parse_space_list ());
@@ -1112,39 +1127,16 @@ namespace Sass {
11121127 {
11131128 Expression_Obj disj1 = parse_disjunction ();
11141129 // if it's a singleton, return it (don't wrap it)
1115- if (peek_css< alternatives <
1116- // exactly<'!'>,
1117- exactly<' ;' >,
1118- exactly<' }' >,
1119- exactly<' {' >,
1120- exactly<' )' >,
1121- exactly<' ]' >,
1122- exactly<' ,' >,
1123- exactly<' :' >,
1124- end_of_file,
1125- exactly<ellipsis>,
1126- default_flag,
1127- global_flag
1128- > >(position)
1129- ) { return disj1; }
1130+ if (peek_css< space_list_terminator >(position)
1131+ ) {
1132+ return disj1; }
11301133
11311134 List_Obj space_list = SASS_MEMORY_NEW (List, pstate, 2 , SASS_SPACE);
11321135 space_list->append (disj1);
11331136
1134- while (!(peek_css< alternatives <
1135- // exactly<'!'>,
1136- exactly<' ;' >,
1137- exactly<' }' >,
1138- exactly<' {' >,
1139- exactly<' )' >,
1140- exactly<' ]' >,
1141- exactly<' ,' >,
1142- exactly<' :' >,
1143- end_of_file,
1144- exactly<ellipsis>,
1145- default_flag,
1146- global_flag
1147- > >(position)) && peek_css< optional_css_whitespace >() != end
1137+ while (
1138+ !(peek_css< space_list_terminator >(position)) &&
1139+ peek_css< optional_css_whitespace >() != end
11481140 ) {
11491141 // the space is parsed implicitly?
11501142 space_list->append (parse_disjunction ());
@@ -1339,18 +1331,10 @@ namespace Sass {
13391331 }
13401332 else if (lex_css< exactly<' [' > >()) {
13411333 // explicit bracketed
1342- Expression_Obj value = parse_list ();
1334+ Expression_Obj value = parse_bracket_list ();
13431335 // lex the expected closing square bracket
13441336 if (!lex_css< exactly<' ]' > >()) error (" unclosed squared bracket" , pstate);
1345- // fix delimiter
1346- List_Obj list = SASS_MEMORY_CAST (List, value);
1347- if (!list || list->delimiter () != SASS_NO_DELIMITER) {
1348- List_Ptr outer_list = SASS_MEMORY_NEW (List, pstate, 1 , SASS_SPACE, false , SASS_BRACKETS);
1349- outer_list->append (&value);
1350- return outer_list;
1351- }
1352- list->delimiter (SASS_BRACKETS);
1353- return value;
1337+ return &value;
13541338 }
13551339 // string may be interpolated
13561340 // if (lex< quoted_string >()) {
0 commit comments