Skip to content

Commit cccda81

Browse files
committed
Merge pull request #1354 from mgreter/feature/interpolate-ns-in-ref-comb
Fix parsing for interpolated reference combinator
2 parents 1184e99 + e78ba4b commit cccda81

File tree

3 files changed

+59
-7
lines changed

3 files changed

+59
-7
lines changed

parser.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -739,7 +739,7 @@ namespace Sass {
739739
else if (lex< sequence < exactly<'/'>, negate < exactly < '*' > > > >()) {
740740
// comments are allowed, but not spaces?
741741
combinator = Complex_Selector::REFERENCE;
742-
if (!lex < identifier >()) return 0; // ToDo: error msg?
742+
if (!lex < re_reference_combinator >()) return 0;
743743
reference = new (ctx.mem) String_Quoted(pstate, lexed);
744744
if (!lex < exactly < '/' > >()) return 0; // ToDo: error msg?
745745
}
@@ -851,7 +851,7 @@ namespace Sass {
851851
else if (lex< quoted_string >()) {
852852
return new (ctx.mem) Type_Selector(pstate, unquote(lexed));
853853
}
854-
else if (lex< alternatives < variable, number, re_reference_selector > >()) {
854+
else if (lex< alternatives < variable, number, static_reference_combinator > >()) {
855855
return new (ctx.mem) Type_Selector(pstate, lexed);
856856
}
857857
else if (peek< pseudo_not >()) {
@@ -2146,8 +2146,8 @@ namespace Sass {
21462146
// consume whitespace and comments
21472147
spaces, block_comment, line_comment,
21482148
// match `/deep/` selector (pass-trough)
2149-
// there is no functionality for it yet
2150-
re_reference_selector,
2149+
// match reference /\/[^\/]+\//;
2150+
schema_reference_combinator,
21512151
// match selector ops /[*&%,()\[\]]/
21522152
class_char < selector_lookahead_ops >,
21532153
// match selector combinators /[>+~]/

prelexer.cpp

Lines changed: 52 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -214,8 +214,56 @@ namespace Sass {
214214
return sequence<exactly<'@'>, identifier>(src);
215215
}
216216

217-
const char* re_reference_selector(const char* src) {
218-
return sequence < exactly <'/'>, identifier, exactly <'/'> >(src);
217+
const char* re_reference_combinator(const char* src) {
218+
return sequence <
219+
optional <
220+
sequence <
221+
zero_plus <
222+
exactly <'-'>
223+
>,
224+
identifier,
225+
exactly <'|'>
226+
>
227+
>,
228+
zero_plus <
229+
exactly <'-'>
230+
>,
231+
identifier
232+
>(src);
233+
}
234+
235+
const char* static_reference_combinator(const char* src) {
236+
return sequence <
237+
exactly <'/'>,
238+
re_reference_combinator,
239+
exactly <'/'>
240+
>(src);
241+
}
242+
243+
const char* schema_reference_combinator(const char* src) {
244+
return sequence <
245+
exactly <'/'>,
246+
optional <
247+
sequence <
248+
zero_plus <
249+
exactly <'-'>
250+
>,
251+
alternatives <
252+
identifier,
253+
interpolant
254+
>,
255+
exactly <'|'>
256+
>
257+
>,
258+
zero_plus <
259+
exactly <'-'>
260+
>,
261+
alternatives <
262+
identifier,
263+
interpolant
264+
>,
265+
exactly <'/'>
266+
> (src);
219267
}
220268

221269
const char* kwd_import(const char* src) {
@@ -754,6 +802,8 @@ namespace Sass {
754802
static_string,
755803
percentage,
756804
hex,
805+
exactly<'|'>,
806+
// exactly<'+'>,
757807
number,
758808
sequence< exactly<'!'>, word<important_kwd> >
759809
>(src);

prelexer.hpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,9 @@ namespace Sass {
197197
const char* identifier_alnum(const char* src);
198198
const char* identifier_alnums(const char* src);
199199
// Match reference selector.
200-
const char* re_reference_selector(const char* src);
200+
const char* re_reference_combinator(const char* src);
201+
const char* static_reference_combinator(const char* src);
202+
const char* schema_reference_combinator(const char* src);
201203

202204
// Match interpolant schemas
203205
const char* identifier_schema(const char* src);

0 commit comments

Comments
 (0)