@@ -2522,24 +2522,23 @@ export function createScanner(languageVersion: ScriptTarget, skipTrivia: boolean
2522
2522
if ( ! isIdentifierPart ( ch , languageVersion ) ) {
2523
2523
break ;
2524
2524
}
2525
- const size = charSize ( ch ) ;
2526
2525
if ( reportErrors ) {
2527
- const flag = characterToRegularExpressionFlag ( utf16EncodeAsString ( ch ) ) ;
2526
+ const flag = characterToRegularExpressionFlag ( String . fromCharCode ( ch ) ) ;
2528
2527
if ( flag === undefined ) {
2529
- error ( Diagnostics . Unknown_regular_expression_flag , pos , size ) ;
2528
+ error ( Diagnostics . Unknown_regular_expression_flag , pos , 1 ) ;
2530
2529
}
2531
2530
else if ( regExpFlags & flag ) {
2532
- error ( Diagnostics . Duplicate_regular_expression_flag , pos , size ) ;
2531
+ error ( Diagnostics . Duplicate_regular_expression_flag , pos , 1 ) ;
2533
2532
}
2534
2533
else if ( ( ( regExpFlags | flag ) & RegularExpressionFlags . UnicodeMode ) === RegularExpressionFlags . UnicodeMode ) {
2535
- error ( Diagnostics . The_Unicode_u_flag_and_the_Unicode_Sets_v_flag_cannot_be_set_simultaneously , pos , size ) ;
2534
+ error ( Diagnostics . The_Unicode_u_flag_and_the_Unicode_Sets_v_flag_cannot_be_set_simultaneously , pos , 1 ) ;
2536
2535
}
2537
2536
else {
2538
2537
regExpFlags |= flag ;
2539
- checkRegularExpressionFlagAvailability ( flag , size ) ;
2538
+ checkRegularExpressionFlagAvailable ( flag , pos ) ;
2540
2539
}
2541
2540
}
2542
- pos += size ;
2541
+ pos ++ ;
2543
2542
}
2544
2543
if ( reportErrors ) {
2545
2544
scanRange ( startOfRegExpBody , endOfRegExpBody - startOfRegExpBody , ( ) => {
@@ -2795,26 +2794,25 @@ export function createScanner(languageVersion: ScriptTarget, skipTrivia: boolean
2795
2794
2796
2795
function scanPatternModifiers ( currFlags : RegularExpressionFlags ) : RegularExpressionFlags {
2797
2796
while ( true ) {
2798
- const ch = codePointChecked ( pos ) ;
2797
+ const ch = charCodeChecked ( pos ) ;
2799
2798
if ( ch === CharacterCodes . EOF || ! isIdentifierPart ( ch , languageVersion ) ) {
2800
2799
break ;
2801
2800
}
2802
- const size = charSize ( ch ) ;
2803
- const flag = characterToRegularExpressionFlag ( utf16EncodeAsString ( ch ) ) ;
2801
+ const flag = characterToRegularExpressionFlag ( String . fromCharCode ( ch ) ) ;
2804
2802
if ( flag === undefined ) {
2805
- error ( Diagnostics . Unknown_regular_expression_flag , pos , size ) ;
2803
+ error ( Diagnostics . Unknown_regular_expression_flag , pos , 1 ) ;
2806
2804
}
2807
2805
else if ( currFlags & flag ) {
2808
- error ( Diagnostics . Duplicate_regular_expression_flag , pos , size ) ;
2806
+ error ( Diagnostics . Duplicate_regular_expression_flag , pos , 1 ) ;
2809
2807
}
2810
2808
else if ( ! ( flag & RegularExpressionFlags . Modifiers ) ) {
2811
- error ( Diagnostics . This_regular_expression_flag_cannot_be_toggled_within_a_subpattern , pos , size ) ;
2809
+ error ( Diagnostics . This_regular_expression_flag_cannot_be_toggled_within_a_subpattern , pos , 1 ) ;
2812
2810
}
2813
2811
else {
2814
2812
currFlags |= flag ;
2815
- checkRegularExpressionFlagAvailability ( flag , size ) ;
2813
+ checkRegularExpressionFlagAvailable ( flag , pos ) ;
2816
2814
}
2817
- pos += size ;
2815
+ pos ++ ;
2818
2816
}
2819
2817
return currFlags ;
2820
2818
}
@@ -3527,10 +3525,10 @@ export function createScanner(languageVersion: ScriptTarget, skipTrivia: boolean
3527
3525
} ) ;
3528
3526
}
3529
3527
3530
- function checkRegularExpressionFlagAvailability ( flag : RegularExpressionFlags , size : number ) {
3528
+ function checkRegularExpressionFlagAvailable ( flag : RegularExpressionFlags , pos : number ) {
3531
3529
const availableFrom = regExpFlagToFirstAvailableLanguageVersion . get ( flag ) as ScriptTarget | undefined ;
3532
3530
if ( availableFrom && languageVersion < availableFrom ) {
3533
- error ( Diagnostics . This_regular_expression_flag_is_only_available_when_targeting_0_or_later , pos , size , getNameOfScriptTarget ( availableFrom ) ) ;
3531
+ error ( Diagnostics . This_regular_expression_flag_is_only_available_when_targeting_0_or_later , pos , 1 , getNameOfScriptTarget ( availableFrom ) ) ;
3534
3532
}
3535
3533
}
3536
3534
0 commit comments