@@ -385,22 +385,27 @@ namespace Sass {
385
385
386
386
Parameters_Obj Parser::parse_parameters ()
387
387
{
388
- std::string name (lexed);
389
- Position position = after_token;
390
388
Parameters_Obj params = SASS_MEMORY_NEW (Parameters, pstate);
391
389
if (lex_css< exactly<' (' > >()) {
392
390
// if there's anything there at all
393
391
if (!peek_css< exactly<' )' > >()) {
394
- do params->append (parse_parameter ());
395
- while (lex_css< exactly<' ,' > >());
392
+ do {
393
+ if (peek< exactly<' )' > >()) break ;
394
+ params->append (parse_parameter ());
395
+ } while (lex_css< exactly<' ,' > >());
396
+ }
397
+ if (!lex_css< exactly<' )' > >()) {
398
+ css_error (" Invalid CSS" , " after " , " : expected \" )\" , was " );
396
399
}
397
- if (!lex_css< exactly<' )' > >()) error (" expected a variable name (e.g. $x) or ')' for the parameter list for " + name, position);
398
400
}
399
401
return params;
400
402
}
401
403
402
404
Parameter_Obj Parser::parse_parameter ()
403
405
{
406
+ if (peek< alternatives< exactly<' ,' >, exactly< ' {' >, exactly<' ;' > > >()) {
407
+ css_error (" Invalid CSS" , " after " , " : expected variable (e.g. $foo), was " );
408
+ }
404
409
while (lex< alternatives < spaces, block_comment > >());
405
410
lex < variable >();
406
411
std::string name (Util::normalize_underscores (lexed));
@@ -420,22 +425,27 @@ namespace Sass {
420
425
421
426
Arguments_Obj Parser::parse_arguments ()
422
427
{
423
- std::string name (lexed);
424
- Position position = after_token;
425
428
Arguments_Obj args = SASS_MEMORY_NEW (Arguments, pstate);
426
429
if (lex_css< exactly<' (' > >()) {
427
430
// if there's anything there at all
428
431
if (!peek_css< exactly<' )' > >()) {
429
- do args->append (parse_argument ());
430
- while (lex_css< exactly<' ,' > >());
432
+ do {
433
+ if (peek< exactly<' )' > >()) break ;
434
+ args->append (parse_argument ());
435
+ } while (lex_css< exactly<' ,' > >());
436
+ }
437
+ if (!lex_css< exactly<' )' > >()) {
438
+ css_error (" Invalid CSS" , " after " , " : expected expression (e.g. 1px, bold), was " );
431
439
}
432
- if (!lex_css< exactly<' )' > >()) error (" expected a variable name (e.g. $x) or ')' for the parameter list for " + name, position);
433
440
}
434
441
return args;
435
442
}
436
443
437
444
Argument_Obj Parser::parse_argument ()
438
445
{
446
+ if (peek< alternatives< exactly<' ,' >, exactly< ' {' >, exactly<' ;' > > >()) {
447
+ css_error (" Invalid CSS" , " after " , " : expected \" )\" , was " );
448
+ }
439
449
if (peek_css< sequence < exactly< hash_lbrace >, exactly< rbrace > > >()) {
440
450
position += 2 ;
441
451
css_error (" Invalid CSS" , " after " , " : expected expression (e.g. 1px, bold), was " );
0 commit comments