@@ -1146,6 +1146,9 @@ export class Tokenizer extends DiagnosticEmitter {
1146
1146
}
1147
1147
return this . readUnicodeEscape ( ) ; // \uDDDD
1148
1148
}
1149
+ case CharCode . x : {
1150
+ return this . readHexadecimalEscape ( ) ; // \xDD
1151
+ }
1149
1152
case CharCode . CARRIAGERETURN : {
1150
1153
if (
1151
1154
this . pos < end &&
@@ -1237,21 +1240,18 @@ export class Tokenizer extends DiagnosticEmitter {
1237
1240
testInteger ( ) : bool {
1238
1241
var end = this . end ;
1239
1242
var text = this . source . text ;
1240
- if ( this . pos + 1 < end && text . charCodeAt ( this . pos ) == CharCode . _0 ) {
1241
- switch ( text . charCodeAt ( this . pos + 2 ) ) {
1243
+ var pos = this . pos ;
1244
+ if ( pos + 1 < end && text . charCodeAt ( pos ) == CharCode . _0 ) {
1245
+ switch ( text . charCodeAt ( pos + 2 ) | 32 ) {
1242
1246
case CharCode . x :
1243
- case CharCode . X :
1244
1247
case CharCode . b :
1245
- case CharCode . B :
1246
- case CharCode . o :
1247
- case CharCode . O : return true ;
1248
+ case CharCode . o : return true ;
1248
1249
}
1249
1250
}
1250
- var pos = this . pos ;
1251
1251
while ( pos < end ) {
1252
1252
let c = text . charCodeAt ( pos ) ;
1253
- if ( c == CharCode . DOT || c == CharCode . e || c == CharCode . E ) return false ;
1254
- if ( ( c < CharCode . _0 || c > CharCode . _9 ) && c != CharCode . _ ) break ;
1253
+ if ( c == CharCode . DOT || ( c | 32 ) == CharCode . e ) return false ;
1254
+ if ( c != CharCode . _ && ( c < CharCode . _0 || c > CharCode . _9 ) ) break ;
1255
1255
// does not validate separator placement (this is done in readXYInteger)
1256
1256
pos ++ ;
1257
1257
}
@@ -1261,19 +1261,16 @@ export class Tokenizer extends DiagnosticEmitter {
1261
1261
readInteger ( ) : I64 {
1262
1262
var text = this . source . text ;
1263
1263
if ( this . pos + 2 < this . end && text . charCodeAt ( this . pos ) == CharCode . _0 ) {
1264
- switch ( text . charCodeAt ( this . pos + 1 ) ) {
1265
- case CharCode . x :
1266
- case CharCode . X : {
1264
+ switch ( text . charCodeAt ( this . pos + 1 ) | 32 ) {
1265
+ case CharCode . x : {
1267
1266
this . pos += 2 ;
1268
1267
return this . readHexInteger ( ) ;
1269
1268
}
1270
- case CharCode . b :
1271
- case CharCode . B : {
1269
+ case CharCode . b : {
1272
1270
this . pos += 2 ;
1273
1271
return this . readBinaryInteger ( ) ;
1274
1272
}
1275
- case CharCode . o :
1276
- case CharCode . O : {
1273
+ case CharCode . o : {
1277
1274
this . pos += 2 ;
1278
1275
return this . readOctalInteger ( ) ;
1279
1276
}
@@ -1517,7 +1514,7 @@ export class Tokenizer extends DiagnosticEmitter {
1517
1514
}
1518
1515
if ( this . pos < end ) {
1519
1516
let c = text . charCodeAt ( this . pos ) ;
1520
- if ( c == CharCode . e || c == CharCode . E ) {
1517
+ if ( ( c | 32 ) == CharCode . e ) {
1521
1518
if (
1522
1519
++ this . pos < end &&
1523
1520
( c = text . charCodeAt ( this . pos ) ) == CharCode . MINUS || c == CharCode . PLUS &&
@@ -1537,8 +1534,7 @@ export class Tokenizer extends DiagnosticEmitter {
1537
1534
throw new Error ( "not implemented" ) ; // TBD
1538
1535
}
1539
1536
1540
- readUnicodeEscape ( ) : string {
1541
- var remain = 4 ;
1537
+ readHexadecimalEscape ( remain : i32 = 2 ) : string {
1542
1538
var value = 0 ;
1543
1539
var end = this . end ;
1544
1540
var text = this . source . text ;
@@ -1569,6 +1565,10 @@ export class Tokenizer extends DiagnosticEmitter {
1569
1565
return String . fromCharCode ( value ) ;
1570
1566
}
1571
1567
1568
+ readUnicodeEscape ( ) : string {
1569
+ return this . readHexadecimalEscape ( 4 ) ;
1570
+ }
1571
+
1572
1572
private readExtendedUnicodeEscape ( ) : string {
1573
1573
var start = this . pos ;
1574
1574
var value = this . readHexInteger ( ) ;
@@ -1603,11 +1603,11 @@ export class Tokenizer extends DiagnosticEmitter {
1603
1603
}
1604
1604
1605
1605
if ( invalid ) return "" ;
1606
- return value32 < 65536
1606
+ return value32 < 0x10000
1607
1607
? String . fromCharCode ( value32 )
1608
1608
: String . fromCharCode (
1609
- ( ( value32 - 65536 ) >>> 10 ) + 0xD800 ,
1610
- ( ( value32 - 65536 ) & 1023 ) + 0xDC00
1609
+ ( ( value32 - 0x10000 ) >>> 10 ) | 0xD800 ,
1610
+ ( ( value32 - 0x10000 ) & 1023 ) | 0xDC00
1611
1611
) ;
1612
1612
}
1613
1613
0 commit comments