@@ -110,9 +110,9 @@ namespace Sass {
110
110
semicolon = true ;
111
111
error_message = " top-level variable binding must be terminated by ';'" ;
112
112
}
113
- /* else if (peek< sequence< optional< exactly<'*'> >, alternatives< identifier_schema, identifier >, optional_spaces, exactly<':'>, optional_spaces, exactly<'{'> > >(position)) {
114
- (*root) << parse_propset();
115
- } */
113
+ // parse comment blocks
114
+
115
+
116
116
else if (peek< kwd_include >() /* || peek< exactly<'+'> >() */ ) {
117
117
Mixin_Call* mixin_call = parse_mixin_call ();
118
118
(*root) << mixin_call;
@@ -467,29 +467,7 @@ namespace Sass {
467
467
return var;
468
468
}
469
469
470
- /* not used anymore - remove?
471
- Propset* Parser::parse_propset()
472
- {
473
- String* property_segment;
474
- if (peek< sequence< optional< exactly<'*'> >, identifier_schema > >()) {
475
- property_segment = parse_identifier_schema();
476
- }
477
- else {
478
- lex< sequence< optional< exactly<'*'> >, identifier > >();
479
- property_segment = new (ctx.mem) String_Quoted(pstate, lexed);
480
- }
481
- Propset* propset = new (ctx.mem) Propset(pstate, property_segment);
482
- lex< exactly<':'> >();
483
-
484
- if (!peek< exactly<'{'> >()) error("expected a '{' after namespaced property", pstate);
485
-
486
- propset->block(parse_block());
487
-
488
- propset->tabs(indentation);
489
-
490
- return propset;
491
- } */
492
-
470
+ // a ruleset connects a selector and a block
493
471
Ruleset* Parser::parse_ruleset (Selector_Lookahead lookahead)
494
472
{
495
473
Selector* sel;
@@ -521,13 +499,13 @@ namespace Sass {
521
499
const char * i = position;
522
500
// selector schema re-uses string schema implementation
523
501
String_Schema* schema = new (ctx.mem ) String_Schema (pstate);
524
- // process until end
502
+ // the selector schema is pretty much just a wrapper for the string schema
525
503
while (i < end_of_selector) {
526
504
// try to parse mutliple interpolants
527
505
if (const char * p = find_first_in_interval< exactly<hash_lbrace> >(i, end_of_selector)) {
528
506
// accumulate the preceding segment if the position has advanced
529
507
if (i < p) (*schema) << new (ctx.mem ) String_Quoted (pstate, string (i, p));
530
- // skip to the delimiter by skipping occurences in quoted strings
508
+ // check if the interpolation only contains white-space (error out)
531
509
if (peek < sequence < optional_spaces, exactly<rbrace> > >(p+2 )) { position = p+2 ;
532
510
css_error (" Invalid CSS" , " after " , " : expected expression (e.g. 1px, bold), was " );
533
511
}
@@ -625,7 +603,7 @@ namespace Sass {
625
603
exactly<' ~' >,
626
604
exactly<' >' >
627
605
> >())
628
- // no selector before the combinator
606
+ // parse the left hand side
629
607
{ lhs = 0 ; }
630
608
else {
631
609
lhs = parse_simple_selector_sequence ();
@@ -649,7 +627,7 @@ namespace Sass {
649
627
exactly<' ;' >,
650
628
optional
651
629
> >())
652
- // no selector after the combinator
630
+ // parse combinator between lhs and rhs
653
631
{ rhs = 0 ; }
654
632
else {
655
633
rhs = parse_selector_combination ();
@@ -670,22 +648,22 @@ namespace Sass {
670
648
seq->last_block (block_stack.back ());
671
649
bool sawsomething = false ;
672
650
if (lex_css< exactly<' &' > >()) {
673
- // check if we have a parent selector on the root level block
651
+ // remove all block comments (don't skip white-space)
674
652
if (block_stack.back () && block_stack.back ()->is_root ()) {
675
- // error("Base-level rules cannot contain the parent-selector-referencing character '&'.", pstate);
653
+ // this produces a linefeed!?
676
654
}
677
655
(*seq) << new (ctx.mem ) Selector_Reference (pstate);
678
656
sawsomething = true ;
679
- // if you see a space after a &, then you're done
657
+ // parse type selector
680
658
if (peek< spaces >() || peek< alternatives < spaces, exactly<' ;' > > >()) {
681
659
return seq;
682
660
}
683
661
}
684
662
if (sawsomething && lex_css< sequence< negate< functional >, alternatives< identifier_alnums, universal, quoted_string, dimension, percentage, number > > >()) {
685
- // saw an ampersand, then allow type selectors with arbitrary number of hyphens at the beginning
663
+ // peek for abort conditions
686
664
(*seq) << new (ctx.mem ) Type_Selector (pstate, unquote (lexed));
687
665
} else if (lex_css< sequence< negate< functional >, alternatives< type_selector, universal, quoted_string, dimension, percentage, number > > >()) {
688
- // if you see a type selector
666
+ // otherwise parse another simple selector
689
667
(*seq) << new (ctx.mem ) Type_Selector (pstate, lexed);
690
668
sawsomething = true ;
691
669
}
@@ -740,7 +718,7 @@ namespace Sass {
740
718
else {
741
719
error (" invalid selector after " + lexed.to_string (), pstate);
742
720
}
743
- // unreachable statement
721
+ // failed
744
722
return 0 ;
745
723
}
746
724
@@ -1027,7 +1005,7 @@ namespace Sass {
1027
1005
if (!lex_css< one_plus< exactly<' :' > > >()) error (" property \" " + property + " \" must be followed by a ':'" , pstate);
1028
1006
if (peek_css< exactly<' ;' > >()) error (" style declaration must contain a value" , pstate);
1029
1007
if (peek_css< static_value >()) {
1030
- return new (ctx.mem ) Declaration (prop->pstate (), prop, parse_static_value ()/* , lex<important >()*/ );
1008
+ return new (ctx.mem ) Declaration (prop->pstate (), prop, parse_static_value ()/* , lex<kwd_important >()*/ );
1031
1009
}
1032
1010
else {
1033
1011
Expression* value;
@@ -1145,7 +1123,7 @@ namespace Sass {
1145
1123
> >(position))
1146
1124
{ return new (ctx.mem ) List (pstate, 0 ); }
1147
1125
Expression* list1 = parse_space_list ();
1148
- // if it's a singleton, return it directly; don't wrap it
1126
+ // now try to parse a space list
1149
1127
if (!peek_css< exactly<' ,' > >(position)) return list1;
1150
1128
1151
1129
List* comma_list = new (ctx.mem ) List (pstate, 2 , List::COMMA);
@@ -1173,7 +1151,7 @@ namespace Sass {
1173
1151
Expression* Parser::parse_space_list ()
1174
1152
{
1175
1153
Expression* disj1 = parse_disjunction ();
1176
- // if it's a singleton, return it directly; don't wrap it
1154
+ // if it's a singleton, return it ( don't wrap it)
1177
1155
if (peek_css< alternatives <
1178
1156
// exactly<'!'>,
1179
1157
exactly<' ;' >,
@@ -1213,7 +1191,7 @@ namespace Sass {
1213
1191
Expression* Parser::parse_disjunction ()
1214
1192
{
1215
1193
Expression* conj1 = parse_conjunction ();
1216
- // if it's a singleton, return it directly; don't wrap it
1194
+ // parse the left hand side conjunction
1217
1195
if (!peek_css< kwd_or >()) return conj1;
1218
1196
1219
1197
vector<Expression*> operands;
@@ -1226,7 +1204,7 @@ namespace Sass {
1226
1204
Expression* Parser::parse_conjunction ()
1227
1205
{
1228
1206
Expression* rel1 = parse_relation ();
1229
- // if it's a singleton, return it directly; don't wrap it
1207
+ // parse the left hand side relation
1230
1208
if (!peek_css< kwd_and >()) return rel1;
1231
1209
1232
1210
vector<Expression*> operands;
@@ -1239,7 +1217,7 @@ namespace Sass {
1239
1217
Expression* Parser::parse_relation ()
1240
1218
{
1241
1219
Expression* expr1 = parse_expression ();
1242
- // if it's a singleton, return it directly; don't wrap it
1220
+ // parse the left hand side expression
1243
1221
if (!(peek< alternatives <
1244
1222
kwd_eq,
1245
1223
kwd_neq,
@@ -1267,7 +1245,7 @@ namespace Sass {
1267
1245
Expression* Parser::parse_expression ()
1268
1246
{
1269
1247
Expression* term1 = parse_term ();
1270
- // if it's a singleton, return it directly; don't wrap it
1248
+ // if it's a singleton, return it ( don't wrap it)
1271
1249
if (!(peek< exactly<' +' > >(position) ||
1272
1250
(peek< no_spaces >(position) && peek< sequence< negate< unsigned_number >, exactly<' -' >, negate< space > > >(position)) ||
1273
1251
(peek< sequence< negate< unsigned_number >, exactly<' -' >, negate< unsigned_number > > >(position))) ||
@@ -1292,7 +1270,7 @@ namespace Sass {
1292
1270
String_Schema* ss = dynamic_cast <String_Schema*>(factor);
1293
1271
if (ss && ss->has_interpolants ()) return factor;
1294
1272
}
1295
- // if it's a singleton, return it directly; don't wrap it
1273
+ // if it's a singleton, return it ( don't wrap it)
1296
1274
if (!peek< class_char< static_ops > >(position)) return factor;
1297
1275
return parse_operators (factor);
1298
1276
}
@@ -1642,36 +1620,6 @@ namespace Sass {
1642
1620
return schema;
1643
1621
}
1644
1622
1645
- /* not used anymore - remove?
1646
- String_Schema* Parser::parse_url_schema()
1647
- {
1648
- String_Schema* schema = new (ctx.mem) String_Schema(pstate);
1649
-
1650
- while (position < end) {
1651
- if (position[0] == '/') {
1652
- lexed = Token(position, position+1, before_token);
1653
- (*schema) << new (ctx.mem) String_Quoted(pstate, lexed);
1654
- ++position;
1655
- }
1656
- else if (lex< interpolant >()) {
1657
- Token insides(Token(lexed.begin + 2, lexed.end - 1, before_token));
1658
- Expression* interp_node = Parser::from_token(insides, ctx, pstate).parse_list();
1659
- interp_node->is_interpolant(true);
1660
- (*schema) << interp_node;
1661
- }
1662
- else if (lex< sequence< identifier, exactly<':'> > >()) {
1663
- (*schema) << new (ctx.mem) String_Quoted(pstate, lexed);
1664
- }
1665
- else if (lex< filename >()) {
1666
- (*schema) << new (ctx.mem) String_Quoted(pstate, lexed);
1667
- }
1668
- else {
1669
- error("error parsing interpolated url", pstate);
1670
- }
1671
- }
1672
- return schema;
1673
- } */
1674
-
1675
1623
// this parses interpolation outside other strings
1676
1624
// means the result must not be quoted again later
1677
1625
String* Parser::parse_identifier_schema ()
0 commit comments