@@ -514,6 +514,7 @@ function pr_isIE6() {
514514 } ) ( ) ;
515515
516516 var nPatterns = fallthroughStylePatterns . length ;
517+ var notWs = / \S / ;
517518
518519 return function ( sourceCode , opt_basePos ) {
519520 opt_basePos = opt_basePos || 0 ;
@@ -557,7 +558,7 @@ function pr_isIE6() {
557558 decorations . push ( opt_basePos + pos , style ) ;
558559 pos += token . length ;
559560 tail = tail . substring ( token . length ) ;
560- if ( style !== PR_COMMENT && / \S / . test ( token ) ) { lastToken = token ; }
561+ if ( style !== PR_COMMENT && notWs . test ( token ) ) { lastToken = token ; }
561562 }
562563 return decorations ;
563564 } ;
@@ -677,16 +678,25 @@ function pr_isIE6() {
677678 }
678679 if ( options . cStyleComments ) {
679680 fallthroughStylePatterns . push ( [ PR_COMMENT , / ^ \/ \/ [ ^ \r \n ] * / , null ] ) ;
680- }
681- if ( options . regexLiterals ) {
682681 fallthroughStylePatterns . push (
683- [ PR_STRING ,
684- / ^ \/ (?: [ ^ \\ \* \/ \[ ] | \\ [ \s \S ] | \[ (?: [ ^ \] \\ ] | \\ .) * (?: \] | $ ) ) + (?: \/ | $ ) / ,
685- REGEXP_PRECEDER_PATTERN ] ) ;
682+ [ PR_COMMENT , / ^ \/ \* [ \s \S ] * ?(?: \* \/ | $ ) / , null ] ) ;
686683 }
687- if ( options . cStyleComments ) {
684+ if ( options . regexLiterals ) {
685+ var REGEX_LITERAL = (
686+ // A regular expression literal starts with a slash that is
687+ // not followed by * or / so that it is not confused with
688+ // comments.
689+ '^/(?=[^/*])'
690+ // and then contains any number of raw characters,
691+ + '(?:[^/\\x5B\\x5C]'
692+ // escape sequences (\x5C),
693+ + '|\\x5C[\\s\\S]'
694+ // or non-nesting character sets (\x5B\x5D);
695+ + '|\\x5B(?:[^\\x5C\\x5D]|\\x5C[\\s\\S])*(?:\\x5D|$))+'
696+ // finally closed by a /.
697+ + '(?:/|$)' ) ;
688698 fallthroughStylePatterns . push (
689- [ PR_COMMENT , / ^ \/ \* [ \s \S ] * ? (?: \* \/ | $ ) / , null ] ) ;
699+ [ PR_STRING , new RegExp ( REGEX_LITERAL ) , REGEXP_PRECEDER_PATTERN ] ) ;
690700 }
691701
692702 var keywords = wordSet ( options . keywords ) ;
0 commit comments