@@ -316,7 +316,7 @@ export default (superClass: Class<Parser>): Class<Parser> =>
316
316
const typeNode = this . startNode ( ) ;
317
317
const typeContainer = this . startNode ( ) ;
318
318
319
- if ( this . isRelational ( "<" ) ) {
319
+ if ( this . match ( tt . lt ) ) {
320
320
typeNode . typeParameters = this . flowParseTypeParameterDeclaration ( ) ;
321
321
} else {
322
322
typeNode . typeParameters = null ;
@@ -600,7 +600,7 @@ export default (superClass: Class<Parser>): Class<Parser> =>
600
600
node . id . start ,
601
601
) ;
602
602
603
- if ( this . isRelational ( "<" ) ) {
603
+ if ( this . match ( tt . lt ) ) {
604
604
node . typeParameters = this . flowParseTypeParameterDeclaration ( ) ;
605
605
} else {
606
606
node . typeParameters = null ;
@@ -643,7 +643,7 @@ export default (superClass: Class<Parser>): Class<Parser> =>
643
643
const node = this . startNode ( ) ;
644
644
645
645
node . id = this . flowParseQualifiedTypeIdentifier ( ) ;
646
- if ( this . isRelational ( "<" ) ) {
646
+ if ( this . match ( tt . lt ) ) {
647
647
node . typeParameters = this . flowParseTypeParameterInstantiation ( ) ;
648
648
} else {
649
649
node . typeParameters = null ;
@@ -692,7 +692,7 @@ export default (superClass: Class<Parser>): Class<Parser> =>
692
692
) ;
693
693
this . scope . declareName ( node . id . name , BIND_LEXICAL , node . id . start ) ;
694
694
695
- if ( this . isRelational ( "<" ) ) {
695
+ if ( this . match ( tt . lt ) ) {
696
696
node . typeParameters = this . flowParseTypeParameterDeclaration ( ) ;
697
697
} else {
698
698
node . typeParameters = null ;
@@ -715,7 +715,7 @@ export default (superClass: Class<Parser>): Class<Parser> =>
715
715
) ;
716
716
this . scope . declareName ( node . id . name , BIND_LEXICAL , node . id . start ) ;
717
717
718
- if ( this . isRelational ( "<" ) ) {
718
+ if ( this . match ( tt . lt ) ) {
719
719
node . typeParameters = this . flowParseTypeParameterDeclaration ( ) ;
720
720
} else {
721
721
node . typeParameters = null ;
@@ -770,7 +770,7 @@ export default (superClass: Class<Parser>): Class<Parser> =>
770
770
this . state . inType = true ;
771
771
772
772
// istanbul ignore else: this condition is already checked at all call sites
773
- if ( this . isRelational ( "<" ) || this . match ( tt . jsxTagStart ) ) {
773
+ if ( this . match ( tt . lt ) || this . match ( tt . jsxTagStart ) ) {
774
774
this . next ( ) ;
775
775
} else {
776
776
this . unexpected ( ) ;
@@ -787,11 +787,11 @@ export default (superClass: Class<Parser>): Class<Parser> =>
787
787
defaultRequired = true ;
788
788
}
789
789
790
- if ( ! this . isRelational ( ">" ) ) {
790
+ if ( ! this . match ( tt . gt ) ) {
791
791
this . expect ( tt . comma ) ;
792
792
}
793
- } while ( ! this . isRelational ( ">" ) ) ;
794
- this . expectRelational ( ">" ) ;
793
+ } while ( ! this . match ( tt . gt ) ) ;
794
+ this . expect ( tt . gt ) ;
795
795
796
796
this . state . inType = oldInType ;
797
797
@@ -805,17 +805,17 @@ export default (superClass: Class<Parser>): Class<Parser> =>
805
805
806
806
this . state . inType = true ;
807
807
808
- this . expectRelational ( "<" ) ;
808
+ this . expect ( tt . lt ) ;
809
809
const oldNoAnonFunctionType = this . state . noAnonFunctionType ;
810
810
this . state . noAnonFunctionType = false ;
811
- while ( ! this . isRelational ( ">" ) ) {
811
+ while ( ! this . match ( tt . gt ) ) {
812
812
node . params . push ( this . flowParseType ( ) ) ;
813
- if ( ! this . isRelational ( ">" ) ) {
813
+ if ( ! this . match ( tt . gt ) ) {
814
814
this . expect ( tt . comma ) ;
815
815
}
816
816
}
817
817
this . state . noAnonFunctionType = oldNoAnonFunctionType ;
818
- this . expectRelational ( ">" ) ;
818
+ this . expect ( tt . gt ) ;
819
819
820
820
this . state . inType = oldInType ;
821
821
@@ -829,14 +829,14 @@ export default (superClass: Class<Parser>): Class<Parser> =>
829
829
830
830
this . state . inType = true ;
831
831
832
- this . expectRelational ( "<" ) ;
833
- while ( ! this . isRelational ( ">" ) ) {
832
+ this . expect ( tt . lt ) ;
833
+ while ( ! this . match ( tt . gt ) ) {
834
834
node . params . push ( this . flowParseTypeOrImplicitInstantiation ( ) ) ;
835
- if ( ! this . isRelational ( ">" ) ) {
835
+ if ( ! this . match ( tt . gt ) ) {
836
836
this . expect ( tt . comma ) ;
837
837
}
838
838
}
839
- this . expectRelational ( ">" ) ;
839
+ this . expect ( tt . gt ) ;
840
840
841
841
this . state . inType = oldInType ;
842
842
@@ -902,7 +902,7 @@ export default (superClass: Class<Parser>): Class<Parser> =>
902
902
node . id = this . flowParseObjectPropertyKey ( ) ;
903
903
this . expect ( tt . bracketR ) ;
904
904
this . expect ( tt . bracketR ) ;
905
- if ( this . isRelational ( "<" ) || this . match ( tt . parenL ) ) {
905
+ if ( this . match ( tt . lt ) || this . match ( tt . parenL ) ) {
906
906
node . method = true ;
907
907
node . optional = false ;
908
908
node . value = this . flowParseObjectTypeMethodish (
@@ -926,7 +926,7 @@ export default (superClass: Class<Parser>): Class<Parser> =>
926
926
node . typeParameters = null ;
927
927
node . this = null ;
928
928
929
- if ( this . isRelational ( "<" ) ) {
929
+ if ( this . match ( tt . lt ) ) {
930
930
node . typeParameters = this . flowParseTypeParameterDeclaration ( ) ;
931
931
}
932
932
@@ -1047,7 +1047,7 @@ export default (superClass: Class<Parser>): Class<Parser> =>
1047
1047
this . flowParseObjectTypeIndexer ( node , isStatic , variance ) ,
1048
1048
) ;
1049
1049
}
1050
- } else if ( this . match ( tt . parenL ) || this . isRelational ( "<" ) ) {
1050
+ } else if ( this . match ( tt . parenL ) || this . match ( tt . lt ) ) {
1051
1051
if ( protoStart != null ) {
1052
1052
this . unexpected ( protoStart ) ;
1053
1053
}
@@ -1169,7 +1169,7 @@ export default (superClass: Class<Parser>): Class<Parser> =>
1169
1169
node . kind = kind ;
1170
1170
1171
1171
let optional = false ;
1172
- if ( this . isRelational ( "<" ) || this . match ( tt . parenL ) ) {
1172
+ if ( this . match ( tt . lt ) || this . match ( tt . parenL ) ) {
1173
1173
// This is a method property
1174
1174
node . method = true ;
1175
1175
@@ -1287,7 +1287,7 @@ export default (superClass: Class<Parser>): Class<Parser> =>
1287
1287
node . typeParameters = null ;
1288
1288
node . id = this . flowParseQualifiedTypeIdentifier ( startPos , startLoc , id ) ;
1289
1289
1290
- if ( this . isRelational ( "<" ) ) {
1290
+ if ( this . match ( tt . lt ) ) {
1291
1291
node . typeParameters = this . flowParseTypeParameterInstantiation ( ) ;
1292
1292
}
1293
1293
@@ -1453,23 +1453,20 @@ export default (superClass: Class<Parser>): Class<Parser> =>
1453
1453
this . state . noAnonFunctionType = oldNoAnonFunctionType ;
1454
1454
return type ;
1455
1455
1456
- case tt . relational :
1457
- if ( this . state . value === "<" ) {
1458
- node . typeParameters = this . flowParseTypeParameterDeclaration ( ) ;
1459
- this . expect ( tt . parenL ) ;
1460
- tmp = this . flowParseFunctionTypeParams ( ) ;
1461
- node . params = tmp . params ;
1462
- node . rest = tmp . rest ;
1463
- node . this = tmp . _this ;
1464
- this . expect ( tt . parenR ) ;
1456
+ case tt . lt :
1457
+ node . typeParameters = this . flowParseTypeParameterDeclaration ( ) ;
1458
+ this . expect ( tt . parenL ) ;
1459
+ tmp = this . flowParseFunctionTypeParams ( ) ;
1460
+ node . params = tmp . params ;
1461
+ node . rest = tmp . rest ;
1462
+ node . this = tmp . _this ;
1463
+ this . expect ( tt . parenR ) ;
1465
1464
1466
- this . expect ( tt . arrow ) ;
1465
+ this . expect ( tt . arrow ) ;
1467
1466
1468
- node . returnType = this . flowParseType ( ) ;
1467
+ node . returnType = this . flowParseType ( ) ;
1469
1468
1470
- return this . finishNode ( node , "FunctionTypeAnnotation" ) ;
1471
- }
1472
- break ;
1469
+ return this . finishNode ( node , "FunctionTypeAnnotation" ) ;
1473
1470
1474
1471
case tt . parenL :
1475
1472
this . next ( ) ;
@@ -2178,7 +2175,7 @@ export default (superClass: Class<Parser>): Class<Parser> =>
2178
2175
2179
2176
parseClassId ( node : N . Class , isStatement : boolean , optionalId : ?boolean ) {
2180
2177
super . parseClassId ( node , isStatement , optionalId ) ;
2181
- if ( this . isRelational ( "<" ) ) {
2178
+ if ( this . match ( tt . lt ) ) {
2182
2179
node . typeParameters = this . flowParseTypeParameterDeclaration ( ) ;
2183
2180
}
2184
2181
}
@@ -2241,7 +2238,7 @@ export default (superClass: Class<Parser>): Class<Parser> =>
2241
2238
this . state . inType &&
2242
2239
( code === charCodes . greaterThan || code === charCodes . lessThan )
2243
2240
) {
2244
- return this . finishOp ( tt . relational , 1 ) ;
2241
+ return this . finishOp ( code === charCodes . greaterThan ? tt . gt : tt . lt , 1 ) ;
2245
2242
} else if ( this . state . inType && code === charCodes . questionMark ) {
2246
2243
if ( next === charCodes . dot ) {
2247
2244
return this . finishOp ( tt . questionDot , 2 ) ;
@@ -2369,7 +2366,7 @@ export default (superClass: Class<Parser>): Class<Parser> =>
2369
2366
2370
2367
// determine whether or not we're currently in the position where a class method would appear
2371
2368
isClassMethod ( ) : boolean {
2372
- return this . isRelational ( "<" ) || super . isClassMethod ( ) ;
2369
+ return this . match ( tt . lt ) || super . isClassMethod ( ) ;
2373
2370
}
2374
2371
2375
2372
// determine whether or not we're currently in the position where a class property would appear
@@ -2394,7 +2391,7 @@ export default (superClass: Class<Parser>): Class<Parser> =>
2394
2391
this . unexpected ( ( method : $FlowFixMe ) . variance . start ) ;
2395
2392
}
2396
2393
delete ( method : $FlowFixMe ) . variance ;
2397
- if ( this . isRelational ( "<" ) ) {
2394
+ if ( this . match ( tt . lt ) ) {
2398
2395
method . typeParameters = this . flowParseTypeParameterDeclaration ( ) ;
2399
2396
}
2400
2397
@@ -2436,7 +2433,7 @@ export default (superClass: Class<Parser>): Class<Parser> =>
2436
2433
this . unexpected ( ( method : $FlowFixMe ) . variance . start ) ;
2437
2434
}
2438
2435
delete ( method : $FlowFixMe ) . variance;
2439
- if ( this . isRelational ( "<" ) ) {
2436
+ if ( this . match ( tt . lt ) ) {
2440
2437
method . typeParameters = this . flowParseTypeParameterDeclaration ( ) ;
2441
2438
}
2442
2439
@@ -2446,7 +2443,7 @@ export default (superClass: Class<Parser>): Class<Parser> =>
2446
2443
// parse a the super class type parameters and implements
2447
2444
parseClassSuper ( node : N . Class ) : void {
2448
2445
super . parseClassSuper ( node ) ;
2449
- if ( node . superClass && this . isRelational ( "<" ) ) {
2446
+ if ( node . superClass && this . match ( tt . lt ) ) {
2450
2447
node . superTypeParameters = this . flowParseTypeParameterInstantiation ( ) ;
2451
2448
}
2452
2449
if ( this . isContextual ( tt . _implements ) ) {
@@ -2455,7 +2452,7 @@ export default (superClass: Class<Parser>): Class<Parser> =>
2455
2452
do {
2456
2453
const node = this . startNode ( ) ;
2457
2454
node . id = this . flowParseRestrictedIdentifier ( /*liberal*/ true ) ;
2458
- if ( this . isRelational ( "<" ) ) {
2455
+ if ( this . match ( tt . lt ) ) {
2459
2456
node . typeParameters = this . flowParseTypeParameterInstantiation ( ) ;
2460
2457
} else {
2461
2458
node . typeParameters = null ;
@@ -2508,7 +2505,7 @@ export default (superClass: Class<Parser>): Class<Parser> =>
2508
2505
let typeParameters ;
2509
2506
2510
2507
// method shorthand
2511
- if ( this . isRelational ( "<" ) && ! isAccessor ) {
2508
+ if ( this . match ( tt . lt ) && ! isAccessor ) {
2512
2509
typeParameters = this . flowParseTypeParameterDeclaration ( ) ;
2513
2510
if ( ! this . match ( tt . parenL ) ) this . unexpected ( ) ;
2514
2511
}
@@ -2740,7 +2737,7 @@ export default (superClass: Class<Parser>): Class<Parser> =>
2740
2737
parseFunctionParams ( node : N . Function , allowModifiers ? : boolean ) : void {
2741
2738
// $FlowFixMe
2742
2739
const kind = node . kind ;
2743
- if ( kind !== "get" && kind !== "set" && this . isRelational ( "<" ) ) {
2740
+ if ( kind !== "get" && kind !== "set" && this . match ( tt . lt ) ) {
2744
2741
node . typeParameters = this . flowParseTypeParameterDeclaration ( ) ;
2745
2742
}
2746
2743
super . parseFunctionParams ( node , allowModifiers ) ;
@@ -2798,7 +2795,7 @@ export default (superClass: Class<Parser>): Class<Parser> =>
2798
2795
2799
2796
if (
2800
2797
this . hasPlugin ( "jsx" ) &&
2801
- ( this . match ( tt . jsxTagStart ) || this . isRelational ( "<" ) )
2798
+ ( this . match ( tt . jsxTagStart ) || this . match ( tt . lt ) )
2802
2799
) {
2803
2800
state = this . state . clone ( ) ;
2804
2801
@@ -2823,7 +2820,7 @@ export default (superClass: Class<Parser>): Class<Parser> =>
2823
2820
}
2824
2821
}
2825
2822
2826
- if ( jsx ?. error || this . isRelational ( "<" ) ) {
2823
+ if ( jsx ?. error || this . match ( tt . lt ) ) {
2827
2824
state = state || this . state . clone ( ) ;
2828
2825
2829
2826
let typeParameters ;
@@ -3020,7 +3017,7 @@ export default (superClass: Class<Parser>): Class<Parser> =>
3020
3017
} else if (
3021
3018
base . type === "Identifier" &&
3022
3019
base . name === "async" &&
3023
- this . isRelational ( "<" )
3020
+ this . match ( tt . lt )
3024
3021
) {
3025
3022
const state = this . state . clone ( ) ;
3026
3023
const arrow = this . tryParse (
@@ -3081,11 +3078,7 @@ export default (superClass: Class<Parser>): Class<Parser> =>
3081
3078
node . arguments = this . parseCallExpressionArguments ( tt . parenR , false ) ;
3082
3079
node . optional = true ;
3083
3080
return this . finishCallExpression ( node , /* optional */ true ) ;
3084
- } else if (
3085
- ! noCalls &&
3086
- this . shouldParseTypes ( ) &&
3087
- this . isRelational ( "<" )
3088
- ) {
3081
+ } else if ( ! noCalls && this . shouldParseTypes ( ) && this . match ( tt . lt ) ) {
3089
3082
const node = this . startNodeAt ( startPos , startLoc ) ;
3090
3083
node . callee = base ;
3091
3084
@@ -3118,7 +3111,7 @@ export default (superClass: Class<Parser>): Class<Parser> =>
3118
3111
3119
3112
parseNewArguments ( node : N . NewExpression ) : void {
3120
3113
let targs = null ;
3121
- if ( this . shouldParseTypes ( ) && this . isRelational ( "<" ) ) {
3114
+ if ( this . shouldParseTypes ( ) && this . match ( tt . lt ) ) {
3122
3115
targs = this . tryParse ( ( ) =>
3123
3116
this . flowParseTypeParameterInstantiationCallOrNew ( ) ,
3124
3117
) . node ;
@@ -3665,7 +3658,7 @@ export default (superClass: Class<Parser>): Class<Parser> =>
3665
3658
return this . finishNode ( node , "EnumDeclaration" ) ;
3666
3659
}
3667
3660
3668
- // check if the next token is a tt.relation("<")
3661
+ // check if the next token is a tt.lt
3669
3662
isLookaheadToken_lt ( ) : boolean {
3670
3663
const next = this . nextTokenStart ( ) ;
3671
3664
if ( this . input . charCodeAt ( next ) === charCodes . lessThan ) {
0 commit comments