@@ -385,22 +385,27 @@ namespace Sass {
385385
386386 Parameters_Obj Parser::parse_parameters ()
387387 {
388- std::string name (lexed);
389- Position position = after_token;
390388 Parameters_Obj params = SASS_MEMORY_NEW (Parameters, pstate);
391389 if (lex_css< exactly<' (' > >()) {
392390 // if there's anything there at all
393391 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 " );
396399 }
397- if (!lex_css< exactly<' )' > >()) error (" expected a variable name (e.g. $x) or ')' for the parameter list for " + name, position);
398400 }
399401 return params;
400402 }
401403
402404 Parameter_Obj Parser::parse_parameter ()
403405 {
406+ if (peek< alternatives< exactly<' ,' >, exactly< ' {' >, exactly<' ;' > > >()) {
407+ css_error (" Invalid CSS" , " after " , " : expected variable (e.g. $foo), was " );
408+ }
404409 while (lex< alternatives < spaces, block_comment > >());
405410 lex < variable >();
406411 std::string name (Util::normalize_underscores (lexed));
@@ -420,22 +425,27 @@ namespace Sass {
420425
421426 Arguments_Obj Parser::parse_arguments ()
422427 {
423- std::string name (lexed);
424- Position position = after_token;
425428 Arguments_Obj args = SASS_MEMORY_NEW (Arguments, pstate);
426429 if (lex_css< exactly<' (' > >()) {
427430 // if there's anything there at all
428431 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 " );
431439 }
432- if (!lex_css< exactly<' )' > >()) error (" expected a variable name (e.g. $x) or ')' for the parameter list for " + name, position);
433440 }
434441 return args;
435442 }
436443
437444 Argument_Obj Parser::parse_argument ()
438445 {
446+ if (peek< alternatives< exactly<' ,' >, exactly< ' {' >, exactly<' ;' > > >()) {
447+ css_error (" Invalid CSS" , " after " , " : expected \" )\" , was " );
448+ }
439449 if (peek_css< sequence < exactly< hash_lbrace >, exactly< rbrace > > >()) {
440450 position += 2 ;
441451 css_error (" Invalid CSS" , " after " , " : expected expression (e.g. 1px, bold), was " );
0 commit comments