summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEevee (Alex Munroe) <eevee.git@veekun.com>2014-10-17 15:53:18 -0700
committerEevee (Alex Munroe) <eevee.git@veekun.com>2014-10-17 15:53:18 -0700
commitb6d086d4802ecc21f4d799ee9d9a74bcafeba897 (patch)
tree722d3ea42731567f65359e76455440e8161cf6c9
parent42cd58952d71e30ef8ef51996394be217d76c415 (diff)
downloadpyscss-b6d086d4802ecc21f4d799ee9d9a74bcafeba897.tar.gz
Allow arbitrary expressions as map keys, beyond the first key. Fixes #306.
-rw-r--r--scss/grammar/expression.g3
-rw-r--r--scss/grammar/expression.py7
-rw-r--r--scss/tests/files/general/maps-complex-keys.css3
-rw-r--r--scss/tests/files/general/maps-complex-keys.scss22
4 files changed, 31 insertions, 4 deletions
diff --git a/scss/grammar/expression.g b/scss/grammar/expression.g
index b843dc7..454e112 100644
--- a/scss/grammar/expression.g
+++ b/scss/grammar/expression.g
@@ -158,7 +158,8 @@ parser SassExpression:
)
rule map_item:
- atom ":" expr_slst {{ return (atom, expr_slst) }}
+ expr_slst {{ left = expr_slst }}
+ ":" expr_slst {{ return (left, expr_slst) }}
# Lists:
diff --git a/scss/grammar/expression.py b/scss/grammar/expression.py
index 1187d18..b2ba877 100644
--- a/scss/grammar/expression.py
+++ b/scss/grammar/expression.py
@@ -185,10 +185,11 @@ class SassExpression(Parser):
return ListLiteral(items) if use_list else items[0]
def map_item(self):
- atom = self.atom()
+ expr_slst = self.expr_slst()
+ left = expr_slst
self._scan('":"')
expr_slst = self.expr_slst()
- return (atom, expr_slst)
+ return (left, expr_slst)
def expr_lst(self):
expr_slst = self.expr_slst()
@@ -514,7 +515,7 @@ class SassExpression(Parser):
return Interpolation.maybe(parts)
atom_chks_ = frozenset(['BAREWORD', 'INTERP_START'])
- expr_map_or_list_rsts__ = frozenset(['LPAR', 'DOUBLE_QUOTE', 'BAREWORD', 'URL_FUNCTION', 'INTERP_START', 'COLOR', 'ALPHA_FUNCTION', 'RPAR', 'VAR', 'NUM', 'FNCT', 'LITERAL_FUNCTION', 'BANG_IMPORTANT', 'SINGLE_QUOTE', '","'])
+ expr_map_or_list_rsts__ = frozenset(['LPAR', 'DOUBLE_QUOTE', 'VAR', 'URL_FUNCTION', 'BAREWORD', 'COLOR', 'ALPHA_FUNCTION', 'INTERP_START', 'SIGN', 'LITERAL_FUNCTION', 'ADD', 'NUM', 'RPAR', 'FNCT', 'NOT', 'BANG_IMPORTANT', 'SINGLE_QUOTE', '","'])
u_expr_chks = frozenset(['LPAR', 'DOUBLE_QUOTE', 'BAREWORD', 'URL_FUNCTION', 'INTERP_START', 'COLOR', 'ALPHA_FUNCTION', 'VAR', 'NUM', 'FNCT', 'LITERAL_FUNCTION', 'BANG_IMPORTANT', 'SINGLE_QUOTE'])
m_expr_rsts = frozenset(['LPAR', 'DOUBLE_QUOTE', 'SUB', 'ALPHA_FUNCTION', 'RPAR', 'MUL', 'INTERP_END', 'BANG_IMPORTANT', 'DIV', 'LE', 'URL_FUNCTION', 'INTERP_START', 'COLOR', 'NE', 'LT', 'NUM', '":"', 'LITERAL_FUNCTION', 'GT', 'END', 'SIGN', 'BAREWORD', 'GE', 'FNCT', 'VAR', 'EQ', 'AND', 'ADD', 'SINGLE_QUOTE', 'NOT', 'OR', '","'])
interpolated_bare_url_rsts_ = frozenset(['RPAR', 'INTERP_START', 'BAREURL', 'SPACE'])
diff --git a/scss/tests/files/general/maps-complex-keys.css b/scss/tests/files/general/maps-complex-keys.css
new file mode 100644
index 0000000..68cc0b2
--- /dev/null
+++ b/scss/tests/files/general/maps-complex-keys.css
@@ -0,0 +1,3 @@
+caption {
+ properties: show hide show-columns show-baseline;
+}
diff --git a/scss/tests/files/general/maps-complex-keys.scss b/scss/tests/files/general/maps-complex-keys.scss
new file mode 100644
index 0000000..8698bd6
--- /dev/null
+++ b/scss/tests/files/general/maps-complex-keys.scss
@@ -0,0 +1,22 @@
+// Taken from issue #306
+$susy-keywords: (
+ container: auto,
+ math: static fluid,
+ output: isolate float,
+ container-position: left center right,
+ flow: ltr rtl,
+ gutter-position: before after split inside inside-static,
+ box-sizing: border-box content-box,
+ span: full,
+ edge: first alpha last omega full,
+ spread: narrow wide wider,
+ gutter-override: no-gutters no-gutter,
+ role: nest,
+ clear: break nobreak,
+ debug image: show hide show-columns show-baseline,
+ debug output: background overlay,
+);
+
+caption {
+ properties: map-get($susy-keywords, debug image);
+}